Initial Commit
This commit is contained in:
141
pages/welfare/goodsDetails/goodsDetails.js
Normal file
141
pages/welfare/goodsDetails/goodsDetails.js
Normal file
@ -0,0 +1,141 @@
|
||||
// pages/goodsDetails/goodsDetails.js
|
||||
const app = getApp()
|
||||
const WxParse = require('../../../wxParse/wxParse.js');
|
||||
Page({
|
||||
|
||||
data: {
|
||||
ip: app.globalData.ipUrl,
|
||||
contents: '',//富文本
|
||||
standardNum: 1,//商品数量
|
||||
minusStatus: 'disabled',
|
||||
goodsList: [],
|
||||
bnrUrl: [],//轮播图
|
||||
carNum: 1,//购物车数量
|
||||
specsIndex: 0,//选择规格
|
||||
specs: '',//规格
|
||||
pay: false,
|
||||
packageId: 0,
|
||||
},
|
||||
// 页面加载时
|
||||
onLoad: function (options) {
|
||||
console.log(options.goodsId)
|
||||
this.setData({
|
||||
goodsId: options.goodsId,
|
||||
})
|
||||
if (options.packageId) {
|
||||
this.setData({
|
||||
packageId: options.packageId,
|
||||
pay: true,
|
||||
})
|
||||
} else {
|
||||
//根据套餐商品获取套餐卷
|
||||
wx.request({
|
||||
url: app.globalData.ip + '/wisdommining/api/goods/getPackage',
|
||||
method: 'GET',
|
||||
header: {
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
data: {
|
||||
goodsId: this.data.goodsId,
|
||||
userId: app.globalData.userId,
|
||||
},
|
||||
success: res => {
|
||||
wx.hideLoading();
|
||||
console.log(res)
|
||||
if (res.data.code == 1) {
|
||||
let goods = res.data.value;
|
||||
if (goods == null) {
|
||||
this.setData({
|
||||
pay: false,
|
||||
})
|
||||
console.log('nullllllll')
|
||||
} else {
|
||||
this.setData({
|
||||
packageId: goods[0].id,
|
||||
pay: true,
|
||||
})
|
||||
console.log('trueeeeee')
|
||||
}
|
||||
} else {
|
||||
wx.showModal({
|
||||
title: '提示!',
|
||||
content: res.data.message,
|
||||
showCancel: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
this.goodDtail()
|
||||
},
|
||||
|
||||
// 商品详情
|
||||
goodDtail() {
|
||||
wx.showLoading({
|
||||
title: '加载中',
|
||||
})
|
||||
wx.request({
|
||||
url: app.globalData.ip + '/wisdommining/api/user/getPackageGoods',
|
||||
method: 'GET',
|
||||
header: {
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
data: {
|
||||
goodsId: this.data.goodsId
|
||||
},
|
||||
success: res => {
|
||||
wx.hideLoading();
|
||||
console.log(res)
|
||||
if (res.data.code == 1) {
|
||||
let goods = res.data.value;
|
||||
WxParse.wxParse('contents', 'html', goods.goodsInfo, this, 20);
|
||||
this.setData({
|
||||
goodsList: goods,
|
||||
bnrUrl: goods.goodsBanner.split(',')
|
||||
})
|
||||
} else {
|
||||
wx.showModal({
|
||||
title: '提示!',
|
||||
content: res.data.message,
|
||||
showCancel: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
// 轮播
|
||||
onSlideChange(e) {
|
||||
this.setData({
|
||||
lunboindex: e.detail.current + 1
|
||||
})
|
||||
},
|
||||
//点击显示底部弹窗
|
||||
choose: function (e) {
|
||||
if (!this.data.pay) {
|
||||
wx.showToast({
|
||||
title: '无此商品套餐券,无法兑换',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
let goodsList = this.data.goodsList
|
||||
let goods = [{
|
||||
goodsPhoto: goodsList.goodsPhoto,
|
||||
goodsName: goodsList.goodsName,
|
||||
goodsId: goodsList.id,
|
||||
num: this.data.standardNum
|
||||
}]
|
||||
wx.navigateTo({
|
||||
url: '/pages/welfare/cartPay/cartPay?goods=' + JSON.stringify(goods) + '&packageId=' + this.data.packageId,
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
Reference in New Issue
Block a user