创建项目价格计算优化,首页跑马灯优化

This commit is contained in:
itgaojian163 2025-04-18 11:29:05 +08:00
parent 58b92b9009
commit e96e4ebb63
4 changed files with 50 additions and 17 deletions

View File

@ -3,7 +3,8 @@ import UserService from '../../../net/api/userApi'
const utils = require("../../../utils/util") const utils = require("../../../utils/util")
const { const {
isValidPhone, isValidPhone,
isValidEmail isValidEmail,
objIsEmpty
} = require('../../../utils/validator') } = require('../../../utils/validator')
Page({ Page({
@ -143,15 +144,39 @@ Page({
_self.setData({ _self.setData({
isUrgent: !_self.data.isUrgent isUrgent: !_self.data.isUrgent
}) })
var newPrice = Number(_self.data.price) _self.countPrice()
if (_self.data.isUrgent) { },
newPrice = Number(_self.data.price) + Number(_self.data.urgent) //计算价格
countPrice() {
const _self = this;
// 传递过来的价格
const trPrice = Number(_self.data.proPrice);
let newPrice = trPrice;
// 选中了套餐包,直接将价格设为 0
if (!objIsEmpty(_self.data.selectPackage)) {
newPrice = 0;
} else { } 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({ _self.setData({
price: newPrice price: newPrice < 0 ? 0 : newPrice
}) });
}, },
//开发完成时间 //开发完成时间
bindDateChange(e) { bindDateChange(e) {
@ -236,10 +261,7 @@ Page({
selectPackage: {}, selectPackage: {},
tempPackage: {} tempPackage: {}
}) })
var newPrice = Number(_self.data.price) - Number(_self.data.selectCoupons.coupon.amount) _self.countPrice()
_self.setData({
price: newPrice > 0 ? newPrice : 0
})
}, },
//监听项目名称 //监听项目名称
inputProjectName(e) { inputProjectName(e) {
@ -389,8 +411,8 @@ Page({
tempCoupons: {}, tempCoupons: {},
isUrgent: false, //取消加急 isUrgent: false, //取消加急
isUrgentDisable: true, //加急不能选择 isUrgentDisable: true, //加急不能选择
price: 0
}) })
this.countPrice()
}, },
//取消选中的套餐包或优惠卷 //取消选中的套餐包或优惠卷
clearSelectPackageOrCoupons() { clearSelectPackageOrCoupons() {
@ -403,8 +425,8 @@ Page({
canSelPackage: true, canSelPackage: true,
isUrgent: false, //取消加急 isUrgent: false, //取消加急
isUrgentDisable: false, //加急可以选择 isUrgentDisable: false, //加急可以选择
price: this.data.proPrice, //重置价格
}) })
this.countPrice()
}, },
//点击选择套餐包 //点击选择套餐包
selectPackage(e) { selectPackage(e) {

View File

@ -417,6 +417,7 @@ page {
color: #5D3900; color: #5D3900;
margin-top: 10px; margin-top: 10px;
font-weight: 400; font-weight: 400;
min-height: 12px;
} }

View File

@ -388,15 +388,16 @@
.marquee-text { .marquee-text {
display: inline-block; display: inline-block;
animation: marquee 9s linear infinite; animation: marquee 10s linear infinite;
color: rgba(85, 0, 0, 1); color: rgba(85, 0, 0, 1);
font-size: 14px; font-size: 14px;
margin-left: 15px; margin-left: 15px;
transform: translateX(100%);
} }
@keyframes marquee { @keyframes marquee {
0% { 0% {
transform: translateX(0); transform: translateX(100%);
} }
100% { 100% {

View File

@ -27,7 +27,15 @@ const isValidIdCard = (idCard) => {
const isValidCreditCode = (creditCode) => { const isValidCreditCode = (creditCode) => {
return /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/.test(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位 // 密码强度验证至少包含数字和字母长度8-20位
const isValidPassword = (password) => { const isValidPassword = (password) => {
return /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,20}$/.test(password); return /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,20}$/.test(password);
@ -39,5 +47,6 @@ module.exports = {
isValidUrl, isValidUrl,
isValidIdCard, isValidIdCard,
isValidCreditCode, isValidCreditCode,
isValidPassword isValidPassword,
objIsEmpty
}; };