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

sign-up.vue 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <image style="
  3. margin-top: 20rpx;
  4. width: 100%;
  5. height: 240rpx;
  6. background-color: #eeeeee;
  7. " :src="`${$imgUrl}applyCard/car-service.png`"></image>
  8. <view class="title"> 微信车主服务 </view>
  9. <view class="value">
  10. <view class="content_1">
  11. 微信车主服务是微信支付为车主用户提供的安全便捷的智慧服务
  12. </view>
  13. <view class="content_2">
  14. 本次将为贵州黔通智联科技股份有限公司开启免密支付服务,后续相关的费用将通过微信车主服务从你的微信支付账户扣除
  15. </view>
  16. <view class="content_3">
  17. 注:签约成功后请返回本页面,再次点击{{state.channelSing=="0"?'开通服务':'恢复签约'}}
  18. </view>
  19. </view>
  20. <view class="as-layout-horizontal agreement">
  21. <checkbox-group @change="checkboxChange">
  22. <checkbox :checked="state.checked" style="transform: scale(0.8)" />我已阅读并同意
  23. </checkbox-group>
  24. <text style="color:#007AFF;text-decoration: underline;" @click="downAuthD()">《代扣协议》</text>
  25. </view>
  26. <view class="action">
  27. <button type="default" class="button" @click="savaHandle()">
  28. {{state.channelSing=="0"?'开通服务':'恢复签约'}}
  29. </button>
  30. </view>
  31. </template>
  32. <script setup lang="ts">
  33. import { onLoad, onShow } from "@dcloudio/uni-app";
  34. import { reactive } from "vue";
  35. import { request } from "@/utils/network/request.js";
  36. import { stringToJson } from "@/utils/network/encryption";
  37. import { fileURL } from "@/datas/fileURL.js";
  38. import { setItem } from "@/utils/storage";
  39. import { msg } from "@/utils/utils";
  40. import {
  41. getOpenidApi,
  42. infoQuery,
  43. envs, etcQYAction, channelSingQueryApi
  44. } from "@/utils/network/api";
  45. const imgURL = `${fileURL}image/`;
  46. const state = reactive({
  47. openid: "",
  48. orderId: "",
  49. id: "",
  50. clientFee: "",
  51. checked: false,
  52. agreeURL: "",
  53. channelSing: "0",//0 正常签约 1恢复签约
  54. vehiclePlate: "",
  55. code: ""
  56. });
  57. onLoad((option : any) => {
  58. getOpenID();
  59. state.orderId = option.orderId;
  60. if (option.channelSing) {
  61. state.channelSing = option.channelSing;
  62. }
  63. state.vehiclePlate = option.vehiclePlate;
  64. getInfo();
  65. });
  66. const checkboxChange = (e) => {
  67. state.checked = !state.checked;
  68. console.log(state.checked);
  69. };
  70. const getInfo = () => {
  71. //参数说明
  72. let options = {
  73. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  74. data: {
  75. businessType: 'WITHHOLD_AGREEMENT' //代扣协议
  76. }, //请求参数
  77. method: "POST", //提交方式(默认POST)
  78. showLoading: true, //是否显示加载中(默认显示)
  79. };
  80. //调用方式
  81. request(infoQuery, options)
  82. .then((res) => {
  83. let data = stringToJson(res.bizContent)
  84. if (data.textType = "URL") {
  85. state.agreeURL = envs[process.env.NODE_ENV].baseUrl + data.text
  86. }
  87. console.log("代扣协议", state.agreeURL);
  88. })
  89. .catch((err) => {
  90. console.log(err);
  91. });
  92. }
  93. //获取微信小程序openid
  94. const getOpenID = () => {
  95. // #ifdef MP-WEIXIN
  96. uni.login({
  97. provider: "weixin",
  98. success: function (e) {
  99. console.log(e);
  100. state.code = e.code
  101. getOpenid(e.code);
  102. },
  103. });
  104. // #endif
  105. };
  106. const downAuthD = () => {
  107. // tools.showLoadingAlert("加载中");
  108. uni.downloadFile({
  109. url: state.agreeURL,
  110. filePath: wx.env.USER_DATA_PATH + '/' + '代扣协议.docx',
  111. success(res) {
  112. const filePath = res.filePath
  113. uni.openDocument({
  114. filePath: filePath,
  115. fileType: 'docx',
  116. showMenu: true, //关键点
  117. success: function (res) {
  118. msg("打开文档成功");
  119. },
  120. fail: function (err) {
  121. msg("打开文档失败");
  122. }
  123. });
  124. },
  125. fail: function (err) {
  126. msg("下载文档失败");
  127. console.log("err", err)
  128. },
  129. complete(res) {
  130. }
  131. })
  132. }
  133. const getOpenid = (code) => {
  134. const options = {
  135. type: 2,
  136. data: {
  137. "jsCode": code
  138. },
  139. method: "POST",
  140. showLoading: true,
  141. };
  142. // #ifdef MP-WEIXIN
  143. request(getOpenidApi, options).then((res) => {
  144. const result = stringToJson(res.bizContent);
  145. const openidData = stringToJson(result.data);
  146. state.openid = openidData.openid;
  147. console.log("获取微信小程序openid", state.openid);
  148. setItem("QYorder", state);
  149. });
  150. // #endif
  151. }
  152. const savaHandle = () => {
  153. if (!state.checked) {
  154. msg("请勾选协议!")
  155. return;
  156. }
  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. request(etcQYAction, options).then((res) => {
  171. const data = stringToJson(res.bizContent);
  172. console.log("data", data)
  173. if (data.userState === "UNAUTHORIZED") {
  174. if (state.channelSing == "0") {
  175. uni.navigateToMiniProgram({
  176. appId: "wxbcad394b3d99dac9",
  177. path: "pages/route/index",
  178. extraData: {
  179. appid: "wxcb1388c809fe25a9",
  180. sub_appid: "wx008c60533388527a",
  181. mch_id: "1500877591",
  182. sub_mch_id: "1622652848",
  183. nonce_str: data.nonceStr,
  184. sign_type: "HMAC-SHA256",
  185. trade_scene: "HIGHWAY",
  186. plate_number: data.plateNumber,
  187. sub_openid: data.subOpenId,
  188. sign: data.sign,
  189. channel_type: "ETC"
  190. },
  191. success(res) {
  192. console.log(res);
  193. },
  194. complete(res) {
  195. console.log(res);
  196. },
  197. fail(res) {
  198. console.log(res);
  199. // 未成功跳转到车主小程序
  200. },
  201. });
  202. } else {
  203. // 恢复签约
  204. const optionss = {
  205. type: 2,
  206. data: {
  207. plateNumber: state.vehiclePlate,
  208. openid: state.openid,
  209. channelId: '52010188925',
  210. tradeScene: 'HIGHWAY',
  211. code: state.code
  212. },
  213. method: "POST",
  214. showLoading: true,
  215. };
  216. request(channelSingQueryApi, optionss)
  217. .then((res) => {
  218. let data = stringToJson(res.bizContent)
  219. uni.navigateToMiniProgram({
  220. appId: "wxbcad394b3d99dac9",
  221. path: "pages/route/index",
  222. extraData: {
  223. appid: data.appid,
  224. sub_appid: data.subAppid,
  225. mch_id: data.mchId,
  226. sub_mch_id: data.subMchId,
  227. nonce_str: data.nonceStr,
  228. sign_type: data.signType,
  229. trade_scene: data.tradeScene,
  230. plate_number: data.plateNumber,
  231. sub_openid: data.subOpenid,
  232. sign: data.sign,
  233. channel_type: data.channelType
  234. },
  235. success(res) {
  236. },
  237. complete(res) {
  238. console.log(res);
  239. },
  240. fail(res) {
  241. console.log(res);
  242. // 未成功跳转到车主小程序
  243. },
  244. });
  245. })
  246. .catch((err) => {
  247. console.log(err);
  248. });
  249. }
  250. } else if (data.userState === "NORMAL") {
  251. msg("已开通车主服务");
  252. setTimeout(() => {
  253. uni.switchTab({
  254. url: "/pages/order/order"
  255. })
  256. }, 1500)
  257. } else if (data.userState === "PAUSED") {
  258. msg("已暂停车主服务");
  259. return;
  260. } else if (data.userState === "OVERDUE") {
  261. msg("用户已开通车主服务,但欠费状态。提示用户还款,请跳转到车主服务");
  262. return;
  263. }
  264. });
  265. } else {
  266. //如果获取openId失败
  267. uni.showToast({
  268. title: "网络异常,请重试!",
  269. icon: "none",
  270. duration: 1000,
  271. });
  272. return;
  273. }
  274. };
  275. </script>
  276. <style lang="scss" scoped>
  277. .action {
  278. margin-top: 40rpx;
  279. padding-left: 20rpx;
  280. padding-right: 20rpx;
  281. padding-bottom: 30rpx;
  282. .button {
  283. height: 80rpx;
  284. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  285. border-radius: 40rpx;
  286. font-size: 32rpx;
  287. font-weight: 400;
  288. color: #ffffff;
  289. line-height: 80rpx;
  290. }
  291. }
  292. .title {
  293. text-align: center;
  294. margin-top: 15rpx;
  295. font-size: 36rpx;
  296. font-family: Microsoft YaHei;
  297. font-weight: 400;
  298. color: #333333;
  299. line-height: 36rpx;
  300. }
  301. .value {
  302. padding: 0rpx 60rpx;
  303. }
  304. .content_1 {
  305. margin-top: 60rpx;
  306. font-size: 30rpx;
  307. font-family: Microsoft YaHei;
  308. font-weight: 400;
  309. color: #666666;
  310. line-height: 58rpx;
  311. }
  312. .content_2 {
  313. margin-top: 50rpx;
  314. font-size: 30rpx;
  315. font-family: Microsoft YaHei;
  316. font-weight: 400;
  317. color: #666666;
  318. line-height: 58rpx;
  319. }
  320. .content_3 {
  321. margin-top: 50rpx;
  322. font-size: 30rpx;
  323. font-family: Microsoft YaHei;
  324. font-weight: 400;
  325. color: #ff0000;
  326. line-height: 58rpx;
  327. }
  328. .agreement {
  329. font-size: 30rpx;
  330. display: flex;
  331. flex-wrap: wrap;
  332. margin-top: 20rpx;
  333. align-items: center;
  334. justify-content: center;
  335. }
  336. </style>