Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

sign-up.vue 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. <template>
  2. <view class="container">
  3. <view class="t-card">
  4. <view class="title">
  5. <image :src="`${$imgUrl}issuance/title-bg.png`" mode="aspectFit" class='bg'></image>
  6. <image :src="`${$imgUrl}issuance/bg-xia.png`" mode="aspectFit" class='bg-xia'></image>
  7. <view class="txt">
  8. 微信车主服务
  9. </view>
  10. </view>
  11. <view class="value">
  12. <view class="item">
  13. <view class="l-icon"></view>
  14. <view class="r-txt">
  15. 微信车主服务是微信支付为车主用户提供的安全便捷的智慧服务
  16. </view>
  17. </view>
  18. <view class="item item2">
  19. <view class="l-icon"></view>
  20. <view class="r-txt">
  21. 本次将为贵州黔通智联科技股份有限公司开启免密支付服务,后续相关的费用将通过微信车主服务从你的微信支付账户扣除
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- <view class="action">
  27. <view class="btn-tip">
  28. <image :src="`${$imgUrl}issuance/note.png`" mode="aspectFit" class="tip-icon"></image>
  29. 注:签约成功后请返回本页面,再次点击{{state.channelSing=="0"?'开通服务':'恢复签约'}}
  30. </view>
  31. <button type="default" class="button" @click="savaHandle()">
  32. {{state.channelSing=="0"?'开通服务':'恢复签约'}}
  33. </button>
  34. </view> -->
  35. <FixedFooter>
  36. <view class="footer-action">
  37. <view class="btn-tip">
  38. <image :src="`${$imgUrl}issuance/note.png`" mode="aspectFit" class="tip-icon"></image>
  39. 注:签约成功后请返回本页面,再次点击{{state.channelSing=="0"?'开通服务':'恢复签约'}}
  40. </view>
  41. <button type="default" class="button" @click="savaHandle()">
  42. {{state.channelSing=="0"?'开通服务':'恢复签约'}}
  43. </button>
  44. </view>
  45. </FixedFooter>
  46. </view>
  47. </template>
  48. <script setup lang="ts">
  49. import { onLoad, onShow } from "@dcloudio/uni-app";
  50. import { reactive } from "vue";
  51. import { request, requestNew } from "@/utils/network/request.js";
  52. import { stringToJson } from "@/utils/network/encryption";
  53. import { fileURL } from "@/datas/fileURL.js";
  54. import { getItem, setItem } from "@/utils/storage";
  55. import { msg, navTo } from "@/utils/utils";
  56. import FixedFooter from '@/components/common/FixedFooter.vue'
  57. import {
  58. infoQuery,
  59. envs, channelSingQueryApi, userSign, getOpenId, reSign, getSignParams, reSignCheck
  60. } from "@/utils/network/api";
  61. const imgURL = `${fileURL}image/`;
  62. import useOrderSkip from "@/composables/order/useOrderSkip";
  63. const { gotoActiveOrder} = useOrderSkip();
  64. const state = reactive({
  65. openid: "",
  66. orderId: "",
  67. id: "",
  68. clientFee: "",
  69. checked: false,
  70. agreeURL: "",
  71. channelSing: "0",//0 正常签约 1恢复签约
  72. vehiclePlate: "",
  73. code: "",
  74. orderQuery:"0",
  75. from: "",
  76. vehicleId: "",
  77. isTestSign: 0 // 是否开始检测已经签约,大于等于1的时候再去检测
  78. });
  79. onLoad((option : any) => {
  80. getOpenID();
  81. state.orderId = option.orderId;
  82. if (option.from == '37') {
  83. state.from = option.from;
  84. state.vehicleId = decodeURIComponent(option.vehicleId);
  85. }
  86. if (option.channelSing) {
  87. state.channelSing = option.channelSing;
  88. }
  89. state.vehiclePlate = option.vehiclePlate;
  90. state.orderQuery = option.orderQuery;
  91. getInfo();
  92. });
  93. onShow(() => {
  94. console.log()
  95. if (state.isTestSign >= 1) {
  96. if (state.from == '37') { // 恢复签约
  97. isReSignCheck()
  98. } else {
  99. isUserSign()
  100. }
  101. } else {
  102. state.isTestSign += 1
  103. }
  104. })
  105. const checkboxChange = (e) => {
  106. state.checked = !state.checked;
  107. console.log(state.checked);
  108. };
  109. // 签约检测
  110. const isUserSign = () => {
  111. let options = {
  112. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  113. data: {
  114. orderNo: state.orderId,
  115. subOpenId: state.openid,
  116. signChannelType: 1,
  117. }, //请求参数
  118. method: "POST", //提交方式(默认POST)
  119. showLoading: true, //是否显示加载中(默认显示)
  120. };
  121. requestNew(userSign, options).then(res => {
  122. console.log(res)
  123. let { userState, step } = res
  124. if (userState === "NORMAL") {
  125. msg("已开通车主服务");
  126. // 如果是等待激活
  127. if(step === 'WAITING_ACTIVE'){
  128. gotoActiveOrder(getItem('orderQueryActivate'))
  129. }else{
  130. // 正常订单
  131. setTimeout(() => {
  132. uni.redirectTo({
  133. url: `/pages/order/order?index=0`
  134. })
  135. }, 1500)
  136. }
  137. } else if (userState === "PAUSED") {
  138. msg("已暂停车主服务");
  139. return;
  140. } else if (userState === "OVERDUE") {
  141. msg("用户已开通车主服务,但欠费状态。提示用户还款,请跳转到车主服务");
  142. return;
  143. }
  144. })
  145. }
  146. // 恢复签约检测
  147. const isReSignCheck = () => {
  148. let options = {
  149. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  150. data: {
  151. subOpenId: state.openid,
  152. signChannelType: 1,
  153. vehicleId: state.vehicleId,
  154. }, //请求参数
  155. method: "POST", //提交方式(默认POST)
  156. showLoading: true, //是否显示加载中(默认显示)
  157. };
  158. requestNew(reSignCheck, options).then(res => {
  159. console.log(res)
  160. let { userState, step } = res
  161. if (userState === "NORMAL") {
  162. msg("已开通车主服务");
  163. // 如果是等待激活
  164. navTo('/pages/service/service')
  165. } else if (userState === "PAUSED") {
  166. msg("已暂停车主服务");
  167. return;
  168. } else if (userState === "OVERDUE") {
  169. msg("用户已开通车主服务,但欠费状态。提示用户还款,请跳转到车主服务");
  170. return;
  171. }
  172. })
  173. }
  174. const getInfo = () => {
  175. //参数说明
  176. let options = {
  177. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  178. data: {
  179. businessType: 'WITHHOLD_AGREEMENT' //代扣协议
  180. }, //请求参数
  181. method: "POST", //提交方式(默认POST)
  182. showLoading: true, //是否显示加载中(默认显示)
  183. };
  184. //调用方式
  185. requestNew(infoQuery, options)
  186. .then((res) => {
  187. let data = res
  188. if (data.textType = "URL") {
  189. state.agreeURL = envs[process.env.NODE_ENV].baseUrl + data.text
  190. }
  191. console.log("代扣协议", state.agreeURL);
  192. })
  193. .catch((err) => {
  194. console.log(err);
  195. });
  196. }
  197. //获取微信小程序openid
  198. const getOpenID = () => {
  199. // #ifdef MP-WEIXIN
  200. uni.login({
  201. provider: "weixin",
  202. success: function (e) {
  203. console.log(e);
  204. state.code = e.code
  205. getOpenid(e.code);
  206. },
  207. });
  208. // #endif
  209. };
  210. const downAuthD = () => {
  211. uni.downloadFile({
  212. url: state.agreeURL,
  213. filePath: wx.env.USER_DATA_PATH + '/' + '代扣协议.docx',
  214. success(res) {
  215. const filePath = res.filePath
  216. uni.openDocument({
  217. filePath: filePath,
  218. fileType: 'docx',
  219. showMenu: true, //关键点
  220. success: function (res) {
  221. msg("打开文档成功");
  222. },
  223. fail: function (err) {
  224. msg("打开文档失败");
  225. }
  226. });
  227. },
  228. fail: function (err) {
  229. msg("下载文档失败");
  230. console.log("err", err)
  231. },
  232. complete(res) {
  233. }
  234. })
  235. }
  236. const getOpenid = (code) => {
  237. const options = {
  238. type: 2,
  239. data: {
  240. "jsCode": code
  241. },
  242. method: "POST",
  243. showLoading: true,
  244. };
  245. // #ifdef MP-WEIXIN
  246. uni.showLoading({
  247. mask: true
  248. })
  249. requestNew(getOpenId, options).then((res) => {
  250. const result = res;
  251. state.openid = result.openid;
  252. console.log("获取微信小程序openid", state.openid);
  253. setItem("wxOpenid", result.openid);
  254. uni.hideLoading()
  255. }).catch(() => {
  256. uni.hideLoading()
  257. });
  258. // #endif
  259. }
  260. const savaHandle = () => {
  261. console.log("openid*******", state.openid);
  262. //如果获取openId成功
  263. if (state.openid) {
  264. // 从恢复签约列表进入进行恢复签约
  265. if (state.from == '37') {
  266. const options = {
  267. data: {
  268. signChannelType: 1,
  269. subOpenId: state.openid,
  270. vehicleId: state.vehicleId,
  271. },
  272. method: "POST",
  273. showLoading: true
  274. };
  275. requestNew(reSign, options).then((res) => {
  276. console.log(res, 3222);
  277. const data = res;
  278. // if (data.userState === "UNAUTHORIZED") {
  279. uni.navigateToMiniProgram({
  280. appId: "wxbcad394b3d99dac9",
  281. path: "pages/route/index",
  282. extraData: {
  283. appid: data.appId,
  284. sub_appid: data.subAppId,
  285. mch_id: data.mchId,
  286. sub_mch_id: data.subMchId,
  287. nonce_str: data.nonceStr,
  288. sign_type: data.signType,
  289. trade_scene: data.tradeScene,
  290. plate_number: data.plateNumber,
  291. sub_openid: data.subOpenId,
  292. sign: data.sign,
  293. channel_type: data.channelType
  294. },
  295. success(res) {
  296. console.log(res);
  297. },
  298. complete(res) {
  299. console.log(res);
  300. },
  301. fail(res) {
  302. console.log(res);
  303. // 未成功跳转到车主小程序
  304. },
  305. });
  306. // } else {
  307. // msg("用户已签约");
  308. // setTimeout(() => {
  309. // uni.navigateBack();
  310. // }, 1000);
  311. // }
  312. });
  313. return;
  314. }
  315. var data = {
  316. orderNo: state.orderId,
  317. subOpenId: state.openid,
  318. signChannelType: 1,
  319. };
  320. const options = {
  321. type: 2,
  322. data: data,
  323. method: "POST",
  324. showLoading: true,
  325. };
  326. requestNew(getSignParams, options).then((res) => {
  327. const data = res;
  328. console.log("data", data)
  329. uni.navigateToMiniProgram({
  330. appId: "wxbcad394b3d99dac9",
  331. path: "pages/route/index",
  332. extraData: {
  333. appid: data.appId,
  334. sub_appid: data.subAppId,
  335. mch_id: data.mchId,
  336. sub_mch_id: data.subMchId,
  337. nonce_str: data.nonceStr,
  338. sign_type: data.signType,
  339. trade_scene: data.tradeScene,
  340. plate_number: data.plateNumber,
  341. sub_openid: data.subOpenId,
  342. sign: data.sign,
  343. channel_type: data.channelType
  344. },
  345. success(res) {
  346. console.log("签约返回信息返回信息",res);
  347. },
  348. complete(res) {
  349. console.log(res);
  350. },
  351. fail(res) {
  352. console.log(res);
  353. // 未成功跳转到车主小程序
  354. },
  355. });
  356. // if (data.userState === "UNAUTHORIZED") {
  357. // console.log("state.channelSing",state.channelSing,state.channelSing=="0")
  358. // if (state.channelSing == "0") {
  359. // uni.navigateToMiniProgram({
  360. // appId: "wxbcad394b3d99dac9",
  361. // path: "pages/route/index",
  362. // extraData: {
  363. // appid: data.appId,
  364. // sub_appid: data.subAppId,
  365. // mch_id: data.mchId,
  366. // sub_mch_id: data.subMchId,
  367. // nonce_str: data.nonceStr,
  368. // sign_type: data.signType,
  369. // trade_scene: data.tradeScene,
  370. // plate_number: data.plateNumber,
  371. // sub_openid: data.subOpenId,
  372. // sign: data.sign,
  373. // channel_type: data.channelType
  374. // },
  375. // success(res) {
  376. // console.log("签约返回信息返回信息",res);
  377. // },
  378. // complete(res) {
  379. // console.log(res);
  380. // },
  381. // fail(res) {
  382. // console.log(res);
  383. // // 未成功跳转到车主小程序
  384. // },
  385. // });
  386. // }
  387. // } else if (data.userState === "NORMAL") {
  388. // msg("已开通车主服务");
  389. // console.log("开通车主服务",data)
  390. // if(data.step === 'WAITING_ACTIVE'){
  391. // // 查询订单直接去激活
  392. // // 待激活
  393. // gotoActiveOrder(getItem('orderQueryActivate'))
  394. // }else{
  395. // // 正常订单
  396. // setTimeout(() => {
  397. // uni.redirectTo({
  398. // url: `/pages/order/order?index=0`
  399. // })
  400. // }, 1500)
  401. // }
  402. // } else if (data.userState === "PAUSED") {
  403. // msg("已暂停车主服务");
  404. // return;
  405. // } else if (data.userState === "OVERDUE") {
  406. // msg("用户已开通车主服务,但欠费状态。提示用户还款,请跳转到车主服务");
  407. // return;
  408. // }
  409. });
  410. } else {
  411. //如果获取openId失败
  412. uni.showToast({
  413. title: "网络异常,请重试!",
  414. icon: "none",
  415. duration: 1000,
  416. });
  417. return;
  418. }
  419. };
  420. </script>
  421. <style lang="scss" scoped>
  422. .container {
  423. background: #E9EDF0;
  424. height: 100vh;
  425. width: 100%;
  426. position: relative;
  427. overflow: hidden;
  428. .t-card {
  429. margin: 30rpx;
  430. background-color: #fff;
  431. border-radius: 12rpx;
  432. padding: 50rpx 30rpx;
  433. }
  434. }
  435. .footer-action {
  436. display: flex;
  437. align-items: center;
  438. justify-content: center;
  439. flex-direction: column;
  440. .btn-tip {
  441. font-family: SourceHanSansSC, SourceHanSansSC;
  442. font-weight: 400;
  443. font-size: 24rpx;
  444. color: #CCB375;
  445. margin-bottom: 14rpx;
  446. display: flex;
  447. align-items: center;
  448. .tip-icon{
  449. width: 26rpx;
  450. height: 26rpx;
  451. margin-right: 10rpx;
  452. }
  453. }
  454. .button {
  455. height: 88rpx;
  456. background: radial-gradient(at 0% 0%, #C6B077 0%, #DFCC96 100%);
  457. border-radius: 40rpx;
  458. font-size: 32rpx;
  459. font-weight: 400;
  460. color: #ffffff;
  461. line-height: 88rpx;
  462. width: 660rpx;
  463. margin: 0 auto;
  464. }
  465. }
  466. .title {
  467. margin: 0 auto;
  468. width: 322rpx;
  469. height: 44rpx;
  470. position: relative;
  471. .bg {
  472. width: 322rpx;
  473. height: 44rpx;
  474. }
  475. .bg-xia {
  476. left: 50%;
  477. position: absolute;
  478. width: 200rpx;
  479. height: 8rpx;
  480. transform: translateX(-50%);
  481. bottom: 0;
  482. }
  483. .txt {
  484. font-family: SourceHanSansSC, SourceHanSansSC;
  485. font-weight: bold;
  486. font-size: 36rpx;
  487. color: #004576;
  488. position: absolute;
  489. width: 322rpx;
  490. text-align: center;
  491. bottom: 0;
  492. }
  493. }
  494. .value {}
  495. .item {
  496. display: flex;
  497. margin-top: 60rpx;
  498. font-size: 28rpx;
  499. font-family: SourceHanSansSC, SourceHanSansSC;
  500. font-weight: 400;
  501. color: #222;
  502. line-height: 48rpx;
  503. .l-icon {
  504. margin-top: 20rpx;
  505. flex-shrink: 0;
  506. border-radius: 50%;
  507. height: 10rpx;
  508. width: 10rpx;
  509. background-color: #004576;
  510. margin-right: 18rpx;
  511. }
  512. }
  513. .item2 {
  514. margin-top: 30rpx;
  515. }
  516. </style>