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.8KB

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