Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

sign-up-ali-yd.vue 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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 { request,requestNew } from "@/utils/network/request.js";
  36. import { stringToJson } from "@/utils/network/encryption";
  37. import { fileURL } from "@/datas/fileURL.js";
  38. import { msg, confirm } from "@/utils/utils";
  39. import {
  40. aliPayConfigIdTwo,
  41. obtainUserId,
  42. infoQuery,
  43. envs, signTest
  44. } from "@/utils/network/api";
  45. const imgURL = `${fileURL}image/`;
  46. import { getItem } from "@/utils/storage";
  47. const state = reactive({
  48. openid: "",
  49. orderId: "",
  50. id: "",
  51. clientFee: "",
  52. code: "",
  53. checked: false,
  54. agreeURL: "",
  55. });
  56. onLoad((option : any) => {
  57. state.orderId = option.orderId;
  58. getInfo();
  59. });
  60. const checkboxChange = (e) => {
  61. state.checked = !state.checked;
  62. console.log(state.checked);
  63. };
  64. const downAuthD = () => {
  65. uni.downloadFile({
  66. url: state.agreeURL,
  67. filePath: uni.env.USER_DATA_PATH + '/' + '代扣协议.docx',
  68. success(res) {
  69. const filePath = res.filePath
  70. uni.openDocument({
  71. filePath: filePath,
  72. fileType: 'docx',
  73. showMenu: true, //关键点
  74. success: function (res) {
  75. },
  76. fail: function (err) {
  77. msg("打开文档失败");
  78. }
  79. });
  80. },
  81. fail: function (err) {
  82. msg("下载文档失败");
  83. console.log("err", err)
  84. },
  85. complete(res) {
  86. }
  87. })
  88. }
  89. const getInfo = () => {
  90. //参数说明
  91. let options = {
  92. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  93. data: {
  94. businessType: 'WITHHOLD_AGREEMENT' //代扣协议
  95. }, //请求参数
  96. method: "POST", //提交方式(默认POST)
  97. showLoading: true, //是否显示加载中(默认显示)
  98. };
  99. //调用方式
  100. requestNew(infoQuery, options)
  101. .then((res) => {
  102. let data = res
  103. if (data.textType = "URL") {
  104. state.agreeURL = envs[process.env.NODE_ENV].baseUrl + data.text
  105. }
  106. console.log("代扣协议", state.agreeURL);
  107. })
  108. .catch((err) => {
  109. console.log(err);
  110. });
  111. }
  112. const savaHandle = () => {
  113. if (!state.checked) {
  114. msg("请勾选协议!")
  115. return;
  116. }
  117. my.getAuthCode({
  118. scopes: 'auth_user',
  119. success: res => {
  120. // 获取需要的用户信息
  121. state.code = res.authCode
  122. //如果获取openId成功
  123. if (state.code) {
  124. console.log("code*******", state.code);
  125. const optionsUser = {
  126. type: 2,
  127. data: {
  128. payConfigId: aliPayConfigIdTwo,
  129. code: res.authCode,
  130. mobile:getItem('mobile')
  131. },
  132. method: "POST",
  133. showLoading: true,
  134. };
  135. console.log('支付宝用户编号请求:', optionsUser)
  136. requestNew(obtainUserId, optionsUser).then((res) => {
  137. console.log('支付宝用户编号返回:', res,res.bizContent)
  138. // const bizContent = stringToJson(res.bizContent);
  139. var data = {
  140. outOrderId: state.orderId,
  141. // subOpenId: bizContent.openId,
  142. };
  143. const options = {
  144. type: 2,
  145. data: data,
  146. method: "POST",
  147. showLoading: true,
  148. };
  149. request(signTest, options).then((res) => {
  150. console.log("res*******", res);
  151. const data = stringToJson(res.bizContent);
  152. console.log("data*******", data);
  153. if (data.signStatusCode === "WAIT_SIGN") {
  154. //待签约
  155. my.ap.navigateToAlipayPage({
  156. path: "https://render.alipay.com/p/yuyan/180020010001250649/sign.html?orderId=" + data.alipayOrderId
  157. });
  158. } else if (data.signStatusCode === "SIGNED" || data.signStatusCode === "ACTIVED") {
  159. //已签约
  160. // msg("已签约");
  161. confirm("您已完成签约,等待业务员审核发货", () => {
  162. uni.redirectTo({
  163. url: `/pages/order/order?index=0`
  164. })
  165. }, "已完成签约", false);
  166. } else if (data.signStatusCode === "UNSIGN") {
  167. //已解约
  168. // msg("已解约");
  169. confirm(
  170. "您已解约!",
  171. () => {
  172. uni.redirectTo({
  173. url: `/pages/order/order?index=0`
  174. })
  175. },
  176. "您已解约",
  177. false
  178. );
  179. }
  180. });
  181. })
  182. } else {
  183. //如果获取openId失败
  184. uni.showToast({
  185. title: "网络异常,请重试!",
  186. icon: "none",
  187. duration: 1000,
  188. });
  189. return;
  190. }
  191. },
  192. fail: err => {
  193. console.log('my.getAuthCode 调用失败', err)
  194. }
  195. });
  196. }
  197. </script>
  198. <style lang="scss" scoped>
  199. .action {
  200. margin-top: 40rpx;
  201. padding-left: 20rpx;
  202. padding-right: 20rpx;
  203. padding-bottom: 30rpx;
  204. .button {
  205. height: 80rpx;
  206. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  207. border-radius: 40rpx;
  208. font-size: 32rpx;
  209. font-weight: 400;
  210. color: #ffffff;
  211. line-height: 80rpx;
  212. }
  213. }
  214. .title {
  215. text-align: center;
  216. margin-top: 15rpx;
  217. font-size: 36rpx;
  218. font-family: Microsoft YaHei;
  219. font-weight: 400;
  220. color: #333333;
  221. line-height: 36rpx;
  222. }
  223. .value {
  224. padding: 0rpx 60rpx;
  225. }
  226. .content_1 {
  227. margin-top: 60rpx;
  228. font-size: 30rpx;
  229. font-family: Microsoft YaHei;
  230. font-weight: 400;
  231. color: #666666;
  232. line-height: 58rpx;
  233. }
  234. .content_2 {
  235. margin-top: 50rpx;
  236. font-size: 30rpx;
  237. font-family: Microsoft YaHei;
  238. font-weight: 400;
  239. color: #666666;
  240. line-height: 58rpx;
  241. }
  242. .content_3 {
  243. margin-top: 50rpx;
  244. font-size: 30rpx;
  245. font-family: Microsoft YaHei;
  246. font-weight: 400;
  247. color: #ff0000;
  248. line-height: 58rpx;
  249. }
  250. .agreement {
  251. font-size: 30rpx;
  252. display: flex;
  253. flex-wrap: wrap;
  254. margin-top: 20rpx;
  255. align-items: center;
  256. justify-content: center;
  257. }
  258. </style>