From 8680ee31c612af9bea67ca2d2ae70dfb7d93d22b Mon Sep 17 00:00:00 2001
From: huzhiming <zhiming.hu@yoho.cn>
Date: Mon, 11 Nov 2019 16:59:48 +0800
Subject: [PATCH] feat(商品详情): 添加初稿闲鱼分享代码

---
 apps/common/xianyu.js                 | 22 ++++++++++------------
 apps/pages/product/product-detail.vue | 19 ++++++++++++++++++-
 apps/pages/zhiming/index.js           |  2 +-
 apps/pages/zhiming/xianyu-js-sdk.vue  | 21 ++++++++++++++++++---
 4 files changed, 47 insertions(+), 17 deletions(-)

diff --git a/apps/common/xianyu.js b/apps/common/xianyu.js
index 3bd2779..f87903a 100644
--- a/apps/common/xianyu.js
+++ b/apps/common/xianyu.js
@@ -30,14 +30,15 @@ const xianyu = {
    * @ date: 2019-11-05 11:54:24
    * @ version: V1.0.5
   */
-  setNavigatorRightItem() {
-    window._xianyuShare = () =>{
-      this.setXianyuShare();
+  setNavigatorRightItem (shareParam = null) {
+    window._xianyuShare = () => {
+      this.setXianyuShare(shareParam);
     }
     if (this.isAliApp && window.WindVane) {
       return new Promise((resolve, reject) => {
         window.WindVane.call('WVIdleFishApi', 'setNavigatorRightItem', {
-          title: '∙∙∙', // 按钮名称 func:'test' //点击调用函数
+          // title: '∙∙∙', // 按钮名称 func:'test' //点击调用函数
+          title: '分享', // 按钮名称 func:'test' //点击调用函数
           func: '_xianyuShare' // func: 'test' //点击调用函数 注意调用的函数必须挂载在window上
         }, function(data) {
           resolve(data);
@@ -59,14 +60,11 @@ const xianyu = {
     // image: 'http://gw.alicdn.com/tps/i1/TB1Nep5FVXXXXXDaXXXE799_VXX-800-800.jpg',
     // url: 'http://h5.xianyu.tb.cn/xianyu/maishen.html?wxIsAvailable', // 分享链接
     // link: 'http://h5.xianyu.tb.cn/xianyu/maishen.html?wxIsAvailable', // 和url保持
-    image: 'http://img11.static.yhbimg.com/goodsimg/2018/12/24/17/01070adae9791c70ed02593550437cf30e.jpg?imageMogr2/thumbnail/600x600/background/d2hpdGU=/position/center/quality/80',
-    url: 'http://xianyu.yohobuy.com/xianyu/product/10014937.html?wxIsAvailable', // 分享链接
-    link: 'http://xianyu.yohobuy.com/xianyu/product/10014937.html?wxIsAvailable', // 和url保持
-    // image: 'http://img11.static.yhbimg.com/goodsimg/2019/07/15/10/01ed8e7b5051c543f7a15c06e1efa8e211.jpg?imageMogr2/thumbnail/600x600/background/d2hpdGU=/position/center/quality/80',
-    // url: 'http://xianyu.yohobuy.com/xianyu/product/10014937.html?wxIsAvailable', // 分享链接
-    // link: 'http://xianyu.yohobuy.com/xianyu/product/10014937.html?wxIsAvailable', // 和url保持
-    title: '下载闲鱼App', // 分享标题
-    text: '你可记得家里堆积的闲置物,你可知他们正在黯然神伤。让他们来闲鱼卖身吧,即可' // 分享描述
+    image: '//img11.static.yhbimg.com/goodsimg/2018/12/24/17/01070adae9791c70ed02593550437cf30e.jpg?imageMogr2/thumbnail/600x600/background/d2hpdGU=/position/center/quality/80',
+    url: '//xianyu.yohobuy.com/xianyu/index/channel?wxIsAvailable', // 分享链接
+    link: '//xianyu.yohobuy.com/xianyu/index/channel?wxIsAvailable', // 和url保持
+    title: '闲鱼潮品首页', // 分享标题
+    text: '你可记得家里堆积的闲置物,你可知他们正在黯然神伤。让他们来闲鱼卖身吧' // 分享描述
   }) {
     if (this.isAliApp && window.WindVane) {
       window.WindVane.call('WVIdleFishApi', 'showShareMenu', param, (data) => {
diff --git a/apps/pages/product/product-detail.vue b/apps/pages/product/product-detail.vue
index 0fdf0c6..697a632 100644
--- a/apps/pages/product/product-detail.vue
+++ b/apps/pages/product/product-detail.vue
@@ -16,7 +16,7 @@
             </cube-slide-item>
             <template slot="dots" slot-scope="props">
               <div class="dot-wrap">
-                <span class="cube-dot" :class="{active: props.current === index}" v-for="(item, index) in props.dots">&bull;</span>
+                <span class="cube-dot" :class="{active: props.current === index}" v-for="(item, index) in props.dots" :key="item">&bull;</span>
               </div>
             </template>
           </cube-slide>
@@ -212,6 +212,23 @@ export default {
         }
       }));
     });
+
+    /*
+     * @ description: 打开闲鱼导航栏右上角分享按钮,并配置分享信息
+     * @ author: huzhiming
+     * @ date: 2019-11-11 15:20:38
+     * @ version: V1.0.5
+    */
+    this.$nextTick(async () => {
+      await this.$xianyu.setNavigatorRightItem({
+        shareType: 'activity', // 类型,默认activity
+        image: this.sizeImg(this.imageList[0].image_url,200,200),
+        url: location.href, // 分享链接
+        link: location.href, // 和url保持
+        title: this.productDetail.product_name, // 分享标题
+        text: '你可记得家里堆积的闲置物,你可知他们正在黯然神伤。让他们来闲鱼卖身吧,即可' // 分享描述
+      });
+    })
   },
   beforeDestroy() {
     if (this.watchList) {
diff --git a/apps/pages/zhiming/index.js b/apps/pages/zhiming/index.js
index bd0cfff..c4b5731 100644
--- a/apps/pages/zhiming/index.js
+++ b/apps/pages/zhiming/index.js
@@ -1,5 +1,5 @@
 export default [{
   name: 'zhiming',
   path: '/xianyu/zhiming',
-  component: () => import(/* webpackChunkName: "list" */ './xianyu-js-sdk.vue')
+  component: () => import(/* webpackChunkName: "zhiming" */ './xianyu-js-sdk.vue')
 }];
diff --git a/apps/pages/zhiming/xianyu-js-sdk.vue b/apps/pages/zhiming/xianyu-js-sdk.vue
index 0f7b433..09e65f4 100644
--- a/apps/pages/zhiming/xianyu-js-sdk.vue
+++ b/apps/pages/zhiming/xianyu-js-sdk.vue
@@ -13,10 +13,13 @@
     <ul>
       <li @click="share()">点击拉出分享弹窗</li>
     </ul>
+    {{ searchWord }}
   </div>
 </template>
 
 <script>
+import { createNamespacedHelpers } from 'vuex'
+const { mapState, mapActions } = createNamespacedHelpers('list')
 export default {
   // head() {
   //   return {
@@ -26,18 +29,25 @@ export default {
   //     // script: [{ src: '' }]
   //   }
   // },
+  asyncData({store, router}) {
+    return store.dispatch('list/fetchSearchWords');
+  },
   props: {},
   data() {
     return {}
   },
   created() {},
   mounted() {
+    // this.fetchSearchWords()
     this.$nextTick(async ()=>{
       await this.$xianyu.setNavigatorRightItem();
     })
   },
   destroyed() {},
   methods: {
+    ...mapActions([
+      'fetchSearchWords'
+    ]),
     share() {
       this.$xianyu.setXianyuShare({
         shareType: 'activity', // 类型,默认activity
@@ -49,7 +59,12 @@ export default {
       })
     }
   },
-  computed: {},
+  computed: {
+    ...mapState([
+      'filterVisible',
+      'searchWord'
+    ])
+  },
   watch: {},
   components: {}
 };
@@ -57,6 +72,6 @@ export default {
 
 /* 定义局部样式,添加外围容器,scss嵌套尽量不要超过三层,会影响查找器性能 */
 <style rel='stylesheet/scss' lang='scss' scoped>
-.xianyu-js-sdk-wrap {}
-//@import "./style.scss";
+// .xianyu-js-sdk-wrap {}
+// @import "./style.scss";
 </style>
--
libgit2 0.24.0