运维小程序
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. // pages/privacy/index.js
  2. const api = require('../../api/index.js');
  3. // const getCurrentTime = require("../../utils/util.js")
  4. const getCurrentTime = require('../../utils/util.js');
  5. // import { getCurrentTime } from '../../utils/util.js';
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. // 状态栏高度
  12. statusBarHeight:'',
  13. // 导航栏高度
  14. navBarHeight:'',
  15. // 导航栏和状态栏高度
  16. navStatusBarHeight: '',
  17. // 胶囊
  18. menu:'',
  19. index:0,
  20. objectArray: [],
  21. workorder:[],
  22. reviewdata:[],
  23. currentTime:'',
  24. intervalId:''
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad(options) {
  30. console.log(getCurrentTime);
  31. // 启动定时器:每秒(1000ms)更新一次时间
  32. this.intervalId = setInterval(() => {
  33. const time = getCurrentTime.getCurrentTime(); // 获取当前时间(补零后的时分秒)
  34. this.setData({
  35. currentTime: time.ymdhms // 更新到页面数据,如 "15:08:03"
  36. });
  37. }, 1000); // 必须指定时间间隔(毫秒),这里设为1秒
  38. if (wx.getStorageSync('powerstationId')=='') {
  39. wx.setStorage({
  40. key: 'powerstationId', // 存储的key值
  41. data:''
  42. });
  43. }
  44. this.getShowScreenHeight()
  45. // this.getpowestation()
  46. this.setData({
  47. statusBarHeight:wx.getStorageSync('statusBarHeight'),
  48. navBarHeight: wx.getStorageSync('navBarHeight'),
  49. navStatusBarHeight:wx.getStorageSync('navStatusBarHeight'),
  50. menu:wx.getStorageSync('menu')
  51. })
  52. },
  53. getShowScreenHeight(){
  54. //系统信息
  55. const systemInfo = wx.getWindowInfo()
  56. //胶囊位置
  57. const capsuleInfo = wx.getMenuButtonBoundingClientRect()
  58. //计算导航栏高度
  59. let navHeight = systemInfo.statusBarHeight + capsuleInfo.height + (capsuleInfo.top - systemInfo.statusBarHeight) * 2
  60. //计算tabbar高度
  61. let tabHeight = systemInfo.safeArea.bottom - systemInfo.safeArea.height
  62. //计算可现实内容高度(中间区域)
  63. // let screenHeight = systemInfo.screenHeight-navHeight-tabHeight-30
  64. const menu = wx.getMenuButtonBoundingClientRect()
  65. wx.setStorageSync('menu', menu)
  66. // 手机系统状态栏高度
  67. wx.setStorageSync('statusBarHeight', tabHeight)
  68. // 导航栏高度
  69. wx.setStorageSync('navBarHeight', menu.height+(menu.top-systemInfo.statusBarHeight) *2 )
  70. // 状态栏加导航栏
  71. wx.setStorageSync('navStatusBarHeight',navHeight)
  72. },
  73. // 查询电站
  74. getpowestation(){
  75. this.setData({
  76. objectArray:[]
  77. })
  78. api.request(`/syspowerstation/selectpowestation`, 'POST',{})
  79. .then((res) => {
  80. if (res.code==200) {
  81. res.data.unshift({
  82. powerstationAddress: "",
  83. powerstationId: "",
  84. powerstationImg: "",
  85. powerstationName: "全部电站"
  86. })
  87. this.setData({
  88. objectArray:res.data
  89. })
  90. for (let index = 0; index < res.data.length; index++) {
  91. if (res.data[index].powerstationId==wx.getStorageSync('powerstationId')) {
  92. this.setData({
  93. index:index
  94. })
  95. return
  96. }else{
  97. this.setData({
  98. index:0
  99. })
  100. }
  101. }
  102. // this.getuser()
  103. }
  104. })
  105. .catch((err) => {
  106. console.error('请求失败:', err);
  107. // 在这里处理请求失败的情况
  108. });
  109. },
  110. getworkoder(){
  111. let data = {
  112. workorderType:''
  113. }
  114. api.request(`/workoder/statistics`, 'POST',data)
  115. .then((res) => {
  116. console.log(res);
  117. this.setData({
  118. workorder:res.data
  119. })
  120. })
  121. .catch((err) => {
  122. console.error('请求失败:', err);
  123. // 在这里处理请求失败的情况
  124. });
  125. },
  126. getreview(){
  127. let data = {
  128. workorderName:'',
  129. workorderType:'',
  130. workorderAddress:'',
  131. starttime:'',
  132. type:'',
  133. examineType:5
  134. }
  135. api.request(`/workoder/selectworkoder`, 'POST',data)
  136. .then((res) => {
  137. console.log(res);
  138. this.setData({
  139. reviewdata:res.data
  140. })
  141. })
  142. .catch((err) => {
  143. console.error('请求失败:', err);
  144. // 在这里处理请求失败的情况
  145. });
  146. },
  147. rolelocate(e){
  148. console.log(e.currentTarget.dataset.index);
  149. if (e.currentTarget.dataset.index==1) {
  150. if (wx.getStorageSync('partnerPosition').partnerPosition==1||wx.getStorageSync('partnerPosition').partnerPosition==5) {
  151. wx.showToast({
  152. title: '暂无权限',
  153. icon: 'none'
  154. });
  155. return
  156. }
  157. wx.navigateTo({
  158. url: '/pages/malfunction/index',
  159. })
  160. }else if(e.currentTarget.dataset.index==2){
  161. wx.navigateTo({
  162. url: '/pages/statistics/index',
  163. })
  164. }else if(e.currentTarget.dataset.index==3){
  165. if (wx.getStorageSync('partnerPosition').partnerPosition==5) {
  166. wx.showToast({
  167. title: '暂无权限',
  168. icon: 'none'
  169. });
  170. return
  171. }
  172. wx.navigateTo({
  173. url: '/pages/device/index',
  174. })
  175. }else if(e.currentTarget.dataset.index==4){
  176. if (wx.getStorageSync('partnerPosition').partnerPosition==5) {
  177. wx.showToast({
  178. title: '暂无权限',
  179. icon: 'none'
  180. });
  181. return
  182. }
  183. wx.navigateTo({
  184. url: '/pages/scheduling/index',
  185. })
  186. }
  187. },
  188. ondetails(e){
  189. console.log(e.currentTarget.dataset.id);
  190. wx.navigateTo({
  191. url: `/pages/workorderdetails/index?id=${e.currentTarget.dataset.id}&workorderId=${e.currentTarget.dataset.workorderid}`,
  192. })
  193. },
  194. /**
  195. * 生命周期函数--监听页面初次渲染完成
  196. */
  197. onReady() {
  198. },
  199. /**
  200. * 生命周期函数--监听页面显示
  201. */
  202. onShow() {
  203. if (!this.intervalId) { // 避免重复创建定时器
  204. this.intervalId = setInterval(() => {
  205. const time = getCurrentTime.getCurrentTime();
  206. this.setData({ currentTime: time.ymdhms });
  207. }, 1000);
  208. }
  209. let _this = this
  210. // _this.getpowestation()
  211. _this.authorizationbtn()
  212. _this.getworkoder()
  213. _this.getreview()
  214. // wx.getSetting({
  215. // withSubscriptions: true,
  216. // success (res) {
  217. // console.log(res.authSetting)
  218. // if (res.authSetting['scope.subscribeMessage']) {
  219. // }else{
  220. // wx.showModal({
  221. // title: '',
  222. // content: '检测到您没有开启工单服务通知的权限,是否开启',
  223. // success (res) {
  224. // if (res.confirm) {
  225. // console.log('用户点击确定')
  226. // _this.authorizationbtn()
  227. // } else if (res.cancel) {
  228. // console.log('用户点击取消')
  229. // }
  230. // }
  231. // })
  232. // }
  233. // }
  234. // })
  235. //
  236. },
  237. authorizationbtn(){
  238. wx.requestSubscribeMessage({
  239. tmplIds: ['G_37RkJ_mwZeTdPv5A0fjBlYW6_lRQIW9_SywmUAX7Q','AhToqLaCeOvSvSSQ7RvZYd2WgGA11Da13j1PMvqcGqQ'],
  240. success(res) {
  241. console.log(res);
  242. if(res['AhToqLaCeOvSvSSQ7RvZYd2WgGA11Da13j1PMvqcGqQ'] === 'accept' && res['G_37RkJ_mwZeTdPv5A0fjBlYW6_lRQIW9_SywmUAX7Q'] === 'accept') {
  243. // 用户同意订阅
  244. }
  245. }
  246. })
  247. },
  248. bindPickerChange: function(e) {
  249. console.log('picker发送选择改变,携带值为', e.detail.value)
  250. this.setData({
  251. index: e.detail.value
  252. })
  253. wx.setStorage({
  254. key: 'powerstationId', // 存储的key值
  255. data:this.data.objectArray[e.detail.value].powerstationId});
  256. let data = {
  257. powerstationId:this.data.objectArray[e.detail.value].powerstationId
  258. }
  259. api.request(`/syspowerstation/addredisredis`, 'POST',data)
  260. .then((res) => {
  261. console.log(res);
  262. this.getworkoder()
  263. this.getreview()
  264. })
  265. .catch((err) => {
  266. console.error('请求失败:', err);
  267. // 在这里处理请求失败的情况
  268. });
  269. },
  270. /**
  271. * 生命周期函数--监听页面隐藏
  272. */
  273. onHide() {
  274. if (this.intervalId) {
  275. clearInterval(this.intervalId);
  276. this.intervalId = null;
  277. }
  278. },
  279. /**
  280. * 生命周期函数--监听页面卸载
  281. */
  282. onUnload() {
  283. if (this.intervalId) {
  284. clearInterval(this.intervalId); // 停止定时器
  285. this.intervalId = null; // 释放引用
  286. }
  287. },
  288. /**
  289. * 页面相关事件处理函数--监听用户下拉动作
  290. */
  291. async onPullDownRefresh() {
  292. let _this = this
  293. // _this.authorizationbtn()
  294. await _this.getworkoder()
  295. await _this.getreview()
  296. wx.stopPullDownRefresh();
  297. },
  298. /**
  299. * 页面上拉触底事件的处理函数
  300. */
  301. onReachBottom() {
  302. console.log(11111111);
  303. },
  304. /**
  305. * 用户点击右上角分享
  306. */
  307. onShareAppMessage() {
  308. }
  309. })