// pages/privacy/index.js const api = require('../../api/index.js'); Page({ /** * 页面的初始数据 */ data: { // 状态栏高度 statusBarHeight:'', // 导航栏高度 navBarHeight:'', // 导航栏和状态栏高度 navStatusBarHeight: '', // 胶囊 menu:'', index:0, objectArray: [], workorder:[], reviewdata:[] }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.getpowestation() this.setData({ statusBarHeight:wx.getStorageSync('statusBarHeight'), navBarHeight: wx.getStorageSync('navBarHeight'), navStatusBarHeight:wx.getStorageSync('navStatusBarHeight'), menu:wx.getStorageSync('menu') }) }, getShowScreenHeight(){ //系统信息 const systemInfo = wx.getWindowInfo() //胶囊位置 const capsuleInfo = wx.getMenuButtonBoundingClientRect() //计算导航栏高度 let navHeight = systemInfo.statusBarHeight + capsuleInfo.height + (capsuleInfo.top - systemInfo.statusBarHeight) * 2 //计算tabbar高度 let tabHeight = systemInfo.safeArea.bottom - systemInfo.safeArea.height //计算可现实内容高度(中间区域) // let screenHeight = systemInfo.screenHeight-navHeight-tabHeight-30 const menu = wx.getMenuButtonBoundingClientRect() wx.setStorageSync('menu', menu) // 手机系统状态栏高度 wx.setStorageSync('statusBarHeight', tabHeight) // 导航栏高度 wx.setStorageSync('navBarHeight', menu.height+(menu.top-systemInfo.statusBarHeight) *2 ) // 状态栏加导航栏 wx.setStorageSync('navStatusBarHeight',navHeight) }, // 查询电站 getpowestation(){ api.request(`/syspowerstation/selectpowestation`, 'POST',{}) .then((res) => { if (res.code==200) { this.setData({ objectArray:res.data }) this.getuser() this.getShowScreenHeight() } }) .catch((err) => { console.error('请求失败:', err); // 在这里处理请求失败的情况 }); }, getworkoder(){ let data = { workorderType:'' } api.request(`/workoder/statistics`, 'POST',data) .then((res) => { console.log(res); this.setData({ workorder:res.data }) }) .catch((err) => { console.error('请求失败:', err); // 在这里处理请求失败的情况 }); }, getreview(){ let data = { workorderName:'', workorderType:'', workorderAddress:'', starttime:'', type:'', examineType:5 } api.request(`/workoder/selectworkoder`, 'POST',data) .then((res) => { console.log(res); this.setData({ reviewdata:res.data }) }) .catch((err) => { console.error('请求失败:', err); // 在这里处理请求失败的情况 }); }, rolelocate(e){ console.log(e.currentTarget.dataset.index); if (e.currentTarget.dataset.index==1) { if (wx.getStorageSync('partnerPosition').partnerPosition==1) { wx.showToast({ title: '暂无权限', icon: 'none' }); return } wx.navigateTo({ url: '/pages/malfunction/index', }) }else if(e.currentTarget.dataset.index==2){ wx.navigateTo({ url: '/pages/statistics/index', }) }else if(e.currentTarget.dataset.index==3){ wx.navigateTo({ url: '/pages/device/index', }) }else if(e.currentTarget.dataset.index==4){ wx.navigateTo({ url: '/pages/scheduling/index', }) } }, ondetails(e){ console.log(e.currentTarget.dataset.id); wx.navigateTo({ url: `/pages/workorderdetails/index?id=${e.currentTarget.dataset.id}&workorderId=${e.currentTarget.dataset.workorderid}`, }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { let _this = this _this.authorizationbtn() _this.getworkoder() _this.getreview() // wx.getSetting({ // withSubscriptions: true, // success (res) { // console.log(res.authSetting) // if (res.authSetting['scope.subscribeMessage']) { // }else{ // wx.showModal({ // title: '', // content: '检测到您没有开启工单服务通知的权限,是否开启', // success (res) { // if (res.confirm) { // console.log('用户点击确定') // _this.authorizationbtn() // } else if (res.cancel) { // console.log('用户点击取消') // } // } // }) // } // } // }) // }, authorizationbtn(){ wx.requestSubscribeMessage({ tmplIds: ['G_37RkJ_mwZeTdPv5A0fjBlYW6_lRQIW9_SywmUAX7Q','AhToqLaCeOvSvSSQ7RvZYd2WgGA11Da13j1PMvqcGqQ'], success(res) { console.log(res); if(res['AhToqLaCeOvSvSSQ7RvZYd2WgGA11Da13j1PMvqcGqQ'] === 'accept' && res['G_37RkJ_mwZeTdPv5A0fjBlYW6_lRQIW9_SywmUAX7Q'] === 'accept') { // 用户同意订阅 } } }) }, bindPickerChange: function(e) { console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ index: e.detail.value }) let data = { powerstationId:this.data.objectArray[e.detail.value].powerstationId } api.request(`/workoder/selectworkoder`, 'POST',data) .then((res) => { console.log(res); }) .catch((err) => { console.error('请求失败:', err); // 在这里处理请求失败的情况 }); }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ async onPullDownRefresh() { console.log(11111111); let _this = this // _this.authorizationbtn() await _this.getworkoder() await _this.getreview() wx.stopPullDownRefresh(); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { console.log(11111111); }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })