From 50adb938204501abddffbb08b20a3cb0bb611f06 Mon Sep 17 00:00:00 2001 From: WindowBird <13870814+windows-bird@user.noreply.gitee.com> Date: Wed, 10 Sep 2025 17:54:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=B3=E8=AF=B7=E7=A7=9F?= =?UTF-8?q?=E8=B5=81=E9=A1=B5=E9=9D=A2=E8=83=BD=E5=A4=9F=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E7=A7=9F=E8=B5=81n=E5=8F=B0=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/lease/lease.js | 1 + pages/lease/lease.vue | 39 ++++++++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/api/lease/lease.js b/api/lease/lease.js index 197ca7c..8449d89 100644 --- a/api/lease/lease.js +++ b/api/lease/lease.js @@ -58,6 +58,7 @@ export function getPeriodPackages(suitIds) { * @param {string} orderData.appId - 应用ID * @param {string} orderData.payAmount - 支付金额 * @param {string} orderData.channelId - 渠道ID + * @param {string} orderData.quantity - 设备数量 * @returns {Promise} 返回订单创建结果 */ export function createLeaseOrder(orderData) { diff --git a/pages/lease/lease.vue b/pages/lease/lease.vue index f5d9bcf..77a8e01 100644 --- a/pages/lease/lease.vue +++ b/pages/lease/lease.vue @@ -68,11 +68,15 @@ 租赁设备 - - + + {{ formData.equipment || '选择设备类型' }} - > + > + @@ -92,7 +96,7 @@ @@ -116,6 +120,10 @@ 设备类型 {{ selectedDevice.name }} + + 设备数量 + {{ formData.quantity }} + 租赁周期 {{ selectedPackage.name }} @@ -126,7 +134,7 @@ 租金 - ¥{{ totalAmount }} + ¥{{ payAmount }} @@ -184,7 +192,10 @@ export default { commonEnum() { return commonEnum }, - // 检查是否可以支付 - 直接验证,不依赖formData默认值 + // 计算总金额 + payAmount() { + return this.formData.amount * this.formData.quantity + }, }, onShow() { if (!this.hasAgreed) { @@ -205,6 +216,7 @@ export default { return { hasAgreed: false, formData: { + quantity: 1, name: '', phone: '', address: '', @@ -214,10 +226,11 @@ export default { period: '', suitId: '', // 租赁周期ID channelId: '3', //渠道id + amount: 0, payAmount: 0, }, showDetails: false, - totalAmount: '0.00', + deviceTypes: [], // 设备类型列表 periodPackages: [], // 租赁周期套餐列表 selectedDevice: null, // 选中的设备 @@ -330,7 +343,7 @@ export default { this.formData.suitId = '' this.selectedPackage = null - this.totalAmount = '0.00' + this.payAmount = '0.00' // 根据选中的设备类型获取租赁套餐 this.getPeriodPackages(selectedDevice.suitId) @@ -368,8 +381,7 @@ export default { this.selectedPackage = selectedPackage this.formData.period = selectedPackage.name this.formData.suitId = selectedPackage.id - this.formData.payAmount = selectedPackage.amount - this.totalAmount = selectedPackage.amount.toFixed(2) + this.formData.amount = selectedPackage.amount console.log('选中套餐:', selectedPackage) console.log('选中租赁周期id:', this.formData.suitId) }, @@ -379,6 +391,7 @@ export default { this.showDetails = !this.showDetails }, handlePayment() { + this.formData.payAmount = this.payAmount if (checkLoginStatus()) { return } @@ -440,7 +453,7 @@ export default { return } - if (parseFloat(this.totalAmount) <= 0) { + if (parseFloat(this.payAmount) <= 0) { uni.showToast({ title: '金额无效', icon: 'none', @@ -460,7 +473,7 @@ export default { // 支付逻辑 uni.showModal({ title: '确认支付', - content: `确认支付 ¥${this.totalAmount} 吗?\n\n设备:${this.formData.equipment}\n周期:${this.formData.period}`, + content: `确认支付 ¥${this.payAmount} 吗?\n\n${this.formData.quantity}台${this.formData.equipment}\n周期:${this.formData.period}`, success: async res => { if (res.confirm) { // 这里可以调用支付API @@ -517,7 +530,7 @@ export default { console.log('支付信息:', { ...this.formData, - amount: this.totalAmount, + amount: this.payAmount, selectedDevice: this.selectedDevice, selectedPackage: this.selectedPackage, })