1***@163.com
1***@163.com
  • 发布:2023-12-28 10:03
  • 更新:2024-01-03 14:15
  • 阅读:427

uni.share ios分享微信不显示图片 qq微博都正常 安卓也都正常只有微信不显示图片

分类:uni-app
分享页  
wxShare(n) {  
                let vider, scence, typeNum, hrefUrl, title, summary, imgPath = '';  
                hrefUrl = 'pages/index/index?infoCode=' + this.detailData.infoCode + '&type=article'  
                title = this.detailData.title  
                imgPath = this.arrImgList[0] ? this.arrImgList[0] : '/static/image\index/ala_a@2x.png'  
                summary = removeHtmlStyle(this.detailData.summary) ? removeHtmlStyle(this.detailData.summary) : ''  
                typeNum = 0  
                switch (n) {  
                    case 1:  
                        vider = 'weixin'  
                        scence = 'WXSceneSession'  
                        break;  
                    case 2:  
                        vider = 'weixin'  
                        scence = 'WXSceneTimeline'  
                        break;  
                    case 3:  
                        vider = 'qq'  
                        break;  
                    case 4:  
                        vider = 'sinaweibo'  
                        break;  
                }  
                shareApp(vider, scence, typeNum, hrefUrl, title, summary, imgPath)  
            }  

封装的方法  
function share(vider, scence, typeNum, newhrefUrl, title, summary, imgPath) {  

    if (plus.os.name.toLocaleLowerCase() == 'ios' && imgPath != '/static/image\index/ala_a@2x.png') {  

        uni.downloadFile({  
            url: imgPath,  
            success: (e) => {  
                // 将png转换成jpg格式 只有jpg格式支持压缩api  
                plus.zip.compressImage({  
                        src: e.tempFilePath,  
                        format: "jpg"  
                    },  
                    response => {  
                        // 压缩图片  
                        plus.zip.compressImage({  
                            src: response.target,  
                            quality: 1 // 1-100  
                        }, res => {  
                            imgPath = res.target  
                            imgPath = 'file://' + plus.io.convertLocalFileSystemURL(imgPath);  
                            // uni.showModal({  
                            //  title: imgPath  
                            // })  
                            uni.share({  
                                provider: vider, //weixin|qq|sinaweibo  
                                scene: scence,  
                                type: typeNum,  
                                href: newhrefUrl,  
                                title: title,  
                                summary: summary,  
                                imageUrl: imgPath,  
                                success: function(res) {  
                                    console.log("success:" + JSON.stringify(res));  
                                },  
                                fail: function(err) {  
                                    console.log("fail:" + JSON.stringify(err));  
                                }  
                            });  
                        })  
                    });  
            },  
        })  
    } else {  
        imgPath = 'file://' + plus.io.convertLocalFileSystemURL(imgPath);  
        uni.share({  
            provider: vider, //weixin|qq|sinaweibo  
            scene: scence,  
            type: typeNum,  
            href: newhrefUrl,  
            title: title,  
            summary: summary,  
            imageUrl: imgPath,  
            success: function(res) {  
                console.log("success:" + JSON.stringify(res));  
            },  
            fail: function(err) {  
                console.log("fail:" + JSON.stringify(err));  
            }  
        });  
    }
2023-12-28 10:03 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com

你好 请问这个问题解决了嘛~~

要回复问题请先登录注册