diff --git a/components/common/down-popup.vue b/components/common/down-popup.vue index 84a631b..ab6d2b9 100644 --- a/components/common/down-popup.vue +++ b/components/common/down-popup.vue @@ -64,7 +64,7 @@ }, methods: { onCancel(){ - this.$emit('click'); + this.$emit('cancel'); }, onOk(){ this.$emit('ok'); @@ -82,7 +82,9 @@ flex-direction: column; background-color: rgba(0,0,0,0.3); position: fixed; - z-index: 2000; + left:0; + top:0; + z-index: 10000; .down-panel{ width:100%; height:764rpx; diff --git a/manifest.json b/manifest.json index d37fc25..85eebd9 100644 --- a/manifest.json +++ b/manifest.json @@ -124,5 +124,5 @@ "uniStatistics" : { "enable" : false }, - "vueVersion" : "3" + "vueVersion" : "2" } diff --git a/pages/contract/check.vue b/pages/contract/check.vue index 0f938cb..7b6fb59 100644 --- a/pages/contract/check.vue +++ b/pages/contract/check.vue @@ -4,7 +4,7 @@
- + 消费型合伙人协议 @@ -32,6 +32,7 @@ + diff --git a/pages/contract/index.vue b/pages/contract/index.vue index 24b9e29..4461b37 100644 --- a/pages/contract/index.vue +++ b/pages/contract/index.vue @@ -1,14 +1,18 @@ @@ -18,30 +22,63 @@ import Header from '@/components/common/header.vue'; import TopSafe from '@/components/common/top-safe.nvue' import ContractItem from './components/contract-item.vue' import DownPopup from '@/components/common/down-popup.vue'; -import { getContractList,signContract } from '@/api/contract.js' +import { getContractList, signContract } from '@/api/contract.js' +import { getSignUrl, getMiniProgramSignUrl } from '@/api/order.js'; import func from '@/utils/func.js'; export default { - components: { Header,TopSafe,ContractItem,DownPopup }, + components: { Header, TopSafe, ContractItem, DownPopup }, data() { return { - type:false, - obj:null + type: false, + obj: null, + flowId: null, + signUrl: null, + downShow: false, + selectItem: null, + tipsShow:false, + userInfo:null }; }, onShow() { + }, + onLoad(){ this.init(); + this.userinfo(); }, methods: { - init(){ - // this.isSignContract() - this.getSignContract() + init() { + this.isSignContract() + }, - isSignContract(){ - signContract().then(res=>{ + userinfo(){ + getUserInfo().then(res=>{ if(res.bizcode == 100){ + this.userInfo = res.data; + } + console.log('res',res) + }) + }, + onConfirm(){ + this.onTipsCancel(); + uni.navigateTo({ + url:'/pages/mine_package/mine_authentication/mine_authentication' + }) + }, + onTipsCancel(){ + this.tipsShow =false; + }, + onCancel(){ + this.downShow = false; + }, + isSignContract() { + signContract().then(res => { + if (res.bizcode == 100) { this.type = res.data; - }else{ + if(this.type){ + this.getSignContract() + } + } else { this.$refs.uToastRef.show({ type: 'error', message: res.msg, @@ -49,12 +86,12 @@ export default { } }) }, - getSignContract(){ - getContractList().then(res=>{ - if(res.bizcode == 100){ + getSignContract() { + getContractList().then(res => { + if (res.bizcode == 100 && res.data.length) { this.obj = res.data[0]; - this.obj.time = func.formatDate(new Date(res.data[0].signatureTime),3) - }else{ + this.obj.time = func.formatDate(new Date(res.data[0].signatureTime), 3) + } else { this.$refs.uToastRef.show({ type: 'error', message: res.msg, @@ -62,25 +99,116 @@ export default { } }) }, - onBtn(){ - if(this.type){ + onBtn() { + if (this.type) { //查看 uni.navigateTo({ - url:`/pages/contract/check` + url: `/pages/contract/check` }) - }else{ + } else { //去签署 - + this.downShow = true; } + }, + // 发起合同签章 + async onSignContract() { + if(this.userInfo.certStatus == 0){ + this.downShow = false; + this.tipsShow = true; + return; + }else if(this.userInfo.certStatus == 1){ + this.downShow = false; + this.$refs.uToastRef.show({ + type: 'success', + message: '请耐心等待审核通过', + }); + return; + } + const params = { + // 需要的参数 + orderId: this.selectItem.id, + } + const { bizcode, data } = await signContract(params); + if (bizcode === 100) { + this.flowId = data.flowId; + + if (this.flowId) + // #ifdef APP-PLUS || WEB + this.onGetSignUrl(this.flowId); + // #endif + + // #ifdef MP-WEIXIN + // 小程序 + this.onGetMiniProgramSignUrl(this.flowId) + // #endif + } + }, + + // 获取H5签署链接 + async onGetSignUrl(flowId) { + const params = { + // 需要的参数 + flowId: flowId, + } + const { bizcode, data } = await getSignUrl(params); + if (bizcode === 100) { + this.signUrl = data.flowApproverUrlInfos[0].longUrl; + } else { + this.$refs.uToastRef.show({ + type: 'error', + message: "获取签署链接失败,请稍后再试", + }); + return null; + } + }, + // 获取跳转至腾讯电子签小程序的签署链接 + async onGetMiniProgramSignUrl(flowId) { + const params = { + flowId: flowId, + endPoint: 'HTTP_SHORT_URL' + } + const { bizcode, data } = await getMiniProgramSignUrl(params); + if (bizcode === 100) { + console.log("跳转至腾讯电子签小程序的签署链接", data); + this.openTencentESign(data.schemeUrl); + } else { + this.$refs.uToastRef.show({ + type: 'error', + message: "获取签署链接失败,请稍后再试", + }); + return null; + } + }, + + // 电子签的回调地址 + handleMessage(e) { + const data = e.detail; + console.log('电子签的回调地址', e); + }, + // 小程序签名 + openTencentESign(signPath) { + // 这个链接需要后端调用腾讯电子签 API 获取 + uni.navigateToMiniProgram({ + appId: 'wxa023b292fd19d41d', // 腾讯电子签官方小程序的 appId + path: signPath, // 跳转到的页面路径 + 参数 + extraData: {}, // 如果需要传额外参数 + envVersion: 'release', // 小程序版本 release / trial / develop + success(res) { + console.log('跳转成功', res) + }, + fail(err) { + console.error('跳转失败', err) + } + }) } } }