mirror of
https://gitee.com/liuxioabin/fengketrade.git
synced 2026-04-17 21:03:17 +08:00
'登录逻辑优化和去除订单支付方式显示'
This commit is contained in:
parent
03ef33c8af
commit
178f5c87b4
@ -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');
|
|
||||||
}
|
|
||||||
|
|
||||||
// 调用建行登录API(静默登录,不显示loading)
|
// 调用建行登录API(静默登录,不显示loading)
|
||||||
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());
|
||||||
|
|
||||||
// 设置token(这会触发loginAfter异步加载完整数据)
|
// 设置token(这会触发loginAfter异步加载完整数据)
|
||||||
// 注意:不使用await,让它在后台加载,不阻塞UI
|
// 注意:不使用await,让它在后台加载,不阻塞UI
|
||||||
|
|||||||
@ -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>
|
||||||
<!-- 价格信息 -->
|
<!-- 价格信息 -->
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user