提交对首页跳转登录页的问题

This commit is contained in:
qiaomu 2024-08-02 16:41:52 +08:00
parent 01e3d60b6c
commit 6f253ba5b9
7 changed files with 30 additions and 88 deletions

View File

@ -1,7 +1,7 @@
{ {
"pages": [ "pages": [
"pages/login/index",
"pages/home/index", "pages/home/index",
"pages/login/index",
"pages/billList/index", "pages/billList/index",
"pages/rechargeRecord/index", "pages/rechargeRecord/index",
"pages/invoiceList/index", "pages/invoiceList/index",
@ -16,9 +16,7 @@
"pages/qrCode/index", "pages/qrCode/index",
"pages/recharge/index", "pages/recharge/index",
"pages/questions/index", "pages/questions/index",
"pages/editInvoice/index",
"pages/rechargeDetail/index", "pages/rechargeDetail/index",
"pages/updateInvoice/index", "pages/updateInvoice/index",
"pages/rechargeWay/index" "pages/rechargeWay/index"
], ],

View File

@ -1,66 +0,0 @@
// pages/editInvoice/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

View File

@ -1,2 +0,0 @@
<!--pages/editInvoice/index.wxml-->
<text>pages/editInvoice/index.wxml</text>

View File

@ -32,10 +32,9 @@ Page({
// }) // })
// return // return
// } // }
wx.switchTab({ wx.redirectTo({
url: '/pages/home/index', url: '/pages/login/index',
}) })
}, },
async getPrivacy() { async getPrivacy() {
const { code, message, data } = await getPrivaciList() const { code, message, data } = await getPrivaciList()
@ -81,6 +80,7 @@ Page({
}, },
getPhoneNumber(e) { getPhoneNumber(e) {
const { errno, code: phoneCode } = e.detail; const { errno, code: phoneCode } = e.detail;
console.log('e', e)
switch(errno) { switch(errno) {
case 103: case 103:
alertInfo("已拒绝"); alertInfo("已拒绝");

View File

@ -6,11 +6,10 @@
"enhance": true, "enhance": true,
"postcss": true, "postcss": true,
"preloadBackgroundData": false, "preloadBackgroundData": false,
"ignoreDevUnusedFiles": false,
"minified": true, "minified": true,
"newFeature": false, "newFeature": false,
"coverView": true, "coverView": true,
"nodeModules": false, "nodeModules": true,
"autoAudits": false, "autoAudits": false,
"showShadowRootInWxmlPanel": true, "showShadowRootInWxmlPanel": true,
"scopeDataCheck": false, "scopeDataCheck": false,
@ -19,14 +18,19 @@
"checkSiteMap": true, "checkSiteMap": true,
"uploadWithSourceMap": true, "uploadWithSourceMap": true,
"compileHotReLoad": false, "compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
"useMultiFrameRuntime": true, "useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"babelSetting": { "babelSetting": {
"ignore": [], "ignore": [],
"disablePlugins": [], "disablePlugins": [],
"outputPath": "" "outputPath": ""
}, },
"enableEngineNative": false, "enableEngineNative": false,
"bundle": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false, "userConfirmedBundleSwitch": false,
"packNpmManually": true, "packNpmManually": true,
"packNpmRelationList": [ "packNpmRelationList": [
@ -35,14 +39,8 @@
"miniprogramNpmDistDir": "./" "miniprogramNpmDistDir": "./"
} }
], ],
"minifyWXSS": true, "minifyWXSS": true
"showES6CompileOption": false,
"condition": false,
"compileWorklet": false,
"ignoreUploadUnusedFiles": false,
"useIsolateContext": true
}, },
"condition": {},
"editorSetting": { "editorSetting": {
"tabIndent": "insertSpaces", "tabIndent": "insertSpaces",
"tabSize": 2 "tabSize": 2
@ -51,5 +49,7 @@
"ignore": [], "ignore": [],
"include": [] "include": []
}, },
"appid": "wxb34b4e70f8a5c6f1" "appid": "wxb34b4e70f8a5c6f1",
"projectname": "elec",
"condition": {}
} }

View File

@ -238,4 +238,12 @@ export const getPixelRatio = () => {
export function isValidPhoneNumber(phoneNumber) { export function isValidPhoneNumber(phoneNumber) {
return /^1\d{10}$/.test(phoneNumber); return /^1\d{10}$/.test(phoneNumber);
}
/** 获取当前页面url */
export function getPageUrl() {
const pages = getCurrentPages() //获取加载的页面
const currentPage = pages[pages.length-1] //获取当前页面的对象
const url = currentPage.route //当前页面url
return url
} }

View File

@ -82,12 +82,16 @@ const parseResponse = function (response, url) {
alertError("服务异常") alertError("服务异常")
return return
} }
const { statusCode } = response; const { statusCode } = response;
console.log('url', url, 'response.status', statusCode, 'response.data', response.data) console.log('url', url, 'response.status', statusCode, 'response.data', response.data)
if (statusCode === 401) { if (statusCode === 401) {
wx.redirectTo({ const currentUrl = getPageUrl()
url: '/pages/login/index', if (!['pages/home/index', 'pages/login/index'].includes(currentUrl)) {
}) wx.redirectTo({
url: '/pages/login/index',
})
}
wx.clearStorageSync() wx.clearStorageSync()
return { code: 401, message: '未登录状态' } return { code: 401, message: '未登录状态' }
} }