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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. 注:签约成功后请返回本页面,再次点击开通服务
  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. 开通服务
  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 { etcQYAction } from "@/utils/network/api.js";
  36. import { request } from "@/utils/network/request.js";
  37. import { stringToJson } from "@/utils/network/encryption";
  38. import { fileURL } from "@/datas/fileURL.js";
  39. import navBar from "@/components/nav-bar/nav-bar2.vue";
  40. import navBgCar from "./components/nav-bg-car4";
  41. import { setItem } from "@/utils/storage";
  42. import { msg } from "@/utils/utils";
  43. import {
  44. checkOrderStatus,
  45. wechatAppID,
  46. wechatSecret,
  47. getOpenidApi,
  48. infoQuery,
  49. envs
  50. } from "@/utils/network/api";
  51. const imgURL = `${fileURL}image/`;
  52. const state = reactive({
  53. openid: "",
  54. orderId: "",
  55. id: "",
  56. clientFee: "",
  57. checked: false,
  58. agreeURL: "",
  59. });
  60. onLoad((option : any) => {
  61. getOpenID();
  62. state.orderId = option.orderId;
  63. getInfo();
  64. });
  65. const checkboxChange = (e) => {
  66. state.checked = !state.checked;
  67. console.log(state.checked);
  68. };
  69. const getInfo = () => {
  70. //参数说明
  71. let options = {
  72. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  73. data: {
  74. businessType: 'WITHHOLD_AGREEMENT' //代扣协议
  75. }, //请求参数
  76. method: "POST", //提交方式(默认POST)
  77. showLoading: true, //是否显示加载中(默认显示)
  78. };
  79. //调用方式
  80. request(infoQuery, options)
  81. .then((res) => {
  82. let data = stringToJson(res.bizContent)
  83. if (data.textType = "URL") {
  84. state.agreeURL = envs[process.env.NODE_ENV].baseUrl + data.text
  85. }
  86. console.log("代扣协议", state.agreeURL);
  87. })
  88. .catch((err) => {
  89. console.log(err);
  90. });
  91. }
  92. //获取微信小程序openid
  93. const getOpenID = () => {
  94. // #ifdef MP-WEIXIN
  95. uni.login({
  96. provider: "weixin",
  97. success: function (e) {
  98. console.log(e);
  99. getOpenid(e.code);
  100. },
  101. });
  102. // #endif
  103. };
  104. const downAuthD = () => {
  105. // tools.showLoadingAlert("加载中");
  106. uni.downloadFile({
  107. url: state.agreeURL,
  108. filePath: wx.env.USER_DATA_PATH + '/' + '代扣协议.docx',
  109. success(res) {
  110. const filePath = res.filePath
  111. uni.openDocument({
  112. filePath: filePath,
  113. fileType: 'docx',
  114. showMenu: true, //关键点
  115. success: function (res) {
  116. msg("打开文档成功");
  117. },
  118. fail: function (err) {
  119. msg("打开文档失败");
  120. }
  121. });
  122. },
  123. fail: function (err) {
  124. msg("下载文档失败");
  125. console.log("err", err)
  126. },
  127. complete(res) {
  128. }
  129. })
  130. }
  131. const getOpenid = (code) => {
  132. const options = {
  133. type: 2,
  134. data: {
  135. "jsCode": code
  136. },
  137. method: "POST",
  138. showLoading: true,
  139. };
  140. // #ifdef MP-WEIXIN
  141. request(getOpenidApi, options).then((res) => {
  142. const result = stringToJson(res.bizContent);
  143. const openidData = stringToJson(result.data);
  144. state.openid = openidData.openid;
  145. console.log("获取微信小程序openid", state.openid);
  146. setItem("QYorder", state);
  147. });
  148. // #endif
  149. }
  150. const savaHandle = () => {
  151. if (!state.checked) {
  152. msg("请勾选协议!")
  153. return;
  154. }
  155. console.log("openid*******", state.openid);
  156. //如果获取openId成功
  157. if (state.openid) {
  158. var data = {
  159. orderId: state.orderId,
  160. subOpenId: state.openid,
  161. };
  162. const options = {
  163. type: 2,
  164. data: data,
  165. method: "POST",
  166. showLoading: true,
  167. };
  168. request(etcQYAction, options).then((res) => {
  169. const data = stringToJson(res.bizContent);
  170. console.log("data", data)
  171. if (data.userState === "UNAUTHORIZED") {
  172. uni.navigateToMiniProgram({
  173. appId: "wxbcad394b3d99dac9",
  174. path: "pages/route/index",
  175. extraData: {
  176. appid: "wxcb1388c809fe25a9",
  177. sub_appid: "wx008c60533388527a",
  178. mch_id: "1500877591",
  179. sub_mch_id: "1622652848",
  180. nonce_str: data.nonceStr,
  181. sign_type: "HMAC-SHA256",
  182. trade_scene: "HIGHWAY",
  183. plate_number: data.plateNumber,
  184. sub_openid: data.subOpenId,
  185. sign: data.sign,
  186. channel_type: "ETC"
  187. },
  188. success(res) {
  189. console.log(res);
  190. },
  191. complete(res) {
  192. console.log(res);
  193. },
  194. fail(res) {
  195. console.log(res);
  196. // 未成功跳转到车主小程序
  197. },
  198. });
  199. } else if (data.userState === "NORMAL") {
  200. msg("已开通车主服务");
  201. setTimeout(() => {
  202. uni.switchTab({
  203. url: "/pages/order/order"
  204. })
  205. }, 1500)
  206. } else if (data.userState === "PAUSED") {
  207. msg("已暂停车主服务");
  208. return;
  209. } else if (data.userState === "OVERDUE") {
  210. msg("用户已开通车主服务,但欠费状态。提示用户还款,请跳转到车主服务");
  211. return;
  212. }
  213. });
  214. } else {
  215. //如果获取openId失败
  216. uni.showToast({
  217. title: "网络异常,请重试!",
  218. icon: "none",
  219. duration: 1000,
  220. });
  221. return;
  222. }
  223. };
  224. </script>
  225. <style lang="scss" scoped>
  226. .action {
  227. margin-top: 40rpx;
  228. padding-left: 20rpx;
  229. padding-right: 20rpx;
  230. padding-bottom: 30rpx;
  231. .button {
  232. height: 80rpx;
  233. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  234. border-radius: 40rpx;
  235. font-size: 32rpx;
  236. font-weight: 400;
  237. color: #ffffff;
  238. line-height: 80rpx;
  239. }
  240. }
  241. .title {
  242. text-align: center;
  243. margin-top: 15rpx;
  244. font-size: 36rpx;
  245. font-family: Microsoft YaHei;
  246. font-weight: 400;
  247. color: #333333;
  248. line-height: 36rpx;
  249. }
  250. .value {
  251. padding: 0rpx 60rpx;
  252. }
  253. .content_1 {
  254. margin-top: 60rpx;
  255. font-size: 30rpx;
  256. font-family: Microsoft YaHei;
  257. font-weight: 400;
  258. color: #666666;
  259. line-height: 58rpx;
  260. }
  261. .content_2 {
  262. margin-top: 50rpx;
  263. font-size: 30rpx;
  264. font-family: Microsoft YaHei;
  265. font-weight: 400;
  266. color: #666666;
  267. line-height: 58rpx;
  268. }
  269. .content_3 {
  270. margin-top: 50rpx;
  271. font-size: 30rpx;
  272. font-family: Microsoft YaHei;
  273. font-weight: 400;
  274. color: #ff0000;
  275. line-height: 58rpx;
  276. }
  277. .agreement {
  278. font-size: 30rpx;
  279. display: flex;
  280. flex-wrap: wrap;
  281. margin-top: 20rpx;
  282. align-items: center;
  283. justify-content: center;
  284. }
  285. </style>