From 0bafa6aa253c9ef6f5cb24e9a24c5282860e4c59 Mon Sep 17 00:00:00 2001
From: zhangback <zhangback@163.com>
Date: 星期一, 30 三月 2026 11:44:37 +0800
Subject: [PATCH] 新增线上配置
---
ui/car_wx_app/components/nav/index.vue | 151 +++++++++++++++++++++++++++++---------------------
1 files changed, 87 insertions(+), 64 deletions(-)
diff --git a/ui/car_wx_app/components/nav/index.vue b/ui/car_wx_app/components/nav/index.vue
index e131452..871c23f 100644
--- a/ui/car_wx_app/components/nav/index.vue
+++ b/ui/car_wx_app/components/nav/index.vue
@@ -1,113 +1,136 @@
<template>
- <u-navbar :bgColor="bgColor" :left-icon="leftIcon"
- :leftIconColor="leftIconColor" :leftText="leftText"
- :isShowLeft="isShowLeft" :placeholder="true"
- :title="title" :titleStyle="titleStyle"
- @leftClick="leftClick"
+ <u-navbar
+ :bgColor="bgColor"
+ :left-icon="leftIcon"
+ :leftIconColor="leftIconColor"
+ :leftText="leftText"
+ :isShowLeft="isShowLeft"
+ :placeholder="true"
+ :title="displayTitle"
+ :titleStyle="titleStyle"
+ @leftClick="leftClick"
>
- <view
- class="u-nav-slot"
- slot="right"
- >
- <u-icon :color="rightIconColor" @click="rightIconClick"
- :name="rightIcon"
- size="20"
- ></u-icon>
+ <view v-if="rightIcon" class="u-nav-slot" slot="right">
+ <u-icon
+ :color="rightIconColor"
+ @click="rightIconClick"
+ :name="rightIcon"
+ size="20"
+ />
</view>
</u-navbar>
</template>
<script>
+import { navigateBack, navigateToBack, getPageParams } from '@/common/router'
+
export default {
- name: "index",
- props:{
- title:{
+ name: 'NavBar',
+ props: {
+ // 鏍囬 - 鍙互鐩存帴浼犲瓧绗︿覆锛屾垨浠庨〉闈㈠弬鏁颁腑璇诲彇
+ title: {
type: String,
default: ''
},
- leftText:{
+ // 鏍囬瀛楁鍚� - 濡傛灉浠庨〉闈㈠弬鏁颁腑璇诲彇锛屾寚瀹氬瓧娈靛悕
+ titleKey: {
+ type: String,
+ default: 'title'
+ },
+ leftText: {
type: String,
default: ''
},
- leftIconColor:{
+ leftIconColor: {
type: String,
default: '#fff'
},
- leftIcon:{
+ leftIcon: {
type: String,
default: 'arrow-left'
},
-
- bgColor:{
+ bgColor: {
type: String,
- default: '#409effc1'
+ default: '#409eff'
},
- isShowLeft:{
+ isShowLeft: {
type: Boolean,
default: true
},
- customBack:{
+ // 鑷畾涔夎繑鍥炶矾寰� - 鍙互鏄〉闈㈤敭鍚嶆垨璺緞
+ customBack: {
type: String,
default: ''
},
- customType:{
+ // 杩斿洖鏂瑰紡: navigateBack(榛樿杩斿洖涓婁竴椤�) | navigateTo(璺宠浆鍒版寚瀹氶〉)
+ backType: {
type: String,
- default: 'redirectTo'
+ default: 'navigateBack',
+ validator: (value) => ['navigateBack', 'navigateTo'].includes(value)
},
- rightIcon:{
+ rightIcon: {
type: String,
default: ''
},
- rightIconColor:{
+ rightIconColor: {
type: String,
default: '#fff'
- },
- rightClick:{
- default:()=>{}
}
},
- data(){
- return{
- titleStyle:{
- color: "#fff"
+ data() {
+ return {
+ pageParams: {}
+ }
+ },
+ computed: {
+ // 鏈�缁堟樉绀虹殑鏍囬
+ displayTitle() {
+ // 浼樺厛浣跨敤 props 浼犲叆鐨� title
+ if (this.title) {
+ return this.title
+ }
+ // 鍏舵浠庨〉闈㈠弬鏁颁腑璇诲彇
+ if (this.pageParams[this.titleKey]) {
+ return this.pageParams[this.titleKey]
+ }
+ return ''
+ },
+ // 鏍囬鏍峰紡
+ titleStyle() {
+ return {
+ color: '#fff',
+ fontSize: '16px',
+ fontWeight: 500
}
}
},
- methods:{
- leftClick(){
- if (this.customBack){
- if (this.customType == 'navigateBack'){
- console.log('杩斿洖')
- uni.navigateBack({
- delta: 1,
- success: function () {
- console.log('杩斿洖鎴愬姛')
- },
- fail: function (e) {
- console.log(e)
- }
- });
- }else{
- uni.$u.route({
- url: this.customBack,
- type: this.customType
- }).catch(e=>{
- console.log(e)
- })
- }
- }else{
- uni.redirectTo();
+ mounted() {
+ // 鑾峰彇椤甸潰鍙傛暟
+ this.pageParams = getPageParams()
+ },
+ methods: {
+ leftClick() {
+ // 濡傛灉鐖剁粍浠剁洃鍚簡 back 浜嬩欢锛岀敱鐖剁粍浠舵帴绠¤繑鍥為�昏緫
+ if (this.$listeners && this.$listeners.back) {
+ this.$emit('back')
+ return
+ }
+ if (this.customBack) {
+ navigateToBack(this.customBack)
+ } else {
+ navigateBack()
}
},
- rightIconClick(){
- console.log(1)
- // this.rightClick();
- this.$emit('rightClick')
+ rightIconClick() {
+ this.$emit('rightClick')
}
}
}
</script>
<style scoped>
-
+.u-nav-slot {
+ display: flex;
+ align-items: center;
+}
</style>
--
Gitblit v1.8.0