APICloud实现上传图片

<div id="cards1" onclick="popo('cards1','popoa1')" style="">
              <img style="height:80px;width:80px;border-radius:50%" src="../img/t.jpg" alt="">
              <span>{{infoList.username}}<br><span style="font-size:0.8em">{{LocalStrLan.Invite_code}}:{{infoList.invitation_code}}</span>
            </span>

          </div>
var pay_zheng = "",pay_zheng2="";
function popo(ele,ele2){
    api.getPicture({
                sourceType: 'library',
                encodingType: 'png',
                mediaValue: 'pic',
                destinationType: 'base64',
                allowEdit: true,
                saveToPhotoAlbum: false
            }, function(ret, err){
                if (ret) {
                  api.showProgress();//隐藏加载进度框
                 var element=document.getElementById(ele)
                 var flag=$api.byId(ele2)
                 if(ele=="cards1"){
                   pay_zheng=ret.data
                 }else{
                    //pay_zheng2=ret.data
                 }
                 if(flag){
                   $api.attr(flag,"src",ret.base64Data)
                  // alert(1)
                 }else{
					 document.getElementById(ele).innerHTML = '<img id="'+ele2+'" style="height:80px;width:80px;border-radius:50%" src="'+ret.base64Data+'" alt=""/>'
					 //上传图像的方法
					 uploadPicName();
                 }

                 api.hideProgress();//隐藏加载进度框
                } else {
                    // api.alert({msg:err.msg});
                };

            });
}

猜你喜欢

转载自blog.csdn.net/l425059010/article/details/84967909
今日推荐