Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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