1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
| <script>
| export default {
| name: "navbar",
| props: {
| title: {
| type: String,
| default: "", // 默认值为空字符串
| validator(value) {
| return typeof value === 'string'; // 确保传入的值是字符串类型
| }
| },
| rightText: {
| type: String,
| default: "联系客服", // 默认值为空字符串
|
| },
| bgColor: {
| type: String,
| default: "#FFFFFF",
| }
| },
|
| created() {
| uni.getSystemInfo({
| success: (res) => {
| this.statusBarHeight = res.statusBarHeight + 44;
| },
| });
| },
|
| data() {
| return {
| // 为未来扩展预留状态变量
| isLoading: false,
| titleStyle: {
| color: this.bgColor==='#FFFFFF'?'#252938':'#FFFFFF'
| },
| };
| },
|
| methods: {
| // 封装 navigateBack 的逻辑,增加边界条件检查
| safeNavigateBack(delta = 1) {
| if (getCurrentPages().length <= delta) {
| console.warn("无法返回更多页面,当前页面栈不足");
| return;
| }
| uni.navigateBack({ delta });
| },
|
| back() {
| this.safeNavigateBack(1); // 调用封装方法
| },
| ermai(){
|
| uni.navigateTo({
| url: 'pages/web/index'
| });
| location.href =
| "https://ykf-weixin01.7moor.com/wapchat.html?accessId=0a043e50-4a64-11ef-8b85-491e10dcec05&fromUrl=http://hhttsl&urlTitle=APP&language=ZHCN&wechatOrAppImplant=true";
| }
| }
| };
| </script>
|
| <template>
| <uv-navbar
| :class="bgColor==='#FFFFFF'?'color0':'colorf'"
| :bgColor="bgColor"
| :leftIconColor="bgColor==='#FFFFFF'?'#252938':'#FFFFFF'"
| :title="title"
| @leftClick="back"
| autoBack
|
|
| :rightIconColor="bgColor==='#FFFFFF'?'#252938':'#FFFFFF'"
| :titleStyle="titleStyle"
| @rightClick="ermai"
| >
|
| </uv-navbar>
| </template>
|
| <style scoped lang="scss">
| .colorf{
| color: white;
|
| }
| </style>
|
|