Files
yuxingu-Miniprogram-dev/components/yxg/yxg-nav.vue
T
jackyu66gitandCursor b09d82df8d feat: 小程序统一走 Go 后台,咨询与登录切到 /api/v1
去掉协会 WebView 和魔方账密页,微信登录与咨询接口共用同一 token 和拦截器。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-15 00:26:28 +08:00

112 lines
2.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="yxg-nav" :style="barStyle">
<view class="yxg-nav-row" :style="rowStyle">
<view v-if="showBack" class="yxg-nav-back" @click="onBack">
<text class="yxg-nav-back-ico"></text>
</view>
<image
v-if="logo"
class="yxg-nav-logo"
:src="logoSrc"
mode="aspectFit"
:style="logoStyle"
/>
<text v-else class="yxg-nav-title">{{ title }}</text>
</view>
</view>
<view v-if="placeholder" :style="barStyle" />
</template>
<script setup>
import { YXG_MP_LOGO_URL } from '@/util/yxgConfig.js'
import { yxgBack } from '@/util/yxgNav.js'
const props = defineProps({
title: { type: String, default: '' },
logo: { type: Boolean, default: false },
showBack: { type: Boolean, default: true },
placeholder: { type: Boolean, default: true },
})
function readWindow() {
// #ifdef MP-WEIXIN
if (typeof wx !== 'undefined' && wx.getWindowInfo) return wx.getWindowInfo()
// #endif
return uni.getSystemInfoSync()
}
const win = readWindow()
const statusBarH = win.statusBarHeight || 0
const screenW = win.windowWidth || win.screenWidth || 375
let navBarH = 44
let menuH = 32
try {
const menu = uni.getMenuButtonBoundingClientRect()
if (menu?.height) {
navBarH = (menu.top - statusBarH) * 2 + menu.height
menuH = menu.height
}
} catch (e) {
/* keep default */
}
const headH = statusBarH + navBarH
const logoH = Math.min(menuH, 30)
const logoW = Math.min(Math.round((logoH * 598) / 130), Math.floor(screenW * 0.4))
const barStyle = `height:${headH}px;padding-top:${statusBarH}px;box-sizing:border-box;`
const rowStyle = `height:${navBarH}px;`
const logoStyle = `width:${logoW}px;height:${logoH}px;`
const logoSrc = YXG_MP_LOGO_URL
function onBack() {
yxgBack()
}
</script>
<style scoped>
.yxg-nav {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
background: #ffd1c7;
}
.yxg-nav-row {
display: flex;
align-items: center;
justify-content: center;
position: relative;
width: 100%;
}
.yxg-nav-back {
position: absolute;
left: 8px;
top: 0;
bottom: 0;
width: 44px;
display: flex;
align-items: center;
justify-content: center;
}
.yxg-nav-back-ico {
font-size: 28px;
line-height: 1;
color: #614d49;
font-weight: 300;
}
.yxg-nav-title {
font-size: 16px;
font-weight: 700;
color: #333;
max-width: 56%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.yxg-nav-logo {
display: block;
}
</style>