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.9KB

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