소스 검색

feat:提交代码 ,完成头部UI改造

longzhicheng 1 년 전
부모
커밋
c16b41b316
3개의 변경된 파일892개의 추가작업 그리고 706개의 파일을 삭제
  1. 224 127
      src/pages/home/components/header.vue
  2. 19 0
      src/pages/home/constants.js
  3. 649 579
      src/pages/home/index.vue

+ 224 - 127
src/pages/home/components/header.vue

@@ -1,133 +1,230 @@
1 1
 <script lang="ts" setup>
2
-import { computed, PropType } from "vue";
3
-import FSearch from "~/components/FSearch/FSearch.vue";
4
-import type { UserInfoModel } from "~/apis/model/userInfoModel";
5
-import { useUserStore } from "~/stores/userStore";
6
-// import {useUserStore} from "~/stores/userStore";
7
-const userStore = useUserStore()
8
-
9
-const systemInfo = uni.getSystemInfoSync()
10
-const statusBarHeight = systemInfo.statusBarHeight ?? 0
11
-const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
12
-
13
-const navBarHeight = computed(() => {
14
-  // const propsHeight = Number(props.height)
15
-  let defaultHeight = 44
16
-  // #ifdef MP
17
-  // if (props.fixed) {
18
-  const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
19
-  const menuHeight = menuButtonInfo.height
20
-  const menuTop = menuButtonInfo.top
21
-  // console.log(menuButtonInfo)
22
-  defaultHeight = (menuTop - statusBarHeight) * 2 + menuHeight
23
-  // }
24
-  // #endif
25
-  // return propsHeight || defaultHeight
26
-  return defaultHeight
27
-})
28
-
29
-const navBarStyle = computed(() => {
30
-  return {
31
-    paddingTop: `${statusBarHeight}px`,
32
-  }
33
-})
34
-
35
-const props = defineProps({
36
-  exClass: {
37
-    type: String
38
-  },
39
-  // userInfo: {
40
-  //   type: Object as PropType<UserInfoModel>,
41
-  //   required: true
42
-  // },
43
-  yanglaojin: {
44
-    type: Number,
45
-    default: NaN
46
-  }
47
-})
48
-function handleClick() {
49
-  if (userStore.userInfo && userStore.uid) {
50
-    uni.navigateTo({
51
-      url: '/pages/annuity/index'
52
-    })
53
-  } else {
54
-    uni.navigateTo({
55
-      url: '/pages/user/login/index?key=30'
56
-    })
57
-  }
58
-}
59
-// function handleShowSearchPage() {
60
-//
61
-// }
62
-
63
-function handleShowMessage() {
64
-  uni.navigateTo({
65
-    url: '/pages/message/index'
66
-  })
67
-}
68
-function handleClickser() {
69
-  uni.navigateTo({
70
-    url: '/pages/search/index'
71
-  })
72
-}
2
+	import { computed, PropType } from "vue";
3
+	import FSearch from "~/components/FSearch/FSearch.vue";
4
+	import type { UserInfoModel } from "~/apis/model/userInfoModel";
5
+	import { useUserStore } from "~/stores/userStore";
6
+	import { TOP_LAB_ARR } from '../constants.js';
7
+
8
+
9
+	// import {useUserStore} from "~/stores/userStore";
10
+	const userStore = useUserStore()
11
+	
12
+
13
+	const systemInfo = uni.getSystemInfoSync()
14
+	const statusBarHeight = systemInfo.statusBarHeight ?? 0
15
+	const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
16
+
17
+	const navBarHeight = computed(() => {
18
+		// const propsHeight = Number(props.height)
19
+		let defaultHeight = 44
20
+		// #ifdef MP
21
+		// if (props.fixed) {
22
+		const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
23
+		const menuHeight = menuButtonInfo.height
24
+		const menuTop = menuButtonInfo.top
25
+		// console.log(menuButtonInfo)
26
+		defaultHeight = (menuTop - statusBarHeight) * 2 + menuHeight
27
+		// }
28
+		// #endif
29
+		// return propsHeight || defaultHeight
30
+		return defaultHeight
31
+	})
32
+	const currentIndex=ref(0)
33
+
34
+	const navBarStyle = computed(() => {
35
+		return {
36
+			paddingTop: `${statusBarHeight}px`,
37
+		}
38
+	})
39
+
40
+	const props = defineProps({
41
+		exClass: {
42
+			type: String
43
+		},
44
+		// userInfo: {
45
+		//   type: Object as PropType<UserInfoModel>,
46
+		//   required: true
47
+		// },
48
+		yanglaojin: {
49
+			type: Number,
50
+			default: NaN
51
+		}
52
+	})
53
+	function handleClick() {
54
+		if (userStore.userInfo && userStore.uid) {
55
+			uni.navigateTo({
56
+				url: '/pages/annuity/index'
57
+			})
58
+		} else {
59
+			uni.navigateTo({
60
+				url: '/pages/user/login/index?key=30'
61
+			})
62
+		}
63
+	}
64
+	// function handleShowSearchPage() {
65
+	//
66
+	// }
67
+
68
+	function handleShowMessage() {
69
+		uni.navigateTo({
70
+			url: '/pages/message/index'
71
+		})
72
+	}
73
+	function handleClickser() {
74
+		uni.navigateTo({
75
+			url: '/pages/search/index'
76
+		})
77
+	}
78
+	
79
+	function onTabClick(position:number){
80
+		console.log("===onTabClick",position);
81
+		currentIndex.value=position
82
+	}
73 83
 </script>
74 84
 <template>
75
-  <div class="home-header fixed w-screen text-white z-10" :style="navBarStyle" :class="exClass">
76
-    <div class="flex">
77
-      <div @click="handleClick" class="flex gap-2 mb-2 pl-2 flex-1">
78
-        <image v-if="userStore && userStore.userInfo && userStore.userInfo.avatar" :src="userStore.userInfo.avatar"
79
-          style="width:74rpx; height:74rpx;" class="rounded-full" />
80
-        <image v-else src="https://app.bjtdba.com/uploads/logo.jpg" mode="widthFix" class="w-9 h-9 rounded-full" />
81
-        <div class="flex flex-col ">
82
-          <div class="text-sm" v-if="userStore.userInfo && userStore.userInfo.nickname">{{ userStore.userInfo.nickname ?
85
+	<div class="home-header-content home-header fixed w-screen text-white z-10" :style="navBarStyle">
86
+		<image  class="top-bg" src="/static/img/jd_bg.png" mode="widthFix"></image>
87
+		<div class="flex user-info">
88
+			<div @click="handleClick" class="flex gap-2 mb-2 pl-2 flex-1">
89
+				<image v-if="userStore && userStore.userInfo && userStore.userInfo.avatar"
90
+					:src="userStore.userInfo.avatar" style="width:74rpx; height:74rpx;" class="rounded-full" />
91
+				<image v-else src="https://app.bjtdba.com/uploads/logo.jpg" mode="widthFix"
92
+					class="w-9 h-9 rounded-full" />
93
+				<div class="flex flex-col ">
94
+					<div class="text-sm" v-if="userStore &&userStore.userInfo && userStore.userInfo.nickname">{{ userStore.userInfo.nickname ?
83 95
             userStore.userInfo.nickname : '登录' }}</div>
84
-          <div class="text-sm" v-else>登录</div>
85
-          <div class="text-xs" v-if="!isNaN(yanglaojin) && userStore.userInfo">{{ yanglaojin }}元养老金</div>
86
-          <div v-else class="text-xs">
87
-            领取养老金
88
-          </div>
89
-        </div>
90
-
91
-      </div>
92
-      <div class=" right-26 flex flex-col text-[10px] justify-center items-center " @tap.stop="handleShowMessage"
93
-        :style="{ marginRight: `${menuButtonInfo.width + 15}px` }">
94
-        <image src="/static/icon/message-dark.png" mode="widthFix" class="w-4 h-4" v-if="exClass"></image>
95
-        <image src="/static/icon/message.png" mode="widthFix" class="w-4 h-4" v-else></image>
96
-        <div>消息</div>
97
-      </div>
98
-
99
-
100
-    </div>
101
-    <div class="p_3">
102
-      <!-- 搜索 -->
103
-      <div @click="handleClickser"
104
-        class="w-full bg-white rounded-full flex flex-row justify-between items-center border-solid border-1 border-red h-8">
105
-
106
-        <image src="https://cdn.bjtdba.com/vod/image/2023-02-15/20230215112840149.png" mode="widthFix"
107
-          class="w-5 h-5  pl-2 py-1"></image>
108
-        <div class="flex flex-1 w-100%">
109
-          <div class="flex-1 guand ">输入商品关键字</div>
110
-          <div class="bg-[#D71608] text-white text-xs w-11 rounded-full text-center p-1.5  mr-0.5 ">
111
-            搜索
112
-          </div>
113
-        </div>
114
-
115
-
116
-      </div>
117
-
118
-    </div>
119
-
120
-  </div>
96
+					<div class="text-sm" v-else>登录</div>
97
+					<div class="text-xs" v-if="!isNaN(yanglaojin) && userStore &&userStore.userInfo">{{ yanglaojin }}元养老金</div>
98
+					<div v-else class="text-xs">
99
+						领取养老金
100
+					</div>
101
+				</div>
102
+			</div>
103
+			<div class=" right-26 flex flex-col text-[10px] justify-center items-center " @tap.stop="handleShowMessage"
104
+				:style="{ marginRight: `${menuButtonInfo.width + 15}px` }">
105
+				<image src="/static/icon/message-dark.png" mode="widthFix" class="w-4 h-4" v-if="exClass"></image>
106
+				<image src="/static/icon/message.png" mode="widthFix" class="w-4 h-4" v-else></image>
107
+				<div>消息</div>
108
+			</div>
109
+		</div>
110
+
111
+		<view class="head-conent">
112
+			<div class="p_3">
113
+				<!-- 搜索 -->
114
+				<div @click="handleClickser"
115
+					class="w-full bg-white rounded-full flex flex-row justify-between items-center border-solid border-1 border-red h-8">
116
+					<image src="https://cdn.bjtdba.com/vod/image/2023-02-15/20230215112840149.png" mode="widthFix"
117
+						class="w-5 h-5  pl-2 py-1"></image>
118
+					<div class="flex flex-1 w-100%">
119
+						<div class="flex-1 guand ">输入商品关键字</div>
120
+						<div class="bg-[#D71608] text-white text-xs w-11 rounded-full text-center p-1.5  mr-0.5 ">
121
+							搜索
122
+						</div>
123
+					</div>
124
+				</div>
125
+			</div>
126
+
127
+			<view class="lab-content">
128
+				<scroll-view scroll-x="true" class="lab-item">
129
+                     <view class="lab-item-x" v-for="(item,index) in TOP_LAB_ARR">
130
+						<view class="lab-item-small"  @click="onTabClick(index)">
131
+							<text :class="currentIndex==index?'lab-title':'lab-default-title'" >{{item.title}}</text>
132
+							<view :class="currentIndex==index?'lab-line':'lab-default-line'"></view>
133
+						</view>
134
+					 </view>
135
+				</scroll-view>
136
+			</view>
137
+
138
+		</view>
139
+
140
+	</div>
121 141
 </template>
122
-<style  scoped>
123
-.p_3 {
124
-  padding-left: 24rpx;
125
-  padding-right: 24rpx;
126
-}
127
-
128
-.guand {
129
-  padding-left: 10rpx;
130
-  line-height: 56rpx;
131
-  color: #9ca3af
132
-}
142
+<style scoped lang="scss">
143
+	.home-header-content {
144
+		display: flex;
145
+		flex-direction: column;
146
+	}
147
+
148
+	.p_3 {
149
+		padding-left: 24rpx;
150
+		padding-right: 24rpx;
151
+	}
152
+
153
+	.guand {
154
+		padding-left: 10rpx;
155
+		line-height: 56rpx;
156
+		color: #9ca3af
157
+	}
158
+
159
+	.user-info {
160
+		z-index: 666;
161
+	}
162
+
163
+	.lab-content {
164
+		width: 100%;
165
+		height: 90rpx;
166
+		display: flex;
167
+		flex-direction: row;
168
+		align-items: center;
169
+		margin-top: 20rpx;
170
+
171
+		.lab-item {
172
+			display: flex;
173
+			flex-direction: row;
174
+			white-space: nowrap;
175
+			width: 100%;
176
+		}
177
+		
178
+		.lab-item-x {
179
+			display: inline-block;
180
+			margin-right: 10px;
181
+			text-align: center;
182
+		}
183
+		.lab-item-small{
184
+			display: flex;
185
+			flex-direction: column;
186
+			align-items: center;
187
+			width: 124rpx;
188
+			
189
+			.lab-default-title {
190
+				font-size: 28rpx;
191
+				margin-bottom: 10rpx;
192
+			}
193
+			.lab-title {
194
+				font-size: 32rpx;
195
+				margin-bottom: 10rpx;
196
+			}
197
+			.lab-line{
198
+				width: 50rpx;
199
+				height: 6rpx;
200
+				background-color: #FFF;
201
+				border-radius: 4rpx;
202
+			}
203
+			
204
+			.lab-default-line{
205
+				width: 50rpx;
206
+				height: 6rpx;
207
+				border-radius: 4rpx;
208
+			}
209
+			
210
+		}
211
+	}
212
+
213
+	.user-info {
214
+		z-index: 666;
215
+	}
216
+
217
+	.head-conent {
218
+		z-index: 666;
219
+		display: flex;
220
+		flex-direction: column;
221
+	}
222
+
223
+	.top-bg {
224
+		width: 100%;
225
+		height: 100rpx;
226
+		position: absolute;
227
+		top: 0;
228
+		left: 0;
229
+	}
133 230
 </style>

+ 19 - 0
src/pages/home/constants.js

@@ -0,0 +1,19 @@
1
+export const TOP_LAB_ARR = [
2
+	{title:"精品", checked:true,titleId: 0},
3
+	{title:"居家日用", checked:true,titleId: 1},
4
+	{title:"食品", checked:false,titleId: 2},
5
+	{title:"生鲜", checked:false,titleId: 3},
6
+	{title:"图书", checked:false,titleId: 4},
7
+	{title:"美妆个护", checked:false,titleId: 5},
8
+	{title:"母婴", checked:false,titleId: 6},
9
+	{title:"数码家电", checked:false,titleId: 7},
10
+	{title:"内衣", checked:false,titleId: 8},
11
+	{title:"配饰", checked:false,titleId: 9},
12
+	{title:"女装", checked:false,titleId: 10},
13
+	{title:"男装", checked:false,titleId: 11},
14
+	{title:"鞋品", checked:false,titleId: 12},
15
+	{title:"家装家纺", checked:false,titleId: 13},
16
+	{title:"文娱车品", checked:false,titleId: 14},
17
+	{title:"箱包", checked:false,titleId: 15},
18
+	{title:"户外运动", checked:false,titleId: 16},
19
+];

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 649 - 579
src/pages/home/index.vue