市北党建引领小程序初始化
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.

47 lines
1.1 KiB

2 years ago
const api = require('../../../../utils/api')
Page({
data: {
gridList: [],
selectGridList: []
},
onShow () {
this.loadGridList()
},
// 加载网格长管辖的网格列表
loadGridList () {
api.getGridList().then(res => {
if (res.code === 0 && res.msg === 'success') {
const gridList = res.data
let selectGridList = []
if (gridList.length > 0) {
selectGridList = gridList.slice(1)
}
this.setData({
gridList,
selectGridList
})
}
}).catch(err => {
console.log(err)
})
},
// 改变所在网格
changeGrid (e) {
wx.showLoading({
title: '加载中...'
})
api.changeGrid(e.currentTarget.dataset.grid).then(res => {
console.log('切换网格', res)
if (res.code === 0 && res.msg === 'success') {
wx.reLaunch({
url: `/pages/index/index?departmentId=${e.currentTarget.dataset.grid}`
})
}
}).catch(err => {
console.log(err)
}).finally(() => {
wx.hideLoading()
})
}
})