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.
 
 
 

411 lines
8.6 KiB

  1. <script>
  2. import Vue from 'vue';
  3. //app.js
  4. var config = require("./config");
  5. export default {
  6. onLaunch: function(options) {
  7. uni.getSystemInfo({
  8. success: function(e) {
  9. console.log(e, 'adjsakljdklasjdklsakjdslakjd')
  10. // #ifdef MP-WEIXIN
  11. Vue.prototype.StatusBar = e.statusBarHeight;
  12. let custom = wx.getMenuButtonBoundingClientRect();
  13. Vue.prototype.Custom = custom;
  14. Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
  15. Vue.prototype.windowHeight = e.safeArea.height
  16. // #endif
  17. Vue.mixin({
  18. data() {
  19. return {
  20. StatusBar: Vue.prototype.StatusBar,
  21. CustomBar: Vue.prototype.CustomBar,
  22. windowHeight: Vue.prototype.windowHeight
  23. };
  24. }
  25. });
  26. }
  27. });
  28. if (wx.canIUse('getUpdateManager')) {
  29. const updateManager = wx.getUpdateManager()
  30. updateManager.onCheckForUpdate(function(res) {
  31. if (res.hasUpdate) {
  32. updateManager.onUpdateReady(function() {
  33. uni.showModal({
  34. title: '更新提示',
  35. cancelColor: "#999999",
  36. content: '新版本已经准备好,是否重启应用?',
  37. success: function(res) {
  38. if (res.confirm) {
  39. updateManager.applyUpdate()
  40. }
  41. }
  42. })
  43. })
  44. updateManager.onUpdateFailed(function() {
  45. uni.showModal({
  46. title: '已经有新版本了哟~',
  47. cancelColor: "#999999",
  48. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  49. })
  50. })
  51. }
  52. })
  53. } else {
  54. uni.showModal({
  55. title: '提示',
  56. cancelColor: "#999999",
  57. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  58. })
  59. }
  60. const token = uni.getStorageSync("weapp_session_login_data")
  61. if (typeof token.token != "string") {
  62. return
  63. }
  64. uni.request({
  65. url: config.service.getUser,
  66. method: "GET",
  67. header: {
  68. 'content-type': 'application/json',
  69. 'Authorization': 'Bearer ' + uni.getStorageSync('weapp_session_login_data').token
  70. },
  71. success: (res) => {
  72. let rescor = res.data.data;
  73. console.log(res, '数据', rescor)
  74. // return
  75. if (res.statusCode == 401) {
  76. uni.showToast({
  77. title: '登陆过期请重新登陆',
  78. icon: "none",
  79. duration: 2000,
  80. })
  81. uni.navigateTo({
  82. url: `/pages/login/index`
  83. })
  84. return
  85. }
  86. if (rescor.user.total == 0) {
  87. uni.showToast({
  88. title: '暂无绑定楼盘',
  89. duration: 2000,
  90. icon: "none"
  91. });
  92. return
  93. } else {
  94. let lopan = {
  95. id: rescor.houseList[0].id,
  96. name: rescor.houseList[0].propertyName
  97. }
  98. let users = rescor.user
  99. users.zkProperties = rescor.houseList
  100. console.log(users, '角色数据')
  101. uni.setStorageSync("weapp_session_userInfo_data", users); //写入缓存
  102. }
  103. }
  104. })
  105. // this.$u.get("/user/getUser")
  106. // .then(data => {
  107. // if (data.user.total==0) {
  108. // uni.showToast({
  109. // title: '暂无绑定楼盘',
  110. // duration: 2000,
  111. // icon:"none"
  112. // });
  113. // return
  114. // } else {
  115. // let lopan = {
  116. // id: data.houseList[0].id,
  117. // name: data.houseList[0].propertyName
  118. // }
  119. // let users=data.user
  120. // users.zkProperties=data.houseList
  121. // uni.setStorageSync("weapp_session_userInfo_data",users); //写入缓存
  122. // }
  123. // })
  124. wx.setInnerAudioOption({
  125. obeyMuteSwitch: false
  126. });
  127. },
  128. onShow(options) {
  129. const token = uni.getStorageSync("weapp_session_login_data")
  130. if (typeof token.token != "string") {
  131. console.log("没有")
  132. return
  133. } else {
  134. // this.infoscoket()
  135. }
  136. },
  137. onHide() {},
  138. methods: {
  139. infoscoket() {
  140. let pushon = uni.getStorageSync('weapp_session_userInfo_data').loginName
  141. uni.connectSocket({
  142. url: 'wss://hfju.com/ws?uid=' + pushon + '_applets',
  143. header: {
  144. "content-type": "application/json",
  145. 'Authorization': 'Bearer ' + uni.getStorageSync('weapp_session_login_data').token
  146. }
  147. });
  148. uni.onSocketOpen(function(res) {
  149. console.log('WebSocket连接已打开!');
  150. });
  151. uni.onSocketError(function(res) {
  152. console.log('WebSocket连接打开失败,请检查!');
  153. });
  154. uni.onSocketMessage(function(res) {
  155. console.log('收到服务器内容:' + res.data);
  156. let cedata = JSON.stringify(res);
  157. let data = JSON.parse(cedata);
  158. let zdata = JSON.parse(data.data)
  159. if (zdata.to == "recCmd") {
  160. uni.$emit('update', {
  161. msg: '页面更新'
  162. })
  163. return
  164. }
  165. uni.showModal({
  166. title: '提示',
  167. content: zdata.to + '的设备电量过低请检查!',
  168. cancelText: "取消", // 取消按钮的文字
  169. confirmText: "查看", // 确认按钮文字
  170. success: function(res) {
  171. if (res.confirm) {
  172. console.log('用户点击确定');
  173. uni.navigateTo({
  174. url: `/pages/main/toviewtherecording/index?jump=` + "jump"
  175. })
  176. } else if (res.cancel) {
  177. console.log('用户点击取消');
  178. }
  179. }
  180. });
  181. });
  182. },
  183. Closewebsocke() {
  184. uni.closeSocket();
  185. uni.onSocketClose(function(res) {
  186. console.log('WebSocket 已关闭!');
  187. });
  188. },
  189. }
  190. };
  191. </script>
  192. <style>
  193. @import "./app.css";
  194. </style>
  195. <style lang="scss">
  196. @import "uview-ui/index.scss";
  197. /*每个页面公共css */
  198. //图表样式等
  199. .single {
  200. width: 100%;
  201. background: #FFFFFF;
  202. .title {
  203. width: 100%;
  204. height: 90rpx;
  205. border-bottom: 1rpx solid #E0E0E0;
  206. display: flex;
  207. .title1 {
  208. flex: 2;
  209. font-size: 30rpx;
  210. font-weight: 600;
  211. color: #333333;
  212. line-height: 90rpx;
  213. text-indent: 30rpx;
  214. }
  215. .title3 {
  216. flex: 3;
  217. height: 90rpx;
  218. display: flex;
  219. align-items: center;
  220. justify-content: flex-end;
  221. .title3-box {
  222. display: flex;
  223. align-items: center;
  224. width: 25%;
  225. justify-content: center;
  226. .activecltab {
  227. border-bottom: 2px solid #2671E2;
  228. }
  229. }
  230. }
  231. .title2 {
  232. flex: 3;
  233. height: 90rpx;
  234. display: flex;
  235. align-items: center;
  236. .title2-che {
  237. width: 178rpx;
  238. height: 48rpx;
  239. background: #FFFFFF;
  240. border-radius: 6rpx;
  241. border: 1px solid #E0E0E0;
  242. line-height: 48rpx;
  243. font-size: 28rpx;
  244. font-weight: 400;
  245. color: #666666;
  246. text-indent: 12rpx;
  247. margin-left: 35rpx;
  248. position: relative;
  249. .righttochoose {
  250. width: 18rpx;
  251. height: 24rpx;
  252. position: absolute;
  253. top: 12rpx;
  254. right: 12rpx;
  255. }
  256. }
  257. }
  258. }
  259. .swiper-box {
  260. width: 97%;
  261. margin: 0 auto;
  262. }
  263. .hejibox {
  264. width: 100%;
  265. height: 80rpx;
  266. display: flex;
  267. .heji {
  268. width: 50%;
  269. height: 100%;
  270. font-size: 28rpx;
  271. font-weight: 400;
  272. color: #666666;
  273. line-height: 80rpx;
  274. text-indent: 30rpx;
  275. }
  276. }
  277. .danwei {
  278. width: 100%;
  279. height: 40rpx;
  280. font-size: 24rpx;
  281. font-weight: 400;
  282. color: #999999;
  283. line-height: 40rpx;
  284. text-indent: 30rpx;
  285. }
  286. .uchaserbox {
  287. width: 95%;
  288. height: 470rpx;
  289. }
  290. .jindu {
  291. width: 100%;
  292. height: 300rpx;
  293. .jindu-box {
  294. width: 100%;
  295. padding-left: 30rpx;
  296. padding-right: 30rpx;
  297. .jindu-boxche {
  298. width: 100%;
  299. height: 46rpx;
  300. display: flex;
  301. align-items: center;
  302. height: 50rpx;
  303. .jindu-name {
  304. width: 120rpx;
  305. font-size: 28rpx;
  306. color: #666666;
  307. }
  308. .jindu-zxl {
  309. width: 120rpx;
  310. font-size: 26rpx;
  311. margin-left: 16rpx;
  312. color: #666666;
  313. text-align: center;
  314. }
  315. }
  316. }
  317. }
  318. }
  319. //时间切换的样式
  320. .boxtittab {
  321. width: 100;
  322. height: 92rpx;
  323. background: #FFFFFF;
  324. border: 1px solid #E0E0E0;
  325. display: flex;
  326. align-items: center;
  327. .tabbox {
  328. flex: 1;
  329. height: 100%;
  330. text-align: center;
  331. line-height: 92rpx;
  332. color: #666666;
  333. font-size: 28rpx;
  334. display: flex;
  335. justify-content: center;
  336. .activecllasscet {
  337. width: 96rpx;
  338. border-bottom: 2px solid #2671E2;
  339. }
  340. }
  341. }
  342. //多个格子的样式
  343. .boxzonglan {
  344. width: 100%;
  345. min-height: 496rpx;
  346. background: #FFFFFF;
  347. padding: 30rpx 30rpx 30rpx 30rpx;
  348. .zonglantit {
  349. font-size: 30rpx;
  350. color: #333333;
  351. font-family: PingFangSC-Semibold, PingFang SC;
  352. font-weight: 600;
  353. }
  354. .zonglanbox {
  355. width: 100%;
  356. display: flex;
  357. flex-wrap: wrap;
  358. margin-top: 24rpx;
  359. .grid {
  360. width: 50%;
  361. height: 128rpx;
  362. border: 1px solid #E0E0E0;
  363. .audonum {
  364. color: #666666;
  365. text-indent: 40rpx;
  366. font-size: 26rpx;
  367. margin-top: 20rpx;
  368. }
  369. .num {
  370. color: #333333;
  371. text-indent: 40rpx;
  372. font-size: 32rpx;
  373. font-weight: 600;
  374. margin-top: 10rpx;
  375. }
  376. }
  377. }
  378. }
  379. </style>