去掉登录页

This commit is contained in:
zhouyanli
2026-08-04 08:40:57 +08:00
parent cc43bcd0e7
commit 4d038dbaf9
3 changed files with 56 additions and 148 deletions

View File

@@ -3,7 +3,7 @@ if (process.env.NODE_ENV === 'development') {
// baseUrl = 'https://wuyeapi.ckdzkj.com'; // 开发环境
baseUrl = "http://192.168.1.222:8080"
} else {
baseUrl = 'https://wuyeapi.bugtc.com'; // 生产环境
baseUrl = 'https://wuyeapi.ckdzkj.com'; // 生产环境
}
/**
@@ -42,21 +42,10 @@ export default function request(url, data = {}, method = "GET") {
const resData = res.data || {};
// token 过期 — 清除登录态,提示用户,但不强制跳转(用户可继续浏览非敏感页面)
// token 过期 — 静默清除登录态,不强制跳转登录页
if (resData.code === 401) {
uni.showToast({ title: '登录已过期,请重新登录', icon: 'none', duration: 2000 });
uni.removeStorageSync('token');
uni.removeStorageSync('userId');
// 使用 navigateTo 而非 reLaunch,用户可通过返回按钮退出登录页
setTimeout(() => {
uni.navigateTo({
url: '/pageSubPack/loginSub/pwd-login',
fail: () => {
// 如果 navigateTo 失败(如页面栈满),则用 reLaunch
uni.reLaunch({ url: '/pageSubPack/loginSub/pwd-login' });
}
});
}, 1500);
reject({ msg: '登录过期', code: 401 });
return;
}

View File

@@ -8,52 +8,52 @@
}
],
"subPackages": [
{
"root": "pageSubPack/loginSub",
"pages": [
{
"path": "register-new-user",
"style": {
"navigationBarTitleText": "注册新用户",
"navigationStyle": "custom"
}
},
{
"path": "pwd-login",
"style": {
"navigationBarTitleText": "账号密码登录",
"navigationStyle": "custom"
}
},
{
"path": "login",
"style": {
"navigationBarTitleText": "验证码登录",
"navigationStyle": "custom"
}
},
{
"path": "forget-pwd",
"style": {
"navigationBarTitleText": "忘记密码",
"navigationStyle": "custom"
}
},
{
"path": "change-pwd",
"style": {
"navigationBarTitleText": "修改密码",
"navigationStyle": "custom"
}
},
{
"path": "privacy",
"style": {
"navigationBarTitleText": "用户隐私政策"
}
}
]
},
// {
// "root": "pageSubPack/loginSub",
// "pages": [
// {
// "path": "register-new-user",
// "style": {
// "navigationBarTitleText": "注册新用户",
// "navigationStyle": "custom"
// }
// },
// {
// "path": "pwd-login",
// "style": {
// "navigationBarTitleText": "账号密码登录",
// "navigationStyle": "custom"
// }
// },
// {
// "path": "login",
// "style": {
// "navigationBarTitleText": "验证码登录",
// "navigationStyle": "custom"
// }
// },
// {
// "path": "forget-pwd",
// "style": {
// "navigationBarTitleText": "忘记密码",
// "navigationStyle": "custom"
// }
// },
// {
// "path": "change-pwd",
// "style": {
// "navigationBarTitleText": "修改密码",
// "navigationStyle": "custom"
// }
// },
// {
// "path": "privacy",
// "style": {
// "navigationBarTitleText": "用户隐私政策"
// }
// }
// ]
// },
{
"root": "pageSubPack/payment-list",
"pages": [

View File

@@ -9,15 +9,8 @@
</view>
<scroll-view class="page" scroll-y="true">
<view class="container">
<!-- 未登录提示条 -->
<view class="login-tip" v-if="!isLogin" @click="handleLoginPrompt">
<image class="login-tip-icon" src="https://wuyeadmin.bugtc.com/images/login/phone.png"></image>
<text class="login-tip-text">登录后可查看缴费账单</text>
<text class="login-tip-link">去登录</text>
</view>
<!-- 账单列表(仅登录后显示) -->
<view class="bill-list" v-if="isLogin && paymentList.length > 0">
<!-- 账单列表 -->
<view class="bill-list" v-if="paymentList.length > 0">
<view class="bill-item" @click="goToBill(item)" v-for="item,index in paymentList" :key="index">
<image class="billIcon" src="https://wuyeadmin.bugtc.com/images/propertyImgs/water.png"
@@ -62,7 +55,7 @@
import { ref } from 'vue'
import { onShow, onLoad } from '@dcloudio/uni-app'
import { getTopUpSelectByResident, getopenIdByCode, postInsertOpenId } from '/pageSubPack/api/apiSub.js'
import { isLoggedIn, requireAuth } from '/pageSubPack/api/auth.js'
import { isLoggedIn } from '/pageSubPack/api/auth.js'
import { getAppPaymentData, clearAppPaymentData, buildPaymentItemFromApp } from '/pageSubPack/api/appLaunch.js'
const isLogin = ref(false)
@@ -86,7 +79,7 @@
}
};
// ===== openid 相关(仅登录后) =====
// ===== openid 相关 =====
const postOpenId = async () => {
if (!isLogin.value) return;
try {
@@ -126,19 +119,13 @@
// ===== 生命周期 =====
onLoad(() => {
refreshLoginState();
if (isLogin.value) {
postOpenId();
// 检查是否由 App 跳转而来,携带了支付参数
checkAppLaunchPayment();
// getPayList();
}
postOpenId();
// 检查是否由 App 跳转而来,携带了支付参数
checkAppLaunchPayment();
});
onShow(() => {
refreshLoginState();
if (isLogin.value) {
// getPayList();
}
});
// ===== App 跳转支付:检测 extraData 并直接进入支付页 =====
@@ -158,63 +145,21 @@
uni.redirectTo({ url: "/pages/arrearsPayment/arrearsPayment" })
}
// ===== 点击事件(统一用 isLogin 判断) =====
// 点击"去登录"提示条
const handleLoginPrompt = () => {
if (isLogin.value) return;
requireAuth({
title: '查看缴费账单',
onLoggedIn: () => {
refreshLoginState();
// getPayList();
}
});
};
// ===== 点击事件 =====
// 点击账单明细
const goToBill = (item) => {
if (!isLogin.value) {
requireAuth({
title: '查看缴费详情',
onLoggedIn: () => {
refreshLoginState();
goToBill(item);
}
});
return;
}
uni.setStorageSync('arrearsPayment', item)
uni.redirectTo({ url: '/pages/arrearsPayment/arrearsPayment' })
};
// 点击缴费记录
const goToRecord = () => {
if (!isLogin.value) {
requireAuth({
title: '查看缴费记录',
onLoggedIn: () => {
refreshLoginState();
goToRecord();
}
});
return;
}
uni.redirectTo({ url: '/pageSubPack/payment-list/paymentRecord' })
};
// 点击新增缴费(水表/电表等)
const goToAdd = (type) => {
if (!isLogin.value) {
requireAuth({
title: '新增缴费',
onLoggedIn: () => {
refreshLoginState();
goToAdd(type);
}
});
return;
}
if (type.name == '燃气' || type.name == '暖气') {
uni.redirectTo({ url: '/pageSubPack/payment-list/selectPaymentEntity' })
} else if (type.name == '水表' || type.name == '电表') {
@@ -272,32 +217,6 @@
bottom: -140rpx;
}
/* ===== 未登录提示条 ===== */
.login-tip {
display: flex;
align-items: center;
background-color: #fff;
padding: 24rpx 30rpx;
border-radius: 10rpx;
margin-bottom: 30rpx;
box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.05);
}
.login-tip-icon {
width: 40rpx;
height: 40rpx;
margin-right: 16rpx;
}
.login-tip-text {
flex: 1;
font-size: 28rpx;
color: #666;
}
.login-tip-link {
font-size: 28rpx;
color: #1677ff;
font-weight: 500;
}
.bill-list {
margin-bottom: 40rpx;
background-color: #fff;