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

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