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 9.7KB

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