vue + 微信分享 分享只剩链接跟参数了

我的代码如下

img

分享至QQ正常显示

img

但是微信分享的如下图所示,分享到微信就只有链接了,是我哪里少写了配置吗?

img

急,求指教

我来说下吧,微信分享如果准备工作都已做好,那么你分享出去是链接,首先,微信现在如果是链接打开再点分享出去依然是链接,可以把链接做成二维码,扫描二维码打开再次分享即可是卡片形式,或者把链接收藏到微信,从收藏夹打开分享依然是卡片形式,或者是从公众号配置设置的链接,如果这几种不行,那肯定是你写的有问题了。可以参考我写的这篇
http://t.csdn.cn/fKFTE

可以用插件引入,weixin-js-sdk
参考链接,希望有帮助哦

红色部分满足吗?

img

我之前是这样写的分享 https://blog.csdn.net/qq_46570160/article/details/121747649?spm=1001.2014.3001.5502

还有就是看看白名单的配置

你是不是直接点击连接打开的分享页面,然后再分享?
可以试下从其他页面进入你想分享的页面,让后再分享;
或者从你分享到QQ 里面打开这个分享页面,再分享到微信,应该可以

我们项目是从企业微信分享到微信,跟你用的API是一样的,参数是这样传的

    this.shareData = {
        title: item.title, // 分享标题
        desc: item.summary, // 分享描述
        link:
          process.env.VUE_APP_PROXY_URL +
          `/isales-content-news/singleInfoDetails?src_id=${item.src_id}`, // 分享链接
        imgUrl: process.env.VUE_APP_PROXY_URL + '/isales-content-news/logo.png' // 分享封面
      }

process.env.VUE_APP_PROXY_URL是.env.test 与 .env.prop测试和生产环境对应的地址,看是否对你有所帮助。
另外我们也碰到过相同的问题, 是下边代码部分的签名没过,可以检查一下!

 injectAgentConfig (success, fail, force) {
    refreshNum++
    console.log(refreshNum, 'refreshNum===>')
    if (!wx.agentConfig) return console.error('不支持 wx.agentConfig')
    // 注入AgentConfig,在wx.config之后做延迟再调用(技术客服要求)
    const curRoute = JSON.parse(window.localStorage.getItem('curRoute'))
    const agentFeature = curRoute ? (curRoute.meta.agentFeature || '') : ''
    console.log('injectAgentConfig agentFeature:::::', agentFeature)
    const timer = setTimeout(() => {
      clearTimeout(timer)
      api.getJsApiConfigParams({
        corpId: Config.corpId,
        ticketType: 1,
        force,
        url: encodeURIComponent(window.location.href),
        agentFeature // 应用名称(比如 mot), 用于在注入config时区分应用; 默认是 '', 表示使用主应用
      }).then(({ code, msg, data: result }) => {
        if (code === 0) {
          const { corpId, nonceStr, signature, timestamp, agentId } = result
          const data = {
            corpid: corpId, // 必填,企业微信的corpid,必须与当前登录的企业一致
            agentid: agentId + '', // 必填,企业微信的应用id (e.g. 1000247)
            timestamp, // 必填,生成签名的时间戳
            nonceStr, // 必填,生成签名的随机串
            signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
            jsApiList: [...agentJsApiList], // 必填
            success: function (res) {
              console.warn('injectAgentConfig success', res)
              success && success()
            },
            fail: res => {
              if (refreshNum <= 1) {
                this.injectAgentConfig(success, fail, true)
              }
              console.error('injectAgentConfig fail', res)
              fail && fail()
            }
          }
          wx.agentConfig(data)
        } else {
          console.error('injectAgentConfig err', msg)
        }
      })
    }, 200)
  },