// pages/userGoods/goodsDet/goodsDet.js Page({ /** * 页面的初始数据 */ data: { isUser : false, //用户登录状态 qrcode : '', //二维码 userInfo : '', //我的信息 current : 0, //产品轮播index rightId : '', //产品id parentId : '', //分享人id productData : '', //详情数据 productStores : [], //门店列表 productContent : '', //图文详情 canShare : '' //分享按钮状态 }, /** * 生命周期函数--监听页面加载 */ onLoad (options) { // 判断是否由分享进入 if(options.type == "share"){ this.setData({ parentId: options.parent_id }) // 写入缓存 wx.setStorage({ key : 'parentId', data : options.parent_id }) this.setData({ rightId : options.rightid }) } this.setData({ rightId : options.rightid }) }, onShow(){ // 获取产品详情 this.goodsShow(); this.setData({ isUser : getApp().globalData.isUser }) }, /** * 产品详情 */ goodsShow(){ wx.$api.user.productInfo(this.data.rightId).then(res=>{ this.setData({ canShare : res.data.canShare, productData : res.data.info, productStores : res.data.stores, productContent: res.data.info.share.content.replace(/\{ if(!err.login){ // 写入缓存 wx.setStorage({ key : 'token', data : '' }) } }) }, /** * 处理未登录时的转跳 */ userNav(e){ let pageUrl = e.currentTarget.dataset.url if(this.data.isUser){ wx.navigateTo({ url: pageUrl }) }else{ // 去登录 wx.navigateTo({ url: "/pages/login/login?way=shareLogin" }) } } })