Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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 addInterestsList = () => {
  112. uni.navigateTo({
  113. url: `/subpackage/orders/interestsList?orderId=${state.orderId}&&clientFee=${state.clientFee}&&id=${state.id}`
  114. });
  115. }
  116. const savaHandle = () => {
  117. if (!state.checked) {
  118. msg("请勾选协议!")
  119. return;
  120. }
  121. my.getAuthCode({
  122. scopes: 'auth_user',
  123. success: res => {
  124. // 获取需要的用户信息
  125. state.code = res.authCode
  126. //如果获取openId成功
  127. if (state.code) {
  128. console.log("code*******", state.code);
  129. const optionsUser = {
  130. type: 2,
  131. data: {
  132. payConfigId: aliPayConfigIdTwo,
  133. code: res.authCode
  134. },
  135. method: "POST",
  136. showLoading: true,
  137. };
  138. console.log('支付宝用户编号请求:', optionsUser)
  139. request(obtainUserId, optionsUser).then((res) => {
  140. console.log('支付宝用户编号返回:', res)
  141. const bizContent = stringToJson(res.bizContent);
  142. var data = {
  143. orderId: state.orderId,
  144. subOpenId: bizContent.openId,
  145. };
  146. const options = {
  147. type: 2,
  148. data: data,
  149. method: "POST",
  150. showLoading: true,
  151. };
  152. request(etcQYAction, options).then((res) => {
  153. console.log("res*******", res);
  154. const data = stringToJson(res.bizContent);
  155. console.log("data*******", data);
  156. if (data.signStatus === "WAIT_SIGN") {
  157. //待签约
  158. my.ap.navigateToAlipayPage({
  159. path: "https://render.alipay.com/p/yuyan/180020010001250649/sign.html?orderId=" + data.alipayOrderId
  160. });
  161. } else if (data.signStatus === "SIGNED") {
  162. //已签约
  163. // msg("已签约");
  164. confirm("您已完成签约,等待业务员审核发货", () => {
  165. uni.switchTab({
  166. url: "/pages/order/order"
  167. })
  168. }, "已完成签约", false);
  169. } else if (data.signStatus === "UNSIGN") {
  170. //已解约
  171. // msg("已解约");
  172. confirm(
  173. "您已解约!",
  174. () => {
  175. uni.switchTab({
  176. url: "/pages/order/order"
  177. })
  178. },
  179. "您已解约",
  180. false
  181. );
  182. }
  183. });
  184. })
  185. } else {
  186. //如果获取openId失败
  187. uni.showToast({
  188. title: "网络异常,请重试!",
  189. icon: "none",
  190. duration: 1000,
  191. });
  192. return;
  193. }
  194. },
  195. fail: err => {
  196. console.log('my.getAuthCode 调用失败', err)
  197. }
  198. });
  199. }
  200. </script>
  201. <style lang="scss" scoped>
  202. .action {
  203. margin-top: 40rpx;
  204. padding-left: 20rpx;
  205. padding-right: 20rpx;
  206. padding-bottom: 30rpx;
  207. .button {
  208. height: 80rpx;
  209. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  210. border-radius: 40rpx;
  211. font-size: 32rpx;
  212. font-weight: 400;
  213. color: #ffffff;
  214. line-height: 80rpx;
  215. }
  216. }
  217. .title {
  218. text-align: center;
  219. margin-top: 15rpx;
  220. font-size: 36rpx;
  221. font-family: Microsoft YaHei;
  222. font-weight: 400;
  223. color: #333333;
  224. line-height: 36rpx;
  225. }
  226. .value {
  227. padding: 0rpx 60rpx;
  228. }
  229. .content_1 {
  230. margin-top: 60rpx;
  231. font-size: 30rpx;
  232. font-family: Microsoft YaHei;
  233. font-weight: 400;
  234. color: #666666;
  235. line-height: 58rpx;
  236. }
  237. .content_2 {
  238. margin-top: 50rpx;
  239. font-size: 30rpx;
  240. font-family: Microsoft YaHei;
  241. font-weight: 400;
  242. color: #666666;
  243. line-height: 58rpx;
  244. }
  245. .content_3 {
  246. margin-top: 50rpx;
  247. font-size: 30rpx;
  248. font-family: Microsoft YaHei;
  249. font-weight: 400;
  250. color: #ff0000;
  251. line-height: 58rpx;
  252. }
  253. .agreement {
  254. font-size: 30rpx;
  255. display: flex;
  256. flex-wrap: wrap;
  257. margin-top: 20rpx;
  258. align-items: center;
  259. justify-content: center;
  260. }
  261. </style>