// pages/taxDisputes/index/index.js import { xcxsfsm, hqdw, xcxGetCompanyList, xcxsmbd, xcxsy } from "../../../apis/index.js" import { getMenu } from "../../../apis/sfzy" Page({ /** * 页面的初始数据 */ data: { menuList: [], addressInfo: {}, hall: {}, markers: [], }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { let that = this }, init() { let that = this let authorize = getApp().globalData.authorize() if (authorize !== 0) { wx.showModal({ title: '提示', content: '检测到您当前未实名,请返回首页实名后点击税费争议模块重新办理。', showCancel: false, complete: (res) => { wx.switchTab({ url: '../../index/index', }) } }) } else { that.getLocation() } }, getLocation() { let that = this wx.getLocation({ type: 'wgs84', isHighAccuracy: true, success(result) { that.getHall(result.latitude, result.longitude) }, fail: (err) => { that.hqdw() } }) }, hqdw() { let that = this hqdw().then(res => { if (res.code == 200) { let data = JSON.parse(res.message) that.getHall(data.result.location.lat, data.result.location.lng) } else { wx.showToast({ title: res.msg || res.message, icon: "none" }) } }) }, getHall(lat, lng) { let that = this let publicId = wx.getStorageSync('PUBLIC_ID') let userinfo = wx.getStorageSync('USERINFO') let form = { xcxId: publicId.openid, unionid: publicId.unionid, longitude: String(lng), latitude: String(lat), nsrsbh: userinfo.nsrsbh || "", swjgdm: userinfo.swjgdm || "" } xcxsy(form).then(res => { if (res.code == 200) { let halls = res.list.sort((a, b) => { return a.zxjl - b.zxjl }) wx.setStorageSync('HALL_LIST', halls) that.setMyHall(halls) } else { wx.showToast({ title: res.msg || res.message, icon: "none", duration: 5000 }) } }) }, setMyHall(e) { let that = this let userinfo = wx.getStorageSync('USERINFO') let myhall = wx.getStorageSync('MY_HALL') if (myhall) { let update = false for (let i = 0; i < e.length; i++) { if (e[i].bsfwtDm == myhall.bsfwtDm) { update = true that.setData({ hall: e[i] }) that.setMarker(e[i]) wx.setStorageSync('MY_HALL', e[i]) break; } } if (!update) { that.setData({ hall: myhall }) that.setMarker(myhall) } } else { if (userinfo.swjgdm) { let hall = {} let uswjgdm = userinfo.swjgdm.substring(0, 7) for (let i = 0; i < e.length; i++) { let hswjgdm = e[i].ssswjgDm.substring(0, 7) if (uswjgdm == hswjgdm) { hall = e[i] break; } } if (!hall.bsfwtmc) hall = e[0] that.setData({ hall: hall }) wx.setStorageSync('MY_HALL', hall) that.setMarker(hall) } else { let hall = e[0] that.setData({ hall: hall }) wx.setStorageSync('MY_HALL', hall) that.setMarker(hall) } } that.getMenu(that.data.hall) }, getMenu(e) { wx.showLoading() let that = this let form = { bsfwtDm: e.bsfwtDm } getMenu(form).then(res => { wx.hideLoading() if (res.code == 200) { that.setData({ menuList: res.data }) } else { wx.showToast({ title: res.msg || res.message, icon: "none", duration: 3000 }) that.setData({ menuList: [] }) } }) }, setMarker(e) { let that = this let lat = e.latitude || e.lat let lng = e.longitude || e.lng let marker = { id: 9527, latitude: lat, longitude: lng, title: "", zIndex: 9, alpha: 0.9, iconPath: "../../../icon/address.png", width: "30rpx", height: "30rpx", callout: { content: "大厅地址", color: "#313131", textAlign: "center", fontSize: 10, borderRadius: 5, bgColor: "#ffffff", padding: 5, display: "ALWAYS" } } that.setData({ markers: [marker] }) }, selectHall(e) { let that = this let type = e.currentTarget.dataset.type wx.navigateTo({ url: '../../indexPages/selectHall/selectHall?type=' + type, }) }, menuTap(e) { let item = e.currentTarget.dataset.item if (item.yxbz == 'Y') { wx.navigateTo({ url: item.tzUrl, }) } else { wx.showToast({ title: '当前大厅禁用此项功能', icon: "none" }) } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { let that = this that.init() }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })