运维小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. // pages/privacy/index.js
  2. const api = require('../../api/index.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. // 状态栏高度
  9. statusBarHeight:'',
  10. // 导航栏高度
  11. navBarHeight:'',
  12. // 导航栏和状态栏高度
  13. navStatusBarHeight: '',
  14. // 胶囊
  15. menu:'',
  16. index:0,
  17. objectArray: [],
  18. workorder:[],
  19. reviewdata:[]
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad(options) {
  25. this.getpowestation()
  26. this.setData({
  27. statusBarHeight:wx.getStorageSync('statusBarHeight'),
  28. navBarHeight: wx.getStorageSync('navBarHeight'),
  29. navStatusBarHeight:wx.getStorageSync('navStatusBarHeight'),
  30. menu:wx.getStorageSync('menu')
  31. })
  32. },
  33. getShowScreenHeight(){
  34. //系统信息
  35. const systemInfo = wx.getWindowInfo()
  36. //胶囊位置
  37. const capsuleInfo = wx.getMenuButtonBoundingClientRect()
  38. //计算导航栏高度
  39. let navHeight = systemInfo.statusBarHeight + capsuleInfo.height + (capsuleInfo.top - systemInfo.statusBarHeight) * 2
  40. //计算tabbar高度
  41. let tabHeight = systemInfo.safeArea.bottom - systemInfo.safeArea.height
  42. //计算可现实内容高度(中间区域)
  43. // let screenHeight = systemInfo.screenHeight-navHeight-tabHeight-30
  44. const menu = wx.getMenuButtonBoundingClientRect()
  45. wx.setStorageSync('menu', menu)
  46. // 手机系统状态栏高度
  47. wx.setStorageSync('statusBarHeight', tabHeight)
  48. // 导航栏高度
  49. wx.setStorageSync('navBarHeight', menu.height+(menu.top-systemInfo.statusBarHeight) *2 )
  50. // 状态栏加导航栏
  51. wx.setStorageSync('navStatusBarHeight',navHeight)
  52. },
  53. // 查询电站
  54. getpowestation(){
  55. api.request(`/syspowerstation/selectpowestation`, 'POST',{})
  56. .then((res) => {
  57. if (res.code==200) {
  58. this.setData({
  59. objectArray:res.data
  60. })
  61. this.getuser()
  62. this.getShowScreenHeight()
  63. }
  64. })
  65. .catch((err) => {
  66. console.error('请求失败:', err);
  67. // 在这里处理请求失败的情况
  68. });
  69. },
  70. getworkoder(){
  71. let data = {
  72. workorderType:''
  73. }
  74. api.request(`/workoder/statistics`, 'POST',data)
  75. .then((res) => {
  76. console.log(res);
  77. this.setData({
  78. workorder:res.data
  79. })
  80. })
  81. .catch((err) => {
  82. console.error('请求失败:', err);
  83. // 在这里处理请求失败的情况
  84. });
  85. },
  86. getreview(){
  87. let data = {
  88. workorderName:'',
  89. workorderType:'',
  90. workorderAddress:'',
  91. starttime:'',
  92. type:'',
  93. examineType:5
  94. }
  95. api.request(`/workoder/selectworkoder`, 'POST',data)
  96. .then((res) => {
  97. console.log(res);
  98. this.setData({
  99. reviewdata:res.data
  100. })
  101. })
  102. .catch((err) => {
  103. console.error('请求失败:', err);
  104. // 在这里处理请求失败的情况
  105. });
  106. },
  107. rolelocate(e){
  108. console.log(e.currentTarget.dataset.index);
  109. if (e.currentTarget.dataset.index==1) {
  110. if (wx.getStorageSync('partnerPosition').partnerPosition==1) {
  111. wx.showToast({
  112. title: '暂无权限',
  113. icon: 'none'
  114. });
  115. return
  116. }
  117. wx.navigateTo({
  118. url: '/pages/malfunction/index',
  119. })
  120. }else if(e.currentTarget.dataset.index==2){
  121. wx.navigateTo({
  122. url: '/pages/statistics/index',
  123. })
  124. }else if(e.currentTarget.dataset.index==3){
  125. wx.navigateTo({
  126. url: '/pages/device/index',
  127. })
  128. }else if(e.currentTarget.dataset.index==4){
  129. wx.navigateTo({
  130. url: '/pages/scheduling/index',
  131. })
  132. }
  133. },
  134. ondetails(e){
  135. console.log(e.currentTarget.dataset.id);
  136. wx.navigateTo({
  137. url: `/pages/workorderdetails/index?id=${e.currentTarget.dataset.id}&workorderId=${e.currentTarget.dataset.workorderid}`,
  138. })
  139. },
  140. /**
  141. * 生命周期函数--监听页面初次渲染完成
  142. */
  143. onReady() {
  144. },
  145. /**
  146. * 生命周期函数--监听页面显示
  147. */
  148. onShow() {
  149. let _this = this
  150. _this.authorizationbtn()
  151. _this.getworkoder()
  152. _this.getreview()
  153. // wx.getSetting({
  154. // withSubscriptions: true,
  155. // success (res) {
  156. // console.log(res.authSetting)
  157. // if (res.authSetting['scope.subscribeMessage']) {
  158. // }else{
  159. // wx.showModal({
  160. // title: '',
  161. // content: '检测到您没有开启工单服务通知的权限,是否开启',
  162. // success (res) {
  163. // if (res.confirm) {
  164. // console.log('用户点击确定')
  165. // _this.authorizationbtn()
  166. // } else if (res.cancel) {
  167. // console.log('用户点击取消')
  168. // }
  169. // }
  170. // })
  171. // }
  172. // }
  173. // })
  174. //
  175. },
  176. authorizationbtn(){
  177. wx.requestSubscribeMessage({
  178. tmplIds: ['G_37RkJ_mwZeTdPv5A0fjBlYW6_lRQIW9_SywmUAX7Q','AhToqLaCeOvSvSSQ7RvZYd2WgGA11Da13j1PMvqcGqQ'],
  179. success(res) {
  180. console.log(res);
  181. if(res['AhToqLaCeOvSvSSQ7RvZYd2WgGA11Da13j1PMvqcGqQ'] === 'accept' && res['G_37RkJ_mwZeTdPv5A0fjBlYW6_lRQIW9_SywmUAX7Q'] === 'accept') {
  182. // 用户同意订阅
  183. }
  184. }
  185. })
  186. },
  187. bindPickerChange: function(e) {
  188. console.log('picker发送选择改变,携带值为', e.detail.value)
  189. this.setData({
  190. index: e.detail.value
  191. })
  192. let data = {
  193. powerstationId:this.data.objectArray[e.detail.value].powerstationId
  194. }
  195. api.request(`/workoder/selectworkoder`, 'POST',data)
  196. .then((res) => {
  197. console.log(res);
  198. })
  199. .catch((err) => {
  200. console.error('请求失败:', err);
  201. // 在这里处理请求失败的情况
  202. });
  203. },
  204. /**
  205. * 生命周期函数--监听页面隐藏
  206. */
  207. onHide() {
  208. },
  209. /**
  210. * 生命周期函数--监听页面卸载
  211. */
  212. onUnload() {
  213. },
  214. /**
  215. * 页面相关事件处理函数--监听用户下拉动作
  216. */
  217. async onPullDownRefresh() {
  218. console.log(11111111);
  219. let _this = this
  220. // _this.authorizationbtn()
  221. await _this.getworkoder()
  222. await _this.getreview()
  223. wx.stopPullDownRefresh();
  224. },
  225. /**
  226. * 页面上拉触底事件的处理函数
  227. */
  228. onReachBottom() {
  229. console.log(11111111);
  230. },
  231. /**
  232. * 用户点击右上角分享
  233. */
  234. onShareAppMessage() {
  235. }
  236. })