App.vue 11 KB

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