商城列表需要优化

This commit is contained in:
bobobobo
2025-12-24 22:21:24 +08:00
parent b67f9611c7
commit 334c0800fa
8 changed files with 202 additions and 64 deletions

View File

@@ -1,39 +1,65 @@
<script setup>
import { reactive } from 'vue'
import { reactive, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getCategory } from '@/api/mall'
// 顶部分类选项
const topNavOptions = [
{ name: '全部', value: '0' },
{ name: '休闲零食', value: '1' },
{ name: '中外名酒', value: '2' },
{ name: '家用洗漱', value: '3' },
{ name: '家电家具', value: '4' },
{ name: '电子产品', value: '5' },
{ name: '户外用品', value: '6' }
]
const topNavOptions = ref([])
const formData = reactive({
name: '',
type: '0'
})
const categoryList = async () => {
const res = await getCategory()
topNavOptions.value = res.data
console.log(res.data, '===22==')
}
const onTop = value => {
formData.type = value
}
onLoad(() => {
categoryList()
})
</script>
<template>
<view class="mall-list">
<cb-search v-model="formData.name"></cb-search>
<view class="top-options">
<view
v-for="item in topNavOptions"
:key="item.value"
:class="{ active: item.value === formData.type }"
class="text"
@click="onTop(item.value)"
>
{{ item.name }}
<view class="top-box">
<cb-search v-model="formData.name"></cb-search>
<view class="top-options">
<view
v-for="item in topNavOptions"
:key="item.value"
:class="{ active: item.id === formData.type }"
class="text"
@click="onTop(item.id)"
>
{{ item.categoryName }}
</view>
</view>
</view>
<!-- 商品卡片 -->
<view class="card-list">
<view v-for="item in 3" :key="item" class="card-item">
<image
src="https://wx1.sinaimg.cn/mw690/92eeb099gy1i29hl0ne80j21jk2bcash.jpg"
mode="scaleToFill"
class="imghead"
></image>
<text class="title">名称</text>
<view class="price">
<view class="num-box">
<text class="num"></text>
<text class="num">0.00</text>
</view>
<text class="buy">好评率99%</text>
</view>
<!-- 拼单数量 -->
<text class="bottom-name">拼单数量:12505</text>
</view>
</view>
</view>
@@ -41,37 +67,107 @@
<style lang="scss" scoped>
.mall-list {
padding: 24rpx;
.top-options {
overflow: hidden;
margin-top: 32rpx;
display: flex;
flex-direction: row;
white-space: nowrap; /* 重要:防止换行 */
-webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
.top-box {
padding: 24rpx;
.top-options {
overflow: hidden;
margin-top: 32rpx;
margin-bottom: 8rpx;
display: flex;
flex-direction: row;
white-space: nowrap; /* 重要:防止换行 */
-webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
.text + .text {
margin-left: 16rpx;
.text + .text {
margin-left: 16rpx;
}
.text {
flex-shrink: 0;
padding: 8rpx 16rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 500;
font-size: 28rpx;
color: #999999;
text-align: center;
font-style: normal;
text-transform: none;
background: #f4f4f4;
border-radius: 64rpx;
box-sizing: border-box;
}
.active {
padding: 6rpx 14rpx;
border-radius: 64rpx;
border: 2rpx solid #00d993;
color: #00d993;
}
}
.text {
flex-shrink: 0;
padding: 8rpx 16rpx;
}
.card-list {
background: #f9f9f9;
padding: 32rpx 24rpx;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
.card-item {
border-radius: 14rpx;
overflow: hidden;
margin-bottom: 18rpx;
display: flex;
flex-direction: column;
width: 344rpx;
background: #ffffff;
font-family: PingFang SC, PingFang SC;
font-weight: 500;
font-size: 28rpx;
color: #999999;
text-align: center;
font-style: normal;
text-transform: none;
background: #f4f4f4;
border-radius: 64rpx;
box-sizing: border-box;
}
.active {
padding: 6rpx 14rpx;
border-radius: 64rpx;
border: 2rpx solid #00d993;
color: #00d993;
.imghead {
width: 100%;
height: 288rpx;
}
.title {
font-weight: bold;
font-size: 28rpx;
color: #333333;
padding: 16rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.price {
padding: 0 16rpx;
display: flex;
justify-content: space-between;
align-items: baseline;
.num-box {
display: flex;
align-items: baseline;
.num {
font-weight: 500;
font-size: 24rpx;
color: #eb1c26;
&:last-child {
margin-left: 2rpx;
font-weight: bold;
font-size: 32rpx;
color: #eb1c26;
}
}
}
.buy {
font-weight: 500;
font-size: 24rpx;
color: #00d993;
}
}
.bottom-name {
padding: 16rpx 16rpx 26rpx 16rpx;
font-weight: 500;
font-size: 24rpx;
color: #999999;
}
}
}
}

View File

@@ -1,5 +1,5 @@
<script setup>
import { useUserStore } from '@/stores/user'
import { useAuthUser } from '@/composables/useAuthUser'
const bottomList = [
{ name: '我的钱包', icon: 'wallet' },
@@ -10,10 +10,7 @@
{ name: '在线客服', icon: 'customer' },
{ name: '系统设置', icon: 'system' }
]
const { userInfo } = useUserStore()
console.log(userInfo)
const { userInfo } = useAuthUser()
</script>
<template>
@@ -26,8 +23,8 @@
class="avatar"
></image>
<view class="nickname">
<text class="name">{{ userInfo.userName }}</text>
<text class="name">ID:{{ userInfo.userId }}</text>
<text class="name">{{ userInfo?.userName || '' }}</text>
<text class="name">ID:{{ userInfo?.userId || '' }}</text>
</view>
</view>
<image

View File

@@ -1,8 +1,9 @@
<script setup>
import { useUserStore } from '@/stores/user'
const { userInfo } = useUserStore()
import { useAuthUser } from '@/composables/useAuthUser'
console.log(userInfo.userId, '====userInfo===')
const { userInfo } = useAuthUser()
console.log(userInfo.value, '====use22rInfo===')
</script>
<template>