Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

App.vue 3.7KB

2 år sedan
2 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <script>
  2. import {
  3. request
  4. } from "@/utils/network/request.js"
  5. import {
  6. etcQYAction,
  7. queryKey
  8. } from "@/utils/network/api.js"
  9. import {
  10. msg,
  11. } from "./utils/utils";
  12. import {
  13. getItem
  14. } from "./utils/storage"
  15. import { log } from "console";
  16. export default {
  17. onLaunch: function(option) {
  18. wx.setStorageSync("extraData", option.referrerInfo.extraData)
  19. console.log('App Launch', uni.getLaunchOptionsSync().path)
  20. // #ifdef MP-WEIXIN
  21. //获取小程序更新机制兼容
  22. if (uni.canIUse('getUpdateManager')) {
  23. // pdateManager,用于管理小程序更新。
  24. const updateManager = uni.getUpdateManager();
  25. updateManager.onCheckForUpdate(function(res) {
  26. // 请求完新版本信息的回调
  27. if (res.hasUpdate) {
  28. updateManager.onUpdateReady(function() {
  29. uni.showModal({
  30. title: '更新提示',
  31. content: '新版本已经准备好,是否重启应用?',
  32. success: function(res) {
  33. if (res.confirm) {
  34. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  35. updateManager.applyUpdate()
  36. }
  37. }
  38. })
  39. });
  40. updateManager.onUpdateFailed(function() {
  41. // 新的版本下载失败
  42. uni.showModal({
  43. title: '已经有新版本了哟~',
  44. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
  45. showCancel: false,
  46. confirmText: '我知道了'
  47. })
  48. });
  49. }
  50. });
  51. } else {
  52. // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
  53. uni.showModal({
  54. title: '提示',
  55. content: '当前微信版本过低,无法更好体验程序,请升级到最新微信版本后重试。',
  56. showCancel: false,
  57. confirmText: '我知道了'
  58. });
  59. }
  60. // #endif
  61. },
  62. onShow: function(option) {
  63. console.log(option);
  64. if (option && option.scene === 1038) {
  65. // 场景值1038:从被打开的小程序返回
  66. const {
  67. appId,
  68. extraData
  69. } = option.referrerInfo;
  70. if (appId == "wxbcad394b3d99dac9") {
  71. console.log(getItem("QYorder"));
  72. const orders = getItem("QYorder")
  73. // appId为wxbcad394b3d99dac9:从车主小程序跳转回来
  74. // TODO
  75. // 客户端小程序不确定授权结果,需要发起‘查询车牌服务开通信息’确认授权结果
  76. var data = {
  77. orderId: orders.orderId,
  78. subOpenId: orders.openid,
  79. };
  80. const options = {
  81. type: 2,
  82. data: data,
  83. method: "POST",
  84. showLoading: true,
  85. };
  86. request(etcQYAction, options).then((res) => {
  87. console.log(res);
  88. msg("授权成功");
  89. //如果我当前路由是签约页面才能跳转
  90. let routes = getCurrentPages();
  91. let curRoute = routes[routes.length - 1].route
  92. console.log(curRoute)
  93. if (curRoute === 'applyCard/sign-up') {
  94. uni.navigateTo({
  95. url: `/applyCard/product-detail?orderId=${orders.orderId}&&clientFee=${getItem("clientFee")}&&id=${getItem("productId")}`,
  96. });
  97. }
  98. if (curRoute === 'pages/app/sign') {
  99. //扫描签约成功
  100. uni.switchTab({
  101. url: "/pages/index/index"
  102. })
  103. }
  104. });
  105. return;
  106. }
  107. }
  108. console.log(option);
  109. },
  110. onLoad: function(option) {
  111. console.log(option)
  112. console.log('进入主视图')
  113. },
  114. onHide: function() {
  115. console.log('App Hide')
  116. },
  117. }
  118. </script>
  119. <style lang="scss">
  120. /*每个页面公共css */
  121. @import './static/css/common.scss';
  122. // @import './uni_modules/vk-uview-ui/index.scss';
  123. page {
  124. font-family: "Microsoft Yahei";
  125. // filter: grayscale(1)
  126. }
  127. </style>