fix(app): 解决页面跳转冲突和登录重定向问题
- 在App.vue中延迟引导页跳转以避免首页未就绪导致的timeout错误 - 添加401跳登录页防重锁机制,防止多个接口同时返回401时的并发冲突 - 移除index.vue中的重复跳转逻辑,统一由App.vue处理首次启动跳转 - 优化record.vue中的品牌选择界面,添加"更多"展开功能和视觉改进 - 改进用量和度数输入框的样式和交互体验
This commit is contained in:
+56
-12
@@ -48,13 +48,18 @@
|
||||
<text class="section-label">品牌</text>
|
||||
<view class="brand-tags">
|
||||
<view
|
||||
v-for="brand in brandList"
|
||||
:key="brand.name"
|
||||
v-for="brand in visibleBrands"
|
||||
:key="brand.name + brand.product"
|
||||
class="tag"
|
||||
:class="{ 'tag-active': currentDrink.brand === brand.name }"
|
||||
:class="{ 'tag-active': currentDrink.brand === brand.name && currentDrink.product === brand.product }"
|
||||
@click="selectBrand(brand)"
|
||||
>
|
||||
<text>{{ brand.name }}</text>
|
||||
<!-- 同品牌多产品时展示产品名以便区分 -->
|
||||
<text>{{ brandList.filter(b => b.name === brand.name).length > 1 ? brand.name + '·' + brand.product : brand.name }}</text>
|
||||
</view>
|
||||
<!-- 更多:默认只展示前几个品牌,点击展开全部 -->
|
||||
<view v-if="brandList.length > maxVisibleBrands" class="tag tag-more" @click="showAllBrands = !showAllBrands">
|
||||
<text>{{ showAllBrands ? '收起 ▴' : '更多 ▾' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="input-row">
|
||||
@@ -81,14 +86,16 @@
|
||||
|
||||
<!-- 用量 + 度数 一行 -->
|
||||
<view class="amount-degree-row">
|
||||
<view class="amount-inline">
|
||||
<view class="amount-inline" :class="{ 'amount-focus-wrap': amountFocused }">
|
||||
<input
|
||||
class="amount-input text-num"
|
||||
type="digit"
|
||||
v-model="amountStr"
|
||||
placeholder="0"
|
||||
placeholder-class="input-placeholder"
|
||||
placeholder="输入用量"
|
||||
placeholder-class="amount-placeholder"
|
||||
@input="onAmountChange"
|
||||
@focus="amountFocused = true"
|
||||
@blur="amountFocused = false"
|
||||
/>
|
||||
<text class="amount-unit">{{ currentDrink.unit === 'ml' ? 'ml' : currentDrink.unit }}</text>
|
||||
</view>
|
||||
@@ -97,6 +104,8 @@
|
||||
class="degree-input text-num"
|
||||
type="digit"
|
||||
v-model="degreeStr"
|
||||
placeholder="度数"
|
||||
placeholder-class="input-placeholder"
|
||||
@input="onAmountChange"
|
||||
/>
|
||||
<text class="degree-symbol">°</text>
|
||||
@@ -339,7 +348,10 @@ export default {
|
||||
currentDrink: { category: '', brand: '', product: '', amount: 0, unit: 'ml', degree: 0 },
|
||||
drinks: [],
|
||||
brandList: [],
|
||||
showAllBrands: false,
|
||||
maxVisibleBrands: 8,
|
||||
amountStr: '',
|
||||
amountFocused: false,
|
||||
degreeStr: '',
|
||||
|
||||
// Step 2
|
||||
@@ -363,6 +375,10 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 品牌列表默认只展示前 maxVisibleBrands 个,点“更多”后展开全部
|
||||
visibleBrands() {
|
||||
return this.showAllBrands ? this.brandList : this.brandList.slice(0, this.maxVisibleBrands)
|
||||
},
|
||||
currentCups() {
|
||||
const ml = unitToMl(parseFloat(this.amountStr) || 0, this.currentDrink.unit)
|
||||
return calcStandardCups(ml, parseFloat(this.degreeStr) || 0)
|
||||
@@ -423,6 +439,7 @@ export default {
|
||||
this.currentDrink.degree = cat.defaultDegree
|
||||
this.degreeStr = String(cat.defaultDegree)
|
||||
this.brandList = BRANDS[cat.id] || []
|
||||
this.showAllBrands = false
|
||||
},
|
||||
selectBrand(brand) {
|
||||
this.currentDrink.brand = brand.name
|
||||
@@ -522,6 +539,7 @@ export default {
|
||||
this.amountStr = ''
|
||||
this.degreeStr = ''
|
||||
this.brandList = []
|
||||
this.showAllBrands = false
|
||||
},
|
||||
async publishRecord() {
|
||||
const recordData = {
|
||||
@@ -725,6 +743,13 @@ export default {
|
||||
margin-bottom: $sp-md;
|
||||
}
|
||||
|
||||
/* 更多/收起按钮:虚线边框与普通品牌标签区分 */
|
||||
.tag-more {
|
||||
border: 2rpx dashed var(--border-faint, rgba(255, 255, 255, 0.2));
|
||||
background: transparent;
|
||||
color: $amber;
|
||||
}
|
||||
|
||||
.input-row {
|
||||
margin-bottom: $sp-sm;
|
||||
}
|
||||
@@ -767,9 +792,19 @@ export default {
|
||||
|
||||
.amount-inline {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
align-items: center;
|
||||
gap: $sp-sm;
|
||||
flex: 1;
|
||||
background: $bg-elevated;
|
||||
border: 2rpx solid var(--border-faint, rgba(255, 255, 255, 0.12));
|
||||
border-radius: $radius-md;
|
||||
padding: $sp-xs $sp-lg;
|
||||
transition: border-color $duration-fast $ease-out;
|
||||
}
|
||||
|
||||
/* 聚焦时高亮边框,强化可输入感知(小程序不支持 :has(),由容器类控制) */
|
||||
.amount-focus-wrap {
|
||||
border-color: $amber;
|
||||
}
|
||||
|
||||
.degree-inline {
|
||||
@@ -796,20 +831,27 @@ export default {
|
||||
}
|
||||
|
||||
.amount-input {
|
||||
font-size: $fs-3xl;
|
||||
font-size: $fs-2xl;
|
||||
font-weight: $fw-black;
|
||||
color: $text-primary;
|
||||
flex: 1;
|
||||
background: transparent;
|
||||
border: none;
|
||||
padding: 0;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
height: 72rpx;
|
||||
line-height: 72rpx;
|
||||
}
|
||||
|
||||
.amount-placeholder {
|
||||
color: $text-tertiary;
|
||||
font-size: $fs-base;
|
||||
font-weight: $fw-normal;
|
||||
}
|
||||
|
||||
.amount-unit {
|
||||
font-size: $fs-md;
|
||||
color: $text-secondary;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.unit-switcher {
|
||||
@@ -849,11 +891,13 @@ export default {
|
||||
}
|
||||
|
||||
.degree-input {
|
||||
width: 100rpx;
|
||||
width: 120rpx;
|
||||
text-align: center;
|
||||
background: $bg-elevated;
|
||||
border-radius: $radius-md;
|
||||
border: 2rpx solid var(--border-faint, rgba(255, 255, 255, 0.12));
|
||||
padding: $sp-sm;
|
||||
height: 72rpx;
|
||||
color: $text-primary;
|
||||
font-size: $fs-lg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user