99 lines
2.4 KiB
Vue
99 lines
2.4 KiB
Vue
<template>
|
|
<div class="class">
|
|
<header>
|
|
<div>分类</div>
|
|
</header>
|
|
<div class="content">
|
|
<div class="list" v-for="(item,index) in list" :key='index'>
|
|
<span>{{ item.name }}</span>
|
|
<ul>
|
|
<li v-for='(item1,index1,key) in item.sub_cate' :key='index1' @tap='to_goodsDetail(item1,index,key)' >
|
|
<view v-if="!item1.show">{{item1.name}}</view>
|
|
<image v-if="item1.show" src="../../static/home/xia.png" mode="" style="height:18upx; width:30upx;"></image>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
list: [], // 分类列表菜单
|
|
all:[],
|
|
item1:[]
|
|
}
|
|
},
|
|
created(){
|
|
this.getClass()
|
|
},
|
|
methods: {
|
|
to_goodsDetail(item,index,key) {
|
|
if(key == 8 && item.show){
|
|
let arr = this.all[item.pid]
|
|
let int = 0
|
|
this.list[index].sub_cate.pop()
|
|
for (let j in arr) {
|
|
int++
|
|
if(int>8){
|
|
this.list[index].sub_cate.push(arr[j])
|
|
}
|
|
}
|
|
}else{
|
|
uni.navigateTo({
|
|
url: '/pages/index/search??cate_id=' + item.cate_id,
|
|
})
|
|
}
|
|
},
|
|
|
|
async getClass(){
|
|
this.list = []
|
|
let res = await this.$http.class.getClass({});
|
|
for (let i in res){
|
|
let arr = res[i].sub_cate
|
|
let son = []
|
|
let int = 0
|
|
this.all[i] =[]
|
|
for (let j in arr){
|
|
int++
|
|
if(int<9){
|
|
son.push(arr[j])
|
|
}
|
|
if(int==9){
|
|
let parames = {
|
|
name:'',
|
|
pid:arr[j].pid,
|
|
show:true
|
|
}
|
|
son.push(parames)
|
|
}
|
|
this.all[i].push(arr[j])
|
|
}
|
|
res[i].sub_cate = son
|
|
this.list.push(res[i])
|
|
console.log(arr)
|
|
}
|
|
// this.classli.forEach((v,i) =>{
|
|
// let name = v.sub_cate
|
|
// for (let k in name) {
|
|
// this.namey = name[k]
|
|
// // console.log(this.namey.name)
|
|
// }
|
|
// })
|
|
// console.log(this.classli)
|
|
// console.log(this.classli[0].sub_cate)
|
|
// console.log(JSON.stringify(this.classli[0].sub_cate).name)
|
|
}
|
|
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
@import "../../common/less/page/classify.less";
|
|
</style>
|