From e96e4ebb634d2d8dd4aa895ec79e1e5ed1847ac8 Mon Sep 17 00:00:00 2001 From: itgaojian163 Date: Fri, 18 Apr 2025 11:29:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=A1=B9=E7=9B=AE=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E8=AE=A1=E7=AE=97=E4=BC=98=E5=8C=96,=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E8=B7=91=E9=A9=AC=E7=81=AF=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../createProjectInfo/createProjectInfo.js | 48 ++++++++++++++----- .../createProjectInfo/createProjectInfo.wxss | 1 + pages/index/index.wxss | 5 +- utils/validator.js | 13 ++++- 4 files changed, 50 insertions(+), 17 deletions(-) diff --git a/pages/copyright/createProjectInfo/createProjectInfo.js b/pages/copyright/createProjectInfo/createProjectInfo.js index d0ee600..09da9e4 100644 --- a/pages/copyright/createProjectInfo/createProjectInfo.js +++ b/pages/copyright/createProjectInfo/createProjectInfo.js @@ -3,7 +3,8 @@ import UserService from '../../../net/api/userApi' const utils = require("../../../utils/util") const { isValidPhone, - isValidEmail + isValidEmail, + objIsEmpty } = require('../../../utils/validator') Page({ @@ -143,15 +144,39 @@ Page({ _self.setData({ isUrgent: !_self.data.isUrgent }) - var newPrice = Number(_self.data.price) - if (_self.data.isUrgent) { - newPrice = Number(_self.data.price) + Number(_self.data.urgent) + _self.countPrice() + }, + //计算价格 + countPrice() { + const _self = this; + // 传递过来的价格 + const trPrice = Number(_self.data.proPrice); + let newPrice = trPrice; + + // 选中了套餐包,直接将价格设为 0 + if (!objIsEmpty(_self.data.selectPackage)) { + newPrice = 0; } else { - newPrice = Number(_self.data.price) - Number(_self.data.urgent) + const isAllType = _self.data.type === 'ALL'; + const hasCoupon = !objIsEmpty(_self.data.selectCoupons); + const isUrgent = _self.data.isUrgent; + + // 写材料/全托管判断 + if (isAllType) { + if (hasCoupon) { + newPrice = isUrgent ? trPrice + Number(_self.data.urgent) - Number(_self.data.selectCoupons.coupon.amount) : trPrice - Number(_self.data.selectCoupons.coupon.amount); + } else { + newPrice = isUrgent ? trPrice + Number(_self.data.urgent) : trPrice; + } + } else { + // 写材料情况 + newPrice = hasCoupon ? trPrice - Number(_self.data.selectCoupons.coupon.amount) : trPrice; + } } + _self.setData({ - price: newPrice - }) + price: newPrice < 0 ? 0 : newPrice + }); }, //开发完成时间 bindDateChange(e) { @@ -236,10 +261,7 @@ Page({ selectPackage: {}, tempPackage: {} }) - var newPrice = Number(_self.data.price) - Number(_self.data.selectCoupons.coupon.amount) - _self.setData({ - price: newPrice > 0 ? newPrice : 0 - }) + _self.countPrice() }, //监听项目名称 inputProjectName(e) { @@ -389,8 +411,8 @@ Page({ tempCoupons: {}, isUrgent: false, //取消加急 isUrgentDisable: true, //加急不能选择 - price: 0 }) + this.countPrice() }, //取消选中的套餐包或优惠卷 clearSelectPackageOrCoupons() { @@ -403,8 +425,8 @@ Page({ canSelPackage: true, isUrgent: false, //取消加急 isUrgentDisable: false, //加急可以选择 - price: this.data.proPrice, //重置价格 }) + this.countPrice() }, //点击选择套餐包 selectPackage(e) { diff --git a/pages/copyright/createProjectInfo/createProjectInfo.wxss b/pages/copyright/createProjectInfo/createProjectInfo.wxss index b2466e7..6f0150c 100644 --- a/pages/copyright/createProjectInfo/createProjectInfo.wxss +++ b/pages/copyright/createProjectInfo/createProjectInfo.wxss @@ -417,6 +417,7 @@ page { color: #5D3900; margin-top: 10px; font-weight: 400; + min-height: 12px; } diff --git a/pages/index/index.wxss b/pages/index/index.wxss index fd00d05..ca27d80 100644 --- a/pages/index/index.wxss +++ b/pages/index/index.wxss @@ -388,15 +388,16 @@ .marquee-text { display: inline-block; - animation: marquee 9s linear infinite; + animation: marquee 10s linear infinite; color: rgba(85, 0, 0, 1); font-size: 14px; margin-left: 15px; + transform: translateX(100%); } @keyframes marquee { 0% { - transform: translateX(0); + transform: translateX(100%); } 100% { diff --git a/utils/validator.js b/utils/validator.js index b3adf66..4853a11 100644 --- a/utils/validator.js +++ b/utils/validator.js @@ -27,7 +27,15 @@ const isValidIdCard = (idCard) => { const isValidCreditCode = (creditCode) => { return /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/.test(creditCode); }; - +const objIsEmpty = (obj) => { + if (obj === undefined) { + return true; + } + if (obj === null) { + return true; + } + return Object.keys(obj).length === 0; +} // 密码强度验证(至少包含数字和字母,长度8-20位) const isValidPassword = (password) => { return /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,20}$/.test(password); @@ -39,5 +47,6 @@ module.exports = { isValidUrl, isValidIdCard, isValidCreditCode, - isValidPassword + isValidPassword, + objIsEmpty }; \ No newline at end of file