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

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