updata
This commit is contained in:
parent
79584c849d
commit
e3f600eb79
|
|
@ -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 = {};
|
// // 在commodityids中查找item
|
||||||
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转为数字
|
// // // 在commodityids中查找item
|
||||||
// let id = +Object.keys(this['GetCartList'])[i];
|
// let index = commodityids.indexOf(id);
|
||||||
// // // 在commodityids中查找item
|
// 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');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
1
unpackage/dist/build/web/static/js/pages-restaurant-home-shop_home-shop_home.967c4a3a.js
vendored
Normal file
1
unpackage/dist/build/web/static/js/pages-restaurant-home-shop_home-shop_home.967c4a3a.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue