diff --git a/App.vue b/App.vue index 2641613..e2fe2ec 100644 --- a/App.vue +++ b/App.vue @@ -64,13 +64,7 @@ ...mapMutations(['setUniverifyErrorMsg', 'setUniverifyLogin']), appCheckUpdate(){ console.log("appCheckUpdate=============") - // #ifdef APP-PLUS - // App平台检测升级,服务端代码是通过uniCloud的云函数实现的,详情可参考:https://ext.dcloud.net.cn/plugin?id=4542 - // if (plus.runtime.appid !== 'HBuilder') { // 真机运行不需要检查更新,真机运行时appid固定为'HBuilder',这是调试基座的appid - // checkUpdate() - // } checkUpdate() - // #endif }, async updateActiveTime(opt = {}){ let { directUpdate } = opt diff --git a/common/request.js b/common/request.js index 55ac922..7386436 100644 --- a/common/request.js +++ b/common/request.js @@ -83,6 +83,26 @@ let coreRequest = function(url, params = {}, options = {}, methodType, coreParam }) } +const coreDownloadRequest = (url, params = {}, options = {}, methodType = 'GET', coreParams = {})=> { + let comReqData = getCommonReqData() + // 统一把emo转unicode + // emoUnicode(params) + const reqParams = { + ...baseParam, + ...params, + } + url = `${host}${url}` + options = { + ...comReqData.header, + ...options, + } + + // get请求 需要转成query参 + url = url + (url.indexOf('?') == -1 ? '?': '') + tansGetParamsToQuery(reqParams) + return { url, header: options } +} + export { + coreDownloadRequest, coreRequest } \ No newline at end of file diff --git a/common/untool.js b/common/untool.js index f5c66c9..4916154 100644 --- a/common/untool.js +++ b/common/untool.js @@ -148,6 +148,8 @@ const downloadFile = (url, ext = {})=> { if (res.statusCode === 200 || res.statusCode === 400) { console.log('下载成功'); resolve(res) + } else { + reject('下载失败') } }, fail: (err)=>{ @@ -158,33 +160,43 @@ const downloadFile = (url, ext = {})=> { }) } -const saveNetFile = (url) => { - return new Promise(async (resolve, reject)=> { +const saveNetFile = ({ url, header } = {}) => { + return new Promise(async (resolve, reject) => { showLoading('正在保存文件') - try{ - let dRes = await getImageInfo(url) - console.log("save:downloadFile:getImageInfo", dRes) - let { tempFilePath, path } = dRes + try { + let dRes = await downloadFile(url, { header }) + console.log("saveNetFile:downloadFile==", dRes) + let { + tempFilePath, + path + } = dRes + path = path || tempFilePath + debugger // #ifdef H5 saveAs(path) // #endif // let res = await saveFile({ path }) - + // #ifdef APP-PLUS plus.io.convertLocalFileSystemURL(path); plus.runtime.openFile(path); //选择软件打开文件 // #endif - + + // #ifdef MP-WEIXIN + debugger + await uniPromiseApi('openDocument', { filePath: path, showMenu: true, }) + // #endif + hideLoading() showToast('保存成功') resolve(tempFilePath) - }catch(e){ + } catch (e) { hideLoading() showToast('保存失败') reject(e) } }) - + } const saveFile = ({ tempFilePath })=> { diff --git a/pages/user/exclusiveQrcode.vue b/pages/user/exclusiveQrcode.vue index 902a215..08f8b4b 100644 --- a/pages/user/exclusiveQrcode.vue +++ b/pages/user/exclusiveQrcode.vue @@ -67,7 +67,7 @@ }, async handleSave(){ - this.saveNetFile(this.qrCodeImgUrl) + this.saveNetFile({ url: this.qrCodeImgUrl }) }, handlePrint() { this.$refs.curPrint.startPrint({