選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

sign-up.vue 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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 class="content_3">
  17. 注:签约成功后请返回本页面,再次点击开通服务
  18. </view>
  19. </view>
  20. <view class="as-layout-horizontal agreement">
  21. <checkbox-group @change="checkboxChange">
  22. <checkbox :checked="state.checked" style="transform: scale(0.8)" />我已阅读并同意
  23. </checkbox-group>
  24. <text style="color:#007AFF;text-decoration: underline;" @click="downAuthD()">《代扣协议》</text>
  25. </view>
  26. <view class="action">
  27. <button type="default" class="button" @click="savaHandle()">
  28. 开通服务
  29. </button>
  30. </view>
  31. </template>
  32. <script setup lang="ts">
  33. import { onLoad, onShow } from "@dcloudio/uni-app";
  34. import { reactive } from "vue";
  35. import { etcQYAction } from "@/utils/network/api.js";
  36. import { request } from "@/utils/network/request.js";
  37. import { stringToJson } from "@/utils/network/encryption";
  38. import { fileURL } from "@/datas/fileURL.js";
  39. import navBar from "@/components/nav-bar/nav-bar2.vue";
  40. import navBgCar from "./components/nav-bg-car4";
  41. import { setItem } from "@/utils/storage";
  42. import { msg } from "@/utils/utils";
  43. import {
  44. checkOrderStatus,
  45. wechatAppID,
  46. wechatPayConfigId,
  47. wechatSecret,
  48. getOpenidApi,
  49. infoQuery,
  50. envs
  51. } from "@/utils/network/api";
  52. const imgURL = `${fileURL}image/`;
  53. const state = reactive({
  54. openid: "",
  55. orderId: "",
  56. id: "",
  57. clientFee: "",
  58. checked: false,
  59. agreeURL: "",
  60. });
  61. onLoad((option : any) => {
  62. getOpenID();
  63. state.orderId = option.orderId;
  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. },
  102. });
  103. // #endif
  104. };
  105. const downAuthD = () => {
  106. // tools.showLoadingAlert("加载中");
  107. uni.downloadFile({
  108. url: state.agreeURL,
  109. filePath: wx.env.USER_DATA_PATH + '/' + '代扣协议.docx',
  110. success(res) {
  111. const filePath = res.filePath
  112. uni.openDocument({
  113. filePath: filePath,
  114. fileType: 'docx',
  115. showMenu: true, //关键点
  116. success: function (res) {
  117. msg("打开文档成功");
  118. },
  119. fail: function (err) {
  120. msg("打开文档失败");
  121. }
  122. });
  123. },
  124. fail: function (err) {
  125. msg("下载文档失败");
  126. console.log("err", err)
  127. },
  128. complete(res) {
  129. }
  130. })
  131. }
  132. const getOpenid = (code) => {
  133. const options = {
  134. type: 2,
  135. data: {
  136. "jsCode": code
  137. },
  138. method: "POST",
  139. showLoading: true,
  140. };
  141. // #ifdef MP-WEIXIN
  142. request(getOpenidApi, options).then((res) => {
  143. const result = stringToJson(res.bizContent);
  144. const openidData = stringToJson(result.data);
  145. state.openid = openidData.openid;
  146. console.log("获取微信小程序openid", state.openid);
  147. setItem("QYorder", state);
  148. });
  149. // #endif
  150. }
  151. const savaHandle = () => {
  152. if (!state.checked) {
  153. msg("请勾选协议!")
  154. return;
  155. }
  156. console.log("openid*******", state.openid);
  157. //如果获取openId成功
  158. if (state.openid) {
  159. var data = {
  160. orderId: state.orderId,
  161. subOpenId: state.openid,
  162. };
  163. const options = {
  164. type: 2,
  165. data: data,
  166. method: "POST",
  167. showLoading: true,
  168. };
  169. request(etcQYAction, options).then((res) => {
  170. const data = stringToJson(res.bizContent);
  171. console.log("data", data)
  172. if (data.userState === "UNAUTHORIZED") {
  173. uni.navigateToMiniProgram({
  174. appId: "wxbcad394b3d99dac9",
  175. path: "pages/route/index",
  176. extraData: {
  177. appid: "wxcb1388c809fe25a9",
  178. sub_appid: "wx008c60533388527a",
  179. mch_id: "1500877591",
  180. sub_mch_id: "1622652848",
  181. nonce_str: data.nonceStr,
  182. sign_type: "HMAC-SHA256",
  183. trade_scene: "HIGHWAY",
  184. plate_number: data.plateNumber,
  185. sub_openid: data.subOpenId,
  186. sign: data.sign,
  187. channel_type: "ETC"
  188. },
  189. success(res) {
  190. console.log(res);
  191. },
  192. complete(res) {
  193. console.log(res);
  194. },
  195. fail(res) {
  196. console.log(res);
  197. // 未成功跳转到车主小程序
  198. },
  199. });
  200. } else if (data.userState === "NORMAL") {
  201. msg("已开通车主服务");
  202. setTimeout(() => {
  203. uni.switchTab({
  204. url: "/pages/order/order"
  205. })
  206. }, 1500)
  207. } else if (data.userState === "PAUSED") {
  208. msg("已暂停车主服务");
  209. return;
  210. } else if (data.userState === "OVERDUE") {
  211. msg("用户已开通车主服务,但欠费状态。提示用户还款,请跳转到车主服务");
  212. return;
  213. }
  214. });
  215. } else {
  216. //如果获取openId失败
  217. uni.showToast({
  218. title: "网络异常,请重试!",
  219. icon: "none",
  220. duration: 1000,
  221. });
  222. return;
  223. }
  224. };
  225. </script>
  226. <style lang="scss" scoped>
  227. .action {
  228. margin-top: 40rpx;
  229. padding-left: 20rpx;
  230. padding-right: 20rpx;
  231. padding-bottom: 30rpx;
  232. .button {
  233. height: 80rpx;
  234. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  235. border-radius: 40rpx;
  236. font-size: 32rpx;
  237. font-weight: 400;
  238. color: #ffffff;
  239. line-height: 80rpx;
  240. }
  241. }
  242. .title {
  243. text-align: center;
  244. margin-top: 15rpx;
  245. font-size: 36rpx;
  246. font-family: Microsoft YaHei;
  247. font-weight: 400;
  248. color: #333333;
  249. line-height: 36rpx;
  250. }
  251. .value {
  252. padding: 0rpx 60rpx;
  253. }
  254. .content_1 {
  255. margin-top: 60rpx;
  256. font-size: 30rpx;
  257. font-family: Microsoft YaHei;
  258. font-weight: 400;
  259. color: #666666;
  260. line-height: 58rpx;
  261. }
  262. .content_2 {
  263. margin-top: 50rpx;
  264. font-size: 30rpx;
  265. font-family: Microsoft YaHei;
  266. font-weight: 400;
  267. color: #666666;
  268. line-height: 58rpx;
  269. }
  270. .content_3 {
  271. margin-top: 50rpx;
  272. font-size: 30rpx;
  273. font-family: Microsoft YaHei;
  274. font-weight: 400;
  275. color: #ff0000;
  276. line-height: 58rpx;
  277. }
  278. .agreement {
  279. font-size: 30rpx;
  280. display: flex;
  281. flex-wrap: wrap;
  282. margin-top: 20rpx;
  283. align-items: center;
  284. justify-content: center;
  285. }
  286. </style>