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.

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