You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sign-up.vue 13KB

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