애플릿의 파일 보기 기능

1500 단어
  downLoadFun:function(e){
    var that = this;
    var fileUrl = e.target.dataset.url;
    fileUrl = fileUrl.replace(/,/g, '');
    console.log(' ', fileUrl);
    //  
    const downloadTask = wx.downloadFile({  // 
      url: 'https://haiyunht.langqiyun.cn/uploads/' + fileUrl, 
      // url: 'https://haiyunht.langqiyun.cn/uploads/20190906/5064d7bf35e7fcfa718dc7a195ec58dd.xlsx', // , 
      success(res) {
        //  ,  success  , 
        console.log('res',res)
        if (res.statusCode === 200) {
          console.log('a', res);
          wx.saveFile({  // 
            tempFilePath: res.tempFilePath,
            success(result) {
              const savedFilePath = result.savedFilePath
              console.log(savedFilePath,'11');
              if(savedFilePath){
                wx.showToast({
                  title: ' ...',
                  icon: 'loading',
                  duration: 2000
                }),
                wx.openDocument({ // 
                  filePath: savedFilePath,
                  success: function (res) {
                    console.log(' ', res)
                  }
                })
              }else{
                wx.showToast({
                  title: ' !',
                  icon: 'none',
                  duration: 2000
                })
              }


            }
          })
        }
      }
    });
  },

좋은 웹페이지 즐겨찾기