|
|
|
@ -44,7 +44,9 @@ Page({ |
|
|
|
seachFlag:false, //搜索模式
|
|
|
|
totalPrice:0, //获取购物车总价
|
|
|
|
name:'非遗专卖', |
|
|
|
nowAddListId:[] |
|
|
|
nowAddListId:[], |
|
|
|
|
|
|
|
user_type: null, |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
@ -69,10 +71,10 @@ Page({ |
|
|
|
delAll() { |
|
|
|
let ids = [] |
|
|
|
this.data.gwcList.forEach(item => { |
|
|
|
ids.push(item.sku_id) |
|
|
|
ids.push(item.id) |
|
|
|
}) |
|
|
|
commonApi.user_post("cart_within/del_sku", { |
|
|
|
sku_id: ids+'', |
|
|
|
id: ids+'', |
|
|
|
type:'2' |
|
|
|
}).then(res => { |
|
|
|
if (res.code == 1) { |
|
|
|
@ -92,10 +94,11 @@ Page({ |
|
|
|
del(e) { |
|
|
|
let item = e.currentTarget.dataset.item |
|
|
|
let gwcList = this.data.gwcList |
|
|
|
let valueNum = e.currentTarget.dataset.value |
|
|
|
commonApi.user_post("cart_within/update_sku", { |
|
|
|
num:item.num-1, |
|
|
|
sku_id: item.sku_id, |
|
|
|
type:'2' |
|
|
|
num:item.num + valueNum, |
|
|
|
id: item.id, |
|
|
|
type:'1' |
|
|
|
}).then(res => { |
|
|
|
if (res.code == 1) { |
|
|
|
// this.getCount()
|
|
|
|
@ -117,6 +120,9 @@ Page({ |
|
|
|
if (item.selected ==1) { |
|
|
|
totalPrice += item.num*item.sku.price |
|
|
|
} |
|
|
|
if (item.delivery_method === null) { |
|
|
|
item.delivery_method = item.sku.sku_model.use_type == 1?1:0 |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
let status = res.data.every(el => el.selected === 1) |
|
|
|
@ -132,6 +138,13 @@ Page({ |
|
|
|
}, |
|
|
|
// 添加产品到购物车
|
|
|
|
addCart: function (e) { |
|
|
|
if (![0,1].includes(this.data.user_type)) { |
|
|
|
wx.showToast({ |
|
|
|
title: "请选择配送方式", |
|
|
|
icon:"none" |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
let item = e.currentTarget.dataset.item |
|
|
|
app.globalData.postProduct = [] |
|
|
|
app.globalData.list = [] |
|
|
|
@ -144,7 +157,8 @@ Page({ |
|
|
|
commonApi.user_post("cart_within/add_sku", { |
|
|
|
sku_id: this.data.showPopup ? item.sku.id :this.data.info.sku[this.data.skuIndex].id, |
|
|
|
num: this.data.producNum, |
|
|
|
type:"2" |
|
|
|
type:"2", |
|
|
|
delivery_method: this.data.user_type |
|
|
|
}).then(res => { |
|
|
|
if (res.code == 1) { |
|
|
|
let sku_id = this.data.showPopup ? item.sku.id :this.data.info.sku[this.data.skuIndex].id |
|
|
|
@ -187,6 +201,9 @@ Page({ |
|
|
|
if (element.selected == 1) { |
|
|
|
totalPrice += Number(element.num*element.sku.price) |
|
|
|
} |
|
|
|
if (element.delivery_method === null) { |
|
|
|
element.delivery_method = element.sku.sku_model.use_type == 1?1:0 |
|
|
|
} |
|
|
|
}) |
|
|
|
let status = res.data.every(el => el.selected === 1) |
|
|
|
this.setData({ |
|
|
|
@ -252,7 +269,7 @@ Page({ |
|
|
|
if (item.product.type == 'post') { |
|
|
|
product.push({ |
|
|
|
product: item.product, |
|
|
|
sku: item.sku, |
|
|
|
sku: {...item.sku, use_type: item.delivery_method||0}, |
|
|
|
productNum: item.num |
|
|
|
}) |
|
|
|
} else { |
|
|
|
@ -271,21 +288,27 @@ Page({ |
|
|
|
// })
|
|
|
|
return; |
|
|
|
} |
|
|
|
if (product.length > 0 && product1.length > 0) { |
|
|
|
this.setData({ |
|
|
|
flag: 'mix', |
|
|
|
isCar: 'multiple' |
|
|
|
let repeatSku = product.find(x=>product.filter(v=>v.sku.id == x.sku.id).length>1) |
|
|
|
if(repeatSku) { |
|
|
|
let str = `${repeatSku.product.title}-${repeatSku.sku.sku_name}邮寄和自提只能选择一种` |
|
|
|
wx.showModal({ |
|
|
|
content: str, |
|
|
|
showCancel: false, |
|
|
|
complete: (res) => {} |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
if (product1.length > 1) { |
|
|
|
this.setData({ |
|
|
|
isCar: 'multiple' |
|
|
|
}) |
|
|
|
} else { |
|
|
|
this.setData({ |
|
|
|
isCar: 'single' |
|
|
|
}) |
|
|
|
|
|
|
|
let useType = product[0].sku.use_type |
|
|
|
let flag = this.data.flag, isCar = "single"; |
|
|
|
if (product.some(x=>x.sku.use_type!=useType)) { |
|
|
|
flag = "mix" |
|
|
|
isCar = "multiple" |
|
|
|
} |
|
|
|
this.setData({ |
|
|
|
flag: flag, |
|
|
|
isCar: isCar |
|
|
|
}) |
|
|
|
console.log(product1); |
|
|
|
app.globalData.postProduct = product; |
|
|
|
if (app.globalData.list) { |
|
|
|
@ -427,6 +450,9 @@ Page({ |
|
|
|
if(item.selected == 1) { |
|
|
|
totalPrice += item.num*item.sku.price |
|
|
|
} |
|
|
|
if (item.delivery_method === null) { |
|
|
|
item.delivery_method = item.sku.sku_model.use_type == 1?1:0 |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
this.setData({ |
|
|
|
@ -581,6 +607,9 @@ Page({ |
|
|
|
}, |
|
|
|
// 添加产品弹窗 1.首先获取到该产品下的规格
|
|
|
|
addBuyCart(e) { |
|
|
|
this.setData({ |
|
|
|
user_type: null |
|
|
|
}) |
|
|
|
let item = e.currentTarget.dataset.item |
|
|
|
console.log(item); |
|
|
|
commonApi._post("product/get_product_detail", { |
|
|
|
@ -637,9 +666,16 @@ Page({ |
|
|
|
selectSku: function (e) { |
|
|
|
let index = e.currentTarget.dataset.index; |
|
|
|
this.setData({ |
|
|
|
skuIndex: index |
|
|
|
}) |
|
|
|
skuIndex: index, |
|
|
|
user_type: null, |
|
|
|
}) |
|
|
|
}, |
|
|
|
changeSelectSkuPost: function(e) { |
|
|
|
let value = e.currentTarget.dataset.value; |
|
|
|
this.setData({ |
|
|
|
user_type: value, |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 关闭弹窗
|
|
|
|
hideSku: function () { |
|
|
|
this.setData({ |
|
|
|
|