Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

sign-up.vue 7.6KB

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