tanghaolin
2022-11-08 c8c3f384040bad0044dcabf72e162e35b5786afa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
var Constant = require('../../utils/constant.js');
var util = require('../../utils/util.js');
var app = getApp();
Page({
  data: {
    userInfo: null,
    mainCmdList: [
      [
        {id:100,text:"通知",icon: "icon-tongzhi2", iconcolor:"red", badgeNum:5, cb:"onNotice", type:"navigate"}
      ],
      [
        {id:1,text:"今日巡检", icon:"icon-xunjiandian", iconcolor:"#16b5cb",badgeNum: 0, cb:"onTodayInspection", type:'navigate'},
        {id:2,text:"巡检记录",icon: "icon-lishi2", iconcolor:"#16b5cb", badgeNum:0,cb: "onHistoryInspection", type:'navigate'},
        
      ],
      [
        {id:3,text:"新建报修", icon:"icon-zengjia", iconcolor:"#16b5cb", badgeNum:0, cb:"onAddRepairRequest", type:'navigate'},
        {id:4,text:"我的报修", icon:"icon-wangshangbaoming", iconcolor:"#16b5cb", badgeNum:0, cb:"onMyReport", type:'navigate'},
      ],
      [
        {id:5,text:"我的维修", icon:"icon-baoxiu", iconcolor:"#16b5cb", badgeNum:0, cb:"onMyRepairTask", type:'navigate'}
      ]
    ]
  },
 
 
  //
  onLoad: function (options) {
    //判断app中的CropID是否和全局的CropID相同,不同则跳转到登陆界面
    var userInfo = app.globalData.userInfo;
    //console.log('登录之后的用户信息', userInfo)
    if (userInfo == null) {
      wx.redirectTo({
        url: '/login/login/index',
      })
      return;
    }  
 
    this.setData({
      userInfo: app.globalData.userInfo,
    });   
  },
  //
  refreshUserInfo: function () {
    var userInfo = app.globalData.userInfo;
    this.setData({
      userInfo: userInfo
    });
  },
  //通知
  onNotice() {
    var userInfo = this.data.userInfo;
    // 
    if (!userInfo) {
      wx.navigateTo({
        url: '/login/login/index',
      });
      return;
    }
 
    wx.navigateTo({
      url: '/other/notice/index',
    })
  },
  // 今日巡检
  onTodayInspection() {
    var userInfo = this.data.userInfo;
    var that = this
    if (!userInfo) {
      wx.navigateTo({
        url: '/login/login/index'
      });
      return;
    }
    var inspection_url = '/inspection/todayProductList/index'; 
    wx.getSystemInfo({
      success: function (res) {
        // console.log(res, res.locationEnabled)
        if (res.locationEnabled == false) {
          wx.showModal({
            title: '提示',
            content: '请打开GPS定位功能!',
            showCancel: true,
          });
        } else if (res.locationEnabled == true) {
          wx.navigateTo({
            url: inspection_url,
          });
        } else {
          wx.navigateTo({
            url: inspection_url,
          });
        }
      }
    });
  },
  //历史巡检
  onHistoryInspection() {
    wx.navigateTo({
      url: '../../inspection/historyByAllList/index',
    })
  },
  //进入泵房考核
  onTodayAssess(){
    wx.navigateTo({
      url: '../../inspection/todayAssess/index',
    })
  },
  // 新建
  onAddRepairRequest() {
    var userInfo = this.data.userInfo;
    //console.log(userInfo, '新建')
    if (userInfo == null) {
      wx.redirectTo({
        url: '/login/login/index',
      });
      return;
    }
 
    var repair_url = '/repair/addReport/index'; 
    wx.getSystemInfo({
      success: function (res) {
        //  console.log(res, res.locationEnabled)
        if (res.locationEnabled == false) {
          wx.showModal({
            title: '提示',
            content: '请打开GPS定位功能!',
            showCancel: true,
          });
        } else if (res.locationEnabled == true) {
          //console.log(res)
          wx.navigateTo({
            url: repair_url
          });
        } else {
          wx.navigateTo({
            url: repair_url
          });
        }
      }
    });
  },
  // 我的维修
  onMyRepairTask() {
    var userInfo = this.data.userInfo;
    if (!userInfo) {
      wx.navigateTo({
        url: '/login/login/index'
      });
      return;
    }
 
    wx.navigateTo({
      url: '/repair/myTask/index'
    });
  },
  // 我的报修
  onMyReport() {
    var userInfo = this.data.userInfo;
    if (!userInfo) {
      wx.navigateTo({
        url: '/login/login/index',
      });
      return;
    }
 
    wx.navigateTo({
      url: '/repair/myReport/index',
    });
  
  },
 
  onShareAppMessage: function () {
    return Constant.Share;
  },
  onShow: function () {
    if (typeof this.getTabBar === 'function' &&
    this.getTabBar()) {
    this.getTabBar().setData({
      selected: 1
    })
  }
  },
  onReady: function () {},
  onHide: function () {}
})