Files
ClassContent/历届学生/fontendsix/项目练习/上课项目/uniapp-project/pages/index/index.vue
2024-09-27 02:06:13 +08:00

84 lines
2.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="home">
<div class="header">
<div class="header_search theme_color">
<i class="iconfont icon-taozi1"></i>
<div class="search">
<i class="iconfont icon-search"></i>
<span>198万张图,有你想要的...</span>
</div>
<i class="iconfont icon-wo"></i>
</div>
<div class="header_menu">
<scroll-view class="menu_list" scroll-x="true" :scroll-into-view="into">
<text @click="GetList(i)" v-for="(v,i) in list" :id="v.into" :class="i==Index?'active': ''" :key="i">{{ v.title }}</text>
</scroll-view>
<i class="iconfont icon-edit"></i>
</div>
</div>
<div class="content">
<swiper class="swiper" :current="Index" @change="pageChange">
<swiper-item v-for="(v,i) in list" :key="i">
<view class="swiper-item" v-for="(it,index) in v.content" :key="index">
{{ it.title }}
</view>
</swiper-item>
</swiper>
</div>
</view>
</template>
<script>
export default {
data() {
return {
into: "",
Index: 0,
list: []
}
},
async created() {
await this.getType();
await this.getClassList();
},
methods: {
async pageChange(event) {
let { current } = event.detail
this.Index = current;
this.into = `title${current}`
await this.getClassList();
},
async GetList(i) {
this.Index = i;
},
async getType() {
let res = await this.$http.index.type();
this.list = res.principal;
},
async getClassList() {
if (this.list[this.Index].content.length == 0) {
let res = await this.$http.index.classList({
page: this.list[this.Index].page,
id: this.list[this.Index].id,
});
this.list[this.Index].page = res.current_page
this.list[this.Index].total_page = res.total_page
this.list[this.Index].content = [
...this.list[this.Index].content,
...res.data
]
console.log("this.list ==== ", this.list)
}
}
}
}
</script>
<style lang="less" scoped>
@import "@/less/page/index.less";
</style>