Commit 4e6e0c85 by 高淑倩

add: 商品详情添加购物车

parent 4e7d4871
...@@ -171,6 +171,12 @@ Component({ ...@@ -171,6 +171,12 @@ Component({
} }
} }
this.triggerEvent('skuselect', {
skuId: this.data.skuId,
count: this.data.proNum,
})
// this.triggerEvent('skuselect', { // this.triggerEvent('skuselect', {
// selectSku: this.data.curSku, // selectSku: this.data.curSku,
// counts: this.data.proNum, // counts: this.data.proNum,
......
...@@ -9,18 +9,18 @@ wxService.page({ ...@@ -9,18 +9,18 @@ wxService.page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
productId:'', productId: '',
scrollTips: '继续拖动,查看图文详情', // 滑动文案 scrollTips: '继续拖动,查看图文详情', // 滑动文案
productInfo:'', productInfo: '',
showHtml: false, showHtml: false,
reachBottom: false, // 标识是否触底 reachBottom: false, // 标识是否触底
showSkuPopup: false, showSkuPopup: false,
btnText: '确定', btnText: '确定',
baseImgUrl: app.globalData.imageUrl, baseImgUrl: app.globalData.imageUrl,
swiperCurrent: 0, swiperCurrent: 0,
selectSkuName:'', selectSkuName: '',
openPlusStatus:false, openPlusStatus: false,
memberLevel:false, memberLevel: false,
showCardModal: false, showCardModal: false,
currentShareContent: null currentShareContent: null
}, },
...@@ -29,7 +29,7 @@ wxService.page({ ...@@ -29,7 +29,7 @@ wxService.page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
if (options && options.productId){ if (options && options.productId) {
this.setData({ this.setData({
productId: options.productId productId: options.productId
}) })
...@@ -101,7 +101,7 @@ wxService.page({ ...@@ -101,7 +101,7 @@ wxService.page({
}, },
//获取商品详情 //获取商品详情
getProInfo(){ getProInfo() {
wx.showLoading({ wx.showLoading({
title: '加载中' title: '加载中'
}) })
...@@ -119,7 +119,7 @@ wxService.page({ ...@@ -119,7 +119,7 @@ wxService.page({
}, },
// 获取会员等级开关 // 获取会员等级开关
getMemberLevel(){ getMemberLevel() {
wxService.get(`/merchant/brandSwitchSetting/getOpenStatus?businessType=2`).then(res => { wxService.get(`/merchant/brandSwitchSetting/getOpenStatus?businessType=2`).then(res => {
const { result, data } = res.data const { result, data } = res.data
if (result == 0) { if (result == 0) {
...@@ -133,12 +133,12 @@ wxService.page({ ...@@ -133,12 +133,12 @@ wxService.page({
}, },
// 获取plus会员开关 // 获取plus会员开关
getOpenStatus(){ getOpenStatus() {
wxService.get(`/merchant/brandSwitchSetting/getOpenStatus?businessType=3`).then(res => { wxService.get(`/merchant/brandSwitchSetting/getOpenStatus?businessType=3`).then(res => {
const { result, data } = res.data const { result, data } = res.data
if (result == 0) { if (result == 0) {
this.setData({ this.setData({
openPlusStatus:data openPlusStatus: data
}) })
} }
}).finally(() => { }).finally(() => {
...@@ -227,10 +227,16 @@ wxService.page({ ...@@ -227,10 +227,16 @@ wxService.page({
}).exec() }).exec()
}, },
confirmClick(event){ confirmClick(event) {
console.log('confirmClick',event) const { skuId, count } = event.detail
console.log('父组件', skuId, count)
const trolleySku = {
count,
skuId
}
var selectSkuName = [] var selectSkuName = []
for (let i in event.detail.selectSku){ for (let i in event.detail.selectSku) {
selectSkuName.push(event.detail.selectSku[i].name) selectSkuName.push(event.detail.selectSku[i].name)
} }
var selectSkuStr = selectSkuName.join(',') var selectSkuStr = selectSkuName.join(',')
...@@ -240,13 +246,35 @@ wxService.page({ ...@@ -240,13 +246,35 @@ wxService.page({
if (this.data.showSkuPopupType == 'cart') { if (this.data.showSkuPopupType == 'cart') {
// 加入购物车 // 加入购物车
this.getPutCart(trolleySku)
} else if (this.data.showSkuPopupType == 'buy') { } else if (this.data.showSkuPopupType == 'buy') {
// 下单页面 // 下单页面
console.log('buy')
} }
}, },
// put 购物车
getPutCart(trolleySku) {
wx.showLoading({
title: '加载中',
mask: true
})
wxService.post('/sale/trolley/put', trolleySku).then(res => {
if (res) {
const { result } = res.data
if (result == 0) {
// 关闭弹框
this.setData({
showSkuPopup: false
})
wx.hideLoading()
wx.showToast({
title: '添加成功,在购物车等亲~',
icon: 'none'
})
}
}
})
},
/** /**
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
......
...@@ -144,7 +144,7 @@ ...@@ -144,7 +144,7 @@
"id": 16, "id": 16,
"name": "商品详情页", "name": "商品详情页",
"pathName": "pages/productDetail/productDetail", "pathName": "pages/productDetail/productDetail",
"query": "productId=1008190", "query": "productId=1000704",
"scene": null "scene": null
}, },
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment