h5+ 分享到"QQ"失敗: {"code":-100,"message":"[ShareQQ分享:-6]非法的圖片地址!, http://ask.dcloud.net.cn/article/287"}


原因:

QQ不支持網路圖片地址,需要給api傳本地圖片地址,是file///:開頭的路徑,具體可以參考5+的地址轉換方法
requestFileSystem: 請求本地文件系統對象

resolveLocalFileSystemURL: 通過URL參數獲取目錄對象或文件對象

convertLocalFileSystemURL: 將本地URL路徑轉換成平台絕對路徑

convertAbsoluteFileSystem: 將平台絕對路徑轉換成本地URL路徑

 

 if (a == 'qq') {
          $(function() {
            mui.plusReady(function() {
              console.log(' mui.plusReady執行了')
              // plus.io.resolveLocalFileSystemURL('_www/static/img/android.png', function(entry) {//安卓
              plus.io.resolveLocalFileSystemURL('_www/static/img/ios.png', function(entry) {//ios
                let pictures = [];
                var dirReader = entry.toLocalURL();
                pictures.push(dirReader);
                console.log(pictures,'絕對路徑')
                let qq_msg = {
                  type: 'image', //分享的內容的類型
                  pictures:pictures,
                }
                plus.nativeUI.actionSheet({
                  title: '分享圖片到QQ',
                  cancel: '取消',
                  buttons: _this.buttons1,
                }, function(e) {
                  (e.index > 0) && _this.sharePage(_this.sqq, qq_msg, _this.buttons[e.index - 1]);
                })
              }, function(e) {
                alert('路徑或文件不存在')
              });
            })
          })
        }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM