| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <template>
- <!-- 自定义导航栏-->
- <view class="page" :style="{height:windowHeight}">
- <!-- 侧栏 -->
- <scroll-view class="aside" scroll-y="true">
- <view
- class="item acea-row row-center-wrapper"
- :class="categoryDivindex === sideIndex ? 'on' : ''"
- v-for="(item, categoryDivindex) in classifyList"
- :key="categoryDivindex"
- @click="changeSide(categoryDivindex)"
- >
- {{ item.name }}
- </view>
- </scroll-view>
- <!-- 主内容 -->
- <scroll-view class="conter" scroll-y="true">
- <view v-if="classifyList[sideIndex]">
- <view class="title">{{ classifyList[sideIndex].name }}</view>
- <view class="list">
- <view class="item" v-for="(child, childIndex) in classifyList[sideIndex].children" :key="childIndex" @click="goGoodsList(child)">
- <!-- <u-image height="120rpx" width="120rpox" mode="widthFix" :src="child.pic"></u-image> -->
- <view class="name">{{ child.name }}</view>
- </view>
- </view>
- <NoData height="50vh" v-if="classifyList[sideIndex].children.length==0"></NoData>
- </view>
- </scroll-view>
- </view>
- </template>
- <script>
- export default {
- data() {
- const app = getApp();
- return {
- windowHeight:app.globalData.windowHeight + 'px',
- // 分类数据
- classifyList: [],
- // 分类索引
- sideIndex: 0,
- // 传参id
- queryClassifyId: ''
- };
- },
- onLoad(options) {
- if (options.id) {
- this.queryClassifyId = options.id;
- }
- this.getClassifyList();
- },
- methods: {
- // 动态切换分类
- changeClassifyById() {
- let nowClassifyIndex = 0;
- if (!this.queryClassifyId) return;
- this.classifyList.forEach((item, index) => {
- if (item.id === this.queryClassifyId) nowClassifyIndex = index;
- });
- if (nowClassifyIndex !== this.navActive) {
- this.changeSide(index);
- }
- },
- // 查询分类列表
- getClassifyList() {
- this.$u.api.getCateListAjax().then(({code,data})=>{
- if(code==1){
- this.classifyList = data;
- }
- }).catch();
- // this.changeClassifyById();
- },
- // 切换分类
- changeSide(index) {
- this.sideIndex = index;
- },
- // 跳转商品列表页
- goGoodsList(child) {
- this.$u.route('/pages/search-result', { cateInfo: encodeURIComponent(JSON.stringify(child)) });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .page {
- display: flex;
- justify-content: space-between;
- align-items: flex-start;
- background: $app-theme-bg-color;
- // background-color: red;
- .aside {
- width: 270rpx;
- background: $app-theme-bg-gray-color;
- height: 100%;
- .item {
- height: 100rpx;
- // line-height: 100rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- text-align: center;
- font-size: 28rpx;
- font-weight: 500;
- color: $app-theme-text-black-color;
- transition: all 0.3s ease-in-out;
- box-sizing: border-box;
- padding: 0 20rpx;
- &.on {
- color: #fff;
- position: relative;
- background-color: $app-theme-color;
- transition: all 0.3s ease-in-out;
- }
- }
- }
- .conter {
- padding-left: 20rpx;
- box-sizing: border-box;
- height: 100%;
- .title {
- font-size: 36rpx;
- font-weight: bold;
- // color: $app-theme-color;
- padding: 30rpx 0;
- border-bottom: 1rpx solid $app-theme-border-color;
- }
- .list {
- display: flex;
- justify-content: flex-start;
- align-items: flex-start;
- flex-wrap: wrap;
- .item {
- // width: 120rpx;
- margin:20rpx 15rpx 0;
- // &:nth-child(3n) {
- // margin-right: 0;
- // }
- .picture {
- }
- .name {
- font-size: 32rpx;
- color: $app-theme-color;
- text-align: center;
- margin-top: 12rpx;
- padding: 10rpx 20rpx;
- border: 1rpx solid $app-theme-color;
- border-radius: 2em;
- }
- }
- }
- }
- }
- </style>
|