/* * 本时生活 */ 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) this.setData({ isUser : getApp().globalData.isUser }) }, /** * 生命周期函数--监听页面显示 */ 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(/\{ 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 if(this.data.isUser){ 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}` }); }).catch(err => {}); } else { // 跳转权益详情页 wx.navigateTo({ url: '/pages/rights/rights?rightsId=' + newid }) } }else{ // 去登录 wx.navigateTo({ url: "/pages/login/login" }) } } })