Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

sign-up.vue 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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. uni.downloadFile({
  108. url: state.agreeURL,
  109. filePath: wx.env.USER_DATA_PATH + '/' + '代扣协议.docx',
  110. success(res) {
  111. const filePath = res.filePath
  112. uni.openDocument({
  113. filePath: filePath,
  114. fileType: 'docx',
  115. showMenu: true, //关键点
  116. success: function (res) {
  117. msg("打开文档成功");
  118. },
  119. fail: function (err) {
  120. msg("打开文档失败");
  121. }
  122. });
  123. },
  124. fail: function (err) {
  125. msg("下载文档失败");
  126. console.log("err", err)
  127. },
  128. complete(res) {
  129. }
  130. })
  131. }
  132. const getOpenid = (code) => {
  133. const options = {
  134. type: 2,
  135. data: {
  136. "jsCode": code
  137. },
  138. method: "POST",
  139. showLoading: true,
  140. };
  141. // #ifdef MP-WEIXIN
  142. request(getOpenidApi, options).then((res) => {
  143. const result = stringToJson(res.bizContent);
  144. const openidData = stringToJson(result.data);
  145. state.openid = openidData.openid;
  146. console.log("获取微信小程序openid", state.openid);
  147. setItem("QYorder", state);
  148. });
  149. // #endif
  150. }
  151. const savaHandle = () => {
  152. // if (!state.checked) {
  153. // msg("请勾选协议!")
  154. // return;
  155. // }
  156. console.log("openid*******", state.openid);
  157. //如果获取openId成功
  158. if (state.openid) {
  159. var data = {
  160. orderId: state.orderId,
  161. subOpenId: state.openid,
  162. };
  163. const options = {
  164. type: 2,
  165. data: data,
  166. method: "POST",
  167. showLoading: true,
  168. };
  169. request(etcQYAction, options).then((res) => {
  170. const data = stringToJson(res.bizContent);
  171. console.log("data", data)
  172. if (data.userState === "UNAUTHORIZED") {
  173. if (state.channelSing == "0") {
  174. uni.navigateToMiniProgram({
  175. appId: "wxbcad394b3d99dac9",
  176. path: "pages/route/index",
  177. extraData: {
  178. appid: data.appid,
  179. sub_appid: data.subAppid,
  180. mch_id: data.mchId,
  181. sub_mch_id: data.subMchId,
  182. nonce_str: data.nonceStr,
  183. sign_type: data.signType,
  184. trade_scene: data.tradeScene,
  185. plate_number: data.plateNumber,
  186. sub_openid: data.subOpenId,
  187. sign: data.sign,
  188. channel_type: data.channelType
  189. },
  190. success(res) {
  191. console.log(res);
  192. },
  193. complete(res) {
  194. console.log(res);
  195. },
  196. fail(res) {
  197. console.log(res);
  198. // 未成功跳转到车主小程序
  199. },
  200. });
  201. } else {
  202. // 恢复签约
  203. const optionss = {
  204. type: 2,
  205. data: {
  206. plateNumber: state.vehiclePlate,
  207. openid: state.openid,
  208. channelId: '52010188925',
  209. tradeScene: 'HIGHWAY',
  210. code: state.code
  211. },
  212. method: "POST",
  213. showLoading: true,
  214. };
  215. request(channelSingQueryApi, optionss)
  216. .then((res) => {
  217. let data = stringToJson(res.bizContent)
  218. uni.navigateToMiniProgram({
  219. appId: "wxbcad394b3d99dac9",
  220. path: "pages/route/index",
  221. extraData: {
  222. appid: data.appid,
  223. sub_appid: data.subAppid,
  224. mch_id: data.mchId,
  225. sub_mch_id: data.subMchId,
  226. nonce_str: data.nonceStr,
  227. sign_type: data.signType,
  228. trade_scene: data.tradeScene,
  229. plate_number: data.plateNumber,
  230. sub_openid: data.subOpenid,
  231. sign: data.sign,
  232. channel_type: data.channelType
  233. },
  234. success(res) {
  235. },
  236. complete(res) {
  237. console.log(res);
  238. },
  239. fail(res) {
  240. console.log(res);
  241. // 未成功跳转到车主小程序
  242. },
  243. });
  244. })
  245. .catch((err) => {
  246. console.log(err);
  247. });
  248. }
  249. } else if (data.userState === "NORMAL") {
  250. msg("已开通车主服务");
  251. setTimeout(() => {
  252. uni.switchTab({
  253. url: "/pages/order/order"
  254. })
  255. }, 1500)
  256. } else if (data.userState === "PAUSED") {
  257. msg("已暂停车主服务");
  258. return;
  259. } else if (data.userState === "OVERDUE") {
  260. msg("用户已开通车主服务,但欠费状态。提示用户还款,请跳转到车主服务");
  261. return;
  262. }
  263. });
  264. } else {
  265. //如果获取openId失败
  266. uni.showToast({
  267. title: "网络异常,请重试!",
  268. icon: "none",
  269. duration: 1000,
  270. });
  271. return;
  272. }
  273. };
  274. </script>
  275. <style lang="scss" scoped>
  276. .action {
  277. margin-top: 40rpx;
  278. padding-left: 20rpx;
  279. padding-right: 20rpx;
  280. padding-bottom: 30rpx;
  281. .button {
  282. height: 80rpx;
  283. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  284. border-radius: 40rpx;
  285. font-size: 32rpx;
  286. font-weight: 400;
  287. color: #ffffff;
  288. line-height: 80rpx;
  289. }
  290. }
  291. .title {
  292. text-align: center;
  293. margin-top: 15rpx;
  294. font-size: 36rpx;
  295. font-family: Microsoft YaHei;
  296. font-weight: 400;
  297. color: #333333;
  298. line-height: 36rpx;
  299. }
  300. .value {
  301. padding: 0rpx 60rpx;
  302. }
  303. .content_1 {
  304. margin-top: 60rpx;
  305. font-size: 30rpx;
  306. font-family: Microsoft YaHei;
  307. font-weight: 400;
  308. color: #666666;
  309. line-height: 58rpx;
  310. }
  311. .content_2 {
  312. margin-top: 50rpx;
  313. font-size: 30rpx;
  314. font-family: Microsoft YaHei;
  315. font-weight: 400;
  316. color: #666666;
  317. line-height: 58rpx;
  318. }
  319. .content_3 {
  320. margin-top: 50rpx;
  321. font-size: 30rpx;
  322. font-family: Microsoft YaHei;
  323. font-weight: 400;
  324. color: #ff0000;
  325. line-height: 58rpx;
  326. }
  327. .agreement {
  328. font-size: 30rpx;
  329. display: flex;
  330. flex-wrap: wrap;
  331. margin-top: 20rpx;
  332. align-items: center;
  333. justify-content: center;
  334. }
  335. </style>