refactor(price): 优化价格计算逻辑

- 移除调试代码,提高代码可读性
- 使用价格分隔计算,确保精度准确
- 优化购物车和订单详情页面的价格计算方法
- 调整登录账号和应用描述信息
main
Tuzki 8 months ago
parent 5b61df1fce
commit 9f029b5bb5
  1. 4
      manifest.json
  2. 24
      pages/addUserinfo/addUserinfo.vue
  3. 4
      pages/login.vue
  4. 1
      pages/orderDetail/orderDetail.vue
  5. 36
      pages/shoppingCar/shoppingCar.vue
  6. 39
      pages/shoppingTrolley/shoppingTrolley.vue
  7. 2
      uni_modules/wu-calendar/components/wu-calendar/wu-calendar.vue

@ -1,7 +1,7 @@
{
"name" : "芋道移动端",
"name" : "手持机售票",
"appid" : "__UNI__EF91AFC",
"description" : "",
"description" : "手持机售票系统",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,

@ -169,12 +169,12 @@ export default {
let that = this;
that.allTicket = allTickets;
if (options.needInfoItem) {
debugger;
//debugger;
const ticket = JSON.parse(options.needInfoItem);
this.event = options.event ? options.event : null;
//
if (ticket.touristInformation == 2) {
debugger;
//debugger;
console.log('allTickets:', allTickets); // allTickets
console.log('ticket:', ticket); // ticket
let index = allTickets.findIndex(item => Number(item.id) == Number(ticket.id) && item.date == ticket.date);
@ -192,7 +192,7 @@ export default {
}
//
if (ticket.touristInformation == 3) {
debugger;
//debugger;
console.log('allTickets:', allTickets); // allTickets
console.log('ticket:', ticket); // ticket
let index = allTickets.findIndex(item => Number(item.id) == Number(ticket.id) && item.date == ticket.date);
@ -204,7 +204,7 @@ export default {
that.count = allTickets[index].usersNumber * allTickets[index].num - counts;
that.ticket = allTickets[index];
} else {
debugger
//debugger
ticket.num = 1;
that.count = 1 * ticket.usersNumber;
that.ticket = ticket;
@ -225,7 +225,7 @@ export default {
}
that.ticket = allTickets[index];
} else {
debugger
//debugger
ticket.num = 1;
that.count = 1 * ticket.usersNumber;
that.ticket = ticket;
@ -238,20 +238,20 @@ export default {
this.allTicket = [];
let allTickets = [];
if (options.needInfoItem) {
debugger;
//debugger;
const ticket = JSON.parse(options.needInfoItem);
this.event = options.event ? options.event : null;
let that = this;
//
if (ticket.touristInformation == 2) {
debugger;
//debugger;
ticket.num = 1;
that.count = 1;
that.ticket = ticket;
}
//
if (ticket.touristInformation == 3) {
debugger;
//debugger;
ticket.num = 1;
that.count = 1 * ticket.usersNumber;
that.ticket = ticket;
@ -330,7 +330,7 @@ export default {
},10000)
},
saveUserInfo() {
debugger
//debugger
let that = this
if (that.event) {
uni.removeStorageSync('EVENT', that.event)
@ -377,7 +377,7 @@ export default {
}
},
editPerson(val) {
debugger
//debugger
if (this.ticket.touristInformation == 2) {
this.count = 1
this.editIng = true
@ -398,7 +398,7 @@ export default {
content: '确定删除此名游客信息吗?',
success: function (res) {
if (res.confirm) {
debugger
//debugger
const validItems = that.ticket.visitorInfoList.filter(item => item !== undefined && item !== null);
const index = validItems.findIndex(item => Number(item.idx) == Number(val.idx))
that.ticket.visitorInfoList.splice(index, 1)
@ -450,7 +450,7 @@ export default {
this.$refs[ref]
.validate()
.then((res) => {
debugger
//debugger
console.log('success', res);
if (that.customFormData.idx == null) {
that.count--;

@ -47,8 +47,8 @@
captchaEnabled: true, // TODO
globalConfig: getApp().globalData.config,
loginForm: {
username: "13292812222",
password: "812222",
username: "15900000090",
password: "000090",
captchaVerification: ""
},
tentId:null

@ -156,6 +156,7 @@ export default {
})
},
back() {
let that = this
cancelOrder(that.orderDetail.orderInfo.orderNumber).then(res=>{
console.log(res)
}).catch(err=>{

@ -78,7 +78,7 @@ export default {
};
},
onShow(params) {
debugger
//debugger
const allTicket = uni.getStorageSync('ALL_TICKET');
const oldTicket = uni.getStorageSync('oldTicket')
console.log(oldTicket)
@ -89,8 +89,10 @@ export default {
console.log(allTicket)
allTicket.forEach((i) => {
// i.disablePlus = false
const priceInCents = Math.round(Number(i.settlementPrice) * 100);
const quantity = Number(i.num);
allSum += i.num;
allPrice += i.num * i.settlementPrice;
allPrice += quantity * priceInCents/100;
});
this.ticketList = allTicket;
this.ticketSum = allSum;
@ -100,9 +102,11 @@ export default {
const index = allTicket.findIndex(i => Number(i.id) == Number(oldTicket.id) && i.date == oldTicket.date);//
allTicket.splice(index, 1, oldTicket)
allTicket.forEach((i) => {
const priceInCents = Math.round(Number(i.settlementPrice) * 100);
const quantity = Number(i.num);
// i.disablePlus = false
allSum += i.num;
allPrice += i.num * i.settlementPrice;
allPrice += quantity * priceInCents/100;
});
this.ticketList = allTicket;
this.ticketSum = allSum;
@ -125,23 +129,23 @@ export default {
ticketList: {
handler(val) {
console.log(val);
let obj = {};
let allSum = 0, allPrice = 0;
val.forEach((item) => {
debugger
//debugger
obj.ticketId = item.id;
obj.ticketName = item.ticketname;
obj.num = item.num;
obj.ticketPrice = item.settlementPrice;
obj.date = item.date;
obj.visitorInfoList = item.visitorInfoList
const priceInCents = Math.round(Number(item.settlementPrice) * 100);
const quantity = Number(item.num);
allSum += item.num;
allPrice += Number(item.num) * Number(item.settlementPrice);
allPrice += Number(item.num) * Math.round(Number(item.settlementPrice) * 100)/100;
console.log(allPrice);
});
uni.setStorageSync('ALL_TICKET', val);
@ -160,7 +164,7 @@ export default {
methods: {
getMaxValue(item) {
debugger
//debugger
if (item.inventorySettings == 1) {
//
return Number.MAX_SAFE_INTEGER;
@ -198,7 +202,7 @@ export default {
orderPrice: this.priceSum,
settlementAmount: this.priceSum,
};
debugger
//debugger
uni.showLoading({
title: '请等待...'
});
@ -214,7 +218,9 @@ export default {
})
},
sumPrice(val) {
return val.num * val.settlementPrice;
const priceInCents = Math.round(Number(val.settlementPrice) * 100);
const quantity = Number(val.num);
return quantity * priceInCents/100;
},
overlimit(val) {
console.log(val);
@ -227,7 +233,7 @@ export default {
if (e.value >= 1) {
//
if (itm.inventorySettings == 1) {
debugger
//debugger
///
if (itm.touristInformation == 1 || itm.touristInformation == 2) {
itm.num = e.value
@ -235,7 +241,7 @@ export default {
}
//
if (itm.touristInformation == 3) {
debugger
//debugger
uni.setStorageSync('oldTicket', itm)
uni.setStorageSync('ALL_TICKET', that.ticketList)
const data = JSON.stringify(itm)
@ -246,7 +252,7 @@ export default {
}
//
if (itm.inventorySettings == 2) {
debugger
//debugger
///
if (itm.touristInformation == 1 || itm.touristInformation == 2) {
// const filteredItems = that.ticketList.filter(item => item.id == itm.id && item.date == itm.date);
@ -311,7 +317,7 @@ export default {
}
//
if (itm.inventorySettings == 3) {
debugger
//debugger
///
if (itm.touristInformation == 1 || itm.touristInformation == 2) {
// if (Number(itm.num) >= Number(itm.rkc)) {

@ -146,21 +146,25 @@ export default {
this.ticketSumPrice = 0;
if (Array.isArray(val) && val.length > 0) {
val.forEach((i) => {
const priceInCents = Math.round(Number(i.settlementPrice) * 100);
const quantity = Number(i.num);
this.ticketSumNum += i.num;
this.ticketSumPrice += i.num * i.settlementPrice;
this.ticketSumPrice += quantity * priceInCents/100;
});
}
}
},
}
},
onShow() {
debugger
//debugger
const allTicket = uni.getStorageSync('ALL_TICKET');
if (allTicket && Array.isArray(allTicket) && allTicket.length > 0) {
this.car = allTicket
}else{
this.car = []
this.ticketSumNum = 0;
this.ticketSumPrice = 0;
}
},
onReady() {
@ -243,7 +247,7 @@ export default {
calendarConfirm(e) {
let that = this;
console.log(e);
debugger;
//debugger;
//
if (that.selectItem.inventorySettings == 1) {
@ -302,12 +306,12 @@ export default {
if (that.selectItem.touristInformation == 1) {
if (that.car.length > 0) {
debugger;
//debugger;
console.log(that.car, 'car里的数据');
index = that.car.findIndex((items) => Number(items.id) == Number(that.selectItem.id) && items.date == e.fulldate);
if (index != -1) {
debugger;
//debugger;
const currentNum = that.car[index].num;
if (Number(that.selectItem.currentinventory) - currentNum >= 1) {
@ -334,7 +338,7 @@ export default {
}
} else {
debugger;
//debugger;
const newItem = { ...that.selectItem, num: 1, date: e.fulldate, zkc: that.selectItem.currentinventory };
// that.$set(that.car, that.car.length, that.selectItem);
that.car.push(newItem);
@ -346,7 +350,7 @@ export default {
///
if (that.selectItem.touristInformation == 2 || that.selectItem.touristInformation == 3) {
if (that.car.length > 0) {
debugger;
//debugger;
console.log('that.selectItem.id:', that.selectItem.id);
console.log('e.fulldate:', e.fulldate);
console.log('that.car:', that.car);
@ -398,7 +402,7 @@ export default {
//
if (that.selectItem.inventorySettings == 3) {
let index;
debugger
//debugger
const cartItem = that.car.find((item) => Number(item.id) == Number(that.selectItem.id) && item.date == e.fulldate);
const cartQuantity = cartItem ? cartItem.num : 0;
@ -421,7 +425,7 @@ export default {
index = that.car.findIndex((items) => Number(items.id) == Number(that.selectItem.id) && items.date == e.fulldate);
console.log('index:', index);
if (index != -1) {
debugger;
//debugger;
const currentNum = that.car[index].num;
// num1
@ -430,7 +434,7 @@ export default {
that.$set(that.car, index, newItem);
uni.setStorageSync('ALL_TICKET', that.car)
} else {
debugger;
//debugger;
const newItem = { ...that.selectItem, num: 1, date: e.fulldate, rkc: inventory };
// that.$set(that.car, that.car.length, that.selectItem);
that.car.push(newItem);
@ -443,7 +447,7 @@ export default {
index = that.car.findIndex((items) => Number(items.id) == Number(that.selectItem.id) && items.date == e.fulldate);
console.log('index:', index);
if (index != -1) {
debugger;
//debugger;
const currentNum = that.car[index].num;
// num1
@ -455,7 +459,7 @@ export default {
url: '/pages/addUserinfo/addUserinfo?needInfoItem=' + data + '&event=' + eve
})
} else {
debugger;
//debugger;
const newItem = { ...that.selectItem, num: 1, date: e.fulldate, rkc: inventory };
const data = JSON.stringify(newItem)
const eve = JSON.stringify(that.event)
@ -538,7 +542,7 @@ export default {
item.btnLoading = true;
let that = this;
//
debugger;
//debugger;
if (item.datesettings == 1) {
const date = this.parseTime(new Date(),'{y}-{m}-{d}')
item.date = date
@ -546,10 +550,11 @@ export default {
if (item.inventorySettings == 1) {
//
if (item.touristInformation == 1) {
item.num += 1;
if (that.car.length > 0) {
const index = that.car.findIndex((items) => Number(items.id) == Number(item.id));
if (index !== -1) {
that.car[index].num+=1
item.num = that.car[index].num
// 使 Vue.set that.$set
that.$set(that.car, index, item);
uni.setStorageSync('ALL_TICKET', that.car)
@ -612,11 +617,11 @@ export default {
if (item.touristInformation == 1) {
if (Number(item.currentinventory) > item.num) {
//
item.num += 1;
if (that.car.length > 0) {
const index = that.car.findIndex((items) => Number(items.id) == Number(item.id));
if (index !== -1) {
that.car[index].num+=1
item.num = that.car[index].num
// 使 Vue.set that.$set
that.$set(that.car, index, item);
uni.setStorageSync('ALL_TICKET', that.car)

@ -309,7 +309,7 @@
},
selected: {
handler(newVal) {
debugger
//debugger
this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
this.assignmentWeeks()
// weeks this.calendar

Loading…
Cancel
Save