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-ali.vue 6.4KB

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