您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

sign-up.vue 9.2KB

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