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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <script>
  2. import {
  3. request
  4. } from "@/utils/network/request.js";
  5. import {
  6. etcQYAction,
  7. queryKey,
  8. getGlobalParam,
  9. wechatAppID,
  10. wechatSecret,
  11. getOpenidApi
  12. } from "@/utils/network/api.js";
  13. import {
  14. msg
  15. } from "./utils/utils";
  16. import {
  17. getItem,
  18. setItem
  19. } from "./utils/storage";
  20. import {
  21. stringToJson
  22. } from "@/utils/network/encryption";
  23. import {
  24. getCodeName
  25. } from "@/datas/queryKey.js";
  26. export default {
  27. onLaunch: function(option) {
  28. var that = this;
  29. uni.getSystemInfo({
  30. success: (res) => {
  31. if (res.uniPlatform === 'mp-weixin') {
  32. setItem("loginSource", "69af303ba2eb4608a099163f0d2a5dbd");
  33. setItem("environment", "WX")
  34. } else if (res.uniPlatform === 'mp-alipay') {
  35. setItem("loginSource", "601052a249c04155831710b577cb796d");
  36. setItem("environment", "ZFB")
  37. }
  38. that.globalParam();
  39. }
  40. });
  41. //获取微信小程序openid
  42. // #ifdef MP-WEIXIN
  43. uni.login({
  44. provider: "weixin",
  45. success: function(e) {
  46. that.getOpenid(e.code);
  47. },
  48. });
  49. // #endif
  50. uni.setStorageSync("extraData", option.referrerInfo.extraData);
  51. // #ifdef MP-WEIXIN
  52. //获取小程序更新机制兼容
  53. if (uni.canIUse("getUpdateManager")) {
  54. // pdateManager,用于管理小程序更新。
  55. const updateManager = uni.getUpdateManager();
  56. updateManager.onCheckForUpdate(function(res) {
  57. // 请求完新版本信息的回调
  58. if (res.hasUpdate) {
  59. updateManager.onUpdateReady(function() {
  60. uni.showModal({
  61. title: "更新提示",
  62. content: "新版本已经准备好,是否重启应用?",
  63. success: function(res) {
  64. if (res.confirm) {
  65. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  66. updateManager.applyUpdate();
  67. }
  68. },
  69. });
  70. });
  71. updateManager.onUpdateFailed(function() {
  72. // 新的版本下载失败
  73. uni.showModal({
  74. title: "已经有新版本了哟~",
  75. content: "新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~",
  76. showCancel: false,
  77. confirmText: "我知道了",
  78. });
  79. });
  80. }
  81. });
  82. } else {
  83. // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
  84. uni.showModal({
  85. title: "提示",
  86. content: "当前微信版本过低,无法更好体验程序,请升级到最新微信版本后重试。",
  87. showCancel: false,
  88. confirmText: "我知道了",
  89. });
  90. }
  91. // #endif
  92. },
  93. onShow: function(option) {
  94. console.log("进入主视图");
  95. },
  96. onLoad: function(option) {
  97. },
  98. onHide: function() {},
  99. methods: {
  100. globalParam() {
  101. const options = {
  102. type: 2,
  103. data: {
  104. "loginSource": getItem("loginSource")
  105. },
  106. method: "POST",
  107. showLoading: true,
  108. };
  109. request(getGlobalParam, options).then((res) => {
  110. const result = stringToJson(res.bizContent);
  111. setItem('globalParam', result.data)
  112. });
  113. },
  114. getOpenid(code) {
  115. const options = {
  116. type: 2,
  117. data: {
  118. "jsCode": code
  119. },
  120. method: "POST",
  121. showLoading: true,
  122. };
  123. // #ifdef MP-WEIXIN
  124. request(getOpenidApi, options).then((res) => {
  125. const result = stringToJson(res.bizContent);
  126. console.log("getOpenidApi", result)
  127. const openidData = stringToJson(result.data);
  128. setItem("QYorder", openidData);
  129. });
  130. // #endif
  131. },
  132. }
  133. };
  134. </script>
  135. <style lang="scss">
  136. /*每个页面公共css */
  137. @import "./static/css/common.scss";
  138. page {
  139. font-family: "Microsoft Yahei";
  140. }
  141. </style>