WeChatアプレットの進捗バー

1878 ワード

downImg: function (e) {
    var _this = this;

    //       (http://www.playsort.cn/...)
    //var img = e.currentTarget.dataset.src;
    //var img = '../pic/U1513P28T52D3414F872DT20081124143718.jpg?id=' + Math.floor(Math.random() * 100000);;
    var img = 'http://i0.sinaimg.cn/ent/y/w/2008-11-24/U1513P28T52D3414F872DT20081124143718.jpg?id=' + Math.floor(Math.random() * 100000);
    //       
    const downloadTask = wx.downloadFile({
      url: img,
      success: function (res) {
        //           ,               success   ,                   
 console.log(res) if (res.statusCode === 200) { // wx.saveImageToPhotosAlbum({ // filePath: res.tempFilePath, // success: function (res) { // wx.showToast({ // title: '      !~', // }); // }, // fail: function (res) { // wx.showToast({ // title: '      !~', // }); // } // }) console.log('code:' + res.statusCode ) }else{ console.log('code:' + res.statusCode ) } } }); downloadTask.onProgressUpdate((res) => { if (res.progress === 100) { this.setData({ progress: '100%' }); var st = getApp().globalData.st var et = new Date() console.log(et-st) console.log(410.45 * 1000 / (et - st)) }else if(res.progress === 1){ getApp().globalData.st = new Date() console.log(getApp().globalData.st); } else { this.setData({ progress: res.progress + '%' }); } }); }
 
転載先:https://www.cnblogs.com/CryOnMyShoulder/p/11524994.html