Commit 4e6e0c85 by 高淑倩

add: 商品详情添加购物车

parent 4e7d4871
......@@ -171,6 +171,12 @@ Component({
}
}
this.triggerEvent('skuselect', {
skuId: this.data.skuId,
count: this.data.proNum,
})
// this.triggerEvent('skuselect', {
// selectSku: this.data.curSku,
// counts: this.data.proNum,
......
......@@ -9,18 +9,18 @@ wxService.page({
* 页面的初始数据
*/
data: {
productId:'',
productId: '',
scrollTips: '继续拖动,查看图文详情', // 滑动文案
productInfo:'',
productInfo: '',
showHtml: false,
reachBottom: false, // 标识是否触底
showSkuPopup: false,
btnText: '确定',
baseImgUrl: app.globalData.imageUrl,
swiperCurrent: 0,
selectSkuName:'',
openPlusStatus:false,
memberLevel:false,
selectSkuName: '',
openPlusStatus: false,
memberLevel: false,
showCardModal: false,
currentShareContent: null
},
......@@ -29,7 +29,7 @@ wxService.page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (options && options.productId){
if (options && options.productId) {
this.setData({
productId: options.productId
})
......@@ -57,7 +57,7 @@ wxService.page({
showSkuPopupType: 'buy'
})
},
// 分享
onTapShare() {
let content = {
......@@ -101,7 +101,7 @@ wxService.page({
},
//获取商品详情
getProInfo(){
getProInfo() {
wx.showLoading({
title: '加载中'
})
......@@ -119,7 +119,7 @@ wxService.page({
},
// 获取会员等级开关
getMemberLevel(){
getMemberLevel() {
wxService.get(`/merchant/brandSwitchSetting/getOpenStatus?businessType=2`).then(res => {
const { result, data } = res.data
if (result == 0) {
......@@ -133,12 +133,12 @@ wxService.page({
},
// 获取plus会员开关
getOpenStatus(){
getOpenStatus() {
wxService.get(`/merchant/brandSwitchSetting/getOpenStatus?businessType=3`).then(res => {
const { result, data } = res.data
if (result == 0) {
this.setData({
openPlusStatus:data
openPlusStatus: data
})
}
}).finally(() => {
......@@ -227,10 +227,16 @@ wxService.page({
}).exec()
},
confirmClick(event){
console.log('confirmClick',event)
confirmClick(event) {
const { skuId, count } = event.detail
console.log('父组件', skuId, count)
const trolleySku = {
count,
skuId
}
var selectSkuName = []
for (let i in event.detail.selectSku){
for (let i in event.detail.selectSku) {
selectSkuName.push(event.detail.selectSku[i].name)
}
var selectSkuStr = selectSkuName.join(',')
......@@ -240,13 +246,35 @@ wxService.page({
if (this.data.showSkuPopupType == 'cart') {
// 加入购物车
this.getPutCart(trolleySku)
} 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 @@
"id": 16,
"name": "商品详情页",
"pathName": "pages/productDetail/productDetail",
"query": "productId=1008190",
"query": "productId=1000704",
"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