Browse Source

商品详情页:分享优化

panyong 2 years ago
parent
commit
5793a1ca4d

+ 5 - 1
htmldev/cps/README.md

@@ -27,7 +27,11 @@ See [Configuration Reference](https://cli.vuejs.org/config/).
 - [x] 商家logo默认/选中2种状态
 - [ ] 测试省钱页跳转微信小程序
 - [x] 搜索页
-- [ ] 分享测试:默认、带有分享人信息、分享赚钱、商品列表及详情
+- [x] 分享测试:默认、带有分享人信息、分享赚钱、商品列表及详情
 - [x] 商品详情页:淘宝复制口令
 - [x] 底部导航:新增购物
 - [x] 不同商家返回的字段:目前发现拼多多的商品ID对不上
+- [ ] 分享赚钱:分享文案可以自定义
+- [ ] 店铺名字不存在
+- [ ] 淘宝分享落地页
+- [ ] 参照大淘生活新增页面:新手教程、意见反馈、常见问题

+ 1 - 1
htmldev/cps/src/App.vue

@@ -37,7 +37,7 @@ export default {
   watch: {
     '$route.name': {
       handler: function (newVal) {
-        const condition = ['PaymentCode', 'ShareMiddle', 'CategoryIndex', 'CategoryDetail', 'Search'].findIndex(item => item === newVal) === -1
+        const condition = ['PaymentCode', 'ShareMiddle', 'CategoryTBLandingPage'].findIndex(item => item === newVal) === -1
         if (!newVal) {
           return
         }

+ 9 - 0
htmldev/cps/src/router/index.js

@@ -165,6 +165,15 @@ const routes = [
           source: route.params.source,
           goodsId: route.params.goodsId
         })
+      },
+      {
+        path: '/tbLandingPage/:userId/:goodsId', // 淘宝商品详情页
+        name: 'CategoryTBLandingPage',
+        component: _import('views/category/tbLandingPage/index'),
+        props: (route) => ({
+          userId: route.params.userId,
+          goodsId: route.params.goodsId
+        })
       }
     ]
   },

+ 15 - 9
htmldev/cps/src/views/category/detail/index.vue

@@ -131,7 +131,8 @@ export default {
       couponInfo: {}, // 优惠券相关
       goodsCarouselPictures: [], // 商品轮播图
       goodsDetailPictures: [], // 商品详情图片
-      copyPopup: false // 淘口令复制提示
+      copyPopup: false, // 淘口令复制提示
+      isFetchLock: false // 是否调用过分享配置
     }
   },
   computed: {
@@ -154,7 +155,6 @@ export default {
       try {
         const { status, data, msg } = await apiGoodsDetail(this.source, this.goodsId)
         if (status) {
-          let coverImg = ''
           this.goodsInfo = data
           this.couponInfo = data.coupon_info
           if (Array.isArray(data.goods_carousel_pictures)) {
@@ -163,22 +163,28 @@ export default {
           if (Array.isArray(data.goods_detail_pictures)) {
             this.goodsDetailPictures = data.goods_detail_pictures
           }
-          if (this.goodsCarouselPictures.length) {
-            coverImg = this.goodsCarouselPictures[0]
-          } else if (this.goodsDetailPictures.length) {
-            coverImg = this.goodsDetailPictures[0]
-          }
-          platform.isWeixin && funWxShare('返不停', data.goods_name, coverImg, data.url)
         } else {
           Toast(msg)
         }
       } catch (e) {}
     },
     showShareTip () {
-      if (!(Object.keys(this.goodsInfo).length)) {
+      const id = this.$store.getters['common/userinfo'].id
+      let coverImg = ''
+      if (!(Object.keys(this.goodsInfo).length) || id === '') {
         Toast('数据加载中,稍后重试')
         return
       }
+      if (this.goodsCarouselPictures.length) {
+        coverImg = this.goodsCarouselPictures[0]
+      } else if (this.goodsDetailPictures.length) {
+        coverImg = this.goodsDetailPictures[0]
+      }
+      // 处理用户ID未获取成功的场景
+      if (!this.isFetchLock) {
+        platform.isWeixin && funWxShare('返不停', this.goodsInfo.goods_name, coverImg, this.source === 'taobao' ? `${location.origin}/tbLandingPage/${id}/${this.goodsId}` : this.goodsInfo.url)
+        this.isFetchLock = true
+      }
       this.$refs.fbtShareTipInWechat.init()
     },
     jumpShops () {

+ 3 - 2
htmldev/cps/src/views/category/index/child/main.vue

@@ -60,8 +60,9 @@
               <span>¥&nbsp;{{ item.commission }}</span>
             </p>
           </div>
-          <!--暂时不用这个字段-->
-          <div class="shop">
+          <div
+            class="shop"
+            v-if="item.shop_name">
             <van-icon
               size="20"
               name="shop-o"/>

+ 3 - 2
htmldev/cps/src/views/search/child/main.vue

@@ -60,8 +60,9 @@
               <span>¥&nbsp;{{ item.commission }}</span>
             </p>
           </div>
-          <!--暂时不用这个字段-->
-          <div class="shop">
+          <div
+            class="shop"
+            v-if="item.shop_name">
             <van-icon
               size="20"
               name="shop-o"/>