Files
Yi.Admin/Yi.Vue3.x.Vant/src/view/main/recommend.vue

187 lines
4.0 KiB
Vue
Raw Normal View History

2022-10-05 23:54:53 +08:00
<template>
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
<van-list
class="list"
v-model:loading="loading"
:finished="finished"
finished-text="没有更多了"
@load="onLoad"
>
<van-row v-for="item in list" :key="item" class="row">
2022-10-08 23:05:19 +08:00
<van-col span="4" class="leftCol">
2022-10-05 23:54:53 +08:00
<van-image
round
width="3rem"
height="3rem"
src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg"
/>
</van-col>
2022-10-08 23:05:19 +08:00
<van-col span="14" class="centerTitle">
<span class="justtitle"> 大白</span>
<br />
<span class="subtitle">一小时前</span>
2022-10-05 23:54:53 +08:00
</van-col>
2022-10-09 00:14:17 +08:00
<van-col span="6" class="down">
2022-10-08 23:05:19 +08:00
<van-icon name="arrow-down" @click="show = true" />
2022-10-05 23:54:53 +08:00
</van-col>
2022-10-08 23:05:19 +08:00
<van-col class="rowBody" span="24"
>这是第:{{
item
}},不要害怕重新开始因为这一次你不是从头开始而是从经验开始</van-col
>
2022-10-05 23:54:53 +08:00
2022-10-08 23:05:19 +08:00
<van-col
span="8"
v-for="item of 9"
:key="item"
class="imageCol"
@click="imageShow = true"
><van-image
width="100%"
height="7rem"
src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg"
radius="5"
/>
</van-col>
2022-10-05 23:54:53 +08:00
2022-10-08 23:05:19 +08:00
<van-col span="24" class="bottomRow">
2022-10-05 23:54:53 +08:00
<van-grid direction="horizontal" :column-num="3">
<van-grid-item icon="share-o" text="分享" />
2022-10-08 23:05:19 +08:00
<van-grid-item icon="comment-o" text="评论" />
2022-10-05 23:54:53 +08:00
<van-grid-item icon="good-job-o" text="点赞" />
</van-grid>
</van-col>
</van-row>
</van-list>
</van-pull-refresh>
<!-- 功能页面 -->
<van-action-sheet
2022-10-08 23:05:19 +08:00
v-model:show="show"
:actions="actions"
cancel-text="取消"
description="这是一段描述信息"
close-on-click-action
/>
<!-- 图片预览 -->
<van-image-preview
v-model:show="imageShow"
:images="images"
@change="onChange"
:closeable=true
>
<template v-slot:index>{{ index }}</template>
</van-image-preview>
2022-10-05 23:54:53 +08:00
</template>
<script setup lang="ts">
import { ref } from "vue";
2022-10-08 23:05:19 +08:00
import { ImagePreview, Toast } from "vant";
const VanImagePreview = ImagePreview.Component;
const imageShow = ref(false);
const index = ref(0);
const images = [
"https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg",
"https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg",
];
const onChange = (newIndex: any) => {
index.value = newIndex;
};
2022-10-05 23:54:53 +08:00
const list = ref<Number[]>([]);
const loading = ref(false);
const finished = ref(false);
const refreshing = ref(false);
2022-10-08 23:05:19 +08:00
2022-10-05 23:54:53 +08:00
const show = ref(false);
2022-10-08 23:05:19 +08:00
const actions = [
{ name: "选项一" },
{ name: "选项二" },
{ name: "选项三", subname: "描述信息" },
];
2022-10-05 23:54:53 +08:00
const onLoad = () => {
setTimeout(() => {
if (refreshing.value) {
list.value = [];
refreshing.value = false;
}
for (let i = 0; i < 10; i++) {
list.value.push(list.value.length + 1);
}
loading.value = false;
if (list.value.length >= 40) {
finished.value = true;
}
}, 1000);
};
const onRefresh = () => {
// 清空列表数据
finished.value = false;
// 重新加载数据
// 将 loading 设置为 true表示处于加载状态
loading.value = true;
onLoad();
};
</script>
<style scoped>
.list {
2022-10-08 23:05:19 +08:00
background-color: #efefef;
2022-10-05 23:54:53 +08:00
}
.row {
background-color: white;
padding-top: 1rem;
margin-bottom: 1rem;
padding-left: 1rem;
2022-10-09 00:14:17 +08:00
padding-right: 1rem;
2022-10-05 23:54:53 +08:00
}
.rowBody {
2022-10-08 23:05:19 +08:00
text-align: left;
2022-10-05 23:54:53 +08:00
background-color: white;
2022-10-08 23:05:19 +08:00
min-height: 2rem;
2022-10-09 00:14:17 +08:00
margin-top: 1rem;
margin-bottom: 1rem;
2022-10-05 23:54:53 +08:00
}
.title {
2022-10-08 23:05:19 +08:00
padding-top: 1rem;
2022-10-05 23:54:53 +08:00
min-height: 3rem;
text-align: left;
}
2022-10-08 23:05:19 +08:00
.leftCol {
align-content: left;
text-align: left;
}
.centerTitle {
text-align: left;
}
.imageCol {
padding: 0.1rem 0.1rem 0.1rem 0.1rem;
}
.subtitle{
color: #CBCBCB;
}
.justtitle{
font-size: large;
}
.bottomRow{
color: #979797;
2022-10-05 23:54:53 +08:00
}
2022-10-09 00:14:17 +08:00
.down
{
text-align: right;
padding-right: 0.5rem;
}
2022-10-05 23:54:53 +08:00
</style>