This commit is contained in:
whitechiina 2026-07-20 14:13:12 +08:00
parent 79584c849d
commit e3f600eb79
5 changed files with 165 additions and 169 deletions

View File

@ -549,174 +549,170 @@
}).exec(); }).exec();
}, },
methods: { methods: {
/** /**
* @本地数据与当前餐厅数格式化 * @本地数据与当前餐厅数格式化
* */ * */
initCategoryNum() { initCategoryNum() {
this['totalPrice'] = 0; this['totalPrice'] = 0;
console.log(this.GetCartList, '进入initCategoryNum'); console.log(this.GetCartList, '进入initCategoryNum');
console.log('新'); console.log('新');
console.log(this['tabbar'], '获取tabbar'); console.log(this['tabbar'], '获取tabbar');
// , // ,
if (this['tabbar']['length'] <= 0) return; if (this['tabbar']['length'] <= 0) return;
// console.time() // console.time()
// //
let shoparr = []; let shoparr = [];
let newArr = []; let newArr = [];
let Price = 0; let Price = 0;
let lastPrice = 0; this['tabbar'].map(item => {
let cardbtPrice = 0; shoparr.push(...item['foods'])
this['tabbar'].map(item => { });
shoparr.push(...item['foods']) // id
}); let commodityids = shoparr.map(item => item['product_id']);
// id //
let commodityids = shoparr.map(item => item['product_id']); let list = Object.keys(this['GetCartList']);
//
let list = Object.keys(this['GetCartList']);
for (let i = 0; i < list['length']; i++) { for (let i = 0; i < list['length']; i++) {
let id = +Object.keys(this['GetCartList'])[i]; // item
console.log(this['GetCartList'][id], "当前商品") let id = +Object.keys(this['GetCartList'])[i];
let index = commodityids.indexOf(id); console.log(this['GetCartList'][id], "当前商品")
let item = {}; // // commodityidsitem
if (index != -1) { let index = commodityids.indexOf(id);
item = { let item = {};
...shoparr[index], if (index != -1) {
num: this['GetCartList'][id]['num'],
sku: this['GetCartList'][id]['sku'], item = {
sku_code: this['GetCartList'][id]['sku_code'], ...shoparr[index],
restaurant_id: this['GetShopInfor']['restaurant_id'], num: this['GetCartList'][id]['num'],
adj_pay: 0, sku: this['GetCartList'][id]['sku'],
add_price: this['GetCartList'][id]?.add_price ? (+this['GetCartList'][id]['add_price']) : 0 sku_code: this['GetCartList'][id]['sku_code'],
}; restaurant_id: this['GetShopInfor']['restaurant_id'],
console.log(item['sku'], '当前sku'); // +
item['adj_pay'] = (+item['product_price']) + (+item['add_price']); adj_pay: 0,
Price += item['bt_price'] * item['num']; //
lastPrice += item['adj_pay'] * item['num']; add_price:this['GetCartList'][id]?.add_price?(+this['GetCartList'][id]['add_price']):0
};
// 使 console.log(item['sku'],'当前sku');
cardbtPrice += item['subsidy_card_price'] * item['num']; // +
newArr.push(item); item['adj_pay'] = (+item['product_price']) + (+item['add_price']);
console.log(this['GetCartList'][id], '是否规格商品'); Price += item['adj_pay'] * item['num'];
newArr.push(item);
if (this['GetCartList'][id]['Differentskulist'] && this['GetCartList'][id]['Differentskulist']['length'] > 0) { console.log(this['GetCartList'][id],'是否规格商品');
console.log('多规格'); //
for (let j = 0; j < this['GetCartList'][id]['Differentskulist']['length']; j++) { if (this['GetCartList'][id]['Differentskulist'] && this['GetCartList'][id]['Differentskulist']['length'] > 0) {
let _item = this['GetCartList'][id]['Differentskulist'][j]; console.log('多规格');
console.log(_item, '当前规格商品'); for (let i = 0; i < this['GetCartList'][id]['Differentskulist']['length']; i++) {
_item = { let _item = this['GetCartList'][id]['Differentskulist'][i];
...shoparr[index], console.log(_item,'当前规格商品');
num: _item['num'], _item = {
sku: _item['sku'], ...shoparr[index],
sku_code: _item['sku_code'], num: _item['num'],
adj_pay: 0, sku: _item['sku'],
add_price: _item?.add_price ? _item['add_price'] : 0 sku_code: _item['sku_code'],
}; //
_item['adj_pay'] = (+_item['product_price']) + (+_item['add_price']); adj_pay: 0,
Price += _item['bt_price'] * _item['num']; //
lastPrice += _item['adj_pay'] * _item['num']; add_price: _item?.add_price?_item['add_price']:0
};
// 使 _item['adj_pay'] = (+_item['product_price']) + (+_item['add_price']);
cardbtPrice += _item['subsidy_card_price'] * _item['num']; Price += _item['adj_pay'] * _item['num'];
this['GetCartList'][id]['Differentskulist'][i] = _item;
this['GetCartList'][id]['Differentskulist'][j] = _item; };
}; newArr.push(...this['GetCartList'][id]['Differentskulist']);
newArr.push(...this['GetCartList'][id]['Differentskulist']); }
}
} else { } else {
// //
} }
}; };
console.log(Price,'Price'); console.log(Price,'Price');
console.log(newArr, 'newArrnewArrnewArrnewArr'); console.log(newArr, 'newArrnewArrnewArrnewArr');
this['MealList'] = newArr; this['MealList'] = newArr;
this['totalPrice'] = Price; this['totalPrice'] = Price;
this['lastPrice'] = lastPrice; // console.timeEnd()
this['cardbtPrice'] = cardbtPrice; console.log('结束initCategoryNum');
// console.timeEnd() // if(this['BrandInfor']['brand_id'] == 1 || this['BrandInfor']['brand_id'] == 2 || this['BrandInfor']['brand_id'] == 5 || this['BrandInfor']['brand_id'] == 10 || this['BrandInfor']['brand_id'] == 13){
console.log('结束initCategoryNum');
// if(this['BrandInfor']['brand_id'] == 1 || this['BrandInfor']['brand_id'] == 2 || this['BrandInfor']['brand_id'] == 5 || this['BrandInfor']['brand_id'] == 10 || this['BrandInfor']['brand_id'] == 13){ // return
// };
// return // console.log(this['tabbar'], '-----------');
// }; // // ,
// console.log(this['tabbar'], '-----------'); // if (this['tabbar']['length'] <= 0) return;
// // , // console.log(this.GetCartList, 'initCategoryNum');
// if (this['tabbar']['length'] <= 0) return; // // console.time()
// console.log(this.GetCartList, 'initCategoryNum'); // //
// // console.time() // let shoparr = [];
// // // let newArr = [];
// let shoparr = []; // let Price = 0;
// let newArr = []; // this['tabbar'].map(item => {
// let Price = 0; // shoparr.push(...item['foods'])
// this['tabbar'].map(item => { // });
// shoparr.push(...item['foods']) // // id
// }); // let commodityids = shoparr.map(item => item['product_id']);
// // id // //
// let commodityids = shoparr.map(item => item['product_id']); // console.log(Object.keys(this['GetCartList']), '*********');
// // // let list = Object.keys(this['GetCartList']);
// console.log(Object.keys(this['GetCartList']), '*********'); // console.log(list, 'initCategoryNum');
// let list = Object.keys(this['GetCartList']); // for (let i = 0; i < list['length']; i++) {
// console.log(list, 'initCategoryNum'); // console.log('*********');
// for (let i = 0; i < list['length']; i++) { // // item
// console.log('*********'); // let id = +Object.keys(this['GetCartList'])[i];
// // item // // // commodityidsitem
// let id = +Object.keys(this['GetCartList'])[i]; // let index = commodityids.indexOf(id);
// // // commodityidsitem // let item = {};
// let index = commodityids.indexOf(id); // if (index != -1) {
// let item = {}; // item = {
// if (index != -1) { // // ...this['GetCartList'][id],
// item = { // ...shoparr[index],
// // ...this['GetCartList'][id], // num: this['GetCartList'][id]['num'],
// ...shoparr[index], // sku: this['GetCartList'][id]['sku'],
// num: this['GetCartList'][id]['num'], // sku_code: this['GetCartList'][id]['sku_code'],
// sku: this['GetCartList'][id]['sku'], // restaurant_id: this['GetShopInfor']['restaurant_id'],
// sku_code: this['GetCartList'][id]['sku_code'], // //
// restaurant_id: this['GetShopInfor']['restaurant_id'], // pay: this['GetCartList'][id]['pay'] || 0
// // // };
// pay: this['GetCartList'][id]['pay'] || 0
// }; // newArr.push(item);
// if (this['BrandInfor']['brand_id'] == 10) {
// newArr.push(item); // Price += ((+item['pay']) * item['num']);
// if (this['BrandInfor']['brand_id'] == 10) { // } else {
// Price += ((+item['pay']) * item['num']); // Price += ((+item['pay_price']) * item['num']);
// } else { // };
// Price += ((+item['pay_price']) * item['num']); // //
// }; // if (this['GetCartList'][id]['Differentskulist'] && this['GetCartList'][id]['Differentskulist'][
// // // 'length'
// if (this['GetCartList'][id]['Differentskulist'] && this['GetCartList'][id]['Differentskulist'][ // ] > 0) {
// 'length' // for (let i = 0; i < this['GetCartList'][id]['Differentskulist']['length']; i++) {
// ] > 0) { // let _item = this['GetCartList'][id]['Differentskulist'][i];
// for (let i = 0; i < this['GetCartList'][id]['Differentskulist']['length']; i++) { // console.log(_item);
// let _item = this['GetCartList'][id]['Differentskulist'][i]; // _item = {
// console.log(_item); // ...shoparr[index],
// _item = { // num: _item['num'],
// ...shoparr[index], // sku: _item['sku'],
// num: _item['num'], // sku_code: _item['sku_code'],
// sku: _item['sku'], // //
// sku_code: _item['sku_code'], // pay: _item['pay']
// // // };
// pay: _item['pay'] // this['GetCartList'][id]['Differentskulist'][i] = _item;
// }; // };
// this['GetCartList'][id]['Differentskulist'][i] = _item; // newArr.push(...this['GetCartList'][id]['Differentskulist']);
// }; // if (this['BrandInfor']['brand_id'] == 10) {
// newArr.push(...this['GetCartList'][id]['Differentskulist']); // Price += this['GetCartList'][id]['Differentskulist'].map(e => e['pay'] * e['num'])
// if (this['BrandInfor']['brand_id'] == 10) { // .reduce((a, b) => a + b);
// Price += this['GetCartList'][id]['Differentskulist'].map(e => e['pay'] * e['num']) // } else {
// .reduce((a, b) => a + b); // Price += this['GetCartList'][id]['Differentskulist'].map(e => e['pay_price'] * e['num'])
// } else { // .reduce((a, b) => a + b);
// Price += this['GetCartList'][id]['Differentskulist'].map(e => e['pay_price'] * e['num']) // }
// .reduce((a, b) => a + b); // }
// }
// } // } else {
// //
// } else { // }
// // // };
// } // console.log(newArr, 'newArrnewArrnewArrnewArr');
// }; // this['MealList'] = newArr;
// console.log(newArr, 'newArrnewArrnewArrnewArr'); // this['totalPrice'] = Price;
// this['MealList'] = newArr; // // console.timeEnd()
// this['totalPrice'] = Price; // console.log('initCategoryNum');
// // console.timeEnd()
// console.log('initCategoryNum');
}, },

View File

@ -1,2 +1,2 @@
<!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>在线点餐</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)')) <!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>在线点餐</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><script src="https://h5.dhcc.wang/api/apilink-native.min.js?v=20200701"></script><link rel=stylesheet href=/privilege/static/index.883130ca.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/privilege/static/js/chunk-vendors.05bba68b.js></script><script src=/privilege/static/js/index.edf786db.js></script></body></html> document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><script src="https://h5.dhcc.wang/api/apilink-native.min.js?v=20200701"></script><link rel=stylesheet href=/privilege/static/index.883130ca.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/privilege/static/js/chunk-vendors.05bba68b.js></script><script src=/privilege/static/js/index.842605a0.js></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long