diff --git a/pages/list/list.vue b/pages/list/list.vue index 3420dcf..620fe61 100644 --- a/pages/list/list.vue +++ b/pages/list/list.vue @@ -211,21 +211,32 @@ }, //确定导出 async exportClick() { - let ids + const sessionId = uni.getStorageSync("sessionId"); + let filePath = `${wx.env.USER_DATA_PATH}/${+new Date}.xlsx` + let ids = '' ids = this.checkboxList.length === 0 ? this.list.map(item=>item.id).join() : this.checkboxList.map(item=> item.id).join() - wx.downloadFile({ - url: `https://visitor.gd.smartlog.work/visitor/exportMessage?ids=${ids}`, - success: function (res) { - const filePath = res.tempFilePath - console.log(res) - wx.openDocument({ - filePath: filePath, - success: function (res) { - console.log(res) - } - }) - } - }) + uni.request({ + url: `https://visitor.gd.smartlog.work/visitor/exportMessage?ids=${ids}`, + responseType:"arraybuffer", + header: { + 'token':sessionId //自定义请求头信息 + }, + success: ({data}) => { + let fm = wx.getFileSystemManager() + fm.writeFile({ + filePath, + data, + success:(res)=>{ + uni.openDocument({ + filePath, + fileType:'xlsx', + showMenu:true + }) + } + }) + } + }); + this.checkboxList = [] }, //根据条件搜索 async searchList(){