| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- // pages/privacy/index.js
- const api = require('../../api/index.js');
-
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- // 状态栏高度
- statusBarHeight:'',
- // 导航栏高度
- navBarHeight:'',
- // 导航栏和状态栏高度
- navStatusBarHeight: '',
- // 胶囊
- menu:'',
- workorder:[],
- reviewdata:[]
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.getuser()
- this.getShowScreenHeight()
- 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)
-
- },
- getuser(){
- api.request(`/partner/selectinformation`, 'POST',{})
- .then((res) => {
- // 设置数据到本地存储
- wx.setStorage({
- key: 'partnerPosition', // 存储的key值
- data:res.data,
- success: function(ress) {
-
- // wx.getStorageSync('token');
- }
- });
- })
- .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') {
- // 用户同意订阅
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- 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() {
-
- }
- })
|