运维小程序
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.

index.js 5.7KB

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