diff --git a/pages/seller/index.js b/pages/seller/index.js index c5f37c8..740514f 100644 --- a/pages/seller/index.js +++ b/pages/seller/index.js @@ -3276,6 +3276,34 @@ Page({ }) }, + // 跳转到商品详情页面 + showGoodsDetail: function (e) { + // 检查用户是否登录 + const openid = wx.getStorageSync('openid'); + const userId = wx.getStorageSync('userId'); + + if (!openid || !userId) { + console.log('用户未登录,显示登录提示和弹窗'); + // 提示登录后才可查看详情 + wx.showToast({ + title: '登录后才可查看详情', + icon: 'none', + duration: 1500 + }); + // 显示登录弹窗 + setTimeout(() => { + this.showOneKeyLogin(); + }); + return; + } + + const goodsItem = e.currentTarget.dataset.item; + // 跳转到商品详情页面,并传递商品数据,使用encodeURIComponent编码JSON字符串 + wx.navigateTo({ + url: '/pages/goods-detail/goods-detail?goodsData=' + encodeURIComponent(JSON.stringify(goodsItem)) + }); + }, + // 关闭图片预览 closeImagePreview() { this.setData({ diff --git a/pages/seller/index.wxml b/pages/seller/index.wxml index 124e0c2..48419aa 100644 --- a/pages/seller/index.wxml +++ b/pages/seller/index.wxml @@ -85,7 +85,7 @@ - + {{item.name}} 已上架 @@ -196,7 +196,7 @@ - + {{item.name}} 审核中 @@ -297,7 +297,7 @@ - + {{item.name}} 审核失败