123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- <template>
- <image style="
- margin-top: 20rpx;
- width: 100%;
- height: 240rpx;
- background-color: #eeeeee;
- " :src="`${$imgUrl}applyCard/car-service.png`"></image>
- <view class="title"> 支付宝签约代扣 </view>
- <view class="value">
- <view class="content_1">
- 支付宝签约代扣是支付宝支付为车主用户提供的安全便捷的智慧服务
- </view>
- <view class="content_2">
- 本次将为贵州黔通智联科技股份有限公司开启免密支付服务,后续相关的费用将通过支付宝签约代扣从你的支付宝账户扣除
- </view>
- <view class="content_3">
- 注:签约成功后请返回本页面,再次点击开通服务
- </view>
- </view>
- <view class="as-layout-horizontal agreement">
- <checkbox-group @change="checkboxChange">
- <checkbox :checked="state.checked" style="transform: scale(0.8)" />我已阅读并同意
- </checkbox-group>
- <text style="color:#007AFF;text-decoration: underline;" @click="downAuthD()">《代扣协议》</text>
- </view>
- <view class="action">
- <button type="default" class="button" @click="savaHandle()">
- 开通服务
- </button>
- </view>
- </template>
-
- <script setup lang="ts">
- import { onLoad, onShow } from "@dcloudio/uni-app";
- import { reactive } from "vue";
- import { request,requestNew } from "@/utils/network/request.js";
-
- import { stringToJson } from "@/utils/network/encryption";
- import { fileURL } from "@/datas/fileURL.js";
- import { msg, confirm } from "@/utils/utils";
- import {
- aliPayConfigIdTwo,
- obtainUserId,
- infoQuery,
- envs, signTest
- } from "@/utils/network/api";
- const imgURL = `${fileURL}image/`;
- import { getItem } from "@/utils/storage";
- const state = reactive({
- openid: "",
- orderId: "",
- id: "",
- clientFee: "",
- code: "",
- checked: false,
- agreeURL: "",
- });
- onLoad((option : any) => {
- state.orderId = option.orderId;
- getInfo();
- });
- const checkboxChange = (e) => {
- state.checked = !state.checked;
- console.log(state.checked);
- };
- const downAuthD = () => {
- uni.downloadFile({
- url: state.agreeURL,
- filePath: uni.env.USER_DATA_PATH + '/' + '代扣协议.docx',
- success(res) {
- const filePath = res.filePath
- uni.openDocument({
- filePath: filePath,
- fileType: 'docx',
- showMenu: true, //关键点
- success: function (res) {
- },
- fail: function (err) {
- msg("打开文档失败");
- }
- });
- },
- fail: function (err) {
- msg("下载文档失败");
- console.log("err", err)
- },
- complete(res) {
-
- }
- })
- }
- const getInfo = () => {
- //参数说明
- let options = {
- type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
- data: {
- businessType: 'WITHHOLD_AGREEMENT' //代扣协议
- }, //请求参数
- method: "POST", //提交方式(默认POST)
- showLoading: true, //是否显示加载中(默认显示)
- };
-
- //调用方式
- requestNew(infoQuery, options)
- .then((res) => {
- let data = res
- if (data.textType = "URL") {
- state.agreeURL = envs[process.env.NODE_ENV].baseUrl + data.text
- }
- console.log("代扣协议", state.agreeURL);
- })
- .catch((err) => {
- console.log(err);
- });
- }
- const savaHandle = () => {
- if (!state.checked) {
- msg("请勾选协议!")
- return;
- }
- my.getAuthCode({
- scopes: 'auth_user',
- success: res => {
- // 获取需要的用户信息
- state.code = res.authCode
- //如果获取openId成功
- if (state.code) {
- console.log("code*******", state.code);
- const optionsUser = {
- type: 2,
- data: {
- payConfigId: aliPayConfigIdTwo,
- code: res.authCode,
- mobile:getItem('mobile')
- },
- method: "POST",
- showLoading: true,
- };
- console.log('支付宝用户编号请求:', optionsUser)
-
- requestNew(obtainUserId, optionsUser).then((res) => {
- console.log('支付宝用户编号返回:', res,res.bizContent)
- // const bizContent = stringToJson(res.bizContent);
- var data = {
- outOrderId: state.orderId,
- // subOpenId: bizContent.openId,
- };
- const options = {
- type: 2,
- data: data,
- method: "POST",
- showLoading: true,
- };
- request(signTest, options).then((res) => {
- console.log("res*******", res);
- const data = stringToJson(res.bizContent);
- console.log("data*******", data);
- if (data.signStatusCode === "WAIT_SIGN") {
- //待签约
- my.ap.navigateToAlipayPage({
- path: "https://render.alipay.com/p/yuyan/180020010001250649/sign.html?orderId=" + data.alipayOrderId
- });
- } else if (data.signStatusCode === "SIGNED" || data.signStatusCode === "ACTIVED") {
- //已签约
- // msg("已签约");
- confirm("您已完成签约,等待业务员审核发货", () => {
- uni.redirectTo({
- url: `/pages/order/order?index=0`
- })
- }, "已完成签约", false);
- } else if (data.signStatusCode === "UNSIGN") {
- //已解约
- // msg("已解约");
- confirm(
- "您已解约!",
- () => {
- uni.redirectTo({
- url: `/pages/order/order?index=0`
- })
- },
- "您已解约",
- false
- );
- }
- });
-
- })
-
-
- } else {
- //如果获取openId失败
- uni.showToast({
- title: "网络异常,请重试!",
- icon: "none",
- duration: 1000,
- });
- return;
- }
- },
- fail: err => {
- console.log('my.getAuthCode 调用失败', err)
- }
- });
-
- }
- </script>
-
- <style lang="scss" scoped>
- .action {
- margin-top: 40rpx;
- padding-left: 20rpx;
- padding-right: 20rpx;
- padding-bottom: 30rpx;
-
- .button {
- height: 80rpx;
- background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
- border-radius: 40rpx;
- font-size: 32rpx;
- font-weight: 400;
- color: #ffffff;
- line-height: 80rpx;
- }
- }
-
- .title {
- text-align: center;
- margin-top: 15rpx;
- font-size: 36rpx;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #333333;
- line-height: 36rpx;
- }
-
- .value {
- padding: 0rpx 60rpx;
- }
-
- .content_1 {
- margin-top: 60rpx;
- font-size: 30rpx;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #666666;
- line-height: 58rpx;
- }
-
- .content_2 {
- margin-top: 50rpx;
- font-size: 30rpx;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #666666;
- line-height: 58rpx;
- }
-
- .content_3 {
- margin-top: 50rpx;
- font-size: 30rpx;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #ff0000;
- line-height: 58rpx;
- }
-
- .agreement {
- font-size: 30rpx;
- display: flex;
- flex-wrap: wrap;
- margin-top: 20rpx;
- align-items: center;
- justify-content: center;
- }
- </style>
|