项目场景:
提示:这里简述项目相关背景:
uni-app微信小程序分享
分享使用制定图片
onShareAppMessage() {
let materialUrl = this.oss + this.materialList.materialUrl;
let share = “share”;
return {
title: this.materialList.materialTitle,
imageUrl: this.oss + this.materialList.materialShareThumbnail,
path: “/edrpages/pages/manual/manual?from=” + share + “&materialUrl=” + materialUrl,
};
},
问题描述
分享成功后,点击
例如:数据传输过程中数据不时出现丢失的情况,偶尔会丢失一部分数据
APP 中接收数据代码:
@Override
public void run() {
bytes = mmInStream.read(buffer);
mHandler.obtainMessage(READ_DATA, bytes, -1, buffer).sendToTarget();
}
原因分析:
解决方案:
首先判断是否为分享路径进入
onLoad(opetion) {
if (opetion && opetion.from === “share”) {
this.openFile(opetion.materialUrl);
this.shareBg = true;
} else {
// 非分享进入,执行其他逻辑
this.shareBg = false;
}
this.typeId = opetion.type;
this.getFileList(opetion.type);
this.getProductList();
},
分享之后下载PDF文件
openFile(materialUrl) {
wx.showLoading({
title: “正在打开文档,请等待…”,
});
wx.downloadFile({
url: materialUrl,
// filePath: wx.env.USER_DATA_PATH + “/” + material.materialTitle + “.pdf”,
success: (res) => {
const filePath = res.tempFilePath
wx.openDocument({
filePath,
showMenu: true,
success: (res) => {
wx.hideLoading();
this.shareBg = false;
},
fail: function (err) {
wx.hideLoading();
wx.showToast({
title: “打开文档失败”,
icon: “none”,
});
},
});
},
fail: function (err) {
wx.hideLoading();
wx.showToast({
title: “打开文档失败”,
icon: “none”,
});
},
});
},