121 lines
2.3 KiB
JavaScript
121 lines
2.3 KiB
JavaScript
// user/couponList/couponList.js
|
|
const app = getApp();
|
|
const regeneratorRuntime = app.loadAsync()
|
|
const model = app.loadModel("index")
|
|
const http = app.loadHttp()
|
|
const util = app.loadUtils("util")
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
system: app.globalData.system, //设备相关信息
|
|
pageTitle: "优惠券", //头部标题
|
|
isBack: true,//显示返回
|
|
isLoading: true,//加载显示关闭
|
|
current: '1',//当前所在的标签的 key 值
|
|
couponList: [],//数据列表
|
|
},
|
|
|
|
// tab选中事件
|
|
handleChange({ detail }) {
|
|
this.setData({
|
|
current: detail.key,
|
|
couponList: []
|
|
});
|
|
this.getCouponList()
|
|
},
|
|
// 显示隐藏内容
|
|
isShow(e) {
|
|
let index = e.currentTarget.dataset.index
|
|
let list = this.data.couponList
|
|
list[index].show = !list[index].show
|
|
this.setData({
|
|
couponList: list
|
|
})
|
|
},
|
|
// 获取优惠券列表
|
|
async getCouponList() {
|
|
let res = await http.http.request2({ url: `${http.api.userCoupon}`, method: "POST", data: { status: this.data.current } })
|
|
let rel = res.data.data
|
|
if (rel.length > 0) {
|
|
rel.map((v, i) => {
|
|
rel[i].end_time = util.formatTime(v.end_time, 'Y-M-D h:m:s')
|
|
})
|
|
this.setData({
|
|
couponList: rel,
|
|
isLoading: false
|
|
})
|
|
} else {
|
|
this.setData({
|
|
couponList: [],
|
|
isLoading: false
|
|
})
|
|
}
|
|
},
|
|
// 跳转
|
|
goUrl(e) {
|
|
// let url = e.currentTarget.dataset.url
|
|
if (app.globalData.userInfo.group_type == 0) {
|
|
wx.navigateTo({
|
|
url: '/pages/laundry/laundry'
|
|
})
|
|
}
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.getCouponList()
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}) |