ppypp伦理天堂,91手机在线视频,免费在线观看黄色毛片,夜夜穞天天穞狠狠穞AV美女按摩

聯系官方銷售客服

1835022288

028-61286886

投訴 分享 微信小程序頭像上傳示例,處理base64圖片文件上傳問題 1 0
迅睿CMS版本:4.6.2 #微信小程序

微信小程序頭像上傳功能,解決圖片base64上傳轉碼問題

      <button  open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
              <image class="avatar" :src="member.avatar+Math.floor(Math.random() * 10000)"></image>
             </button>
   onChooseAvatar(e) {
    let that = this;
    const {avatarUrl} = e.detail;
    wx.getFileSystemManager().readFile({
     filePath: avatarUrl, //要讀取的文件的路徑 (本地路徑)
     encoding: "base64", //指定讀取文件的字符編碼
     success(res) {
      //轉換完畢,執行上傳
     let avatar=encodeURI('data:image/png;base64,' + res.data).replace(/\+/g,'%2B');//避免特殊字符+ 傳輸變成空格,重要
     that.http.post('&s=member&c=account&m=avatar&r=9351','is_ajax=1&file='+avatar) //我這里是單獨封裝過的請求方式,按照官方頭像上傳接口傳輸內容即可http://www.zbshanke.com/doc/1081.html
      .then(obj => {
       uni.setStorageSync('member', obj.data.data); //按照自己的用戶保存方式,更新用戶信息
       that.member= obj.data.data;
       uni.showToast({
        icon:false,
        title: obj.data.msg,
        duration: 2000
       });
      }).catch(err => {
       console.log(err)
      })
     }
    })

   },

解決方案
  • 支持 學習一下