You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

App.vue 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <script>
  2. import {
  3. request
  4. } from "@/utils/network/request.js"
  5. import {
  6. etcQYAction
  7. } from "@/utils/network/api.js"
  8. import {
  9. msg
  10. } from "./utils/utils";
  11. import {
  12. getItem
  13. } from "./utils/storage"
  14. export default {
  15. onLaunch: function(option) {
  16. wx.setStorageSync("extraData", option.referrerInfo.extraData)
  17. console.log('App Launch', uni.getLaunchOptionsSync().path)
  18. // #ifdef MP-WEIXIN
  19. //获取小程序更新机制兼容
  20. if (uni.canIUse('getUpdateManager')) {
  21. // pdateManager,用于管理小程序更新。
  22. const updateManager = uni.getUpdateManager();
  23. updateManager.onCheckForUpdate(function(res) {
  24. // 请求完新版本信息的回调
  25. if (res.hasUpdate) {
  26. updateManager.onUpdateReady(function() {
  27. uni.showModal({
  28. title: '更新提示',
  29. content: '新版本已经准备好,是否重启应用?',
  30. success: function(res) {
  31. if (res.confirm) {
  32. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  33. updateManager.applyUpdate()
  34. }
  35. }
  36. })
  37. });
  38. updateManager.onUpdateFailed(function() {
  39. // 新的版本下载失败
  40. uni.showModal({
  41. title: '已经有新版本了哟~',
  42. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
  43. showCancel: false,
  44. confirmText: '我知道了'
  45. })
  46. });
  47. }
  48. });
  49. } else {
  50. // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
  51. uni.showModal({
  52. title: '提示',
  53. content: '当前微信版本过低,无法更好体验程序,请升级到最新微信版本后重试。',
  54. showCancel: false,
  55. confirmText: '我知道了'
  56. });
  57. }
  58. // #endif
  59. },
  60. onShow: function(option) {
  61. console.log(option);
  62. console.log('App Show')
  63. if (option && option.scene === 1038) {
  64. console.log("8888888888888888888");
  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. },
  113. onHide: function() {
  114. console.log('App Hide')
  115. }
  116. }
  117. </script>
  118. <style lang="scss">
  119. /*每个页面公共css */
  120. @import './static/css/common.scss';
  121. // @import './uni_modules/vk-uview-ui/index.scss';
  122. page {
  123. font-family: "Microsoft Yahei";
  124. }
  125. </style>