Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

App.vue 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <script>
  2. import { request } from "@/utils/network/request.js";
  3. import { etcQYAction, queryKey,getGlobalParam,wechatAppID,wechatSecret } from "@/utils/network/api.js";
  4. import { msg } from "./utils/utils";
  5. import { getItem,setItem } from "./utils/storage";
  6. import { stringToJson } from "@/utils/network/encryption";
  7. import {
  8. getCodeName
  9. } from "@/datas/queryKey.js";
  10. // import { log } from "console";
  11. export default {
  12. // data(){
  13. // return{
  14. // isEnableSetGray:true,
  15. // }
  16. // },
  17. onLaunch: function (option) {
  18. uni.getSystemInfo({
  19. success: (res) => {
  20. console.log("sadsd",res)
  21. if (res.uniPlatform === 'mp-weixin') {
  22. console.log('当前为微信小程序',res,1111);
  23. setItem("loginSource","69af303ba2eb4608a099163f0d2a5dbd");
  24. } else if (res.uniPlatform === 'mp-alipay') {
  25. console.log('当前为支付宝小程序');
  26. setItem("loginSource","601052a249c04155831710b577cb796d");
  27. }
  28. }
  29. });
  30. //获取微信小程序openid
  31. uni.login({
  32. provider: "weixin",
  33. success: function (e) {
  34. console.log(e);
  35. uni.request({
  36. url: `https://api.weixin.qq.com/sns/jscode2session?appid=${wechatAppID}&secret=${wechatSecret}&js_code=${e.code}&grant_type=authorization_code`,
  37. success: (res) => {
  38. // state.openid = res.data.openid;
  39. setItem("QYorder", res.data.openid);
  40. console.log(res);
  41. },
  42. fail: (err) => {
  43. uni.showToast({
  44. title: "网络异常,请重试!" + err.errcode,
  45. icon: "error",
  46. duration: 500,
  47. });
  48. return;
  49. },
  50. });
  51. },
  52. });
  53. uni.setStorageSync("extraData", option.referrerInfo.extraData);
  54. // #ifdef MP-WEIXIN
  55. //获取小程序更新机制兼容
  56. if (uni.canIUse("getUpdateManager")) {
  57. // pdateManager,用于管理小程序更新。
  58. const updateManager = uni.getUpdateManager();
  59. updateManager.onCheckForUpdate(function (res) {
  60. // 请求完新版本信息的回调
  61. if (res.hasUpdate) {
  62. updateManager.onUpdateReady(function () {
  63. uni.showModal({
  64. title: "更新提示",
  65. content: "新版本已经准备好,是否重启应用?",
  66. success: function (res) {
  67. if (res.confirm) {
  68. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  69. updateManager.applyUpdate();
  70. }
  71. },
  72. });
  73. });
  74. updateManager.onUpdateFailed(function () {
  75. // 新的版本下载失败
  76. uni.showModal({
  77. title: "已经有新版本了哟~",
  78. content: "新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~",
  79. showCancel: false,
  80. confirmText: "我知道了",
  81. });
  82. });
  83. }
  84. });
  85. } else {
  86. // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
  87. uni.showModal({
  88. title: "提示",
  89. content:
  90. "当前微信版本过低,无法更好体验程序,请升级到最新微信版本后重试。",
  91. showCancel: false,
  92. confirmText: "我知道了",
  93. });
  94. }
  95. // #endif
  96. this.globalParam();
  97. },
  98. onShow: function (option) {
  99. console.log(option);
  100. console.log("进入主视图");
  101. if (option && option.scene === 1038) {
  102. // 场景值1038:从被打开的小程序返回
  103. const { appId, extraData } = option.referrerInfo;
  104. if (appId == "wxbcad394b3d99dac9") {
  105. console.log(getItem("QYorder"));
  106. const orders = getItem("QYorder");
  107. // appId为wxbcad394b3d99dac9:从车主小程序跳转回来
  108. // TODO
  109. // 客户端小程序不确定授权结果,需要发起‘查询车牌服务开通信息’确认授权结果
  110. var data = {
  111. orderId: orders.orderId,
  112. subOpenId: orders.openid,
  113. };
  114. const options = {
  115. type: 2,
  116. data: data,
  117. method: "POST",
  118. showLoading: true,
  119. };
  120. request(etcQYAction, options).then((res) => {
  121. console.log(res);
  122. msg("授权成功");
  123. //如果我当前路由是签约页面才能跳转
  124. let routes = getCurrentPages();
  125. let curRoute = routes[routes.length - 1].route;
  126. console.log(curRoute);
  127. if (curRoute === "orders/sign-up") {
  128. uni.navigateTo({
  129. url: `/subpackage/orders/product-detail?orderId=${
  130. orders.orderId
  131. }&&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. // this.getGlobalParam();
  165. // getItem("globalParam")
  166. console.log("配置",result);
  167. });
  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. }
  180. };
  181. </script>
  182. <style lang="scss">
  183. /*每个页面公共css */
  184. @import "./static/css/common.scss";
  185. // @import './uni_modules/vk-uview-ui/index.scss';
  186. page{
  187. font-family: "Microsoft Yahei";
  188. // filter: grayscale(1)
  189. }
  190. </style>