App.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. <script>
  2. const {
  3. updateManager
  4. } = require('./common/config.js');
  5. import {
  6. newsClassify,
  7. getInformationFindPage
  8. } from "@/api/government.js";
  9. export default {
  10. globalData: {
  11. statusBarHeight: 0, // 状态烂高度
  12. //全局配置参数
  13. barHeight: 0,
  14. screenWidth: 0,
  15. screenHeight: 0,
  16. windowHeight: 0,
  17. viewHeight: 0,
  18. openPay: true,
  19. navHeight: 44,
  20. nav_status_Height: 44,
  21. test: ''
  22. },
  23. onLaunch: function(options) {
  24. uni.preloadPage({
  25. url: "/pages/government/discovery",
  26. success: (e) => {
  27. console.log(e)
  28. },
  29. fail: (e) => {
  30. console.log(e)
  31. },
  32. });
  33. // this.preloadPage();
  34. this.loadExecution()
  35. // setTimeout(() => {
  36. // push.navigator.closeSplashscreen();
  37. // },5000)
  38. // push.screen.lockOrientation("/")
  39. // 监听事件 打开靓码页面
  40. uni.onTabBarMidButtonTap(() => {
  41. uni.navigateTo({
  42. url: '/pages/government/beautiful-code',
  43. fail: err => {
  44. console.log('onTabBarMidButtonTap = ', err)
  45. }
  46. });
  47. })
  48. let that = this;
  49. // #ifdef APP-PLUS
  50. plus.screen.lockOrientation('portrait-primary'); //竖屏正方向锁定
  51. updateManager();
  52. //#endif
  53. // #ifndef APP-PLUS
  54. // 是否开启支付
  55. // that.$http.get('/saleconfig/openPayment').then(res => {
  56. // if (res && res.code == 200) {
  57. // that.globalData.openPay = res.openPayment;
  58. // }
  59. // });
  60. //#endif
  61. if (options.query.code) {
  62. uni.setStorageSync('code', options.query.code);
  63. }
  64. // #ifdef APP-PLUS
  65. // App平台检测升级,服务端代码是通过uniCloud的云函数实现的,详情可参考:https://ext.dcloud.net.cn/plugin?id=2226
  66. // #endif
  67. //获取设备顶部窗口的高度(不同设备窗口高度不一样,根据这个来设置自定义导航栏的高度)
  68. uni.getSystemInfo({
  69. success: (res) => {
  70. this.globalData.barHeight = res.statusBarHeight;
  71. this.globalData.screenWidth = res.screenWidth;
  72. this.globalData.screenHeight = res.screenHeight;
  73. this.globalData.viewHeight = res.windowHeight;
  74. this.globalData.statusBarHeight = res.statusBarHeight || 0;
  75. this.globalData.nav_status_Height = res.statusBarHeight + this.globalData.navHeight
  76. },
  77. });
  78. //应用通知(消息推送)
  79. // uniPush1.getPushClientId()
  80. // #ifdef APP-PLUS
  81. // plus.push.getClientInfoAsync((info) => {
  82. // let cid = info["clientid"];
  83. // uni.setStorageSync('cid', cid)
  84. // // this.cid = cid
  85. // console.log(cid)
  86. // });
  87. // // #endif
  88. // that.getPush()
  89. /**
  90. * 校验session_key是否失效
  91. * 如果失效,则清空登录态,当需要登录的时候,从login.wxml重新登录
  92. */
  93. // uni.checkSession({
  94. // success() {
  95. // // sessionKey有效没有过期
  96. // console.log("checkSession success");
  97. // },
  98. // fail() {
  99. // // sessionKey已经失效,过期
  100. // console.log("checkSession fail");
  101. // // 清空登录所有相关信息
  102. // // clearLoginStatus();
  103. // },
  104. // });
  105. },
  106. onShow: function(e) {
  107. // #ifdef APP-PLUS
  108. setTimeout(() => {
  109. var args = plus.runtime.arguments;
  110. if (args) {
  111. // let obj=this.getQueryParams(args);
  112. // if(obj.orderNo){
  113. // this.getUrlType(obj.orderNo)
  114. // }
  115. try {
  116. let res = args.split('&');
  117. let pageType = res[1].split('=')[1];
  118. let type = res[2].split('=')[1];
  119. let id = res[3].split('=')[1];
  120. let shareId = res[4].split('=')[1];
  121. let teamId = res[5].split('=')[1];
  122. // 普通商品
  123. if (pageType == 1 && type == 1) {
  124. uni.navigateTo({
  125. url: '/pages/product/goods/goods?id=' + id + '&shareId=' + shareId,
  126. });
  127. }
  128. //积分商品
  129. if (pageType == 1 && type == 5) {
  130. uni.navigateTo({
  131. url: '/pages/product/goods/IntegralGood?id=' + id + '&shareId=' +
  132. shareId,
  133. });
  134. }
  135. //服务商品
  136. if (pageType == 1 && type == 4) {
  137. uni.navigateTo({
  138. url: '/pages/product/goods?id=' + id + '&shareId=' + shareId,
  139. });
  140. }
  141. //秒杀商品
  142. if (pageType == 1 && type == 2) {
  143. uni.navigateTo({
  144. url: '/pages/product/goods?id=' + id + '&shareId=' + shareId,
  145. });
  146. }
  147. //团购商品
  148. if (pageType == 1 && type == 3) {
  149. console.log('555555555');
  150. uni.navigateTo({
  151. url: '/pages/product/goods?id=' + id + '&shareId=' + shareId +
  152. '&teamId=' +
  153. teamId,
  154. });
  155. }
  156. //文章
  157. if (pageType == 2) {
  158. console.log('6666666');
  159. uni.navigateTo({
  160. url: '/pages/research/recommend/details?id=' + id + '&shareId=' +
  161. shareId,
  162. });
  163. }
  164. // 作品
  165. if (pageType == 3) {
  166. console.log('777777777777');
  167. uni.navigateTo({
  168. url: '/pages/research/business/article?id=' + id + '&shareId=' +
  169. shareId,
  170. });
  171. }
  172. if (pageType == 4) {
  173. uni.navigateTo({
  174. url: '/pages/login/index',
  175. });
  176. }
  177. } catch (e) {
  178. //TODO handle the exception
  179. }
  180. }
  181. }, 10);
  182. // #endif
  183. },
  184. methods: {
  185. // preloadPage() {
  186. // newsClassify({
  187. // informationChannel: this.$keys.information_discover
  188. // }).then(res => {
  189. // const data = res.data || [];
  190. // getInformationFindPage({
  191. // pageNum: 1,
  192. // pageSize: 10,
  193. // informationTypeId: data[0].informationTypeId
  194. // }).then(res => {
  195. // uni.setStorageSync('discoveryPage', res);
  196. // })
  197. // })
  198. // },
  199. loadExecution() {
  200. /**
  201. * 获取本地存储中launchFlag的值
  202. * 若存在,说明不是首次启动,直接进入首页;
  203. * 若不存在,说明是首次启动,进入引导页;
  204. */
  205. // push.navigator.closeSplashscreen();
  206. // const value = uni.getStorageSync('launchFlag');
  207. // console.log('value = ' , value)
  208. // setTimeout(() => {
  209. // if (value == true) {
  210. // uni.switchTab({
  211. // url: '/pages/home',
  212. // success: res => {
  213. // push.navigator.closeSplashscreen();
  214. // },
  215. // fail: () => {
  216. // push.navigator.closeSplashscreen();
  217. // }
  218. // });
  219. // } else {
  220. // push.navigator.closeSplashscreen();
  221. // }
  222. // })
  223. try {
  224. const value = uni.getStorageSync('launchFlag');
  225. // console.log('value = ' , value)
  226. if (value) {
  227. if (value == true) {
  228. uni.redirectTo({
  229. url: '/pages/index/secondaryGuide'
  230. });
  231. } else {
  232. uni.redirectTo({
  233. url: '/pages/index/guide'
  234. });
  235. }
  236. } else {
  237. uni.setStorage({
  238. key: 'launchFlag',
  239. data: true,
  240. success: function() {
  241. console.log('存储launchFlag');
  242. }
  243. });
  244. uni.redirectTo({
  245. url: '/pages/index/guide'
  246. });
  247. }
  248. } catch (e) {
  249. // error
  250. uni.setStorage({
  251. key: 'launchFlag',
  252. data: true,
  253. success: function() {
  254. console.log('error时存储launchFlag');
  255. }
  256. });
  257. uni.redirectTo({
  258. url: '/pages/index/guide',
  259. });
  260. }
  261. },
  262. watchRouter(e) {
  263. console.log('路由进行跳转', JSON.stringify(e.url));
  264. },
  265. getUrlType(orderNo) {
  266. this.$yghttp.post('/sand/order/getRedirectMode', {
  267. orderNo: orderNo
  268. }).then(res => {
  269. console.log(res)
  270. if (res.data.jumpType == 1) {
  271. uni.redirectTo({
  272. url: res.data.path
  273. });
  274. } else if (res.data.jumpType == 2) {
  275. uni.redirectTo({
  276. url: "/pages/web-view/Apps?path=" + res.data.path + '&title=唯品会'
  277. })
  278. }
  279. })
  280. },
  281. getQueryParams(e) {
  282. const paramsString = e; // 将查询字符串转换为字符串
  283. const paramsArray = paramsString.split('&'); // 将字符串按 & 分割成数组
  284. // 遍历数组,将每个参数存储到对象中
  285. const paramsObj = {};
  286. for (let i = 0; i < paramsArray.length; i++) {
  287. const [key, value] = paramsArray[i].split('=');
  288. paramsObj[decodeURIComponent(key)] = decodeURIComponent(value);
  289. }
  290. return paramsObj
  291. },
  292. //跳转
  293. jump(item, obj) {
  294. let that = this;
  295. if (item.type == 0) {
  296. let activityType = obj.activity_type;
  297. if (activityType == 1) {
  298. uni.navigateTo({
  299. url: '/pages/research/nearby/timeLimit',
  300. });
  301. }
  302. if (activityType == 2) {
  303. uni.navigateTo({
  304. url: '/pages/research/homepage/groupList',
  305. });
  306. }
  307. }
  308. //支付消息
  309. if (item.type == 1) {
  310. let goodsType = obj.goods_type;
  311. if (goodsType == 0) {
  312. let id = obj.order_id;
  313. uni.navigateTo({
  314. url: `/pages/order/orderList/orderDetails?id=${id}&status=pay`,
  315. });
  316. //普通商品完成
  317. }
  318. if (goodsType == 1) {
  319. let id = obj.order_id;
  320. uni.navigateTo({
  321. url: `/pages/order/orderList/serviceOrderDetail?id=${id}&status=pay`,
  322. });
  323. //服务详情完成
  324. }
  325. if (goodsType == 2) {
  326. let id = obj.order_id;
  327. if (obj.activity_type == 2) {
  328. uni.navigateTo({
  329. url: '/pages/order/gbOrder/gbOrderDetails?id=' +
  330. id +
  331. '&status=pay' +
  332. '&groupId=' +
  333. obj.goods[0].team_member_id,
  334. });
  335. }
  336. //跳转秒杀详情地址还没写上去
  337. else if (obj.activity_type == 1) {
  338. uni.navigateTo({
  339. // url:"/pages/product/goods/seckillGoods?id="+obj.goods[0].goods_id
  340. url: `/pages/order/orderList/orderDetails?id=${id}&status=pay`,
  341. });
  342. }
  343. }
  344. //积分商品
  345. if (goodsType == 3) {
  346. let id = obj.order_id;
  347. uni.navigateTo({
  348. url: `/pages/order/orderList/orderDetails?id=${id}&status=pay`,
  349. });
  350. //完成
  351. }
  352. // if (goodsType == 4) {
  353. // uni.navigateTo({
  354. // url: "/pages/user/wallet/transactionDetail"
  355. // })
  356. // }
  357. }
  358. //物流消息
  359. if (item.type == 2) {
  360. let logisticsStatus = obj.logistics_status;
  361. if (logisticsStatus == 0) {
  362. let id = obj.order_id;
  363. uni.navigateTo({
  364. url: `/pages/order/orderList/orderDetails?id=${id}&status=pay`,
  365. });
  366. }
  367. if (logisticsStatus == 1) {
  368. let id = obj.order_id;
  369. uni.navigateTo({
  370. url: `/pages/order/orderList/orderDetails?id=${id}&status=pay`,
  371. });
  372. }
  373. }
  374. //售后消息
  375. if (item.type == 3) {
  376. let id = obj.rights_order_id;
  377. console.log(id);
  378. that.$http.get(`/rights/info/${id}`).then((res) => {
  379. if (res && res.code == 200) {
  380. let shopid = res.data.shop_id;
  381. let rightsType = res.data.rights_type;
  382. let rightsRefundStatus = res.data.rights_operate_status;
  383. uni.navigateTo({
  384. url: '/pages/order/orderList/orderblackDetails?id=' +
  385. id +
  386. '&shopid=' +
  387. shopid +
  388. '&type=' +
  389. rightsType +
  390. '&status=' +
  391. rightsRefundStatus,
  392. });
  393. } else {
  394. uni.showToast({
  395. title: '无此订单',
  396. icon: 'none',
  397. duration: 2000,
  398. });
  399. }
  400. });
  401. //先全部跳售后详情
  402. }
  403. // 互动消息
  404. if (item.type == 4) {
  405. let id = item.user_id;
  406. let personalType = obj.type;
  407. // if (personalType == 0 || personalType == 2) {
  408. // let id = obj.model_id
  409. // uni.navigateTo({
  410. // url: "/pages/research/recommend/details?id=" + id
  411. // })
  412. // } else if (personalType == 1) {
  413. // let id = item.user_id
  414. // uni.navigateTo({
  415. // url: "/pages/research/community/homepage?user_id=" + id
  416. // })
  417. // } else if (personalType == 3) {
  418. // let id = obj.model_id
  419. // uni.navigateTo({
  420. // url: "/pages/research/setup/toExamine?id=" + id
  421. // })
  422. // } else if (personalType == 4) {
  423. // let id = obj.model_id
  424. // uni.navigateTo({
  425. // url: "/pages/research/setup/toBusiness?id=" + id
  426. // })
  427. // }
  428. if (personalType == 4) {
  429. // let id = obj.model_id
  430. uni.navigateTo({
  431. url: '/pages/user/merchant/audit',
  432. });
  433. } else if (personalType == 5) {
  434. uni.navigateTo({
  435. url: '/pages/workbench/shop/audit',
  436. });
  437. }
  438. }
  439. // 系统消息
  440. if (item.type == 5) {
  441. if (obj.type == 0) {
  442. uni.navigateTo({
  443. url: `/pages/user/regional-agency/index`,
  444. });
  445. }
  446. }
  447. },
  448. getPush() {
  449. // #ifdef APP-PLUS
  450. plus.push.setAutoNotification(true); //设置通知栏显示通知必须设置
  451. //从系统消息中心点击消息启动应用事件
  452. let that = this;
  453. let platform = uni.getSystemInfoSync().platform;
  454. plus.push.addEventListener(
  455. 'click',
  456. (data) => {
  457. // JSON.parse(data.payload)
  458. // uni.setClipboardData({
  459. // data: data,
  460. // success: function(res) {
  461. // uni.showToast({
  462. // title: '复制成功',
  463. // });
  464. // }
  465. // });
  466. // uni.showModal({
  467. // title: '苹果离线提示11' + Object.prototype.toString.call(data) + 'type::'+data.type,
  468. // content: JSON.stringify(data),
  469. // success: function(res) {
  470. // if (res.confirm) {
  471. // console.log('用户点击确定');
  472. // } else if (res.cancel) {
  473. // console.log('用户点击取消');
  474. // }
  475. // }
  476. // });
  477. if (platform == 'ios' && data.type == 'click') {
  478. //苹果离线点击事件
  479. let obj = data.payload.payload.message_body;
  480. let item = data.payload.payload;
  481. that.jump(item, obj);
  482. }
  483. if (platform == 'ios') {
  484. //苹果在线点击事件
  485. let item = JSON.parse(data.payload);
  486. let obj = item.message_body;
  487. that.jump(item, obj);
  488. }
  489. if (platform == 'android') {
  490. //安卓在线点击事件
  491. let item = data.payload;
  492. let obj = item.message_body;
  493. that.jump(item, obj);
  494. }
  495. },
  496. false
  497. );
  498. //应用从推送服务器接收到推送消息事件
  499. plus.push.addEventListener(
  500. 'receive',
  501. (res) => {
  502. if (platform == 'android') {
  503. //安卓在线推送
  504. // item = res.payload
  505. var options = {
  506. cover: false,
  507. title: res.title,
  508. };
  509. plus.push.createMessage(res.content, res.payload, options);
  510. // uni.showModal({
  511. // title: '安卓在线提示11' + Object.prototype.toString.call(res.payload),
  512. // content: JSON.stringify(res.payload),
  513. // success: function(r) {
  514. // if (r.confirm) {
  515. // console.log('用户点击确定');
  516. // } else if (r.cancel) {
  517. // console.log('用户点击取消');
  518. // }
  519. // }
  520. // });
  521. } else {
  522. //苹果在线推送事件
  523. if (res.aps == null || res.type == 'receive') {
  524. var options = {
  525. cover: false,
  526. title: res.title,
  527. };
  528. plus.push.createMessage(res.content, JSON.stringify(res.payload), options);
  529. }
  530. }
  531. },
  532. false
  533. );
  534. // #endif
  535. },
  536. },
  537. onHide: function() {
  538. console.log('App Hide');
  539. },
  540. };
  541. </script>
  542. <style lang="scss">
  543. //全局引入政务模块样式
  544. @import './common/style/zw.scss';
  545. //全局引入骨架屏幕样式
  546. @import './common/style/skeleton.scss';
  547. //全局引入u-view ui框架样式
  548. @import 'uview-ui/index.scss';
  549. /* #ifndef APP-PLUS-NVUE */
  550. @import '@/common/style/common.scss';
  551. /* uni.css - 通用组件、模板样式库,可以当作一套ui库应用 */
  552. @import './common/style/uni.css';
  553. /* #endif */
  554. uni-radio .uni-radio-input .uni-radio-input-checked {
  555. background: #ff0000 !important;
  556. }
  557. // 骨架屏遮罩
  558. .u-skeleton-box {
  559. position: relative;
  560. .u-skeleton-shade {
  561. width: 100% !important;
  562. z-index: 1 !important;
  563. top: 0 !important;
  564. left: 0 !important;
  565. }
  566. }
  567. </style>