帖子
帖子
用户
博客
课程
显示全部楼层

[插件使用] QQPlus 分享图片啥时候能搞好?

[复制链接]
发表于 2022-12-5 17:22:01



QQPlus  分享图片啥时候能搞好?

QQPlus  分享图片啥时候能搞好?

QQPlus  分享图片啥时候能搞好?
您好,看到你老帖子里没回复,你可以详细再描述下,
技术咨询-特特 · 2022-12-5 17:24您好,看到你老帖子里没回复,你可以详细再描述下,
  1. //图片缓存到本地
  2. function cacheImage(imagepath,filepath,filename,callback,isShowLoading){
  3.   if(!arguments[0]) return;
  4.   if(!arguments[4]) isShowLoading = false;
  5.   var savePath = 'fs://'+filepath+'/original/'+filename+'.jpeg';
  6.   //判断地址是否为远程地址  http 或 https
  7.   if(getUrl(imagepath)){
  8.     if(isShowLoading){
  9.       api.showProgress();
  10.     }
  11.     api.download({
  12.       url: imagepath,
  13.       savePath: savePath,
  14.       report: true,
  15.       cache: true,
  16.       allowResume: true
  17.     }, function (ret, err) {
  18.       if(ret.state === 1){
  19.         if(isShowLoading){
  20.           api.hideProgress();
  21.         }
  22.         compressLocalImage(savePath,filepath,filename,callback);
  23.       }else if(ret.state === 2){
  24.         if(isShowLoading){
  25.           api.hideProgress();
  26.         }
  27.       }
  28.     });
  29.   }else{
  30.     compressLocalImage(imagepath,filepath,filename,callback);
  31.   }
  32. }

  33. function compressLocalImage(imagepath,filepath,filename,callback){
  34.   if(!arguments[0]) return;
  35.   var imgPath = 'fs://'+filepath+'/thumb';
  36.   var compress_savePath = imgPath+"/"+filename+".jpeg";

  37.   var imageFilter = api.require('imageFilter');
  38.      **.**press({
  39.         img: imagepath,
  40.         quality: 0.3,
  41.         save: {
  42.           imgPath: imgPath,
  43.           imgName: filename+".jpeg"
  44.         }
  45.       },function( ret, err ){
  46.         if( ret.status ){
  47.           //删除缓存文件夹
  48.           var fs = api.require('fs');
  49.               fs.rmdir({path: 'fs://'+filepath+'/original'}, function(ret, err) {});
  50.               var data = {
  51.                 state:1,
  52.                 savePath:compress_savePath,
  53.               };
  54.           callback(data);
  55.         }
  56.       });
  57. }
  58. //QQ分享
  59. var QQPlus = null;
  60. function shareQQImage(type,imagepath,filepath,filename){
  61.     if(!arguments[0]) type = "QFriend";
  62.     if(!QQPlus){
  63.         QQPlus = api.require('QQPlus');
  64.         QQPlus.setIsPermissionGranted({granted:true});
  65.     }
  66.     QQPlus.installed(function(ret, err) {
  67.         if (ret.status) {
  68.             cacheImage(imagepath,filepath,filename,function (ret,err) {
  69.                 if(ret.state === 1){
  70.                     var savePath = ret.savePath;
  71.                     QQPlus.shareImage({
  72.                         type : type,
  73.                         imgPath: savePath
  74.                     },function(ret,err){

  75.                     });
  76.                 }
  77.             },true);
  78.         } else {
  79.             showMessage("请先安装QQ~_~!");
  80.         }
  81.     });
  82. }
复制代码
先降低模块版本试下,看看是不是最新版本有问题
您需要登录后才可以回帖 登录

本版积分规则