163 lines
3.5 KiB
JavaScript
163 lines
3.5 KiB
JavaScript
// pages/welfare/welfare.js
|
|
const app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
bgImg: app.globalData.bgImg,
|
|
packageId: 0,
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
if (options.id) {
|
|
//套餐券id进入
|
|
wx.showLoading({
|
|
title: '加载中..',
|
|
})
|
|
wx.request({
|
|
url: app.globalData.ip + '/wisdommining/api/user/getGoodsByPackage',
|
|
method: 'GET',
|
|
header: {
|
|
"content-type": "application/x-www-form-urlencoded",
|
|
},
|
|
data: {
|
|
packageId: options.id
|
|
},
|
|
success: res => {
|
|
console.log(res.data)
|
|
wx.hideLoading()
|
|
if (res.data.code == 1) {
|
|
this.setData({
|
|
dataList: res.data.value,
|
|
packageId: options.id
|
|
})
|
|
} else {
|
|
wx.showModal({
|
|
title: '提示!',
|
|
content: res.data.message,
|
|
showCancel: false,
|
|
})
|
|
}
|
|
}
|
|
})
|
|
wx.request({
|
|
url: app.globalData.ip + 'wisdommining/api/banner/getBanner?type=13',
|
|
method: 'GET',
|
|
header: {
|
|
"content-type": "application/x-www-form-urlencoded",
|
|
},
|
|
success: res => {
|
|
console.log(res.data)
|
|
wx.hideLoading()
|
|
if (res.data.code == 1) {
|
|
// console.log(res.data.value[0].bannerImage)
|
|
this.setData({
|
|
topImg: res.data.value[0].bannerImage
|
|
})
|
|
} else {
|
|
wx.showModal({
|
|
title: '提示!',
|
|
content: res.data.message,
|
|
showCancel: false,
|
|
})
|
|
}
|
|
}
|
|
})
|
|
} else {
|
|
//首页进入
|
|
wx.showLoading({
|
|
title: '加载中..',
|
|
})
|
|
wx.request({
|
|
url: app.globalData.ip + '/wisdommining/api/goods/getPackageGoods',
|
|
method: 'GET',
|
|
header: {
|
|
"content-type": "application/x-www-form-urlencoded",
|
|
},
|
|
data: {
|
|
userId: app.globalData.userId,
|
|
},
|
|
success: res => {
|
|
console.log(res.data)
|
|
wx.hideLoading()
|
|
if (res.data.code == 1) {
|
|
this.setData({
|
|
dataList: res.data.value == null ? [] : res.data.value,
|
|
})
|
|
} else {
|
|
wx.showModal({
|
|
title: '提示!',
|
|
content: res.data.message,
|
|
showCancel: false,
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
},
|
|
|
|
details(e) {
|
|
let id = e.currentTarget.dataset.id;
|
|
console.log(id);
|
|
if (this.data.packageId == 0) {
|
|
//首页进入
|
|
wx.navigateTo({
|
|
url: '/pages/welfare/goodsDetails/goodsDetails?goodsId=' + id
|
|
})
|
|
} else {
|
|
// 套餐券进入
|
|
wx.navigateTo({
|
|
url: '/pages/welfare/goodsDetails/goodsDetails?goodsId=' + id + '&packageId=' + this.data.packageId,
|
|
})
|
|
}
|
|
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
}) |