- 新增底部导航栏配置,替换原有多页切换逻辑 - 统一页面跳转使用 switchTab 替代 reLaunch,优化性能 - 新增未读消息角标自动更新功能 - 修复登录后跳转逻辑,兼容旧版 tab 参数 - 调整页面高度为 100vh,修复安全区域适配问题 - 优化订单列表页加载逻辑,支持状态参数传递
144 行
3.5 KiB
Vue
144 行
3.5 KiB
Vue
<script>
|
|
import api from '@/utils/api.js';
|
|
import { isLogin } from '@/utils/request.js';
|
|
|
|
let lastNavUrl = '';
|
|
let lastNavAt = 0;
|
|
|
|
async function syncUserTabBadge() {
|
|
if (!isLogin()) {
|
|
uni.removeTabBarBadge({ index: 2, fail: () => {} });
|
|
return;
|
|
}
|
|
try {
|
|
const res = await api.messageUnread({ type: 'user' });
|
|
const count = Number(res?.unread || 0);
|
|
if (count > 0) {
|
|
uni.setTabBarBadge({
|
|
index: 2,
|
|
text: count > 99 ? '99+' : String(count),
|
|
fail: () => {}
|
|
});
|
|
} else {
|
|
uni.removeTabBarBadge({ index: 2, fail: () => {} });
|
|
}
|
|
} catch (e) {}
|
|
}
|
|
|
|
export default {
|
|
onLaunch: function() {
|
|
api.getServiceConfig(true).catch(() => {});
|
|
// #ifdef MP-WEIXIN
|
|
if (typeof wx !== 'undefined' && typeof wx.onNeedPrivacyAuthorization === 'function') {
|
|
wx.onNeedPrivacyAuthorization((resolve) => {
|
|
uni.$emit('yjyf:needPrivacyAuthorization', { resolve });
|
|
});
|
|
}
|
|
// #endif
|
|
uni.$on('yjyf:refreshUnread', syncUserTabBadge);
|
|
if (typeof uni !== 'undefined' && typeof uni.addInterceptor === 'function') {
|
|
uni.addInterceptor('navigateTo', {
|
|
invoke(args) {
|
|
const url = (args && args.url) ? String(args.url) : '';
|
|
const now = Date.now();
|
|
if (url && url === lastNavUrl && now - lastNavAt < 450) {
|
|
return false;
|
|
}
|
|
lastNavUrl = url;
|
|
lastNavAt = now;
|
|
return true;
|
|
}
|
|
});
|
|
}
|
|
},
|
|
onShow: function() {
|
|
syncUserTabBadge();
|
|
},
|
|
onHide: function() {
|
|
console.log('App Hide')
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
/* ============================================================
|
|
优匠优服 · 全局通用样式与基准工具类
|
|
============================================================ */
|
|
|
|
page {
|
|
background-color: $yjyf-bg-page;
|
|
font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', 'Hiragino Sans GB', Arial, sans-serif;
|
|
color: $yjyf-text-main;
|
|
box-sizing: border-box;
|
|
-webkit-font-smoothing: antialiased;
|
|
}
|
|
|
|
view, text, image, input, textarea, scroll-view, button {
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
/* 全局安全区底部内边距 */
|
|
.safe-area-bottom {
|
|
padding-bottom: constant(safe-area-inset-bottom);
|
|
padding-bottom: env(safe-area-inset-bottom);
|
|
}
|
|
|
|
/* 全局规范卡片类 */
|
|
.yjyf-card {
|
|
margin: $yjyf-space-sm $yjyf-space-lg 0;
|
|
padding: $yjyf-space-md;
|
|
background: $yjyf-bg-card;
|
|
border-radius: $yjyf-radius-md;
|
|
box-shadow: $yjyf-shadow-card;
|
|
}
|
|
|
|
/* 即时按压微交互反馈 (消除生硬感) */
|
|
.clickable-hover {
|
|
transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
|
|
}
|
|
.clickable-hover:active {
|
|
opacity: 0.82;
|
|
transform: scale(0.985);
|
|
}
|
|
|
|
/* 全局胶囊主行动按钮 */
|
|
.yjyf-btn-primary {
|
|
height: 88rpx;
|
|
line-height: 88rpx;
|
|
padding: 0 $yjyf-space-xl;
|
|
border-radius: $yjyf-radius-pill;
|
|
background: $yjyf-gradient-primary;
|
|
color: #FFFFFF;
|
|
font-size: $yjyf-font-body;
|
|
font-weight: 600;
|
|
text-align: center;
|
|
box-shadow: 0 8rpx 20rpx rgba(240, 113, 13, 0.28);
|
|
border: none;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
|
|
&[disabled], &.disabled {
|
|
opacity: 0.65;
|
|
box-shadow: none;
|
|
}
|
|
}
|
|
|
|
/* 骨架屏微光呼吸动效 (解决白屏) */
|
|
@keyframes yjyf-shimmer {
|
|
0% {
|
|
background-position: -400rpx 0;
|
|
}
|
|
100% {
|
|
background-position: 400rpx 0;
|
|
}
|
|
}
|
|
|
|
.yjyf-shimmer {
|
|
background: linear-gradient(90deg, #F0F1F3 25%, #E6E8EA 37%, #F0F1F3 63%);
|
|
background-size: 800rpx 100%;
|
|
animation: yjyf-shimmer 1.4s ease infinite;
|
|
border-radius: 8rpx;
|
|
}
|
|
</style>
|