优化
This commit is contained in:
@@ -6,8 +6,9 @@
|
||||
<view class="profile-list">
|
||||
<view class="profile-row"><text>作业仓库</text><text class="profile-value">{{ warehouseDisplay }}</text></view>
|
||||
<view class="profile-row"><text>当前班次</text><text class="profile-value">以海外仓排班为准</text></view>
|
||||
<view class="profile-row"><text>应用版本</text><text class="profile-value">0.1.0</text></view>
|
||||
<view class="profile-row"><text>应用版本</text><text class="profile-value">{{ appVersion }}</text></view>
|
||||
</view>
|
||||
<button class="profile-action" @tap="checkUpdate">检查更新 <text>›</text></button>
|
||||
<button class="profile-action" @tap="showSettings">系统设置 <text>›</text></button>
|
||||
<button class="logout-action" @tap="openLogout">退出登录</button>
|
||||
</view>
|
||||
@@ -20,18 +21,33 @@
|
||||
import PopupHeader from '@/components/PopupHeader.vue'
|
||||
import { getCurrentWarehouseProfile } from '@/api/inbound.js'
|
||||
import { applyWarehouseProfile, session, requireSession, signOut } from '@/stores/session.js'
|
||||
import { checkForAppUpdate } from '@/utils/app-update.js'
|
||||
export default {
|
||||
components: { PopupHeader, PortalHeader },
|
||||
data() { return { user: session.currentUser, logoutOpen: false, toast: false } },
|
||||
data() { return { user: session.currentUser, appVersion: '0.0.1', logoutOpen: false, toast: false } },
|
||||
computed: {
|
||||
displayName() { const name = String(this.user?.name || ''); return name && !/^[a-z0-9._-]+$/i.test(name) ? name : '仓库作业员' },
|
||||
avatar() { return this.displayName.slice(0, 1).toUpperCase() },
|
||||
warehouseDisplay() { return this.user?.warehouseName ? (this.user.warehouseCode ? `${this.user.warehouseName} · ${this.user.warehouseCode}` : this.user.warehouseName) : (this.user?.warehouse || '正在读取仓库主档') }
|
||||
},
|
||||
onShow() { if (!requireSession()) return; this.user = session.currentUser; this.loadWarehouseProfile() },
|
||||
onShow() { if (!requireSession()) return; this.user = session.currentUser; this.loadAppVersion(); this.loadWarehouseProfile() },
|
||||
beforeUnmount() { clearTimeout(this._toastTimer) },
|
||||
onBackPress() { if (!this.logoutOpen) return false; this.closeLogout(); return true },
|
||||
methods: {
|
||||
loadAppVersion() {
|
||||
// #ifdef APP-PLUS
|
||||
this.appVersion = String(plus.runtime.version || this.appVersion)
|
||||
// #endif
|
||||
},
|
||||
checkUpdate() {
|
||||
// #ifdef APP-PLUS
|
||||
checkForAppUpdate({ manual: true })
|
||||
return
|
||||
// #endif
|
||||
// #ifndef APP-PLUS
|
||||
uni.showToast({ title: '请在 PDA App 中检查更新', icon: 'none' })
|
||||
// #endif
|
||||
},
|
||||
async loadWarehouseProfile() { try { this.user = applyWarehouseProfile(await getCurrentWarehouseProfile()) } catch (_) { this.user = session.currentUser } },
|
||||
openLogout() { this.logoutOpen = true; this.$refs.logoutPopup.open() }, closeLogout() { this.logoutOpen = false; this.$refs.logoutPopup.close() }, handleLogoutChange(event) { this.logoutOpen = Boolean(event.show) },
|
||||
showSettings() { clearTimeout(this._toastTimer); this.toast = true; this._toastTimer = setTimeout(() => { this.toast = false }, 2200) },
|
||||
|
||||
Reference in New Issue
Block a user