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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. // #ifdef MP-ALIPAY
  51. my.getAuthCode({
  52. scopes: 'auth_base',
  53. success: res => {
  54. console.log("支付宝授权码", res)
  55. },
  56. });
  57. // #endif
  58. uni.setStorageSync("extraData", option.referrerInfo.extraData);
  59. // #ifdef MP-WEIXIN
  60. //获取小程序更新机制兼容
  61. if (uni.canIUse("getUpdateManager")) {
  62. // pdateManager,用于管理小程序更新。
  63. const updateManager = uni.getUpdateManager();
  64. updateManager.onCheckForUpdate(function(res) {
  65. // 请求完新版本信息的回调
  66. if (res.hasUpdate) {
  67. updateManager.onUpdateReady(function() {
  68. uni.showModal({
  69. title: "更新提示",
  70. content: "新版本已经准备好,是否重启应用?",
  71. success: function(res) {
  72. if (res.confirm) {
  73. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  74. updateManager.applyUpdate();
  75. }
  76. },
  77. });
  78. });
  79. updateManager.onUpdateFailed(function() {
  80. // 新的版本下载失败
  81. uni.showModal({
  82. title: "已经有新版本了哟~",
  83. content: "新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~",
  84. showCancel: false,
  85. confirmText: "我知道了",
  86. });
  87. });
  88. }
  89. });
  90. } else {
  91. // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
  92. uni.showModal({
  93. title: "提示",
  94. content: "当前微信版本过低,无法更好体验程序,请升级到最新微信版本后重试。",
  95. showCancel: false,
  96. confirmText: "我知道了",
  97. });
  98. }
  99. // #endif
  100. },
  101. onShow: function(option) {
  102. console.log("进入主视图");
  103. },
  104. onLoad: function(option) {
  105. },
  106. onHide: function() {},
  107. methods: {
  108. globalParam() {
  109. const options = {
  110. type: 2,
  111. data: {
  112. "loginSource": getItem("loginSource")
  113. },
  114. method: "POST",
  115. showLoading: true,
  116. };
  117. request(getGlobalParam, options).then((res) => {
  118. const result = stringToJson(res.bizContent);
  119. setItem('globalParam', result.data)
  120. });
  121. },
  122. getOpenid(code) {
  123. const options = {
  124. type: 2,
  125. data: {
  126. "jsCode": code
  127. },
  128. method: "POST",
  129. showLoading: true,
  130. };
  131. // #ifdef MP-WEIXIN
  132. request(getOpenidApi, options).then((res) => {
  133. const result = stringToJson(res.bizContent);
  134. console.log("getOpenidApi", result)
  135. const openidData = stringToJson(result.data);
  136. setItem("QYorder", openidData);
  137. });
  138. // #endif
  139. },
  140. }
  141. };
  142. </script>
  143. <style lang="scss">
  144. /*每个页面公共css */
  145. @import "./static/css/common.scss";
  146. page {
  147. font-family: "Microsoft Yahei";
  148. }
  149. </style>