Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

sign-up.vue 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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,requestNew } 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. infoQuery,
  42. envs, channelSingQueryApi,userSign,getOpenId
  43. } from "@/utils/network/api";
  44. const imgURL = `${fileURL}image/`;
  45. const state = reactive({
  46. openid: "",
  47. orderId: "",
  48. id: "",
  49. clientFee: "",
  50. checked: false,
  51. agreeURL: "",
  52. channelSing: "0",//0 正常签约 1恢复签约
  53. vehiclePlate: "",
  54. code: ""
  55. });
  56. onLoad((option : any) => {
  57. getOpenID();
  58. state.orderId = option.orderId;
  59. if (option.channelSing) {
  60. state.channelSing = option.channelSing;
  61. }
  62. state.vehiclePlate = option.vehiclePlate;
  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. requestNew(infoQuery, options)
  81. .then((res) => {
  82. let data = res
  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. state.code = e.code
  100. getOpenid(e.code);
  101. },
  102. });
  103. // #endif
  104. };
  105. const downAuthD = () => {
  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. requestNew(getOpenId, options).then((res) => {
  142. const result = res;
  143. const openidData = stringToJson(result.data);
  144. state.openid = openidData.openid;
  145. console.log("获取微信小程序openid", state.openid);
  146. setItem("QYorder", openidData);
  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. requestNew(userSign, options).then((res) => {
  169. const data = res;
  170. console.log("data", data)
  171. if (data.userState === "UNAUTHORIZED") {
  172. if (state.channelSing == "0") {
  173. uni.navigateToMiniProgram({
  174. appId: "wxbcad394b3d99dac9",
  175. path: "pages/route/index",
  176. extraData: {
  177. appid: data.appid,
  178. sub_appid: data.subAppid,
  179. mch_id: data.mchId,
  180. sub_mch_id: data.subMchId,
  181. nonce_str: data.nonceStr,
  182. sign_type: data.signType,
  183. trade_scene: data.tradeScene,
  184. plate_number: data.plateNumber,
  185. sub_openid: data.subOpenId,
  186. sign: data.sign,
  187. channel_type: data.channelType
  188. },
  189. success(res) {
  190. console.log(res);
  191. },
  192. complete(res) {
  193. console.log(res);
  194. },
  195. fail(res) {
  196. console.log(res);
  197. // 未成功跳转到车主小程序
  198. },
  199. });
  200. } else {
  201. // 恢复签约
  202. const optionss = {
  203. type: 2,
  204. data: {
  205. plateNumber: state.vehiclePlate,
  206. openid: state.openid,
  207. channelId: '52010188925',
  208. tradeScene: 'HIGHWAY',
  209. code: state.code
  210. },
  211. method: "POST",
  212. showLoading: true,
  213. };
  214. request(channelSingQueryApi, optionss)
  215. .then((res) => {
  216. let data = stringToJson(res.bizContent)
  217. uni.navigateToMiniProgram({
  218. appId: "wxbcad394b3d99dac9",
  219. path: "pages/route/index",
  220. extraData: {
  221. appid: data.appid,
  222. sub_appid: data.subAppid,
  223. mch_id: data.mchId,
  224. sub_mch_id: data.subMchId,
  225. nonce_str: data.nonceStr,
  226. sign_type: data.signType,
  227. trade_scene: data.tradeScene,
  228. plate_number: data.plateNumber,
  229. sub_openid: data.subOpenid,
  230. sign: data.sign,
  231. channel_type: data.channelType
  232. },
  233. success(res) {
  234. },
  235. complete(res) {
  236. console.log(res);
  237. },
  238. fail(res) {
  239. console.log(res);
  240. // 未成功跳转到车主小程序
  241. },
  242. });
  243. })
  244. .catch((err) => {
  245. console.log(err);
  246. });
  247. }
  248. } else if (data.userState === "NORMAL") {
  249. msg("已开通车主服务");
  250. setTimeout(() => {
  251. uni.switchTab({
  252. url: "/pages/index/index"
  253. })
  254. }, 1500)
  255. } else if (data.userState === "PAUSED") {
  256. msg("已暂停车主服务");
  257. return;
  258. } else if (data.userState === "OVERDUE") {
  259. msg("用户已开通车主服务,但欠费状态。提示用户还款,请跳转到车主服务");
  260. return;
  261. }
  262. });
  263. } else {
  264. //如果获取openId失败
  265. uni.showToast({
  266. title: "网络异常,请重试!",
  267. icon: "none",
  268. duration: 1000,
  269. });
  270. return;
  271. }
  272. };
  273. </script>
  274. <style lang="scss" scoped>
  275. .action {
  276. margin-top: 40rpx;
  277. padding-left: 20rpx;
  278. padding-right: 20rpx;
  279. padding-bottom: 30rpx;
  280. .button {
  281. height: 80rpx;
  282. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  283. border-radius: 40rpx;
  284. font-size: 32rpx;
  285. font-weight: 400;
  286. color: #ffffff;
  287. line-height: 80rpx;
  288. }
  289. }
  290. .title {
  291. text-align: center;
  292. margin-top: 15rpx;
  293. font-size: 36rpx;
  294. font-family: Microsoft YaHei;
  295. font-weight: 400;
  296. color: #333333;
  297. line-height: 36rpx;
  298. }
  299. .value {
  300. padding: 0rpx 60rpx;
  301. }
  302. .content_1 {
  303. margin-top: 60rpx;
  304. font-size: 30rpx;
  305. font-family: Microsoft YaHei;
  306. font-weight: 400;
  307. color: #666666;
  308. line-height: 58rpx;
  309. }
  310. .content_2 {
  311. margin-top: 50rpx;
  312. font-size: 30rpx;
  313. font-family: Microsoft YaHei;
  314. font-weight: 400;
  315. color: #666666;
  316. line-height: 58rpx;
  317. }
  318. .content_3 {
  319. margin-top: 50rpx;
  320. font-size: 30rpx;
  321. font-family: Microsoft YaHei;
  322. font-weight: 400;
  323. color: #ff0000;
  324. line-height: 58rpx;
  325. }
  326. .agreement {
  327. font-size: 30rpx;
  328. display: flex;
  329. flex-wrap: wrap;
  330. margin-top: 20rpx;
  331. align-items: center;
  332. justify-content: center;
  333. }
  334. </style>