Browse Source

fix: 导航栏page级padding/登录input类型/员工端健壮性

dev
mac 1 day ago
parent
commit
a5f16152af
3 changed files with 35 additions and 32 deletions
  1. +17
    -16
      pages/staff/board.vue
  2. +16
    -8
      pages/staff/login.vue
  3. +2
    -8
      uni.scss

+ 17
- 16
pages/staff/board.vue View File

@ -10,15 +10,12 @@
</view>
</view>
<view class="staff-info">
🧑🍳 {{ staff.nickname }} 别摸鱼了
<text v-if="staff.unread > 0" class="staff-unread">💬 {{ staff.unread }}条新消息</text>
</view>
<view class="staff-info">🧑🍳 {{ staff.nickname }} 别摸鱼了</view>
<view class="board-tabs">
<view v-for="t in tabs" :key="t.status" class="board-tab" :class="{ active: activeTab === t.status }" @tap="switchTab(t.status)">
{{ t.label }}
<text class="tab-count">{{ counts[t.status] }}</text>
<text class="tab-count">{{ counts[t.status] || 0 }}</text>
</view>
</view>
@ -26,7 +23,7 @@
<OrderCard v-for="o in orders" :key="o.id" :order="o">
<template #actions>
<view class="board-actions">
<button class="ba-btn ba-gold" @tap="onDetail(o)">📖 配方</button>
<button class="ba-btn ba-gold" @tap="onDetail(o)">📖 详情</button>
<button class="ba-btn ba-blue" @tap="onChat(o)">💬 聊天</button>
<button v-if="o.status===0" class="ba-btn ba-gold" @tap="onConfirm(o.id)"> 接单</button>
<button v-if="o.status===0" class="ba-btn ba-red" @tap="onCancel(o.id)"> 拒单</button>
@ -41,7 +38,7 @@
<text class="empty-text">暂无订单</text>
</view>
<RecipeModal :visible="recipeVisible" :cardNo="recipeCardNo" :items="recipeItems" @close="recipeVisible=false" />
<RecipeModal v-if="recipeVisible" :visible="recipeVisible" :cardNo="recipeCardNo" :items="recipeItems" @close="recipeVisible=false" />
</view>
</template>
@ -62,6 +59,9 @@ export default {
const activeTab = ref(0)
const orders = ref([])
const counts = ref({ 0: 0, 1: 0, 2: 0 })
const recipeVisible = ref(false)
const recipeCardNo = ref('')
const recipeItems = ref([])
async function loadOrders() {
try {
@ -73,9 +73,11 @@ export default {
}
async function loadCounts() {
try {
const r0 = await get(API.STAFF_ORDERS, { status: 0 })
const r1 = await get(API.STAFF_ORDERS, { status: 1 })
const r2 = await get(API.STAFF_ORDERS, { status: 2, include_cancel: 1 })
const [r0, r1, r2] = await Promise.all([
get(API.STAFF_ORDERS, { status: 0 }),
get(API.STAFF_ORDERS, { status: 1 }),
get(API.STAFF_ORDERS, { status: 2, include_cancel: 1 })
])
counts.value = {
0: Array.isArray(r0) ? r0.length : 0,
1: Array.isArray(r1) ? r1.length : 0,
@ -84,9 +86,9 @@ export default {
} catch (e) {}
}
function switchTab(s) { activeTab.value = s; loadOrders() }
async function onConfirm(id) { try { await post(API.STAFF_CONFIRM, { id }); uni.showToast({ title: '已接单', icon: 'none' }); loadOrders(); loadCounts() } catch (e) {} }
async function onCancel(id) { try { await post(API.STAFF_CANCEL, { id }); uni.showToast({ title: '已拒单', icon: 'none' }); loadOrders(); loadCounts() } catch (e) {} }
async function onDone(id) { try { const res = await post(API.STAFF_DONE, { id }); uni.showToast({ title: res && res.released ? '已结单 ✔ 号码已释放' : '已结单', icon: 'none' }); loadOrders(); loadCounts() } catch (e) {} }
async function onConfirm(id) { try { await post(API.STAFF_CONFIRM, { id }); uni.showToast({ title: '已接单', icon: 'none' }); loadOrders(); loadCounts() } catch (e) {} }
async function onCancel(id) { try { await post(API.STAFF_CANCEL, { id }); uni.showToast({ title: '已拒单', icon: 'none' }); loadOrders(); loadCounts() } catch (e) {} }
async function onDone(id) { try { const res = await post(API.STAFF_DONE, { id }); uni.showToast({ title: res && res.released ? '已结单,号码释放' : '已结单', icon: 'none' }); loadOrders(); loadCounts() } catch (e) {} }
function onDetail(order) { uni.navigateTo({ url: '/pages/staff/detail?id=' + order.id }) }
function onRecipe(order) { recipeCardNo.value = order.cardNo; recipeItems.value = order.items; recipeVisible.value = true }
function onChat(order) { uni.setStorageSync('chatCardNo', order.cardNo); uni.navigateTo({ url: '/pages/staff/chat' }) }
@ -107,9 +109,8 @@ export default {
.nav-logo{font-size:44rpx}
.nav-brand{font-size:32rpx;font-weight:900;color:var(--gold)}
.logout-btn{font-size:26rpx;color:var(--red)}
.staff-info{background:var(--bg-card);padding:16rpx 32rpx;font-size:24rpx;color:var(--text-dim);border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between}
.staff-unread{color:var(--red);font-weight:700;font-size:22rpx}
.board-tabs{display:flex;border-bottom:1px solid var(--border);position:sticky;top:0;z-index:50;background:var(--bg);flex-shrink:0}
.staff-info{background:var(--bg-card);padding:16rpx 32rpx;font-size:24rpx;color:var(--text-dim);border-bottom:1px solid var(--border)}
.board-tabs{display:flex;border-bottom:1px solid var(--border);background:var(--bg);flex-shrink:0}
.board-tab{flex:1;padding:24rpx;text-align:center;font-size:26rpx;font-weight:600;color:var(--text-dim);border-bottom:4rpx solid transparent}
.board-tab.active{color:var(--gold);border-bottom-color:var(--gold)}
.tab-count{margin-left:8rpx;color:var(--red);font-size:22rpx}


+ 16
- 8
pages/staff/login.vue View File

@ -6,13 +6,13 @@
<text class="login-subtitle">别再摸鱼了起来干活</text>
<view class="login-form">
<input class="form-input" v-model="username" placeholder="账号" />
<input class="form-input" v-model="password" placeholder="密码" password />
<button class="login-submit" @tap="onLogin" :loading="loading">🔓 </button>
<input class="form-input" v-model="username" placeholder="账号" type="text" />
<input class="form-input" v-model="password" placeholder="密码" type="password" />
<button class="login-submit" @tap="onLogin" :loading="loading" :disabled="loading">🔓 </button>
</view>
<view style="margin-top:20rpx;">
<text style="color:var(--text-muted);font-size:24rpx" @tap="goBack"> 返回顾客端</text>
<view class="back-link" @tap="goBack">
<text> 返回顾客端</text>
</view>
</view>
</view>
@ -36,13 +36,20 @@ export default {
uni.showToast({ title: '请输入账号密码', icon: 'none' })
return
}
if (loading.value) return
loading.value = true
try {
const res = await post(API.STAFF_LOGIN, { username: username.value, password: password.value })
if (!res || !res.token) {
uni.showToast({ title: '登录失败', icon: 'none' })
loading.value = false
return
}
staff.login(res.token, res.nickname, res.staffId)
uni.redirectTo({ url: '/pages/staff/board' })
} catch (e) {}
loading.value = false
uni.reLaunch({ url: '/pages/staff/board' })
} catch (e) {
loading.value = false
}
}
function goBack() { uni.navigateBack() }
@ -61,5 +68,6 @@ export default {
.login-form{width:100%}
.form-input{width:100%;height:96rpx;background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-sm);padding:0 32rpx;font-size:30rpx;color:var(--text);margin-bottom:24rpx}
.login-submit{width:100%;height:96rpx;border-radius:24rpx;background:linear-gradient(135deg,var(--gold-dark),var(--gold));color:#1A1A1A;border:none;font-size:32rpx;font-weight:800;margin-top:16rpx;display:flex;align-items:center;justify-content:center}
.back-link{margin-top:24rpx;color:var(--text-muted);font-size:24rpx}
@keyframes float{0%,100%{transform:translateY(0)}50%{transform:translateY(-16rpx)}}
</style>

+ 2
- 8
uni.scss View File

@ -1,5 +1,5 @@
// 纯瘾大 全局样式
view,text,button,input,scroll-view,image,navigator,swiper,swiper-item{box-sizing:border-box}
page,view,text,button,input,scroll-view,image,navigator,swiper,swiper-item{box-sizing:border-box}
page {
--bg: #0D0D0D;
@ -22,19 +22,13 @@ page {
--radius-xs: 12rpx;
--nav-h: 100rpx;
--safe-b: 68rpx;
--status-h: var(--status-bar-height);
background-color: var(--bg);
color: var(--text);
font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
font-size: 28rpx;
min-height: 100vh;
width: 100%;
}
// 自定义导航栏基类所有页面 nav-bar 继承
page .nav-bar {
padding-top: var(--status-bar-height);
box-sizing: content-box;
padding-top: 44px;
}
// 动画


Loading…
Cancel
Save