|
|
|
@ -15,7 +15,7 @@ |
|
|
|
:hour="seckill.seckill.end_left_time[1]" |
|
|
|
:minute="seckill.seckill.end_left_time[2]" |
|
|
|
:second="seckill.seckill.end_left_time[3]" |
|
|
|
color="white" |
|
|
|
color="white" |
|
|
|
splitorColor="white" |
|
|
|
> |
|
|
|
</countdown-time> |
|
|
|
@ -331,21 +331,34 @@ |
|
|
|
let stores = this.goods_stock.stores; |
|
|
|
let specs = this.goods_stock.specs; |
|
|
|
|
|
|
|
if(!this.$isRight(specs[1])){ |
|
|
|
return `¥${goods_detail.min_price} - ¥${goods_detail.max_price}`; |
|
|
|
} |
|
|
|
let spec_current_1 = specs[1].spec_current; |
|
|
|
let spec_current_2 = specs[2].spec_current; |
|
|
|
if(specs[1].spec_current != null && specs[2].spec_current != null){ |
|
|
|
let id_1 = specs[1].list[spec_current_1].id; |
|
|
|
let id_2 = specs[2].list[spec_current_2].id; |
|
|
|
if(id_1 < id_2){ |
|
|
|
let id_3 = id_2; |
|
|
|
id_2 = id_1; |
|
|
|
id_1 = id_3; |
|
|
|
if(this.$isRight(specs)){ // 第一种情况,存在规格 |
|
|
|
let selectEnd = true; // 是否选择完所有规格 |
|
|
|
let specs_list = []; // 将对象转成数组 |
|
|
|
for(let i in specs){ |
|
|
|
specs_list.push(specs[i]); |
|
|
|
if(specs[i].spec_current == null){ |
|
|
|
selectEnd = false; |
|
|
|
} |
|
|
|
} |
|
|
|
return "¥"+ stores[id_2 +'-'+ id_1].price; |
|
|
|
}else{ |
|
|
|
|
|
|
|
if(!selectEnd){ // 未选完规格 |
|
|
|
return `¥${goods_detail.min_price} - ¥${goods_detail.max_price}`; |
|
|
|
} |
|
|
|
|
|
|
|
let ids = []; // 取出所有规格id |
|
|
|
specs_list.map((item, index) => { |
|
|
|
console.log("item.list[item.spec_current]", item.list[item.spec_current]) |
|
|
|
ids.push(item.list[item.spec_current].id); |
|
|
|
}) |
|
|
|
|
|
|
|
ids.sort(function(a, b){ // 对所有规格id进行排序,果酱原则,规格从小到大取出商品信息 |
|
|
|
return a - b; |
|
|
|
}) |
|
|
|
|
|
|
|
let idPath = ids.join('-'); // 将ids转成字符串拼接形式 |
|
|
|
return stores[idPath].price; // 收工 |
|
|
|
|
|
|
|
}else{ // 该商品没有规格 |
|
|
|
return `¥${goods_detail.min_price} - ¥${goods_detail.max_price}`; |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -481,7 +494,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
// 跳转至下单页TODO |
|
|
|
// 跳转至下单页 |
|
|
|
confirm(){ |
|
|
|
if(this.is_date_finish){ |
|
|
|
return this.$msg('活动已结束'); |
|
|
|
@ -490,48 +503,42 @@ |
|
|
|
let specs = this.goods_stock.specs; |
|
|
|
let stores = this.goods_stock.stores; |
|
|
|
let par = {}; |
|
|
|
let have_specs = ''; |
|
|
|
let no_specs = ''; |
|
|
|
let have_specs = ''; // 有规格的商品,规格id拼接 |
|
|
|
let no_specs = ''; // 没有规格的商品,直接取商品id |
|
|
|
|
|
|
|
if(this.$isRight(specs)){ |
|
|
|
let s_id_1 = 1; |
|
|
|
let s_id_2 = 2; |
|
|
|
for(let i in specs){ |
|
|
|
if(specs[i].label_key == 'size'){ |
|
|
|
s_id_1 = 1; |
|
|
|
} |
|
|
|
if(specs[i].label_key == 'color'){ |
|
|
|
s_id_2 = 2; |
|
|
|
} |
|
|
|
if(this.$isRight(specs)){ // 有规格的商品 |
|
|
|
let attributes = { |
|
|
|
com_id: goods_detail.id, |
|
|
|
img: goods_detail.img |
|
|
|
} |
|
|
|
let spec_current_1 = specs[s_id_1].spec_current; |
|
|
|
let spec_current_2 = specs[s_id_2].spec_current; |
|
|
|
let id_1 = specs[s_id_1].list[spec_current_1].id; |
|
|
|
let id_2 = specs[s_id_2].list[spec_current_2].id; |
|
|
|
if(id_1 > id_2){ |
|
|
|
let id_3 = id_2; |
|
|
|
id_2 = id_1; |
|
|
|
id_1 = id_3; |
|
|
|
let specs_list = []; // 将对象转成数组 |
|
|
|
let ids = []; // 取出所有规格id |
|
|
|
for(let i in specs){ |
|
|
|
specs_list.push(specs[i]); |
|
|
|
ids.push(specs[i].list[specs[i].spec_current].id); |
|
|
|
attributes[specs[i].label_key] = specs[i].list[specs[i].spec_current].value; // 取出规格label_key和value |
|
|
|
} |
|
|
|
ids.sort(function(a, b){ // 对所有规格id进行排序,果酱原则,规格从小到大取出商品信息 |
|
|
|
return a - b; |
|
|
|
}) |
|
|
|
|
|
|
|
let idPath = ids.join('-'); // 将ids转成字符串拼接形式 |
|
|
|
let specsValue = specs_list[0].list[specs_list[0].spec_current].value; // 取出第一个规格的value |
|
|
|
attributes['sku'] = goods_detail.goods_no +'-'+ specsValue; |
|
|
|
|
|
|
|
par = { |
|
|
|
attributes: { |
|
|
|
color: specs[s_id_2].list[specs[s_id_2].spec_current].value, |
|
|
|
com_id: goods_detail.id, |
|
|
|
img: goods_detail.img, |
|
|
|
size: specs[s_id_1].list[specs[s_id_1].spec_current].value, |
|
|
|
sku: goods_detail.goods_no +'-'+ specs[s_id_1].list[specs[s_id_1].spec_current].value |
|
|
|
}, |
|
|
|
id: stores[id_1 +'-'+ id_2].id, |
|
|
|
product_id: stores[id_1 +'-'+ id_2].id, |
|
|
|
price: stores[id_1 +'-'+ id_2].price, |
|
|
|
store_count: stores[id_1 +'-'+ id_2].store, |
|
|
|
attributes: attributes, |
|
|
|
id: stores[idPath].id, |
|
|
|
product_id: stores[idPath].id, |
|
|
|
price: stores[idPath].price, |
|
|
|
store_count: stores[idPath].store, |
|
|
|
market_price: goods_detail.market_price, |
|
|
|
name: goods_detail.name, |
|
|
|
qty: this.goods_num |
|
|
|
} |
|
|
|
have_specs = stores[id_1 +'-'+ id_2].id; |
|
|
|
}else{ |
|
|
|
have_specs = stores[idPath].id; // 收工 |
|
|
|
|
|
|
|
}else{ // 没有规格的商品 |
|
|
|
par = { |
|
|
|
attributes: { |
|
|
|
com_id: goods_detail.id, |
|
|
|
@ -547,8 +554,8 @@ |
|
|
|
} |
|
|
|
no_specs = goods_detail.id; |
|
|
|
} |
|
|
|
// 秒杀商品 |
|
|
|
if(this.$isRight(this.seckill)){ |
|
|
|
|
|
|
|
if(this.$isRight(this.seckill)){ // 秒杀商品 |
|
|
|
delete par.product_id; |
|
|
|
par.seckill_goods_id = this.seckill.item_id; |
|
|
|
par.seckill_item_id = this.seckill.id; |
|
|
|
@ -556,13 +563,11 @@ |
|
|
|
par.total = new Bigc(this.goods_num).times(this.seckill.seckill_price).round(2, 0); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uni.showLoading({ |
|
|
|
title: '正在提交' |
|
|
|
}) |
|
|
|
this.show_popup = false; |
|
|
|
if(this.click_type == 1){ |
|
|
|
// 加入购物车 |
|
|
|
if(this.click_type == 1){ // 加入购物车 |
|
|
|
this.$http.post({ |
|
|
|
api: 'api/shopping/cart', |
|
|
|
data: {"0": par}, |
|
|
|
@ -578,8 +583,7 @@ |
|
|
|
} |
|
|
|
uni.hideLoading() |
|
|
|
}).catch(err => uni.hideLoading()) |
|
|
|
}else if(this.click_type == 2){ |
|
|
|
// 直接结算 |
|
|
|
}else if(this.click_type == 2){ //普通商品结算 |
|
|
|
this.$cookieStorage.set('order_confirm', par); |
|
|
|
uni.hideLoading(); |
|
|
|
this.$url('/pages/order/confirm/confirm'); |
|
|
|
@ -597,8 +601,7 @@ |
|
|
|
// } |
|
|
|
// uni.hideLoading() |
|
|
|
// }).catch(err => uni.hideLoading()) |
|
|
|
}else if(this.click_type == 3) { |
|
|
|
let params = {}; |
|
|
|
}else if(this.click_type == 3) { // 积分商品结算 |
|
|
|
if(have_specs) { |
|
|
|
uni.hideLoading() |
|
|
|
this.$url('/pages/order/pointconfirm/confirm?quantity='+this.goods_num+'&product_id='+have_specs+'&goods_type=0') |
|
|
|
|