'登录逻辑优化和去除订单支付方式显示'

This commit is contained in:
gonghaoxing 2025-10-29 10:26:18 +08:00
parent 03ef33c8af
commit 178f5c87b4
3 changed files with 23 additions and 62 deletions

View File

@ -129,9 +129,9 @@
* *
* 逻辑 * 逻辑
* 1. 解析URL参数获取ccbParamSJ * 1. 解析URL参数获取ccbParamSJ
* 2. 与本地存储的lastCcbParamSJ比较 * 2. 检查上次登录时间
* 3. 如果一致则无需重新登录 * 3. 如果在3小时内则跳过登录
* 4. 如果不一致则需要切换用户退出当前用户后重新登录 * 4. 超过3小时则重新登录并更新时间戳
*/ */
const checkCCBLogin = () => { const checkCCBLogin = () => {
// #ifdef H5 // #ifdef H5
@ -159,24 +159,23 @@
} }
} }
// ccbParamSJ
const lastCcbParamSJ = uni.getStorageSync('lastCcbParamSJ') || null;
//
const isParamChanged = ccbParamSJ && lastCcbParamSJ !== ccbParamSJ;
const isFirstTime = ccbParamSJ && !lastCcbParamSJ;
// ccbParamSJ // ccbParamSJ
if (ccbParamSJ) { if (ccbParamSJ) {
// //
if (!isParamChanged && !isFirstTime) { const lastLoginTime = uni.getStorageSync('lastCcbLoginTime') || 0;
console.log('[CCB] 参数未变化,跳过登录'); const currentTime = Date.now();
const threeHoursInMs = 3 * 60 * 60 * 1000; // 3
// 3
if (lastLoginTime && currentTime - lastLoginTime < threeHoursInMs) {
const remainingMinutes = Math.ceil((threeHoursInMs - (currentTime - lastLoginTime)) / 1000 / 60);
console.log(`[CCB] 距离上次登录未满3小时剩余${remainingMinutes}分钟),跳过登录`);
const cleanUrl = window.location.origin + '/pages/index/index'; const cleanUrl = window.location.origin + '/pages/index/index';
window.history.replaceState({}, '', cleanUrl); window.history.replaceState({}, '', cleanUrl);
return; return;
} }
console.log(`[CCB] ${isParamChanged ? '切换用户' : '首次登录'}`); console.log(`[CCB] ${lastLoginTime ? '超过3小时重新登录' : '首次登录'}`);
// //
if (isLoggingIn) { if (isLoggingIn) {
@ -189,13 +188,8 @@
// //
setTimeout(async () => { setTimeout(async () => {
try { try {
// 退 // 退
const userStore = sheep.$store('user'); const userStore = sheep.$store('user');
if (isParamChanged && userStore && userStore.isLogin) {
await userStore.logout();
uni.removeStorageSync('token');
uni.removeStorageSync('userInfo');
}
// APIloading // APIloading
const result = await sheep.$api.third.ccbLogin({ const result = await sheep.$api.third.ccbLogin({
@ -224,7 +218,8 @@
// //
uni.setStorageSync('userInfo', result.data.user_info); uni.setStorageSync('userInfo', result.data.user_info);
uni.setStorageSync('lastCcbParamSJ', ccbParamSJ); //
uni.setStorageSync('lastCcbLoginTime', Date.now());
// tokenloginAfter // tokenloginAfter
// 使awaitUI // 使awaitUI

View File

@ -165,10 +165,10 @@
<text class="title">支付时间</text> <text class="title">支付时间</text>
<text class="detail">{{ state.orderInfo.paid_time || '-' }}</text> <text class="detail">{{ state.orderInfo.paid_time || '-' }}</text>
</view> </view>
<view class="notice-item"> <!-- <view class="notice-item">
<text class="title">支付方式</text> <text class="title">支付方式</text>
<text class="detail">{{ state.orderInfo.pay_types_text?.join(',') || '-' }}</text> <text class="detail">{{ state.orderInfo.pay_types_text?.join(',') || '-' }}</text>
</view> </view> -->
</view> </view>
</view> </view>
<!-- 价格信息 --> <!-- 价格信息 -->

View File

@ -93,31 +93,16 @@
<view class="copyright-text ss-m-b-10">{{ appInfo.copyright }}</view> <view class="copyright-text ss-m-b-10">{{ appInfo.copyright }}</view>
<view class="copyright-text">{{ appInfo.copytime }}</view> <view class="copyright-text">{{ appInfo.copytime }}</view>
</view> </view>
<!-- 退出登录按钮已暂时隐藏 -->
<su-fixed bottom placeholder v-if="false">
<view class="ss-p-x-20 ss-p-b-40">
<button
class="loginout-btn ss-reset-button ui-BG-Main ui-Shadow-Main"
@tap="onLogout"
v-if="isLogin"
>
退出登录
</button>
</view>
</su-fixed>
</s-layout> </s-layout>
</template> </template>
<script setup> <script setup>
import sheep from '@/sheep'; import sheep from '@/sheep';
import { computed, reactive } from 'vue'; import { computed } from 'vue';
const appInfo = computed(() => sheep.$store('app').info); const appInfo = computed(() => sheep.$store('app').info);
const isLogin = computed(() => sheep.$store('user').isLogin); const isLogin = computed(() => sheep.$store('user').isLogin);
const storageSize = uni.getStorageInfoSync().currentSize + 'Kb'; const storageSize = uni.getStorageInfoSync().currentSize + 'Kb';
const state = reactive({
showModal: false,
});
function onCheckUpdate() { function onCheckUpdate() {
sheep.$platform.checkUpdate(); sheep.$platform.checkUpdate();
@ -133,22 +118,10 @@
if (res.confirm) { if (res.confirm) {
const { code } = await sheep.$api.user.logoff(); const { code } = await sheep.$api.user.logoff();
if (code === 1) { if (code === 1) {
sheep.$store('user').logout(); //
sheep.$router.go('/pages/index/user'); uni.removeStorageSync('token');
} uni.removeStorageSync('userInfo');
} uni.removeStorageSync('lastCcbParamSJ');
},
});
}
function onLogout() {
uni.showModal({
title: '提示',
content: '确认退出账号?',
success: async function (res) {
if (res.confirm) {
const result = await sheep.$store('user').logout();
if (result) {
sheep.$router.go('/pages/index/user'); sheep.$router.go('/pages/index/user');
} }
} }
@ -213,13 +186,6 @@
} }
} }
.loginout-btn {
width: 100%;
height: 80rpx;
border-radius: 40rpx;
font-size: 30rpx;
}
.list-border { .list-border {
font-size: 28rpx; font-size: 28rpx;
font-weight: 400; font-weight: 400;