Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

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