108 lines
2.8 KiB
JavaScript
108 lines
2.8 KiB
JavaScript
/*
|
|
* 本时生活
|
|
*/
|
|
|
|
const app = getApp()
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
noticeData : '', //公告
|
|
infoData : '', //权益数据
|
|
content : '', //内容简介
|
|
noticeShow : '', //公告开关
|
|
infoItems : [], //卡券专区
|
|
id : '',
|
|
areaname : '',
|
|
latitude : '',
|
|
userlng : ''
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad (options) {
|
|
this.setData({
|
|
id : options.id,
|
|
areaname : options.areaname,
|
|
latitude : options.latitude,
|
|
userlng : options.userlng
|
|
})
|
|
|
|
this.indexNav(options.id,options.areaname,options.latitude,options.userlng)
|
|
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 卡权益分类
|
|
*/
|
|
indexNav(id, areaname,latitude,userlng) {
|
|
wx.$api.index.classify(id, areaname,latitude,userlng).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 newid = e.currentTarget.dataset.id,
|
|
canFrom = e.currentTarget.dataset.from
|
|
wx.getStorage({
|
|
key : 'token',
|
|
success:res=>{
|
|
if(canFrom == 'washcar') {
|
|
wx.$api.index.washcarUrl('', newid).then(res=>{
|
|
const newUrl = res.data
|
|
let url= encodeURIComponent(newUrl)
|
|
wx.redirectTo({
|
|
// 跳转到webview页面
|
|
url: `/pages/washcar/washcar?url=${url}`
|
|
});
|
|
})
|
|
} else {
|
|
// 跳转权益详情页
|
|
wx.navigateTo({
|
|
url: '/pages/rights/rights?rightsId=' + newid
|
|
})
|
|
}
|
|
},
|
|
fail: (err) => {
|
|
wx.navigateTo({
|
|
url: "/pages/login/login"
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}) |