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.

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