Files
sphc/pages/welfare/welfare.js

163 lines
3.5 KiB
JavaScript
Raw Normal View History

2024-05-06 15:34:15 +08:00
// pages/welfare/welfare.js
const app = getApp();
Page({
2024-06-05 17:18:02 +08:00
/**
* 页面的初始数据
*/
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
2024-05-06 15:34:15 +08:00
})
2024-06-05 17:18:02 +08:00
} else {
wx.showModal({
title: '提示!',
content: res.data.message,
showCancel: false,
2024-05-06 15:34:15 +08:00
})
2024-06-05 17:18:02 +08:00
}
}
})
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
2024-05-06 15:34:15 +08:00
})
2024-06-05 17:18:02 +08:00
} else {
wx.showModal({
title: '提示!',
content: res.data.message,
showCancel: false,
2024-05-06 15:34:15 +08:00
})
2024-06-05 17:18:02 +08:00
}
2024-05-06 15:34:15 +08:00
}
2024-06-05 17:18:02 +08:00
})
} 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,
2024-05-06 15:34:15 +08:00
})
2024-06-05 17:18:02 +08:00
} else {
wx.showModal({
title: '提示!',
content: res.data.message,
showCancel: false,
2024-05-06 15:34:15 +08:00
})
2024-06-05 17:18:02 +08:00
}
2024-05-06 15:34:15 +08:00
}
2024-06-05 17:18:02 +08:00
})
}
},
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,
})
}
2024-05-06 15:34:15 +08:00
2024-06-05 17:18:02 +08:00
},
2024-05-06 15:34:15 +08:00
2024-06-05 17:18:02 +08:00
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
2024-05-06 15:34:15 +08:00
2024-06-05 17:18:02 +08:00
},
2024-05-06 15:34:15 +08:00
2024-06-05 17:18:02 +08:00
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
2024-05-06 15:34:15 +08:00
2024-06-05 17:18:02 +08:00
},
2024-05-06 15:34:15 +08:00
2024-06-05 17:18:02 +08:00
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
2024-05-06 15:34:15 +08:00
2024-06-05 17:18:02 +08:00
},
2024-05-06 15:34:15 +08:00
2024-06-05 17:18:02 +08:00
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
2024-05-06 15:34:15 +08:00
2024-06-05 17:18:02 +08:00
},
2024-05-06 15:34:15 +08:00
2024-06-05 17:18:02 +08:00
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
2024-05-06 15:34:15 +08:00
2024-06-05 17:18:02 +08:00
},
2024-05-06 15:34:15 +08:00
2024-06-05 17:18:02 +08:00
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
2024-05-06 15:34:15 +08:00
2024-06-05 17:18:02 +08:00
},
2024-05-06 15:34:15 +08:00
})