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.
 
 
 

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