feat:签名功能

This commit is contained in:
2025-08-12 11:28:59 +08:00
parent 3f87303223
commit cd8ecd0a48
4 changed files with 320 additions and 68 deletions
+129 -13
View File
@@ -73,11 +73,16 @@
<view class="operate_comm operate_but_2" v-if="item.status === ORDER_TYPE.UNPAID"
@click="jumpOrderInfo(item)">去付款</view>
<!-- <view class="operate_comm operate_but_1" v-if="item.status === ORDER_TYPE.COMPLETED">申请退款</view> -->
<view class="operate_comm operate_but_2" v-if="item.status === ORDER_TYPE.NOT_RECEIVE"
@click="confirmReceiptOk(item)">确认收货</view>
<view class="operate_comm operate_but_2" v-if="!isCheckSigne && item.status === ORDER_TYPE.NOT_RECEIVE"
@click="onSignContract(item)">去签署
</view>
<view v-if="isCheckSigne && item.status === ORDER_TYPE.NOT_RECEIVE" @click="confirmReceiptOk(item)">确认收货
</view>
<!-- <view class="operate_comm operate_but_3" v-if="item.status === ORDER_TYPE.UNSHIPPED">提醒发货</view> -->
<view class="operate_comm operate_but_1"
v-if="[ORDER_TYPE.NOT_RECEIVE, ORDER_TYPE.UNSHIPPED].includes(item.status)" @click="afterShow = true;">
v-if="[ORDER_TYPE.NOT_RECEIVE, ORDER_TYPE.UNSHIPPED].includes(item.status) && isCheckSigne"
@click="afterShow = true;">
申请售后
</view>
<!-- <view class="operate_comm operate_but_1" v-if="item.status === ORDER_TYPE.AFTER_SALE">查看售后</view> -->
@@ -184,13 +189,16 @@
</view>
</view>
</up-modal>
<!-- 腾讯电子签H5 → 集成到UniApp -->
<web-view v-if="signUrl" :src="signUrl" @message="handleMessage"></web-view>
</view>
</template>
<script>
import { MINE_ORDER_TYPE, ORDER_TYPE, ORDER_STATUS, getValue } from '@/utils/enumUtils.js';
import { ORDER_STATUS_CSS } from '@/utils/enumCssUtils.js';
import { getOrderList, confirmReceipt } from '@/api/order.js';
import { getOrderList, confirmReceipt, getSignUrl, signContract, isSignContract, getMiniProgramSignUrl } from '@/api/order.js';
import dayjs from 'dayjs';
import { formatDate1, copyData } from '@/utils/index.js'
@@ -267,12 +275,19 @@ export default {
loading: false, // 加载状态标志
openShow: false,
afterShow: false,// 售后申请
isCheckSigne: false,
flowId: null,
signUrl: null
}
},
onLoad(options) {
const type = options.type;
this.form.type = type && type < 5 ? parseInt(type, 10) : MINE_ORDER_TYPE.UNPAID;
this.loadData();
// 待收货判断是否签署
if (this.form.type === MINE_ORDER_TYPE.NOT_RECEIVE) {
this.checkSigned();
}
},
methods: {
dayjs,
@@ -292,9 +307,14 @@ export default {
console.log("searchFun", val);
},
checkType(item) {
console.log("checkType---", item);
this.form.page = 1;
this.form.type = item.id;
this.orderList = [];
// 待收货判断是否签署
if (this.form.type === MINE_ORDER_TYPE.NOT_RECEIVE) {
this.checkSigned();
}
if (item.id !== MINE_ORDER_TYPE.AFTER_SALE) {
this.loadData();
} else {
@@ -389,15 +409,15 @@ export default {
*/
confirmReceiptOk(item) {
const then = this;
uni.showModal({
title: '提示',
content: '是否确认收货?',
success: function (res) {
if (res.confirm) {
then.confirmReceiptFun(item);
}
}
});
// uni.showModal({
// title: '提示',
// content: '是否确认收货?',
// success: function (res) {
// if (res.confirm) {
// then.confirmReceiptFun(item);
// }
// }
// });
},
async confirmReceiptFun(item) {
const params = {
@@ -409,7 +429,103 @@ export default {
this.form.page = 1;
this.loadData();
}
},
// 判断是否已经签名
async checkSigned() {
const { bizcode, data } = await isSignContract();
if (bizcode === 100) {
this.isCheckSigne = data;
}
},
// 发起合同签章
async onSignContract(item) {
const params = {
// 需要的参数
orderId: item.id,
}
const { bizcode, data } = await signContract(params);
if (bizcode === 100) {
this.flowId = item.flowId
if (this.flowId)
this.onGetSignUrl(this.flowId);
}
},
// 获取H5签署链接
async onGetSignUrl(flowId) {
const params = {
// 需要的参数
orderId: flowId,
}
const { bizcode, data } = await getSignUrl(params);
if (bizcode === 100) {
this.onGetMiniProgramSignUrl(data)
} else {
this.$refs.uToastRef.show({
type: 'error',
message: "获取签署链接失败,请稍后再试",
});
return null;
}
},
// 获取跳转至腾讯电子签小程序的签署链接
async onGetMiniProgramSignUrl(item) {
const params = {
// 需要的参数
flowId: this.flowId,
endPoint: item.flowApproverUrlInfos.signUrl
}
const { bizcode, data } = await getMiniProgramSignUrl(params);
if (bizcode === 100) {
// return data;
console.log("跳转至腾讯电子签小程序的签署链接", data);
// #ifdef APP-PLUS || WEB
// #endif
// #ifdef MP-WEIXIN
// 小程序
this.openTencentESign(data);
// #endif
} else {
this.$refs.uToastRef.show({
type: 'error',
message: "获取签署链接失败,请稍后再试",
});
return null;
}
},
// 电子签的回调地址
handleMessage(e) {
const data = e.detail.data[0];
console.log();
// if (data.type === 'signDone' && data.result === 'success') {
// uni.navigateTo({ url: '/pages/result/index' });
// }
},
// 小程序签名
openTencentESign() {
// 这个链接需要后端调用腾讯电子签 API 获取
// 类似:https://esign.tencent.com/miniprogram?flowId=xxxx&token=xxxx
const signPath = '/pages/sign/sign?flowId=xxxxx&token=yyyyy' // 腾讯电子签小程序内部页面路径
uni.navigateToMiniProgram({
appId: 'wxXXXXXXXXXXXXXXX', // 腾讯电子签官方小程序的 appId
path: signPath, // 跳转到的页面路径 + 参数
extraData: {}, // 如果需要传额外参数
envVersion: 'release', // 小程序版本 release / trial / develop
success(res) {
console.log('跳转成功', res)
},
fail(err) {
console.error('跳转失败', err)
}
})
}
}
}
</script>