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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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. console.log("获取微信小程序openid", result);
  164. const openidData = stringToJson(result.data);
  165. state.openid = openidData.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. // orderId: "20231012114651162505354",
  186. subOpenId: state.openid,
  187. };
  188. const options = {
  189. type: 2,
  190. data: data,
  191. method: "POST",
  192. showLoading: true,
  193. };
  194. request(etcQYAction, options).then((res) => {
  195. const data = stringToJson(res.bizContent);
  196. console.log("data", data)
  197. if (data.userState === "UNAUTHORIZED") {
  198. uni.navigateToMiniProgram({
  199. appId: "wxbcad394b3d99dac9",
  200. path: "pages/route/index",
  201. extraData: {
  202. appid: "wxcb1388c809fe25a9",
  203. sub_appid: "wx008c60533388527a",
  204. mch_id: "1500877591",
  205. sub_mch_id: "1622652848",
  206. nonce_str: data.nonceStr,
  207. sign_type: "HMAC-SHA256",
  208. trade_scene: "HIGHWAY",
  209. plate_number: data.plateNumber,
  210. sub_openid: data.subOpenId,
  211. sign: data.sign,
  212. },
  213. success(res) {
  214. console.log(res);
  215. },
  216. complete(res) {
  217. console.log(res);
  218. },
  219. fail(res) {
  220. console.log(res);
  221. // 未成功跳转到车主小程序
  222. },
  223. });
  224. } else if (data.userState === "NORMAL") {
  225. msg("已开通车主服务");
  226. // uni.navigateTo({
  227. // url: `/subpackage/orders/product-detail?orderId=${state.orderId}&&clientFee=${state.clientFee}&&id=${state.id}`,
  228. // });
  229. uni.switchTab({
  230. url: "/pages/order/order"
  231. })
  232. } else if (data.userState === "PAUSED") {
  233. msg("已暂停车主服务");
  234. return;
  235. } else if (data.userState === "OVERDUE") {
  236. msg("用户已开通车主服务,但欠费状态。提示用户还款,请跳转到车主服务");
  237. return;
  238. }
  239. });
  240. } else {
  241. //如果获取openId失败
  242. uni.showToast({
  243. title: "网络异常,请重试!",
  244. icon: "none",
  245. duration: 1000,
  246. });
  247. return;
  248. }
  249. };
  250. </script>
  251. <style lang="scss" scoped>
  252. .action {
  253. margin-top: 40rpx;
  254. padding-left: 20rpx;
  255. padding-right: 20rpx;
  256. padding-bottom: 30rpx;
  257. .button {
  258. height: 80rpx;
  259. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  260. border-radius: 40rpx;
  261. font-size: 32rpx;
  262. font-weight: 400;
  263. color: #ffffff;
  264. line-height: 80rpx;
  265. }
  266. }
  267. .title {
  268. text-align: center;
  269. margin-top: 15rpx;
  270. font-size: 36rpx;
  271. font-family: Microsoft YaHei;
  272. font-weight: 400;
  273. color: #333333;
  274. line-height: 36rpx;
  275. }
  276. .value {
  277. padding: 0rpx 60rpx;
  278. }
  279. .content_1 {
  280. margin-top: 60rpx;
  281. font-size: 30rpx;
  282. font-family: Microsoft YaHei;
  283. font-weight: 400;
  284. color: #666666;
  285. line-height: 58rpx;
  286. }
  287. .content_2 {
  288. margin-top: 50rpx;
  289. font-size: 30rpx;
  290. font-family: Microsoft YaHei;
  291. font-weight: 400;
  292. color: #666666;
  293. line-height: 58rpx;
  294. }
  295. .agreement {
  296. font-size: 30rpx;
  297. display: flex;
  298. flex-wrap: wrap;
  299. margin-top: 20rpx;
  300. align-items: center;
  301. justify-content: center;
  302. }
  303. </style>