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.
 
 
 

445 line
9.5 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. if (uni.getStorageSync('buildingID').id) {
  151. this.$u.post('/user/addLoginCount', {
  152. houseId: uni.getStorageSync('buildingID').id
  153. }).then(res=>{}).catc(e=>{})
  154. }
  155. const token = uni.getStorageSync("weapp_session_login_data")
  156. if (typeof token.token != "string") {
  157. console.log("没有")
  158. return
  159. } else {
  160. this.infoscoket()
  161. }
  162. },
  163. onHide() {},
  164. methods: {
  165. infoscoket() {
  166. let pushon = uni.getStorageSync('weapp_session_userInfo_data').loginName
  167. uni.connectSocket({
  168. url: 'wss://hfju.com/ws?uid=' + pushon + '_applets',
  169. header: {
  170. "content-type": "application/json",
  171. 'Access-Token': uni.getStorageSync('weapp_session_login_data').token
  172. }
  173. });
  174. uni.onSocketOpen(function(res) {
  175. console.log('WebSocket连接已打开!');
  176. });
  177. uni.onSocketError(function(res) {
  178. console.log('WebSocket连接打开失败,请检查!');
  179. });
  180. uni.onSocketMessage(function(res) {
  181. console.log('收到服务器内容:' + res.data);
  182. let cedata = JSON.stringify(res);
  183. let data = JSON.parse(cedata);
  184. let zdata = JSON.parse(data.data)
  185. if (zdata.to == "recCmd") {
  186. uni.$emit('update', {
  187. msg: '页面更新'
  188. })
  189. return
  190. }
  191. uni.showModal({
  192. title: '提示',
  193. content: zdata.to + '的设备电量过低请检查!',
  194. cancelText: "取消", // 取消按钮的文字
  195. confirmText: "查看", // 确认按钮文字
  196. success: function(res) {
  197. if (res.confirm) {
  198. console.log('用户点击确定');
  199. uni.navigateTo({
  200. url: `/pages/main/toviewtherecording/index?jump=` + "jump"
  201. })
  202. } else if (res.cancel) {
  203. console.log('用户点击取消');
  204. }
  205. }
  206. });
  207. });
  208. },
  209. Closewebsocke() {
  210. uni.closeSocket();
  211. uni.onSocketClose(function(res) {
  212. console.log('WebSocket 已关闭!');
  213. });
  214. },
  215. }
  216. };
  217. </script>
  218. <style>
  219. @import "./app.css";
  220. </style>
  221. <style lang="scss">
  222. @import "uview-ui/index.scss";
  223. /*每个页面公共css */
  224. //图表样式等
  225. .single {
  226. width: 100%;
  227. background: #FFFFFF;
  228. .title {
  229. width: 100%;
  230. height: 90rpx;
  231. border-bottom: 1rpx solid #E0E0E0;
  232. display: flex;
  233. .title1 {
  234. flex: 2;
  235. font-size: 30rpx;
  236. font-weight: 600;
  237. color: #333333;
  238. line-height: 90rpx;
  239. text-indent: 30rpx;
  240. }
  241. .title3 {
  242. flex: 3;
  243. height: 90rpx;
  244. display: flex;
  245. align-items: center;
  246. justify-content: flex-end;
  247. .title3-box {
  248. display: flex;
  249. align-items: center;
  250. width: 25%;
  251. justify-content: center;
  252. .activecltab {
  253. border-bottom: 2px solid #2671E2;
  254. }
  255. }
  256. }
  257. .title2 {
  258. flex: 3;
  259. height: 90rpx;
  260. display: flex;
  261. align-items: center;
  262. .title2-che {
  263. width: 178rpx;
  264. height: 48rpx;
  265. background: #FFFFFF;
  266. border-radius: 6rpx;
  267. border: 1px solid #E0E0E0;
  268. line-height: 48rpx;
  269. font-size: 28rpx;
  270. font-weight: 400;
  271. color: #666666;
  272. text-indent: 12rpx;
  273. margin-left: 35rpx;
  274. position: relative;
  275. .righttochoose {
  276. width: 18rpx;
  277. height: 24rpx;
  278. position: absolute;
  279. top: 12rpx;
  280. right: 12rpx;
  281. }
  282. }
  283. }
  284. }
  285. .swiper-box {
  286. width: 97%;
  287. margin: 0 auto;
  288. }
  289. .hejibox {
  290. width: 100%;
  291. height: 80rpx;
  292. display: flex;
  293. .heji {
  294. width: 50%;
  295. height: 100%;
  296. font-size: 28rpx;
  297. font-weight: 400;
  298. color: #666666;
  299. line-height: 80rpx;
  300. text-indent: 30rpx;
  301. }
  302. }
  303. .danwei {
  304. width: 100%;
  305. height: 40rpx;
  306. font-size: 24rpx;
  307. font-weight: 400;
  308. color: #999999;
  309. line-height: 40rpx;
  310. text-indent: 30rpx;
  311. }
  312. .uchaserbox {
  313. width: 95%;
  314. height: 470rpx;
  315. }
  316. .jindu {
  317. width: 100%;
  318. height: 300rpx;
  319. .jindu-box {
  320. width: 100%;
  321. padding-left: 30rpx;
  322. padding-right: 30rpx;
  323. .jindu-boxche {
  324. width: 100%;
  325. height: 46rpx;
  326. display: flex;
  327. align-items: center;
  328. height: 50rpx;
  329. .jindu-name {
  330. width: 120rpx;
  331. font-size: 28rpx;
  332. color: #666666;
  333. }
  334. .jindu-zxl {
  335. width: 120rpx;
  336. font-size: 26rpx;
  337. margin-left: 16rpx;
  338. color: #666666;
  339. text-align: center;
  340. }
  341. }
  342. }
  343. }
  344. }
  345. //时间切换的样式
  346. .boxtittab {
  347. width: 100;
  348. height: 92rpx;
  349. background: #FFFFFF;
  350. border: 1px solid #E0E0E0;
  351. display: flex;
  352. align-items: center;
  353. .tabbox {
  354. flex: 1;
  355. height: 100%;
  356. text-align: center;
  357. line-height: 92rpx;
  358. color: #666666;
  359. font-size: 28rpx;
  360. display: flex;
  361. justify-content: center;
  362. .activecllasscet {
  363. width: 96rpx;
  364. border-bottom: 2px solid #2671E2;
  365. }
  366. }
  367. }
  368. //多个格子的样式
  369. .boxzonglan {
  370. width: 100%;
  371. min-height: 496rpx;
  372. background: #FFFFFF;
  373. padding: 30rpx 30rpx 30rpx 30rpx;
  374. .zonglantit {
  375. font-size: 30rpx;
  376. color: #333333;
  377. font-family: PingFangSC-Semibold, PingFang SC;
  378. font-weight: 600;
  379. }
  380. .zonglanbox {
  381. width: 100%;
  382. display: flex;
  383. flex-wrap: wrap;
  384. margin-top: 24rpx;
  385. .grid {
  386. width: 50%;
  387. height: 128rpx;
  388. border: 1px solid #E0E0E0;
  389. .audonum {
  390. color: #666666;
  391. text-indent: 40rpx;
  392. font-size: 26rpx;
  393. margin-top: 20rpx;
  394. }
  395. .num {
  396. color: #333333;
  397. text-indent: 40rpx;
  398. font-size: 32rpx;
  399. font-weight: 600;
  400. margin-top: 10rpx;
  401. }
  402. }
  403. }
  404. }
  405. </style>