|
|
@ -26,7 +26,9 @@ Page({ |
|
|
totalPrice:0, //获取购物车总价--打开购物车后勾选的产品价格
|
|
|
totalPrice:0, //获取购物车总价--打开购物车后勾选的产品价格
|
|
|
nowAddListId:[], |
|
|
nowAddListId:[], |
|
|
type:'', //购物车分类1文创,2非遗
|
|
|
type:'', //购物车分类1文创,2非遗
|
|
|
show:false |
|
|
show:false, |
|
|
|
|
|
|
|
|
|
|
|
user_type: null, |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -60,6 +62,14 @@ Page({ |
|
|
}, |
|
|
}, |
|
|
// 添加产品到购物车
|
|
|
// 添加产品到购物车
|
|
|
addCart: function (e) { |
|
|
addCart: function (e) { |
|
|
|
|
|
if (![0,1].includes(this.data.user_type)) { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: "请选择配送方式", |
|
|
|
|
|
icon:"none" |
|
|
|
|
|
}) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
let item = e.currentTarget.dataset.item |
|
|
let item = e.currentTarget.dataset.item |
|
|
app.globalData.postProduct = [] |
|
|
app.globalData.postProduct = [] |
|
|
app.globalData.list = [] |
|
|
app.globalData.list = [] |
|
|
@ -72,7 +82,8 @@ Page({ |
|
|
commonApi.user_post("cart_within/add_sku", { |
|
|
commonApi.user_post("cart_within/add_sku", { |
|
|
sku_id: this.data.showPopup ? item.sku.id :this.data.info.sku[this.data.skuIndex].id, |
|
|
sku_id: this.data.showPopup ? item.sku.id :this.data.info.sku[this.data.skuIndex].id, |
|
|
num: this.data.producNum, |
|
|
num: this.data.producNum, |
|
|
type:this.data.type |
|
|
type:this.data.type, |
|
|
|
|
|
delivery_method: this.data.user_type |
|
|
}).then(res => { |
|
|
}).then(res => { |
|
|
if (res.code == 1) { |
|
|
if (res.code == 1) { |
|
|
let sku_id = this.data.showPopup ? item.sku.id :this.data.info.sku[this.data.skuIndex].id |
|
|
let sku_id = this.data.showPopup ? item.sku.id :this.data.info.sku[this.data.skuIndex].id |
|
|
@ -107,6 +118,9 @@ Page({ |
|
|
if (element.selected == 1) { |
|
|
if (element.selected == 1) { |
|
|
totalPrice += Number(element.num*element.sku.price) |
|
|
totalPrice += Number(element.num*element.sku.price) |
|
|
} |
|
|
} |
|
|
|
|
|
if (element.delivery_method === null) { |
|
|
|
|
|
element.delivery_method = element.sku.sku_model.use_type == 1?1:0 |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
console.log(res.data); |
|
|
console.log(res.data); |
|
|
let status = res.data.every(el => el.selected === 1) |
|
|
let status = res.data.every(el => el.selected === 1) |
|
|
@ -173,7 +187,7 @@ Page({ |
|
|
if (item.product.type == 'post') { |
|
|
if (item.product.type == 'post') { |
|
|
product.push({ |
|
|
product.push({ |
|
|
product: item.product, |
|
|
product: item.product, |
|
|
sku: item.sku, |
|
|
sku: {...item.sku, use_type: item.delivery_method||0}, |
|
|
productNum: item.num |
|
|
productNum: item.num |
|
|
}) |
|
|
}) |
|
|
} else { |
|
|
} else { |
|
|
@ -207,6 +221,29 @@ Page({ |
|
|
isCar: 'single' |
|
|
isCar: 'single' |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
console.log(product1); |
|
|
app.globalData.postProduct = product; |
|
|
app.globalData.postProduct = product; |
|
|
if (app.globalData.list) { |
|
|
if (app.globalData.list) { |
|
|
@ -248,10 +285,10 @@ selectedIt(e) { |
|
|
delAll() { |
|
|
delAll() { |
|
|
let ids = [] |
|
|
let ids = [] |
|
|
this.data.gwcList.forEach(item => { |
|
|
this.data.gwcList.forEach(item => { |
|
|
ids.push(item.sku_id) |
|
|
ids.push(item.id) |
|
|
}) |
|
|
}) |
|
|
commonApi.user_post("cart_within/del_sku", { |
|
|
commonApi.user_post("cart_within/del_sku", { |
|
|
sku_id: ids+'', |
|
|
id: ids+'', |
|
|
type:this.data.type |
|
|
type:this.data.type |
|
|
}).then(res => { |
|
|
}).then(res => { |
|
|
if (res.code == 1) { |
|
|
if (res.code == 1) { |
|
|
@ -270,9 +307,10 @@ delAll() { |
|
|
del(e) { |
|
|
del(e) { |
|
|
let item = e.currentTarget.dataset.item |
|
|
let item = e.currentTarget.dataset.item |
|
|
let gwcList = this.data.gwcList |
|
|
let gwcList = this.data.gwcList |
|
|
|
|
|
let valueNum = e.currentTarget.dataset.value |
|
|
commonApi.user_post("cart_within/update_sku", { |
|
|
commonApi.user_post("cart_within/update_sku", { |
|
|
num:item.num-1, |
|
|
num:item.num + valueNum, |
|
|
sku_id: item.sku_id, |
|
|
id: item.id, |
|
|
type:this.data.type |
|
|
type:this.data.type |
|
|
}).then(res => { |
|
|
}).then(res => { |
|
|
if (res.code == 1) { |
|
|
if (res.code == 1) { |
|
|
@ -295,6 +333,9 @@ del(e) { |
|
|
if (item.selected ==1) { |
|
|
if (item.selected ==1) { |
|
|
totalPrice += item.num*item.sku.price |
|
|
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) |
|
|
let status = res.data.every(el => el.selected === 1) |
|
|
@ -367,6 +408,9 @@ openPopup() { |
|
|
if (item.selected == 1) { |
|
|
if (item.selected == 1) { |
|
|
totalPrice += item.num*item.sku.price |
|
|
totalPrice += item.num*item.sku.price |
|
|
} |
|
|
} |
|
|
|
|
|
if (item.delivery_method === null) { |
|
|
|
|
|
item.delivery_method = item.sku.sku_model.use_type == 1?1:0 |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
// console.log(arr);
|
|
|
// console.log(arr);
|
|
|
// debugger
|
|
|
// debugger
|
|
|
@ -380,7 +424,8 @@ openPopup() { |
|
|
}, |
|
|
}, |
|
|
search() { |
|
|
search() { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
list:[] |
|
|
list:[], |
|
|
|
|
|
show:false |
|
|
}) |
|
|
}) |
|
|
this.getList() |
|
|
this.getList() |
|
|
}, |
|
|
}, |
|
|
@ -390,9 +435,6 @@ openPopup() { |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
getList() { |
|
|
getList() { |
|
|
this.setData({ |
|
|
|
|
|
show:false |
|
|
|
|
|
}) |
|
|
|
|
|
let list= this.data.list; |
|
|
let list= this.data.list; |
|
|
if (this.data.keywords == '' || this.data.keywords.indexOf(' ')!==-1) { |
|
|
if (this.data.keywords == '' || this.data.keywords.indexOf(' ')!==-1) { |
|
|
return |
|
|
return |
|
|
@ -445,6 +487,9 @@ openPopup() { |
|
|
}, |
|
|
}, |
|
|
// 添加产品弹窗 1.首先获取到该产品下的规格
|
|
|
// 添加产品弹窗 1.首先获取到该产品下的规格
|
|
|
addBuyCart(e) { |
|
|
addBuyCart(e) { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
user_type: null |
|
|
|
|
|
}) |
|
|
let item = e.currentTarget.dataset.item |
|
|
let item = e.currentTarget.dataset.item |
|
|
console.log(item); |
|
|
console.log(item); |
|
|
commonApi._post("product/get_product_detail", { |
|
|
commonApi._post("product/get_product_detail", { |
|
|
@ -501,9 +546,16 @@ openPopup() { |
|
|
selectSku: function (e) { |
|
|
selectSku: function (e) { |
|
|
let index = e.currentTarget.dataset.index; |
|
|
let index = e.currentTarget.dataset.index; |
|
|
this.setData({ |
|
|
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 () { |
|
|
hideSku: function () { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
|