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.

sign-up.vue 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <image style="
  3. margin-top: 20rpx;
  4. width: 100%;
  5. height: 240rpx;
  6. background-color: #eeeeee;
  7. " :src="`${$imgUrl}applyCard/car-service.png`"></image>
  8. <view class="title"> 微信车主服务 </view>
  9. <view class="value">
  10. <view class="content_1">
  11. 微信车主服务是微信支付为车主用户提供的安全便捷的智慧服务
  12. </view>
  13. <view class="content_2">
  14. 本次将为贵州黔通智联科技股份有限公司开启免密支付服务,后续相关的费用将通过微信车主服务从你的微信支付账户扣除
  15. </view>
  16. </view>
  17. <view class="as-layout-horizontal agreement">
  18. <checkbox-group @change="checkboxChange">
  19. <checkbox :checked="state.checked" style="transform: scale(0.8)" />我已阅读并同意
  20. </checkbox-group>
  21. <text style="color:#007AFF;text-decoration: underline;" @click="downAuthD()">《代扣协议》</text>
  22. </view>
  23. <view class="action">
  24. <button type="default" class="button" @click="savaHandle()">
  25. 开通服务
  26. </button>
  27. </view>
  28. </template>
  29. <script setup lang="ts">
  30. import { onLoad, onShow } from "@dcloudio/uni-app";
  31. import { reactive } from "vue";
  32. import { etcQYAction } from "@/utils/network/api.js";
  33. import { request } from "@/utils/network/request.js";
  34. import { stringToJson } from "@/utils/network/encryption";
  35. import { fileURL } from "@/datas/fileURL.js";
  36. import navBar from "@/components/nav-bar/nav-bar2.vue";
  37. import navBgCar from "./components/nav-bg-car4";
  38. import { setItem } from "@/utils/storage";
  39. import { msg } from "@/utils/utils";
  40. import {
  41. checkOrderStatus,
  42. orderPay,
  43. wechatAppID,
  44. wechatPayConfigId,
  45. wechatSecret,
  46. getOpenidApi,
  47. infoQuery,
  48. envs
  49. } from "@/utils/network/api";
  50. const imgURL = `${fileURL}image/`;
  51. const state = reactive({
  52. openid: "",
  53. orderId: "",
  54. id: "",
  55. clientFee: "",
  56. checked: false,
  57. agreeURL: "",
  58. });
  59. onLoad((option : any) => {
  60. getOpenID();
  61. state.orderId = option.orderId;
  62. // state.clientFee = option.clientFee;
  63. // state.id = option.id;
  64. getInfo();
  65. });
  66. const checkboxChange = (e) => {
  67. state.checked = !state.checked;
  68. console.log(state.checked);
  69. };
  70. const getInfo = () => {
  71. //参数说明
  72. let options = {
  73. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  74. data: {
  75. businessType: 'WITHHOLD_AGREEMENT' //代扣协议
  76. }, //请求参数
  77. method: "POST", //提交方式(默认POST)
  78. showLoading: true, //是否显示加载中(默认显示)
  79. };
  80. //调用方式
  81. request(infoQuery, options)
  82. .then((res) => {
  83. let data = stringToJson(res.bizContent)
  84. if (data.textType = "URL") {
  85. state.agreeURL = envs[process.env.NODE_ENV].baseUrl + data.text
  86. }
  87. console.log("代扣协议", state.agreeURL);
  88. })
  89. .catch((err) => {
  90. console.log(err);
  91. });
  92. }
  93. //获取微信小程序openid
  94. const getOpenID = () => {
  95. // #ifdef MP-WEIXIN
  96. uni.login({
  97. provider: "weixin",
  98. success: function (e) {
  99. console.log(e);
  100. getOpenid(e.code);
  101. // uni.request({
  102. // url: `https://api.weixin.qq.com/sns/jscode2session?appid=${wechatAppID}&secret=${wechatSecret}&js_code=${e.code}&grant_type=authorization_code`,
  103. // success: (res: any) => {
  104. // state.openid = res.data.openid;
  105. // setItem("QYorder", state);
  106. // console.log(res);
  107. // },
  108. // fail: (err: any) => {
  109. // uni.showToast({
  110. // title: "网络异常,请重试!" + err.errcode,
  111. // icon: "error",
  112. // duration: 500,
  113. // });
  114. // return;
  115. // },
  116. // });
  117. },
  118. });
  119. // #endif
  120. };
  121. const downAuthD = () => {
  122. // tools.showLoadingAlert("加载中");
  123. uni.downloadFile({
  124. url: state.agreeURL,
  125. filePath: wx.env.USER_DATA_PATH + '/' + '代扣协议.docx',
  126. success(res) {
  127. const filePath = res.filePath
  128. uni.openDocument({
  129. filePath: filePath,
  130. fileType: 'docx',
  131. showMenu: true, //关键点
  132. success: function (res) {
  133. msg("打开文档成功");
  134. },
  135. fail: function (err) {
  136. msg("打开文档失败");
  137. }
  138. });
  139. },
  140. fail: function (err) {
  141. msg("下载文档失败");
  142. console.log("err", err)
  143. },
  144. complete(res) {
  145. }
  146. })
  147. }
  148. const getOpenid = (code) => {
  149. const options = {
  150. type: 2,
  151. data: {
  152. "jsCode": code
  153. },
  154. method: "POST",
  155. showLoading: true,
  156. };
  157. // #ifdef MP-WEIXIN
  158. request(getOpenidApi, options).then((res) => {
  159. const result = stringToJson(res.bizContent);
  160. const openidData = stringToJson(result.data);
  161. state.openid = openidData.openid;
  162. console.log("获取微信小程序openid", state.openid);
  163. setItem("QYorder", state);
  164. });
  165. // #endif
  166. }
  167. const savaHandle = () => {
  168. if (!state.checked) {
  169. msg("请勾选协议!")
  170. return;
  171. }
  172. console.log("openid*******", state.openid);
  173. //如果获取openId成功
  174. if (state.openid) {
  175. var data = {
  176. orderId: state.orderId,
  177. subOpenId: state.openid,
  178. // orderId: "20231213200339195365136",
  179. // subOpenId: "o_Ucm45wcKKt1W2Ah0OSVco81G_4",
  180. };
  181. const options = {
  182. type: 2,
  183. data: data,
  184. method: "POST",
  185. showLoading: true,
  186. };
  187. request(etcQYAction, options).then((res) => {
  188. const data = stringToJson(res.bizContent);
  189. console.log("data", data)
  190. if (data.userState === "UNAUTHORIZED") {
  191. uni.navigateToMiniProgram({
  192. appId: "wxbcad394b3d99dac9",
  193. path: "pages/route/index",
  194. extraData: {
  195. appid: "wxcb1388c809fe25a9",
  196. sub_appid: "wx008c60533388527a",
  197. mch_id: "1500877591",
  198. sub_mch_id: "1622652848",
  199. nonce_str: data.nonceStr,
  200. sign_type: "HMAC-SHA256",
  201. trade_scene: "HIGHWAY",
  202. plate_number: data.plateNumber,
  203. sub_openid: data.subOpenId,
  204. sign: data.sign,
  205. channel_type: "ETC"
  206. },
  207. success(res) {
  208. console.log(res);
  209. },
  210. complete(res) {
  211. console.log(res);
  212. },
  213. fail(res) {
  214. console.log(res);
  215. // 未成功跳转到车主小程序
  216. },
  217. });
  218. } else if (data.userState === "NORMAL") {
  219. msg("已开通车主服务");
  220. // uni.navigateTo({
  221. // url: `/subpackage/orders/product-detail?orderId=${state.orderId}&&clientFee=${state.clientFee}&&id=${state.id}`,
  222. // });
  223. uni.switchTab({
  224. url: "/pages/order/order"
  225. })
  226. } else if (data.userState === "PAUSED") {
  227. msg("已暂停车主服务");
  228. return;
  229. } else if (data.userState === "OVERDUE") {
  230. msg("用户已开通车主服务,但欠费状态。提示用户还款,请跳转到车主服务");
  231. return;
  232. }
  233. });
  234. } else {
  235. //如果获取openId失败
  236. uni.showToast({
  237. title: "网络异常,请重试!",
  238. icon: "none",
  239. duration: 1000,
  240. });
  241. return;
  242. }
  243. };
  244. </script>
  245. <style lang="scss" scoped>
  246. .action {
  247. margin-top: 40rpx;
  248. padding-left: 20rpx;
  249. padding-right: 20rpx;
  250. padding-bottom: 30rpx;
  251. .button {
  252. height: 80rpx;
  253. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  254. border-radius: 40rpx;
  255. font-size: 32rpx;
  256. font-weight: 400;
  257. color: #ffffff;
  258. line-height: 80rpx;
  259. }
  260. }
  261. .title {
  262. text-align: center;
  263. margin-top: 15rpx;
  264. font-size: 36rpx;
  265. font-family: Microsoft YaHei;
  266. font-weight: 400;
  267. color: #333333;
  268. line-height: 36rpx;
  269. }
  270. .value {
  271. padding: 0rpx 60rpx;
  272. }
  273. .content_1 {
  274. margin-top: 60rpx;
  275. font-size: 30rpx;
  276. font-family: Microsoft YaHei;
  277. font-weight: 400;
  278. color: #666666;
  279. line-height: 58rpx;
  280. }
  281. .content_2 {
  282. margin-top: 50rpx;
  283. font-size: 30rpx;
  284. font-family: Microsoft YaHei;
  285. font-weight: 400;
  286. color: #666666;
  287. line-height: 58rpx;
  288. }
  289. .agreement {
  290. font-size: 30rpx;
  291. display: flex;
  292. flex-wrap: wrap;
  293. margin-top: 20rpx;
  294. align-items: center;
  295. justify-content: center;
  296. }
  297. </style>