Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

App.vue 4.2KB

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