//获取应用实例 const app = getApp() var cityId Page({ /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { let that = this; // wx.getStorage({ // key: 'merchantNo', // success: function (res) { // that.setData({ // merchantNo: res.data // }) // } // }); wx.getStorage({ key: 'districtName', success: function (res) { that.setData({ districtName: res.data }) } }); cityId = options.cityId; wx.request({ url: app.gw.hostUrl + '/mall/wxa/index/opendistictlist', method: 'get', data: { cityId: cityId, }, header: { 'Content-Type': 'application/x-www-form-urlencoded' }, success: function (res) { var districts = res.data; that.setData({ districts }); }, fail: function (res) { wx.showToast({ title: '加载数据失败', }); }, }) }, openGroup: function (e) { wx.setStorage({ key: 'cityId', data: e.currentTarget.dataset.item.cityId, }); wx.setStorage({ key: 'cityName', data: e.currentTarget.dataset.item.cityName, }); wx.setStorage({ key: 'districtId', data: e.currentTarget.dataset.item.districtId, }); wx.setStorage({ key: 'districtName', data: e.currentTarget.dataset.item.districtName, }); wx.setStorage({ key: 'merchantNo', data: e.currentTarget.dataset.item.merchantNo, }); wx.switchTab({ url: '../index/index' }) }, onShow: function () { } })