Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

sign-up.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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. </view>
  36. </template>
  37. <script setup lang="ts">
  38. import { onLoad, onShow } from "@dcloudio/uni-app";
  39. import { reactive } from "vue";
  40. import { request, requestNew } from "@/utils/network/request.js";
  41. import { stringToJson } from "@/utils/network/encryption";
  42. import { fileURL } from "@/datas/fileURL.js";
  43. import { getItem, setItem } from "@/utils/storage";
  44. import { msg } from "@/utils/utils";
  45. import {
  46. infoQuery,
  47. envs, channelSingQueryApi, userSign, getOpenId, reSign
  48. } from "@/utils/network/api";
  49. const imgURL = `${fileURL}image/`;
  50. import useOrderSkip from "@/composables/order/useOrderSkip";
  51. const { gotoActiveOrder} = useOrderSkip();
  52. const state = reactive({
  53. openid: "",
  54. orderId: "",
  55. id: "",
  56. clientFee: "",
  57. checked: false,
  58. agreeURL: "",
  59. channelSing: "0",//0 正常签约 1恢复签约
  60. vehiclePlate: "",
  61. code: "",
  62. orderQuery:"0",
  63. from: "",
  64. vehicleId: "",
  65. });
  66. onLoad((option : any) => {
  67. getOpenID();
  68. state.orderId = option.orderId;
  69. if (option.from == '37') {
  70. state.from = option.from;
  71. state.vehicleId = option.vehicleId;
  72. }
  73. if (option.channelSing) {
  74. state.channelSing = option.channelSing;
  75. }
  76. console.log("state.channelSing",option.channelSing,option)
  77. state.vehiclePlate = option.vehiclePlate;
  78. state.orderQuery = option.orderQuery;
  79. getInfo();
  80. });
  81. const checkboxChange = (e) => {
  82. state.checked = !state.checked;
  83. console.log(state.checked);
  84. };
  85. const getInfo = () => {
  86. //参数说明
  87. let options = {
  88. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  89. data: {
  90. businessType: 'WITHHOLD_AGREEMENT' //代扣协议
  91. }, //请求参数
  92. method: "POST", //提交方式(默认POST)
  93. showLoading: true, //是否显示加载中(默认显示)
  94. };
  95. //调用方式
  96. requestNew(infoQuery, options)
  97. .then((res) => {
  98. let data = res
  99. if (data.textType = "URL") {
  100. state.agreeURL = envs[process.env.NODE_ENV].baseUrl + data.text
  101. }
  102. console.log("代扣协议", state.agreeURL);
  103. })
  104. .catch((err) => {
  105. console.log(err);
  106. });
  107. }
  108. //获取微信小程序openid
  109. const getOpenID = () => {
  110. // #ifdef MP-WEIXIN
  111. uni.login({
  112. provider: "weixin",
  113. success: function (e) {
  114. console.log(e);
  115. state.code = e.code
  116. getOpenid(e.code);
  117. },
  118. });
  119. // #endif
  120. };
  121. const downAuthD = () => {
  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. requestNew(getOpenId, options).then((res) => {
  158. const result = res;
  159. state.openid = result.openid;
  160. console.log("获取微信小程序openid", state.openid);
  161. setItem("wxOpenid", result.openid);
  162. });
  163. // #endif
  164. }
  165. const savaHandle = () => {
  166. console.log("openid*******", state.openid);
  167. //如果获取openId成功
  168. if (state.openid) {
  169. // 从恢复签约列表进入进行恢复签约
  170. if (state.from == '37') {
  171. const options = {
  172. data: {
  173. signChannelType: 1,
  174. subOpenId: state.openid,
  175. vehicleId: state.vehicleId,
  176. },
  177. method: "POST",
  178. showLoading: true
  179. };
  180. requestNew(reSign, options).then((res) => {
  181. console.log(res, 3222);
  182. const data = res;
  183. if (data.userState === "UNAUTHORIZED") {
  184. uni.navigateToMiniProgram({
  185. appId: "wxbcad394b3d99dac9",
  186. path: "pages/route/index",
  187. extraData: {
  188. appid: data.appId,
  189. sub_appid: data.subAppId,
  190. mch_id: data.mchId,
  191. sub_mch_id: data.subMchId,
  192. nonce_str: data.nonceStr,
  193. sign_type: data.signType,
  194. trade_scene: data.tradeScene,
  195. plate_number: data.plateNumber,
  196. sub_openid: data.subOpenId,
  197. sign: data.sign,
  198. channel_type: data.channelType
  199. },
  200. success(res) {
  201. console.log(res);
  202. },
  203. complete(res) {
  204. console.log(res);
  205. },
  206. fail(res) {
  207. console.log(res);
  208. // 未成功跳转到车主小程序
  209. },
  210. });
  211. } else {
  212. msg("用户已签约");
  213. setTimeout(() => {
  214. uni.navigateBack();
  215. }, 1000);
  216. }
  217. });
  218. return;
  219. }
  220. var data = {
  221. orderNo: state.orderId,
  222. subOpenId: state.openid,
  223. };
  224. const options = {
  225. type: 2,
  226. data: data,
  227. method: "POST",
  228. showLoading: true,
  229. };
  230. requestNew(userSign, options).then((res) => {
  231. const data = res;
  232. console.log("data", data)
  233. if (data.userState === "UNAUTHORIZED") {
  234. console.log("state.channelSing",state.channelSing,state.channelSing=="0")
  235. if (state.channelSing == "0") {
  236. uni.navigateToMiniProgram({
  237. appId: "wxbcad394b3d99dac9",
  238. path: "pages/route/index",
  239. extraData: {
  240. appid: data.appId,
  241. sub_appid: data.subAppId,
  242. mch_id: data.mchId,
  243. sub_mch_id: data.subMchId,
  244. nonce_str: data.nonceStr,
  245. sign_type: data.signType,
  246. trade_scene: data.tradeScene,
  247. plate_number: data.plateNumber,
  248. sub_openid: data.subOpenId,
  249. sign: data.sign,
  250. channel_type: data.channelType
  251. },
  252. success(res) {
  253. console.log(res);
  254. },
  255. complete(res) {
  256. console.log(res);
  257. },
  258. fail(res) {
  259. console.log(res);
  260. // 未成功跳转到车主小程序
  261. },
  262. });
  263. } else {
  264. // 恢复签约
  265. const optionss = {
  266. type: 2,
  267. data: {
  268. plateNumber: state.vehiclePlate,
  269. openid: state.openid,
  270. channelId: '52010188925',
  271. tradeScene: 'HIGHWAY',
  272. code: state.code
  273. },
  274. method: "POST",
  275. showLoading: true,
  276. };
  277. requestNew(channelSingQueryApi, optionss)
  278. .then((res) => {
  279. let data = res
  280. uni.navigateToMiniProgram({
  281. appId: "wxbcad394b3d99dac9",
  282. path: "pages/route/index",
  283. extraData: {
  284. appid: data.appid,
  285. sub_appid: data.subAppid,
  286. mch_id: data.mchId,
  287. sub_mch_id: data.subMchId,
  288. nonce_str: data.nonceStr,
  289. sign_type: data.signType,
  290. trade_scene: data.tradeScene,
  291. plate_number: data.plateNumber,
  292. sub_openid: data.subOpenid,
  293. sign: data.sign,
  294. channel_type: data.channelType
  295. },
  296. success(res) {
  297. },
  298. complete(res) {
  299. console.log(res);
  300. },
  301. fail(res) {
  302. console.log(res);
  303. // 未成功跳转到车主小程序
  304. },
  305. });
  306. })
  307. .catch((err) => {
  308. console.log(err);
  309. });
  310. }
  311. } else if (data.userState === "NORMAL") {
  312. msg("已开通车主服务");
  313. if(state.orderQuery=='1'){
  314. // 查询订单直接去激活
  315. // 待激活
  316. gotoActiveOrder(getItem('orderQueryActivate'))
  317. }else{
  318. // 正常订单
  319. setTimeout(() => {
  320. uni.redirectTo({
  321. url: `/pages/order/order?index=0`
  322. })
  323. }, 1500)
  324. }
  325. } else if (data.userState === "PAUSED") {
  326. msg("已暂停车主服务");
  327. return;
  328. } else if (data.userState === "OVERDUE") {
  329. msg("用户已开通车主服务,但欠费状态。提示用户还款,请跳转到车主服务");
  330. return;
  331. }
  332. });
  333. } else {
  334. //如果获取openId失败
  335. uni.showToast({
  336. title: "网络异常,请重试!",
  337. icon: "none",
  338. duration: 1000,
  339. });
  340. return;
  341. }
  342. };
  343. </script>
  344. <style lang="scss" scoped>
  345. .container {
  346. background: #E9EDF0;
  347. height: 100vh;
  348. width: 100%;
  349. position: relative;
  350. overflow: hidden;
  351. .t-card {
  352. margin: 30rpx;
  353. background-color: #fff;
  354. border-radius: 12rpx;
  355. padding: 50rpx 30rpx;
  356. }
  357. }
  358. .action {
  359. position: absolute;
  360. bottom: 0rpx;
  361. left: 0;
  362. height: 188rpx;
  363. background-color: #fff;
  364. border-radius: 30rpx 30rpx 0 0;
  365. width: 100vw;
  366. display: flex;
  367. align-items: center;
  368. justify-content: center;
  369. flex-direction: column;
  370. .btn-tip {
  371. font-family: SourceHanSansSC, SourceHanSansSC;
  372. font-weight: 400;
  373. font-size: 24rpx;
  374. color: #CCB375;
  375. margin-bottom: 14rpx;
  376. display: flex;
  377. align-items: center;
  378. .tip-icon{
  379. width: 26rpx;
  380. height: 26rpx;
  381. margin-right: 10rpx;
  382. }
  383. }
  384. .button {
  385. height: 88rpx;
  386. background: radial-gradient(at 0% 0%, #C6B077 0%, #DFCC96 100%);
  387. border-radius: 40rpx;
  388. font-size: 32rpx;
  389. font-weight: 400;
  390. color: #ffffff;
  391. line-height: 88rpx;
  392. width: 660rpx;
  393. margin: 0 auto;
  394. }
  395. }
  396. .title {
  397. margin: 0 auto;
  398. width: 322rpx;
  399. height: 44rpx;
  400. position: relative;
  401. .bg {
  402. width: 322rpx;
  403. height: 44rpx;
  404. }
  405. .bg-xia {
  406. left: 50%;
  407. position: absolute;
  408. width: 200rpx;
  409. height: 8rpx;
  410. transform: translateX(-50%);
  411. bottom: 0;
  412. }
  413. .txt {
  414. font-family: SourceHanSansSC, SourceHanSansSC;
  415. font-weight: bold;
  416. font-size: 36rpx;
  417. color: #004576;
  418. position: absolute;
  419. width: 322rpx;
  420. text-align: center;
  421. bottom: 0;
  422. }
  423. }
  424. .value {}
  425. .item {
  426. display: flex;
  427. margin-top: 60rpx;
  428. font-size: 28rpx;
  429. font-family: SourceHanSansSC, SourceHanSansSC;
  430. font-weight: 400;
  431. color: #222;
  432. line-height: 48rpx;
  433. .l-icon {
  434. margin-top: 20rpx;
  435. flex-shrink: 0;
  436. border-radius: 50%;
  437. height: 10rpx;
  438. width: 10rpx;
  439. background-color: #004576;
  440. margin-right: 18rpx;
  441. }
  442. }
  443. .item2 {
  444. margin-top: 30rpx;
  445. }
  446. </style>