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.5KB

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