Files
cardsystem/pages/classify/classify.js
2021-05-21 15:02:18 +08:00

84 lines
1.8 KiB
JavaScript

/*
* 本时生活
*/
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
noticeData : '', //公告
infoData : '', //权益数据
content : '', //内容简介
noticeShow : '', //公告开关
infoItems : [], //卡券专区
},
/**
* 生命周期函数--监听页面加载
*/
onLoad (options) {
this.indexNav(options.id)
},
/**
* 生命周期函数--监听页面显示
*/
onShow () {
},
/**
* 卡权益分类
*/
indexNav(id) {
wx.$api.index.classify(id).then(res=>{
this.setData({
noticeData : res.data.notice,
infoData : res.data.info,
infoItems : res.data.items,
content : res.data.info.content.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"'),
})
}).catch(err=>{
if(!err.login){
// 写入缓存
wx.setStorage({
key : 'token',
data : ''
})
}
})
},
/**
* 须知展开收起状态
*/
noticeTap() {
this.setData({
noticeShow : !this.data.noticeShow
})
},
/**
* 处理未登录时的转跳
*/
userNav(e){
let id = e.currentTarget.dataset.id
wx.getStorage({
key : 'token',
success:res=>{
wx.navigateTo({
url: '/pages/rights/rights?rightsId=' + id
})
},
fail: (err) => {
wx.navigateTo({
url: "/pages/login/login"
})
}
})
}
})