// pages/myMembershipCard/index.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { unfoldIndex: 1, cards: [], showCardMask: false, venues: {}, isShowNewplot: false }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { this.getData(); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { return { title: '智慧云馆' } }, // 展开Cell unfoldCell(e) { let index = e.currentTarget.dataset.index; if (this.data.unfoldIndex == index) { this.setData({ unfoldIndex: '' }) } else { this.setData({ unfoldIndex: index }) } }, // 选择默认 selectDefault(e) { let cardFlg = e.currentTarget.dataset.cardflg; let id = e.currentTarget.dataset.id; if (cardFlg == 0) { app.$api.memberVenueUpdateCard({ cardId: id }).then(res => { this.getData(); }) } }, // 获取数据 getData() { wx.showLoading({ title: '加载中...', mask: true, }) app.$api.memberVenueCard({}).then(res => { let list = []; for (let i = 0; i < res.cards.length; i++) { let card = res.cards[i]; for (let j = 0; j < card.memberCards.length; j++) { card.memberCards[j].startTime = card.memberCards[j].startTime.split(' ')[0]; card.memberCards[j].endTime = card.memberCards[j].endTime.split(' ')[0]; } list.push(card); } this.setData({ cards: list, isShowNewplot: true }) }, err => { this.setData({ isShowNewplot: true }) }); }, // 关闭 cancelCardMask() { this.setData({ showCardMask: false }) }, // 开启会员卡提示 showCardContent(e) { this.setData({ showCardMask: true, venues: this.data.cards[e.currentTarget.dataset.index] }) }, })