Files
xl-mobile/src/pages/beginnerTutorial/index.vue

213 lines
6.3 KiB
Vue
Raw Normal View History

2025-03-25 16:35:39 +08:00
<script setup>
2025-05-12 19:45:27 +08:00
import {onMounted, reactive, ref} from "vue";
2025-03-27 15:38:21 +08:00
import XNav from "../../components/XNav.vue";
import videoMask from '../../static/images/video-mask.png';
2025-05-12 19:45:27 +08:00
import Api from "../../api/index.js";
import useTableQuery from "../../hooks/useTableQuery.js";
import OpenTypeFun from "../../components/OpenTypeFun.js";
2025-03-25 16:35:39 +08:00
2025-05-12 19:45:27 +08:00
const tabs = reactive([]);
const advList = reactive([]);
const tab = ref(1);
2025-03-27 15:38:21 +08:00
const collapseCur = ref(0);
2025-05-12 19:45:27 +08:00
const vo = reactive({
rows: [],
top: [],
page: 0,
total: 0,
});
const po = reactive({
category_id: 0,
});
const {loading, pagination, initFetchData} = useTableQuery({
api: Api.system.getArticle,
immediate: false,
parameter: po,
callback: async (data) => {
const {data: top} = await Api.system.getTopArticle(po);
console.log('???LLLL', top);
Object.assign(vo, data);
vo.top = top;
2025-03-27 15:38:21 +08:00
}
2025-05-12 19:45:27 +08:00
});
const getArticleCategory = async () => {
const {data} = await Api.system.getArticleCategory({
pid: tab.value
});
tabs.length = 0;
tabs.push(...data.map(v => ({
value: v.id,
name: v.name
})));
po.category_id = tabs[0].value;
await initFetchData();
}
const changeCategory = async (id) => {
tab.value = id;
await getArticleCategory();
}
const changeMinCategory = async (id) => {
po.category_id = id;
await initFetchData();
}
onMounted(() => {
getArticleCategory();
Api.system.getAdvList({
position: 3,
}).then(({data}) => {
advList.length = 0;
advList.push(...data);
});
})
2025-03-25 16:35:39 +08:00
</script>
<template>
<!--新手教程-->
2025-03-27 15:38:21 +08:00
<XNav></XNav>
<view class="box-border !p-[20rpx]">
<swiper class="!h-[240rpx] !w-full overflow-hidden rounded-[8rpx]">
2025-05-12 19:45:27 +08:00
<swiper-item class="!w-full !h-full" v-for="i in advList" :key="i.id">
<image @click="OpenTypeFun(i)" class="!w-full !h-full" mode="aspectFill" :src="i.file"></image>
2025-03-27 15:38:21 +08:00
</swiper-item>
</swiper>
</view>
<view class="!grid grid-cols-2 gap-[20rpx] !px-[20rpx]">
2025-05-12 19:45:27 +08:00
<view :class="['tab', tab===1 ? 'cur' : '']" @click="changeCategory(1)">
2025-03-27 15:38:21 +08:00
常见问题
</view>
2025-05-12 19:45:27 +08:00
<view :class="['tab', tab===2 ? 'cur' : '']" @click="changeCategory(2)">
2025-03-27 15:38:21 +08:00
基础教学
</view>
</view>
<view class="!mt-[20rpx] !px-[20rpx]">
<view class="!w-full bg-[#fff] rounded-[12rpx] pt-[30rpx] px-[20rpx]">
2025-05-12 19:45:27 +08:00
<template v-if="tab===1">
2025-03-27 15:38:21 +08:00
<view class="!grid grid-cols-4 gap-[20rpx]">
<view
v-for="item in tabs"
2025-05-12 19:45:27 +08:00
@click="changeMinCategory(item.value)"
:class="['rounded-full bg-[#F2F3F5] text-center !py-[8rpx] !text-[13px] duration-500', po.category_id===item.value ? 'current' : '']">
2025-03-27 15:38:21 +08:00
{{ item.name }}
</view>
</view>
2025-05-12 19:45:27 +08:00
<view class="!pt-[28rpx]">
<template v-for="(item,index) in [...vo.top, ...vo.rows]" :key="index">
2025-03-27 15:38:21 +08:00
<tui-collapse :index="index" :current="collapseCur" :disabled="item.disabled"
@click="({index}) => collapseCur=index">
<template v-slot:title>
2025-07-08 18:53:09 +08:00
<tui-list-cell :hover="!item.disabled">
<view class="w-full whitespace-nowrap ellipsis !pr-6">
{{ item.title }}
</view>
</tui-list-cell>
2025-03-27 15:38:21 +08:00
</template>
<template v-slot:content>
2025-05-12 19:45:27 +08:00
<view class="tui-content px-[16px] text-[#86909C]">{{ item.content }}</view>
2025-03-27 15:38:21 +08:00
</template>
</tui-collapse>
</template>
</view>
</template>
<template v-else>
<view class="!grid grid-cols-4 gap-[20rpx]">
<view
v-for="item in tabs"
2025-05-12 19:45:27 +08:00
@click="changeMinCategory(item.value)"
:class="['rounded-full bg-[#F2F3F5] text-center !py-[8rpx] !text-[13px] duration-500', po.category_id===item.value ? 'current' : '']">
2025-03-27 15:38:21 +08:00
{{ item.name }}
</view>
</view>
2025-05-12 19:45:27 +08:00
<view class="!pt-[28rpx]">
<template v-for="(item,index) in [...vo.top, ...vo.rows]" :key="index">
<view
@click="OpenTypeFun(item)"
:class="['!flex gap-[16rpx] py-[28rpx] box-border', index<vo.rows.length-1 ? 'border-b' : '']">
<image
class="!w-[148rpx] !h-[120rpx] rounded-[12rpx]"
mode="aspectFill"
:src="item.files && item.files[0] || videoMask">
</image>
<view class="!flex flex-col gap-[8rpx]">
<view class="title">{{ item.title }}</view>
<view class="info">
{{ item.content }}
2025-03-27 15:38:21 +08:00
</view>
</view>
2025-05-12 19:45:27 +08:00
</view>
2025-03-27 15:38:21 +08:00
</template>
</view>
</template>
</view>
</view>
2025-03-25 16:35:39 +08:00
</template>
2025-03-27 15:38:21 +08:00
<style lang="scss" scoped>
2025-07-08 18:53:09 +08:00
.ellipsis {
text-overflow: ellipsis;
overflow: hidden;
}
2025-03-27 15:38:21 +08:00
.border-b {
border-bottom: 1px solid rgb(229, 230, 235);
}
.title {
color: rgb(29, 33, 41);
font-size: 14px;
font-weight: 500;
letter-spacing: 0;
text-align: left;
}
.info {
color: rgb(134, 144, 156);
font-size: 12px;
font-weight: 400;
line-height: 16px;
letter-spacing: 0;
text-align: left;
}
.tab {
width: 100%;
padding: 20rpx;
background-color: #fff;
border-radius: 12rpx;
color: rgb(29, 33, 41);
font-size: 14px;
font-weight: 500;
line-height: 140%;
letter-spacing: 0;
text-align: center;
transition: 500ms;
}
.current {
background-color: #E8F3FF;
color: #165DFF;
}
#tabs {
width: 100% !important;
padding: 0 !important;
}
2025-03-25 16:35:39 +08:00
2025-03-27 15:38:21 +08:00
.cur {
background-color: rgb(22, 93, 255);
color: #fff;
}
2025-03-25 16:35:39 +08:00
</style>