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.
 
 
 

443 lines
9.4 KiB

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