秦佳浩 2 months ago
commit 29b6209986

@ -2,14 +2,10 @@
<view class="container"> <view class="container">
<!-- 头部搜索区 --> <!-- 头部搜索区 -->
<view class="search-bar"> <view class="search-bar">
<view <view class="search-box"
class="search-box" @tap="toSearchPage">
@tap="toSearchPage" <image src="@/static/images/icon/search.png"
> class="search-img" />
<image
src="@/static/images/icon/search.png"
class="search-img"
/>
<text class="sear-input"> <text class="sear-input">
搜索您想要的商品 搜索您想要的商品
</text> </text>
@ -18,75 +14,52 @@
<!-- 滚动内容区 --> <!-- 滚动内容区 -->
<view class="main"> <view class="main">
<!-- 左侧菜单start --> <!-- 左侧菜单start -->
<scroll-view <scroll-view scroll-y="true"
scroll-y="true" class="leftmenu">
class="leftmenu" <block v-for="(item, index) in categoryList"
> :key="index">
<block <view :class="'menu-item ' + (selIndex==index?'active':'') + ' '"
v-for="(item, index) in categoryList"
:key="index"
>
<view
:class="'menu-item ' + (selIndex==index?'active':'') + ' '"
:data-index="index" :data-index="index"
:data-id="item.categoryId" :data-id="item.categoryId"
@tap="onMenuTab" @tap="onMenuTab">
>
{{ item.categoryName }} {{ item.categoryName }}
</view> </view>
</block> </block>
<view <view v-if="!categoryList ||!categoryList.length"
v-if="!categoryList || !categoryList.length" class="ca-empty">
class="ca-empty"
>
{{ categoryList && categoryList.length? '该分类下暂无商品' : '暂无商品' }} {{ categoryList && categoryList.length? '该分类下暂无商品' : '暂无商品' }}
</view> </view>
</scroll-view> </scroll-view>
<!-- 左侧菜单end --> <!-- 左侧菜单end -->
<!-- 右侧内容start --> <!-- 右侧内容start -->
<scroll-view <scroll-view scroll-y="true"
scroll-y="true" class="rightcontent">
class="rightcontent"
>
<view class="adver-map"> <view class="adver-map">
<view class="item-a"> <view class="item-a">
<image <image :src="util.checkFileUrl(categoryImg)"
:src="util.checkFileUrl(categoryImg)" mode="widthFix" />
mode="widthFix"
/>
</view> </view>
</view> </view>
<!-- 子分类 --> <!-- 子分类 -->
<view <view v-if="subCategoryList.length"
v-if="subCategoryList.length" class="th-cate-con">
class="th-cate-con" <block v-for="(thCateItem, index) in subCategoryList"
> :key="index">
<block
v-for="(thCateItem, index) in subCategoryList"
:key="index"
>
<view class="sub-category"> <view class="sub-category">
<view <view class="sub-category-item"
class="sub-category-item"
:data-categoryid="thCateItem.categoryId" :data-categoryid="thCateItem.categoryId"
:data-parentid="thCateItem.parentId" :data-parentid="thCateItem.parentId"
@tap="toCatePage" @tap="toCatePage">
> <image :src="util.checkFileUrl(thCateItem.pic)"
<image
:src="util.checkFileUrl(thCateItem.pic)"
class="more-pic" class="more-pic"
mode="widthFix" mode="widthFix" />
/>
<text>{{ thCateItem.categoryName }}</text> <text>{{ thCateItem.categoryName }}</text>
</view> </view>
</view> </view>
</block> </block>
</view> </view>
<view <view v-else
v-else class="cont-item empty">
class="cont-item empty"
>
该分类下暂无子分类~ 该分类下暂无子分类~
</view> </view>
</scroll-view> </scroll-view>
@ -97,13 +70,22 @@
<script setup> <script setup>
import util from '@/utils/util.js' import util from '@/utils/util.js'
import { ref, onLoad } from 'vue'
import { uni } from '@dcloudio/uni-app'
import { http } from '@/utils/http.js' // http
//
const categoryList = ref([]) const categoryList = ref([])
//
const subCategoryList = ref([]) const subCategoryList = ref([])
//
const categoryImg = ref('') const categoryImg = ref('')
// ID
const parentId = ref('') const parentId = ref('')
/** // 0
* 生命周期函数--监听页面加载 const selIndex = ref(0)
*/
// -
onLoad(() => { onLoad(() => {
// //
http.request({ http.request({
@ -121,10 +103,7 @@ onLoad(() => {
}) })
}) })
const selIndex = ref(0) //
/**
* 分类点击事件
*/
const onMenuTab = (e) => { const onMenuTab = (e) => {
const index = e.currentTarget.dataset.index const index = e.currentTarget.dataset.index
getProdList(categoryList.value[index].categoryId) getProdList(categoryList.value[index].categoryId)
@ -133,15 +112,14 @@ const onMenuTab = (e) => {
selIndex.value = index selIndex.value = index
} }
/** //
* 跳转搜索页
*/
const toSearchPage = () => { const toSearchPage = () => {
uni.navigateTo({ uni.navigateTo({
url: '/pages/search-page/search-page' url: '/pages/search-page/search-page'
}) })
} }
//
const getProdList = (categoryId) => { const getProdList = (categoryId) => {
// //
http.request({ http.request({
@ -156,9 +134,7 @@ const getProdList = (categoryId) => {
}) })
} }
/** //
* 跳转子分类商品页面
*/
const toCatePage = (e) => { const toCatePage = (e) => {
const { categoryid } = e.currentTarget.dataset const { categoryid } = e.currentTarget.dataset
uni.navigateTo({ uni.navigateTo({

Loading…
Cancel
Save