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