// pages/userGoods/goodsDet/goodsDet.js Page({ /** * 页面的初始数据 */ data: { isUser : false, //用户登录状态 qrcode : '', //二维码 userInfo : '', //我的信息 current : 1, //产品轮播index rightId : '', //产品id parentId : '', //分享人id productData : '', //详情数据 productStores : [], //门店列表 productContent : '', //图文详情 canShare : '' //分享按钮状态 }, /** * 生命周期函数--监听页面加载 */ onLoad (options) { if(options.type){ getApp().globalData.shareObj = { type : options.type, goodsId : options.rightid, userId : options.parent_id } } this.setData({ rightId : options.rightid }) }, onShow(){ // 获取产品详情 this.goodsShow(); this.setData({ isUser : getApp().globalData.isUser }) }, // 商品轮播 swiperChange(e) { this.setData({ current: e.detail.current + 1 }) }, /** * 产品详情 */ 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" }) } } })