[本时生活小程序-线上备份]
This commit is contained in:
84
pages/classify/classify.js
Normal file
84
pages/classify/classify.js
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 本时生活
|
||||
*/
|
||||
|
||||
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"
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user