選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

App.vue 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. console.log("sadsd", res)
  32. if (res.uniPlatform === 'mp-weixin') {
  33. console.log('当前为微信小程序', res, 1111);
  34. setItem("loginSource", "69af303ba2eb4608a099163f0d2a5dbd");
  35. setItem("environment", "WX")
  36. } else if (res.uniPlatform === 'mp-alipay') {
  37. console.log('当前为支付宝小程序');
  38. setItem("loginSource", "601052a249c04155831710b577cb796d");
  39. setItem("environment", "ZFB")
  40. }
  41. that.globalParam();
  42. }
  43. });
  44. //获取微信小程序openid
  45. // #ifdef MP-WEIXIN
  46. uni.login({
  47. provider: "weixin",
  48. success: function(e) {
  49. console.log("ee", e);
  50. that.getOpenid(e.code);
  51. },
  52. });
  53. // #endif
  54. uni.setStorageSync("extraData", option.referrerInfo.extraData);
  55. // #ifdef MP-WEIXIN
  56. //获取小程序更新机制兼容
  57. if (uni.canIUse("getUpdateManager")) {
  58. // pdateManager,用于管理小程序更新。
  59. const updateManager = uni.getUpdateManager();
  60. updateManager.onCheckForUpdate(function(res) {
  61. // 请求完新版本信息的回调
  62. if (res.hasUpdate) {
  63. updateManager.onUpdateReady(function() {
  64. uni.showModal({
  65. title: "更新提示",
  66. content: "新版本已经准备好,是否重启应用?",
  67. success: function(res) {
  68. if (res.confirm) {
  69. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  70. updateManager.applyUpdate();
  71. }
  72. },
  73. });
  74. });
  75. updateManager.onUpdateFailed(function() {
  76. // 新的版本下载失败
  77. uni.showModal({
  78. title: "已经有新版本了哟~",
  79. content: "新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~",
  80. showCancel: false,
  81. confirmText: "我知道了",
  82. });
  83. });
  84. }
  85. });
  86. } else {
  87. // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
  88. uni.showModal({
  89. title: "提示",
  90. content: "当前微信版本过低,无法更好体验程序,请升级到最新微信版本后重试。",
  91. showCancel: false,
  92. confirmText: "我知道了",
  93. });
  94. }
  95. // #endif
  96. },
  97. onShow: function(option) {
  98. console.log(option);
  99. console.log("进入主视图");
  100. if (option && option.scene === 1038) {
  101. // 场景值1038:从被打开的小程序返回
  102. const {
  103. appId,
  104. extraData
  105. } = option.referrerInfo;
  106. if (appId == "wxbcad394b3d99dac9") {
  107. console.log(getItem("QYorder"));
  108. const orders = getItem("QYorder");
  109. // appId为wxbcad394b3d99dac9:从车主小程序跳转回来
  110. // TODO
  111. // 客户端小程序不确定授权结果,需要发起‘查询车牌服务开通信息’确认授权结果
  112. var data = {
  113. orderId: orders.orderId,
  114. subOpenId: orders.openid,
  115. };
  116. const options = {
  117. type: 2,
  118. data: data,
  119. method: "POST",
  120. showLoading: true,
  121. };
  122. request(etcQYAction, options).then((res) => {
  123. console.log(res);
  124. msg("授权成功");
  125. //如果我当前路由是签约页面才能跳转
  126. let routes = getCurrentPages();
  127. let curRoute = routes[routes.length - 1].route;
  128. console.log(curRoute);
  129. if (curRoute === "orders/sign-up") {
  130. uni.navigateTo({
  131. url: `/subpackage/orders/product-detail?orderId=${orders.orderId}&&clientFee=${getItem("clientFee")}&&id=${getItem("productId")}`,
  132. });
  133. }
  134. if (curRoute === "pages/app/sign") {
  135. //扫描签约成功
  136. uni.switchTab({
  137. url: "/pages/index/index",
  138. });
  139. }
  140. });
  141. return;
  142. }
  143. }
  144. console.log(option);
  145. },
  146. onLoad: function(option) {
  147. },
  148. onHide: function() {
  149. console.log("App Hide");
  150. },
  151. methods: {
  152. globalParam() {
  153. const options = {
  154. type: 2,
  155. data: {
  156. "loginSource": getItem("loginSource")
  157. },
  158. method: "POST",
  159. showLoading: true,
  160. };
  161. request(getGlobalParam, options).then((res) => {
  162. const result = stringToJson(res.bizContent);
  163. setItem('globalParam', result.data)
  164. console.log("配置", result);
  165. });
  166. // #ifdef MP-WEIXIN
  167. // #endif
  168. },
  169. getGlobalParam() {
  170. const data = getItem('globalParam')
  171. console.log("全局配置数据1111", getCodeName('IS_ENABLE', data.setGray))
  172. // 申办时是否允许修改OCR识别出来的车辆信息数据
  173. if (getCodeName('IS_ENABLE', data.setGray) == '启用') {
  174. this.isEnableSetGray = true;
  175. } else {
  176. this.isEnableSetGray = true;
  177. }
  178. },
  179. getOpenid(code) {
  180. const options = {
  181. type: 2,
  182. data: {
  183. "jsCode": code
  184. },
  185. method: "POST",
  186. showLoading: true,
  187. };
  188. // #ifdef MP-WEIXIN
  189. request(getOpenidApi, options).then((res) => {
  190. const result = stringToJson(res.bizContent);
  191. console.log("获取微信小程序openid", result);
  192. const openidData = stringToJson(result.data);
  193. setItem("QYorder", openidData);
  194. });
  195. // #endif
  196. },
  197. }
  198. };
  199. </script>
  200. <style lang="scss">
  201. /*每个页面公共css */
  202. @import "./static/css/common.scss";
  203. // @import './uni_modules/vk-uview-ui/index.scss';
  204. page {
  205. font-family: "Microsoft Yahei";
  206. // filter: grayscale(1)
  207. }
  208. </style>