<script setup lang="uts">
|
import { clearSession, hasActiveSession, hasRefreshableSession } from './services/session.uts'
|
import { refreshMerchantSession } from './services/session-refresh.uts'
|
import { initializeDevelopmentApiBaseUrl } from './config/development-server.uts'
|
// #ifdef APP-ANDROID || APP-HARMONY
|
let firstBackTime = 0
|
// #endif
|
|
onLaunch(() => {
|
console.log('App Launch')
|
// 先把服务端地址解析好:开发环境探测本机局域网 IP,换网后不必改代码重新编译。
|
initializeDevelopmentApiBaseUrl()
|
})
|
|
onAppShow(() => {
|
console.log('App Show')
|
if (!hasActiveSession() && hasRefreshableSession()) {
|
refreshMerchantSession((success: boolean) => {
|
if (!success) {
|
clearSession()
|
uni.reLaunch({ url: '/pages/login/login' })
|
}
|
})
|
}
|
})
|
|
onAppHide(() => {
|
console.log('App Hide')
|
})
|
|
// #ifdef APP-ANDROID || APP-HARMONY
|
onLastPageBackPress(() => {
|
console.log('App LastPageBackPress')
|
if (firstBackTime == 0) {
|
uni.showToast({
|
title: '再按一次退出应用',
|
position: 'bottom',
|
})
|
firstBackTime = Date.now()
|
setTimeout(() => {
|
firstBackTime = 0
|
}, 2000)
|
} else if (Date.now() - firstBackTime < 2000) {
|
firstBackTime = Date.now()
|
uni.exit()
|
}
|
})
|
|
onExit(() => {
|
console.log('App Exit')
|
})
|
// #endif
|
</script>
|
|
<style>
|
/*每个页面公共css */
|
.uni-row {
|
flex-direction: row;
|
}
|
|
.uni-column {
|
flex-direction: column;
|
}
|
|
.merchant-tabbar-host {
|
display: flex;
|
height: 138rpx;
|
position: fixed;
|
left: 42rpx;
|
right: 42rpx;
|
bottom: 24rpx;
|
bottom: calc(24rpx + constant(safe-area-inset-bottom));
|
bottom: calc(24rpx + env(safe-area-inset-bottom));
|
z-index: 10;
|
border-radius: 36rpx;
|
background-color: rgba(255, 255, 255, 0.98);
|
box-shadow: 0 10rpx 36rpx rgba(44, 53, 65, 0.14);
|
box-sizing: border-box;
|
overflow: visible;
|
}
|
|
/* 统一商户端自定义导航左上返回箭头,和人才端保持一致 */
|
.navigation-bar .back-button,
|
.hero-nav .hero-back,
|
.page > .back-button {
|
display: flex !important;
|
width: 80rpx !important;
|
height: 80rpx !important;
|
left: 18rpx !important;
|
top: 79rpx !important;
|
margin-left: 0 !important;
|
border-radius: 10rpx !important;
|
background-color: transparent !important;
|
box-shadow: none !important;
|
justify-content: center !important;
|
align-items: center !important;
|
}
|
|
.navigation-bar .back-icon,
|
.hero-nav .hero-back-icon,
|
.page > .back-button .back-icon {
|
width: 44rpx !important;
|
height: 44rpx !important;
|
transform: none !important;
|
}
|
|
.navigation-bar,
|
.hero-nav {
|
padding-left: 18rpx !important;
|
}
|
</style>
|