From 473f0dbc391fe0f290bc51bf9c61d08c10a971be Mon Sep 17 00:00:00 2001 From: hly <2783385703@qq.com> Date: Fri, 29 Aug 2025 16:07:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E4=BF=9D=E9=99=A9):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BF=9D=E9=99=A9=E5=8F=AF=E9=80=89=E5=8A=9F=E8=83=BD=E5=8F=8A?= =?UTF-8?q?=E5=85=8D=E8=B4=A3=E5=A3=B0=E6=98=8E=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将保险从必买改为可选,添加保险选择框 - 新增免责声明组件,在取消保险时显示 - 修改支付页面添加拒绝按钮和免责声明逻辑 - 更新相关API调用添加buyInsurance参数 - 优化订单处理逻辑和错误提示 --- common/config.js | 4 +- components/disclaimer/index.vue | 58 ++++++++++++++++++ pages_subpack/pay/index.vue | 30 +++++++++- pages_subpack/payment/index.vue | 116 +++++++++++++++++------------------- pages_subpack/work-detail/index.vue | 56 ++++++++++++----- store/modules/data.js | 2 +- 6 files changed, 184 insertions(+), 82 deletions(-) create mode 100644 components/disclaimer/index.vue diff --git a/common/config.js b/common/config.js index 441833e..3dfc28a 100644 --- a/common/config.js +++ b/common/config.js @@ -3,8 +3,8 @@ module.exports = { // baseUrl:"https://employadmin.hhlm1688.com" // baseUrl:"http://h5.xzaiyp.top", //测试环境 // baseUrl:"http://youyi-test.natapp1.cc", - baseUrl:"http://127.0.0.1:8002", - // baseUrl:"https://admin.zhixuanlietou.com", + // baseUrl:"http://127.0.0.1:8003", + baseUrl:"https://admin.zhixuanlietou.com", // http://youyi-test.natapp1.cc diff --git a/components/disclaimer/index.vue b/components/disclaimer/index.vue new file mode 100644 index 0000000..262a788 --- /dev/null +++ b/components/disclaimer/index.vue @@ -0,0 +1,58 @@ + + + + + \ No newline at end of file diff --git a/pages_subpack/pay/index.vue b/pages_subpack/pay/index.vue index 74f0e43..6f26e74 100644 --- a/pages_subpack/pay/index.vue +++ b/pages_subpack/pay/index.vue @@ -33,11 +33,12 @@ @@ -121,7 +125,11 @@ userInfo, } from "@/common/api.js" import position from "@/utils/position.js" + import DisclaimerModal from "@/components/disclaimer/index.vue" export default { + components: { + DisclaimerModal + }, data() { return { amount: 0, @@ -129,6 +137,7 @@ orderId : 0, checked : 0, detail : {}, + insuranceChecked: true, // 保险选择框,默认选中 // type 0企业发布招聘,企业不需要支付保险、交通费,由个人承担 // type 1个人发布求职,企业承担保险费、交通费用 @@ -149,7 +158,7 @@ // type 0企业发布招聘,企业不需要支付保险、交通费,由个人承担 // type 1个人发布求职,企业承担保险费、交通费用 let basePrice = Number(this.detail.payMoney) || 0; - let premiumFee = Number(this.detail.premium) || 0; + let premiumFee = this.insuranceChecked ? (Number(this.detail.premium) || 0) : 0; let trafficFee = Number(this.fare) || 0; if (this.detail.type == 1) { @@ -243,6 +252,20 @@ url: "/pages_subpack/order-detail/index" }) }, + onInsuranceChange(value) { + if (!value) { + // 取消选中保险时,显示免责声明 + this.$refs.disclaimerModal.open(); + } + }, + onDisclaimerCancel() { + // 取消免责声明,重新选中保险 + this.insuranceChecked = true; + }, + onDisclaimerConfirm() { + // 确认免责声明,保持不选中保险 + // 不需要额外操作,保持当前状态 + }, payOrderCompany() { let that = this @@ -258,6 +281,7 @@ orderId: this.orderId, payType: this.payRadio, fare : this.fare || 0,//出行费 + buyInsurance: this.insuranceChecked // 新增参数,表示是否购买保险 } payOrderCompany(data) diff --git a/pages_subpack/payment/index.vue b/pages_subpack/payment/index.vue index 25175c2..0ddf4c9 100644 --- a/pages_subpack/payment/index.vue +++ b/pages_subpack/payment/index.vue @@ -27,7 +27,7 @@ - 购买保险(必买) + 购买保险(可选) @@ -68,8 +68,13 @@ 合计 ¥{{items.premium}}元 - - 立即支付 + + + 拒绝 + + + 立即支付 + @@ -87,6 +92,9 @@ + + + @@ -94,7 +102,11 @@ import { getTaskById,orderTask,orderDetail,userInfo,payOrder } from "@/common/api.js" + import DisclaimerModal from "@/components/disclaimer/index.vue" export default{ + components: { + DisclaimerModal + }, data(){ return{ show:false, @@ -142,6 +154,19 @@ }) }, onPay(){ + this.payWithInsurance(true); + }, + onReject(){ + this.$refs.disclaimerModal.open(); + }, + onDisclaimerCancel(){ + // 取消免责声明,不执行任何操作 + }, + onDisclaimerConfirm(){ + // 确认免责声明,继续不购买保险的支付流程 + this.payWithInsurance(false); + }, + payWithInsurance(buyInsurance){ let that = this console.info(that.checked) if(that.checked.length==0){ @@ -154,65 +179,36 @@ let data = { orderId : that.id, payType : that.payRadio, + buyInsurance: buyInsurance // 新增参数,表示是否购买保险 } - // if(that.payRadio==1){ - payOrder(data).then(res=>{ - - if(data.payType == '2'){ - uni.requestPayment({ - provider: 'wxpay', // 服务提提供商 - timeStamp: res.result.timeStamp, // 时间戳 - nonceStr: res.result.nonceStr, // 随机字符串 - package: res.result.packageValue, - signType: res.result.signType, // 签名算法 - paySign: res.result.paySign, // 签名 - success: function (res) { - that.onDetail(); - }, - fail: function (err) { - uni.showToast({ - icon:'none', - title:"支付失败" - }) - } - }); - }else if(res.code == 200){ - that.onDetail(); - } - - - }).catch(error=>{ - - }) - // }else if(that.payRadio==2){ - // payOrder({orderId:that.id}).then(response=>{ - // console.info("payOrder",response) - // uni.requestPayment({ - // provider: "wxpay", - // nonceStr: response.result.nonceStr, - // package: response.result.package, - // timeStamp: response.result.timeStamp, - // signType: response.result.signType, - // paySign: response.result.paySign, - // success(res) { - // that.$u.toast("付款成功!") - // that.onDetail(); - // }, - // fail(err) { - // console.info(err) - // console.log('支付失败',err); - // uni.showToast({ - // icon:'none', - // title:"支付失败" - // }) - // } - // }) - // }).catch(error=>{ - - // }) - // } - + payOrder(data).then(res=>{ + + if(data.payType == '2'){ + uni.requestPayment({ + provider: 'wxpay', // 服务提提供商 + timeStamp: res.result.timeStamp, // 时间戳 + nonceStr: res.result.nonceStr, // 随机字符串 + package: res.result.packageValue, + signType: res.result.signType, // 签名算法 + paySign: res.result.paySign, // 签名 + success: function (res) { + that.onDetail(); + }, + fail: function (err) { + uni.showToast({ + icon:'none', + title:"支付失败" + }) + } + }); + }else if(res.code == 200){ + that.onDetail(); + } + + }).catch(error=>{ + + }) }, onDetail(){ uni.redirectTo({ diff --git a/pages_subpack/work-detail/index.vue b/pages_subpack/work-detail/index.vue index 0cdcd79..a185b03 100644 --- a/pages_subpack/work-detail/index.vue +++ b/pages_subpack/work-detail/index.vue @@ -155,25 +155,49 @@ addOrderWork({id:this.id}).then(response=>{ uni.hideLoading() console.log("下单成功"); - uni.navigateTo({ - url:"/pages_subpack/payment/index?id="+response.result.id - }) + // 根据订单状态决定是否跳转到支付页面 + if (response.result) { + uni.navigateTo({ + url:"/pages_subpack/payment/index?id="+response.result.id + }) + } else { + // 状态不为0时不跳转,可以显示提示信息 + uni.showToast({ + title: '操作完成', + icon: 'success' + }) + } }).catch(error=>{ console.log(error); - setTimeout(()=>{ - if (error.result && error.result.id) { - if(error.result.orderStatusSeek == 'Y'){ - uni.navigateTo({ - url:"/pages_subpack/order-detail/index?orderId="+error.result.id - }) - }else{ - uni.navigateTo({ - url:"/pages_subpack/payment/index?id="+error.result.id - }) - } - } - }, 800); uni.hideLoading() + // 处理错误情况 + if (error.result && error.result.id) { + // 根据订单状态决定跳转 + if (error.result.status == 0) { + setTimeout(()=>{ + if(error.result.orderStatusSeek == 'Y'){ + uni.navigateTo({ + url:"/pages_subpack/order-detail/index?orderId="+error.result.id + }) + }else{ + uni.navigateTo({ + url:"/pages_subpack/payment/index?id="+error.result.id + }) + } + }, 800); + } else { + // 显示错误信息 + uni.showToast({ + title: error.message || '操作失败', + icon: 'none' + }) + } + } else { + uni.showToast({ + title: error.message || '操作失败', + icon: 'none' + }) + } }) }, openAddress(){ diff --git a/store/modules/data.js b/store/modules/data.js index 0dc97a1..22915d1 100644 --- a/store/modules/data.js +++ b/store/modules/data.js @@ -28,7 +28,7 @@ export default { if (res.code == 200) { res.result.forEach(n => { configList[n.paramCode] = n.paramValueText || - n.paramValue || + n.paramValueTextarea || n.paramValueImage }); }