收藏
回答

求技术,H5微信分享二次转发,ios不显示卡片效果只显示连接,android正常?

很奇怪的问题,H5链接,通过微信转发分享后,ios手机不显示卡片效果。android显示正常。

wx.config函数的debug=ture后,android显示success,ios弹出fail。

效果如下:

查了很多资料也无法解决。求助技术大佬!

基础配置如下:

1)微信服务号后台JS安全域配置OK

2),域名h5.daottec.cn支持SSL协议。

代码如下:

//weixin-js-sdk 版本1.6.0,打包放在本地,非远程访问
import config from '@/config';
import { useUserStore } from '@/store/user';
import { get } from '@/utils/request';
import wx from 'weixin-js-sdk';
const { HOST } = config;
const userStore = useUserStore();

export { wx };

//服务器接口,获取config签名相关参数
export const getWXConfigData = () => {
  return get(`/v1/wxaapi/config`, {
    url: location.href,
  });
};

//jsApiList = ["onMenuShareTimeline", "onMenuShareAppMessage", "onMenuShareQQ","onMenuShareWeibo", "onMenuShareQZone", "chooseWXPay"];
export const WXConfig = async (jsApiList: Array<string>) => {
  const { WX_APPID } = userStore.getOrgConfig;
  const { data: wxconfigData } = await getWXConfigData();
  wx.config({
    debug: false,
    appId: WX_APPID,
    ...wxconfigData,
    jsApiList,
  });
};

export const WXConfigReady = async (jsApiList: Array<string>, action: Function) => {
  await WXConfig(jsApiList);
  wx.ready(action);
};

export const WXShareConfigReady = async ({
  title,
  desc,
  link,
  imgUrl,
}: {
  title: string;
  desc?: string;
  link?: string;
  imgUrl: string;
}) => {
  if (link && !link.startsWith(HOST)) {
    link = HOST + link;
  }
  await WXConfigReady(
    [
      'updateAppMessageShareData',
      'updateTimelineShareData',
      'onMenuShareAppMessage',
      'onMenuShareTimeline',
      'onMenuShareQQ',
      'chooseWXPay',
    ],
    () => {
      console.log('updateAppMessageShareData', title, desc, link, imgUrl);
      if (wx.updateAppMessageShareData) {
        updateAppMessageShareData({
          title,
          desc,
          link,
          imgUrl,
          success: () => {
            console.log('updateAppMessageShareData...');
          },
        });
        updateTimelineShareData({
          title,
          link,
          imgUrl,
          success: () => {
            console.log('updateTimelineShareData...');
          },
        });
      } else {
        onMenuShareAppMessage({
          title,
          desc,
          link,
          imgUrl,
          success: () => {
            console.log('onMenuShareAppMessage...');
          },
        });
        onMenuShareTimeline({
          title,
          link,
          imgUrl,
          success: () => {
            console.log('onMenuShareTimeline...');
          },
        });
        onMenuShareQQ({
          title,
          desc,
          link,
          imgUrl,
          success: () => {
            console.log('onMenuShareQQ...');
          },
        });
      }
    },
  );
};

回答关注问题邀请回答
收藏

1 个回答

  • 社区技术运营专员--许涛
    社区技术运营专员--许涛
    2023-05-26

    2023-05-26
    有用
    回复 2
    • Jack陈
      Jack陈
      2023-05-31
      已解决,最终发现wx.config参数传递过程中,nonceStr参数给的是时间戳,int类型,将int类型转成string类型,就可以了。否则就会出现android通过,ios不通过。
      2023-05-31
      回复
    • 阿白
      阿白
      2023-09-09
      你好,我这边返回的也都是string类型,但是分享好友,也是只有安卓分享的自定义可以,苹果还是不行,求回复
      2023-09-09
      回复
登录 后发表内容