uni.share({
provider: "weixin",
scene: "WXSceneSession",
type: 1,
summary: "我正在使用HBuilderX开发uni-app,赶紧跟我一起来体验!",
success: function (res) {
console.log("success:" + JSON.stringify(res));
},
fail: function (err) {
console.log("fail:" + JSON.stringify(err));
},
complete: function (res) {
console.log("complete:" + JSON.stringify(res));
},
});
//稳定运行的代码
// uni.share({
// title: that.goods.name,
// type: "5",
// provider: "weixin", //分享服务提供商
// scene: "WXSceneSession", //场景
// summary: "", //分享内容的摘要
// imageUrl: that?.goods?.info?.share_image,
// miniProgram: {
// id: "gh_430f0641948b",
// path:
// "pages/mall/goods_detail/goods_detail?inviteId=" +
// that.userinfo.id +
// "&goodsId=" +
// that.goodsId,
// type: 0,
// webUrl: "https://cpgstest.gszjxtpt.com/dist/index.html#/",
// }, //分享小程序必要参数
// success: res => {
// console.log(res, "success");
// },
// fail: res => {
// console.log(res, "ree");
// },
// });
//app 打开小程序代码 有成功回调 但是回调是空的数据
plus.share.getServices(
res => {
console.log(res, "share");
let sweixin = res.find(i => i.id === "weixin");
if (sweixin) {
sweixin.launchMiniProgram(
{
id: "gh_430f0641948b",
path: "/pages/pay/pay",
// path: /pages/pay/pay?orderInfo=${encodeURIComponent( // JSON.stringify(that.orderInfo) // )}&&type=${this.type}&&share='app'
,
//测试环境用1 打包后正式环境用0
type: 0,
webUrl: "http://www.dcloud.io/",
},
res => {
console.log(res, "跳转小程序");
},
error => {
console.log(error, "跳转小程序失败");
}
);
} else {
that.$ui.showModal({
title: "提示",
content: "请先安装微信客户端",
showCancel: false,
});
}
},
error => {
console.log(error);
that.$ui.showModal({
title: "提示",
content: "请先安装微信客户端",
showCancel: false,
});
}
);
});

- 发布:2024-04-24 20:25
- 更新:2024-04-25 18:25
- 阅读:185
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: windows11
HBuilderX类型: 正式
HBuilderX版本号: 4.13
手机系统: Android
手机系统版本号: Android 14
手机厂商: 华为
手机机型: 90pro
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
App下载地址或H5⽹址: https://sj.qq.com/appdetail/com.wwgsxt.mall
示例代码:
操作步骤:
app 分享 app 打开小程序
app 分享 app 打开小程序
预期结果:
预期功能能正常使用
预期功能能正常使用
bug描述:
更换包名后(1.已验证安装包的签名和微信开放平台签名是一致的 2. 也绑定了微信小程序 3.代码中也是原始id 4.分享图片不超过100kb
- app模块也配置了开放平台的id)
- 微信分享无法使用 不管分享什么都报 不支持的类型 (代码以前是稳定运行)也多次排查过代码 没问题 uni.share API 一会能拿到fail (报错-3 但是和-3相关的问题都排查过) 一会又什么回调都拿不到 就连complete回调都拿不到
- app 打开小程序报错 无效的app

