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});
                };

            });
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章