How to use Baidu to share each item in the vue loop list?

problem description

the use of Baidu sharing in the vue cycle is not successful. If there is no wrong message, how to deal with it? In addition, is there something wrong with Baidu sharing? Click
http://share.baidu.com/ to intermittently jump to https:. / / www.baidu.com/search/. !

related codes

</a>
            </div>
        </div>
    </div>
</div>
methods: {
    getProducts() {},
    handleShare(productId, productTitle, productImage) {
      const that = this;
      //   that.shareConfig.shareurl = `${process.env.VUE_APP_HOST}product/detail?id${productId}`;
      that.shareConfig.shareurl = "http://www.baidu.com";
      that.shareConfig.sharetitle = productTitle;
      that.shareConfig.sharedesc = "9999";
      that.shareConfig.sharepic = productImage;
    },
    setShareConfig(cmd, config) {
      if (this.shareConfig.shareurl) {
        config.bdUrl = this.shareConfig.shareurl;
      }
      if (this.shareConfig.sharetitle) {
        config.bdText = this.shareConfig.sharetitle;
      }
      console.log(config);
      return config;
    },
  },

mounted() {
    const that = this;
    that.getProducts();
    that.$nextTick(() => {
      window._bd_share_config = {
        common: {
          onBeforeClick: that.setShareConfig,
        },
        share: {},
        image: {
          viewList: ["qzone", "tsina", "tqq", "renren", "weixin"],
          viewText: ":",
          viewSize: "16",
        },
        selectShare: {
          bdContainerClass: null,
          bdSelectMiniList: ["qzone", "tsina", "tqq", "renren", "weixin"],
        },
      };
      const s = document.createElement("script");
      s.type = "text/javascript";
      s.src = `http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=${~(-new Date() / 36e5)}`;
      document.body.appendChild(s);
    });
  },

what result do you expect? What is the error message actually seen?

Weibo icon, qq icon, etc. related to sharing can be called up, but there is no response when clicked?


does not see the call to handleShare, and the error message is that shareurl is not set. It feels like you deleted something behind onBeforeClick. The example doesn't run.


// 
    socialShare(type, productId, title, description, image) {
      let shareUrl = '';

      let port = `:${process.env.VUE_APP_PORT}`;
      if (process.env.VUE_APP_PORT === '' || process.env.VUE_APP_PORT === 80 || process.env.VUE_APP_PORT === '80') {
        port = '';
      }
      let urlMode = '';
      if (this.$router.mode === 'hash') {
        urlMode = '-sharp';
      }
      switch (type) {
        case 'qq':
          shareUrl = `http://connect.qq.com/widget/shareqq/index.html?url=${encodeURIComponent(`${process.env.VUE_APP_HOST}${port}${process.env.VUE_APP_BASE_URL}${urlMode}/share-activity/detail?referrer_id=${this.userId}&id=${encodeURIComponent(productId)}`)}&title=${encodeURIComponent(title)}&desc=${encodeURIComponent(description)}&pics=${encodeURIComponent(image)}`;
          break;
        case 'qzone':
          shareUrl = `http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=${encodeURIComponent(`${process.env.VUE_APP_HOST}${port}${process.env.VUE_APP_BASE_URL}${urlMode}/share-activity/detail?referrer_id=${this.userId}&id=${encodeURIComponent(productId)}`)}&title=${encodeURIComponent(title)}&desc=${encodeURIComponent(description)}&pics=${encodeURIComponent(image)}`;
          break;
        case 'weibo':
          shareUrl = `http://service.weibo.com/share/share.php?url=${encodeURIComponent(`${process.env.VUE_APP_HOST}${port}${process.env.VUE_APP_BASE_URL}${urlMode}/share-activity/detail?referrer_id=${this.userId}&id=${encodeURIComponent(productId)}`)}&title=${encodeURIComponent(title)}&pic=${encodeURIComponent(image)}`;
          break;
        default:
          shareUrl = '';
      }
      console.log(shareUrl);
      if (shareUrl !== '') {
        window.open(shareUrl);
      }
    },

I wrote one directly by myself, but it hasn't perfected the moments of Wechat and Wechat. Jiathis is closed, baidu sharing is unstable, and there is no need for a third party.

Menu