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.9KB

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