操作系统:macOs
开发平台 :HbuilderX 2.6.8.20200330
测试手机:iphone 6s iphone7p 等多台苹果设备
微信版本:7.0.10

产品需求:分享多图

因为需求,寻找到了 plus.share.sendWithSystem 这个 api

出错场景:真机调试时测试分享功能, plus.share.sendWithSystem 传入参数

var msg = {  
    pictures: pictures,   // pictures 参数为数组  
    type:'image'  
};

其中 pictures 数组时,测试过两种数据 ,

// a. 使用线上图片地址  
[  
"http://kmls-vpc.oss-cn-zhangjiakou.aliyuncs.com/kmsypic/18767122265/20200327/1585290790851.JPG",  
"http://kmls-vpc.oss-cn-zhangjiakou.aliyuncs.com/kmsypic/18767122265/20200327/1585290796833.JPG",  
"http://kmls-vpc.oss-cn-zhangjiakou.aliyuncs.com/kmsypic/18767122265/20200327/1585290801138.JPG",  
"http://kmls-vpc.oss-cn-zhangjiakou.aliyuncs.com/kmsypic/18767122265/20200327/1585290803140.JPG",  
"http://kmls-vpc.oss-cn-zhangjiakou.aliyuncs.com/kmsypic/18767122265/20200327/1585290805352.JPG",  
"http://kmls-vpc.oss-cn-zhangjiakou.aliyuncs.com/kmsypic/18767122265/20200327/1585290810835.JPG",  
"http://kmls-vpc.oss-cn-zhangjiakou.aliyuncs.com/kmsypic/18767122265/20200327/1585290814424.JPG",  
"http://kmls-vpc.oss-cn-zhangjiakou.aliyuncs.com/kmsypic/18767122265/20200327/1585290816348.JPG",  
"http://kmls-vpc.oss-cn-zhangjiakou.aliyuncs.com/kmsypic/18767122265/20200327/1585290931181.JPG"  
]  

// b.  使用本地 已下载地址  
[  
"file:///var/mobile/Containers/Data/Application/209CC1CD-CE3E-402A-9EAF-2113B77FBAB8/Library/Caches/Pandora/downloads/1585290803140.JPG",  
"file:///var/mobile/Containers/Data/Application/209CC1CD-CE3E-402A-9EAF-2113B77FBAB8/Library/Caches/Pandora/downloads/1585290790851.JPG",  
"file:///var/mobile/Containers/Data/Application/209CC1CD-CE3E-402A-9EAF-2113B77FBAB8/Library/Caches/Pandora/downloads/1585290801138.JPG",  
"file:///var/mobile/Containers/Data/Application/209CC1CD-CE3E-402A-9EAF-2113B77FBAB8/Library/Caches/Pandora/downloads/1585290796833.JPG",  
"file:///var/mobile/Containers/Data/Application/209CC1CD-CE3E-402A-9EAF-2113B77FBAB8/Library/Caches/Pandora/downloads/1585290805352.JPG",  
"file:///var/mobile/Containers/Data/Application/209CC1CD-CE3E-402A-9EAF-2113B77FBAB8/Library/Caches/Pandora/downloads/1585290931181.JPG",  
"file:///var/mobile/Containers/Data/Application/209CC1CD-CE3E-402A-9EAF-2113B77FBAB8/Library/Caches/Pandora/downloads/1585290816348.JPG",  
"file:///var/mobile/Containers/Data/Application/209CC1CD-CE3E-402A-9EAF-2113B77FBAB8/Library/Caches/Pandora/downloads/1585290814424.JPG",  
"file:///var/mobile/Containers/Data/Application/209CC1CD-CE3E-402A-9EAF-2113B77FBAB8/Library/Caches/Pandora/downloads/1585290810835.JPG"]

结果:a,b 两种数据格式都能成功唤起原生分享样式,但是都无法分享成功。

其中下载线上图片在原生相册后,原生分享可以使用

plus.share.sendWithSystem(  
  msg,  
  function(e) {  
    console.log('success')  
    console.log('success',JSON.stringify(e))  
    for (var i = 0; i < relativePathArr.length; i++) {  
      if (relativePathArr[i] != null) delFile(relativePathArr[i]);  
    }  
  },  
  function(e) {  
    // 执行  fail 函数  
    // fail, {"code":-2,"message":"user cancelled,http://ask.dcloud.net.cn/article/282"}  
    console.log('fail',JSON.stringify(e))  
    for (var i = 0; i < relativePathArr.length; i++) {  
      if (relativePathArr[i] != null) delFile(relativePathArr[i]);  
    }  
  }  
);

·回复

本地地址不要 file:// 试试


·回复

这样操作会导致出现无法分享,只有这两个选项,里面不含有分享到微信。


·回复

同步一下状态:当前问题没有完全解决,依靠每次下载图片后再计算所有图片累计内存大小,小于 5m 再唤起分享,大于 5m 提示文件过大。

Scroll Up