You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
2.5 KiB
105 lines
2.5 KiB
var api = require('../../utils/api.js')
|
|
import { $wuxActionSheet } from '../../dist/index'
|
|
Page({
|
|
data: {
|
|
selectTab: 'resident',
|
|
gridList: [], // 当前用户所拥有的网格
|
|
changeGridList: [], // 筛选掉当前选择的网格的网格列表
|
|
moreThanOneGrid: false,
|
|
gridInfo: {
|
|
gridName: '', // 网格名称
|
|
gridId: '', // 网格id
|
|
},
|
|
partyFlag: '0',
|
|
},
|
|
onLoad(options) {
|
|
if (options.selectTab) {
|
|
this.setData({
|
|
selectTab: options.selectTab,
|
|
})
|
|
}
|
|
},
|
|
// 我是居民/我是党员/我是企业 tab切换
|
|
onTabChange(e) {
|
|
if (e.currentTarget.dataset.tab === 'resident') {
|
|
if (this.data.partyFlag === '1') {
|
|
wx.showToast({
|
|
title: '您已是党员,不可认证居民',
|
|
icon: 'none',
|
|
duration: 2000,
|
|
})
|
|
return false
|
|
}
|
|
}
|
|
this.setData({
|
|
selectTab: e.currentTarget.dataset.tab,
|
|
})
|
|
},
|
|
// 获取当前用户所有网格
|
|
getGridList(e) {
|
|
api
|
|
.getGridList()
|
|
.then((res) => {
|
|
console.log('获取所有网格', res)
|
|
const buttonList = []
|
|
res.data.forEach((item) => {
|
|
if (item.gridId !== e.detail.gridId) {
|
|
buttonList.push({
|
|
id: item.gridId,
|
|
text: item.grid,
|
|
})
|
|
}
|
|
})
|
|
this.setData({
|
|
gridList: res.data,
|
|
changeGridList: buttonList,
|
|
moreThanOneGrid: buttonList.length > 0,
|
|
})
|
|
})
|
|
.catch((err) => {
|
|
this.setData({
|
|
gridList: [],
|
|
changeGridList: [],
|
|
})
|
|
console.log(err)
|
|
})
|
|
},
|
|
// 切换网格
|
|
changeGrid(e) {
|
|
const buttonList = []
|
|
this.data.gridList.forEach((item) => {
|
|
buttonList.push({
|
|
id: item.gridId,
|
|
text: item.grid,
|
|
})
|
|
})
|
|
const index = buttonList.findIndex((item) => item.id === e.detail.gridId)
|
|
if (index > -1) {
|
|
buttonList.splice(index, 1)
|
|
}
|
|
this.setData({
|
|
changeGridList: buttonList,
|
|
})
|
|
const that = this
|
|
$wuxActionSheet().showSheet({
|
|
buttons: this.data.changeGridList,
|
|
className: 'dialog-class',
|
|
buttonClicked(index, item) {
|
|
that.setData({
|
|
'gridInfo.gridId': item.id,
|
|
'gridInfo.gridName': item.text,
|
|
})
|
|
return true
|
|
},
|
|
cancelText: '取消',
|
|
cancel() {},
|
|
destructiveButtonClicked() {},
|
|
})
|
|
},
|
|
selectTabChange(e) {
|
|
this.setData({
|
|
selectTab: e.detail.tab,
|
|
partyFlag: e.detail.partyFlag,
|
|
})
|
|
},
|
|
})
|
|
|