From 2b8dc2840fdc209c89923f6bd1a9c257f58905a9 Mon Sep 17 00:00:00 2001 From: aihe <961836564@qq.com> Date: Sat, 10 Aug 2024 09:39:55 +0800 Subject: [PATCH] uu --- common/untool.js | 14 ++++++++++---- common/upload.js | 8 +++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/common/untool.js b/common/untool.js index 1d1cf19..960d598 100644 --- a/common/untool.js +++ b/common/untool.js @@ -38,7 +38,12 @@ const goto = (url, type = 1)=> { } const goBack = (opt = {})=> { - uni.navigateBack(opt) + uni.navigateBack({ + fail: ()=>{ + goto(opt._finalUrl || `tabBar/home/home`, 2) + }, + ...opt, + }) } const reLaunch = (opt = {})=> { @@ -294,10 +299,11 @@ const setNavigationBarTitle = (title)=> { } const reloadCurrentPage = (_thisPage)=> { + let routes = getCurrentPages(); // 获取当前打开过的页面路由数组 + let curPage = routes[routes.length - 1] // 获取当前页面路由,也就是最后一个打开的页面路由 + _thisPage = curPage || _thisPage let { fullPath } = _thisPage.$page - uni.redirectTo({ - url: fullPath - }); + goto(fullPath, 2) } const playAudio = (src)=> { diff --git a/common/upload.js b/common/upload.js index 776ec95..6f38f33 100644 --- a/common/upload.js +++ b/common/upload.js @@ -30,7 +30,7 @@ const chooseFile = function (action = 'chooseImage', opt = {}) { }) } -const doRequest = function (file) { +const doRequest = function (file, opt = {}) { return new Promise((resolve, reject) => { let comReqData = getCommonReqData() uni.uploadFile({ @@ -55,7 +55,8 @@ const doRequest = function (file) { fail() { showToast("文件上传失败") reject() - } + }, + ...opt }) }) } @@ -104,5 +105,6 @@ const coreMultiUploadFile = async (action = 'chooseImage', opt = {})=> { export { coreUploadFile, - coreMultiUploadFile + coreMultiUploadFile, + doRequest }