App.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. <style lang="scss">
  2. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  3. @import "@/uni_modules/uview-ui/index.scss";
  4. </style>
  5. <script>
  6. import Vue from "vue";
  7. import appUpdate from "common/util/appUpdate.js";
  8. import configService from "@/common/service/config.service.js";
  9. import { connectWebSocket, sendWebSocketMessage, closeWebSocket } from '@/common/util/websocket'
  10. export default {
  11. data() {
  12. return {
  13. socketTask: null,//websocket对象
  14. }
  15. },
  16. onLaunch: function () {
  17. //消息推送
  18. uni.getPushClientId({
  19. //获取客户端推送标识
  20. success: (res) => {
  21. console.log(res.cid, 'cid---');
  22. uni.setStorageSync('push_cid', res.cid); // 存储CID供后续使用
  23. },
  24. fail(err) {
  25. console.log(err)
  26. }
  27. });
  28. // plus.push.addEventListener('click', (msg) => {
  29. // console.log('点击消息内容:', msg);
  30. // });
  31. uni.onPushMessage((res) => {
  32. //客户端监听推送消息
  33. console.log("收到推送消息:", res) //监听推送消息
  34. if (res.data) {
  35. uni.createPushMessage(res.data) //收到消息推送,创建系统状态栏及锁屏通 知
  36. }
  37. })
  38. const savedIP = uni.getStorageSync("selectedIP");
  39. if (configService.apiUrl !== "") {
  40. uni.getSystemInfo({
  41. success: function (e) {
  42. // #ifdef APP-PLUS
  43. // 检测升级
  44. appUpdate();
  45. // #endif
  46. // #ifndef MP
  47. Vue.prototype.StatusBar = e.statusBarHeight;
  48. if (e.platform == "android") {
  49. Vue.prototype.CustomBar = e.statusBarHeight + 50;
  50. } else {
  51. Vue.prototype.CustomBar = e.statusBarHeight + 45;
  52. }
  53. // #endif
  54. // #ifdef MP-WEIXIN
  55. Vue.prototype.StatusBar = e.statusBarHeight;
  56. let custom = wx.getMenuButtonBoundingClientRect();
  57. Vue.prototype.Custom = custom;
  58. Vue.prototype.CustomBar =
  59. custom.bottom + custom.top - e.statusBarHeight;
  60. // #endif
  61. // #ifdef MP-ALIPAY
  62. Vue.prototype.StatusBar = e.statusBarHeight;
  63. Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
  64. // #endif
  65. // #ifdef APP-PLUS
  66. //Vue.prototype.$api.listenTranMsg()
  67. // var info = plus.push.getClientInfo();
  68. // /* 5+ push 消息推送 ps:使用:H5+的方式监听,实现推送*/
  69. // plus.push.addEventListener("click", function(msg) {
  70. // console.log("click:" + JSON.stringify(msg));
  71. // console.log(msg.payload);
  72. // console.log(JSON.stringify(msg));
  73. // //这里可以写跳转业务代码
  74. // }, false);
  75. // // 监听在线消息事件
  76. // plus.push.addEventListener("receive", function(msg) {
  77. // // plus.ui.alert(2);
  78. // //这里可以写跳转业务代码
  79. // console.log("recevice:" + JSON.stringify(msg))
  80. // }, false);
  81. // #endif
  82. //Vue.prototype.$api.initLogin()
  83. },
  84. });
  85. Vue.prototype.NavBarColor = "bg-gradual-blue";
  86. Vue.prototype.Radio_Check_Size = "scale(0.7)";
  87. Vue.prototype.ColorList = [
  88. {
  89. title: "嫣红",
  90. name: "red",
  91. color: "#e54d42",
  92. },
  93. {
  94. title: "桔橙",
  95. name: "orange",
  96. color: "#f37b1d",
  97. },
  98. {
  99. title: "明黄",
  100. name: "yellow",
  101. color: "#fbbd08",
  102. },
  103. {
  104. title: "橄榄",
  105. name: "olive",
  106. color: "#8dc63f",
  107. },
  108. {
  109. title: "森绿",
  110. name: "green",
  111. color: "#39b54a",
  112. },
  113. {
  114. title: "天青",
  115. name: "cyan",
  116. color: "#1cbbb4",
  117. },
  118. {
  119. title: "海蓝",
  120. name: "blue",
  121. color: "#0081ff",
  122. },
  123. {
  124. title: "姹紫",
  125. name: "purple",
  126. color: "#6739b6",
  127. },
  128. {
  129. title: "木槿",
  130. name: "mauve",
  131. color: "#9c26b0",
  132. },
  133. {
  134. title: "桃粉",
  135. name: "pink",
  136. color: "#e03997",
  137. },
  138. {
  139. title: "棕褐",
  140. name: "brown",
  141. color: "#a5673f",
  142. },
  143. {
  144. title: "玄灰",
  145. name: "grey",
  146. color: "#8799a3",
  147. },
  148. {
  149. title: "草灰",
  150. name: "gray",
  151. color: "#aaaaaa",
  152. },
  153. {
  154. title: "墨黑",
  155. name: "black",
  156. color: "#333333",
  157. },
  158. {
  159. title: "雅白",
  160. name: "white",
  161. color: "#ffffff",
  162. },
  163. ];
  164. } else {
  165. if (!savedIP) {
  166. uni.reLaunch({ url: "/pages/ipConfig/ipConfig" });
  167. return;
  168. } else {
  169. uni.getSystemInfo({
  170. success: function (e) {
  171. // #ifdef APP-PLUS
  172. // 检测升级
  173. appUpdate();
  174. // #endif
  175. // #ifndef MP
  176. Vue.prototype.StatusBar = e.statusBarHeight;
  177. if (e.platform == "android") {
  178. Vue.prototype.CustomBar = e.statusBarHeight + 50;
  179. } else {
  180. Vue.prototype.CustomBar = e.statusBarHeight + 45;
  181. }
  182. // #endif
  183. // #ifdef MP-WEIXIN
  184. Vue.prototype.StatusBar = e.statusBarHeight;
  185. let custom = wx.getMenuButtonBoundingClientRect();
  186. Vue.prototype.Custom = custom;
  187. Vue.prototype.CustomBar =
  188. custom.bottom + custom.top - e.statusBarHeight;
  189. // #endif
  190. // #ifdef MP-ALIPAY
  191. Vue.prototype.StatusBar = e.statusBarHeight;
  192. Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
  193. // #endif
  194. // #ifdef APP-PLUS
  195. //Vue.prototype.$api.listenTranMsg()
  196. // var info = plus.push.getClientInfo();
  197. // /* 5+ push 消息推送 ps:使用:H5+的方式监听,实现推送*/
  198. // plus.push.addEventListener("click", function(msg) {
  199. // console.log("click:" + JSON.stringify(msg));
  200. // console.log(msg.payload);
  201. // console.log(JSON.stringify(msg));
  202. // //这里可以写跳转业务代码
  203. // }, false);
  204. // // 监听在线消息事件
  205. // plus.push.addEventListener("receive", function(msg) {
  206. // // plus.ui.alert(2);
  207. // //这里可以写跳转业务代码
  208. // console.log("recevice:" + JSON.stringify(msg))
  209. // }, false);
  210. // #endif
  211. //Vue.prototype.$api.initLogin()
  212. },
  213. });
  214. Vue.prototype.NavBarColor = "bg-gradual-blue";
  215. Vue.prototype.Radio_Check_Size = "scale(0.7)";
  216. Vue.prototype.ColorList = [
  217. {
  218. title: "嫣红",
  219. name: "red",
  220. color: "#e54d42",
  221. },
  222. {
  223. title: "桔橙",
  224. name: "orange",
  225. color: "#f37b1d",
  226. },
  227. {
  228. title: "明黄",
  229. name: "yellow",
  230. color: "#fbbd08",
  231. },
  232. {
  233. title: "橄榄",
  234. name: "olive",
  235. color: "#8dc63f",
  236. },
  237. {
  238. title: "森绿",
  239. name: "green",
  240. color: "#39b54a",
  241. },
  242. {
  243. title: "天青",
  244. name: "cyan",
  245. color: "#1cbbb4",
  246. },
  247. {
  248. title: "海蓝",
  249. name: "blue",
  250. color: "#0081ff",
  251. },
  252. {
  253. title: "姹紫",
  254. name: "purple",
  255. color: "#6739b6",
  256. },
  257. {
  258. title: "木槿",
  259. name: "mauve",
  260. color: "#9c26b0",
  261. },
  262. {
  263. title: "桃粉",
  264. name: "pink",
  265. color: "#e03997",
  266. },
  267. {
  268. title: "棕褐",
  269. name: "brown",
  270. color: "#a5673f",
  271. },
  272. {
  273. title: "玄灰",
  274. name: "grey",
  275. color: "#8799a3",
  276. },
  277. {
  278. title: "草灰",
  279. name: "gray",
  280. color: "#aaaaaa",
  281. },
  282. {
  283. title: "墨黑",
  284. name: "black",
  285. color: "#333333",
  286. },
  287. {
  288. title: "雅白",
  289. name: "white",
  290. color: "#ffffff",
  291. },
  292. ];
  293. }
  294. }
  295. },
  296. onShow: function () {
  297. console.log("App Show");
  298. // this.getConnect()
  299. },
  300. onHide: function () {
  301. console.log("App Hide");
  302. clearInterval(this.$store.state.timer); // 假设定时器存储在 Vuex 的状态管理中
  303. },
  304. methods: {
  305. // //获取推送消息,标题
  306. // getInfoInit(title, message) {
  307. // uni.request({
  308. // url: 'https://fc-mp-2578c13f-eaaa-45e9-a01e-6a48b45fb7a0.next.bspapp.com/testPush', //云函数url
  309. // data: {
  310. // cid: uni.getStorageSync('push_cid'),
  311. // title: title, //可按需传入动态参数,在云函数index.js接收参数
  312. // content: message,
  313. // },
  314. // method: 'get',
  315. // success(result) {
  316. // console.log('发送通知', result);
  317. // },
  318. // fail({ errMsg }) {
  319. // console.log('request fail', errMsg)
  320. // }
  321. // })
  322. // },
  323. //连接websocket
  324. // async getConnect() {
  325. // let that = this
  326. // try {
  327. // that.socketTask = await connectWebSocket();
  328. // that.socketTask.onMessage((res) => {
  329. // console.log('收到消息:websocket已连接 ', res)
  330. // // let message = JSON.parse(res.data)
  331. // // //报警信息推送
  332. // // if (message.warndata) {
  333. // // that.getInfoInit(message.msgTitle, message.warndata)
  334. // // }
  335. // that.getInfoInit('111', '2222')
  336. // });
  337. // } catch (err) {
  338. // console.log('连接失败: ' + err)
  339. // }
  340. // },
  341. }
  342. };
  343. </script>
  344. <style>
  345. @import "plugin/colorui/main.css";
  346. @import "plugin/colorui/icon.css";
  347. @import "plugin/colorui/animation.css";
  348. .nav-list {
  349. display: flex;
  350. flex-wrap: wrap;
  351. padding: 0px 40upx 0px;
  352. justify-content: space-between;
  353. }
  354. .nav-li {
  355. padding: 30upx;
  356. border-radius: 12upx;
  357. width: 45%;
  358. margin: 0 2.5% 40upx;
  359. background-image: url(https://cdn.nlark.com/yuque/0/2019/png/280374/1552996358352-assets/web-upload/cc3b1807-c684-4b83-8f80-80e5b8a6b975.png);
  360. background-size: cover;
  361. background-position: center;
  362. position: relative;
  363. z-index: 1;
  364. }
  365. .nav-li::after {
  366. content: "";
  367. position: absolute;
  368. z-index: -1;
  369. background-color: inherit;
  370. width: 100%;
  371. height: 100%;
  372. left: 0;
  373. bottom: -10%;
  374. border-radius: 10upx;
  375. opacity: 0.2;
  376. transform: scale(0.9, 0.9);
  377. }
  378. .nav-li.cur {
  379. color: #fff;
  380. background: rgb(94, 185, 94);
  381. box-shadow: 4upx 4upx 6upx rgba(94, 185, 94, 0.4);
  382. }
  383. .nav-title {
  384. font-size: 32upx;
  385. font-weight: 300;
  386. }
  387. .nav-title::first-letter {
  388. font-size: 40upx;
  389. margin-right: 4upx;
  390. }
  391. .nav-name {
  392. font-size: 28upx;
  393. text-transform: Capitalize;
  394. margin-top: 20upx;
  395. position: relative;
  396. }
  397. .nav-name::before {
  398. content: "";
  399. position: absolute;
  400. display: block;
  401. width: 40upx;
  402. height: 6upx;
  403. background: #fff;
  404. bottom: 0;
  405. right: 0;
  406. opacity: 0.5;
  407. }
  408. .nav-name::after {
  409. content: "";
  410. position: absolute;
  411. display: block;
  412. width: 100upx;
  413. height: 1px;
  414. background: #fff;
  415. bottom: 0;
  416. right: 40upx;
  417. opacity: 0.3;
  418. }
  419. .nav-name::first-letter {
  420. font-weight: bold;
  421. font-size: 36upx;
  422. margin-right: 1px;
  423. }
  424. .nav-li text {
  425. position: absolute;
  426. right: 30upx;
  427. top: 30upx;
  428. font-size: 52upx;
  429. width: 60upx;
  430. height: 60upx;
  431. text-align: center;
  432. line-height: 60upx;
  433. }
  434. .text-light {
  435. font-weight: 300;
  436. }
  437. @keyframes show {
  438. 0% {
  439. transform: translateY(-50px);
  440. }
  441. 60% {
  442. transform: translateY(40upx);
  443. }
  444. 100% {
  445. transform: translateY(0px);
  446. }
  447. }
  448. @-webkit-keyframes show {
  449. 0% {
  450. transform: translateY(-50px);
  451. }
  452. 60% {
  453. transform: translateY(40upx);
  454. }
  455. 100% {
  456. transform: translateY(0px);
  457. }
  458. }
  459. </style>