初始化导入 hjsq H5 项目代码
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
<template>
|
||||
<div class="postboxs overflow-y-auto">
|
||||
<PullRefresh v-if="!state.loading" :params="moreParams" @onLoad="onLoad" @onRefresh="onRefresh">
|
||||
<div class="post">
|
||||
<div class="boxs" v-for="(item, index) in state.list" :key="index">
|
||||
<div class="bgbox" @click="$router.push({ path: '/communityTagDeatil', query: { id: item.id } })">
|
||||
<lazyImg :src="item.coverImg" :key="item.coverImg" class="avatar" />
|
||||
<div class="dialog">
|
||||
<p>{{ item.name }}</p>
|
||||
{{ item.videoCount || 0 }}个帖子
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn flex-center-center" @click="followUp(item)">
|
||||
{{ item.hasCollected ? '取消关注' : '关注' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</PullRefresh>
|
||||
<Loading v-else />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, nextTick } from 'vue';
|
||||
import UserApi from '@/service/user';
|
||||
import { useUserStore } from '@/stores/user';
|
||||
import CommunityApi from '@/service/community';
|
||||
import { showToast } from 'vant';
|
||||
const userStore = useUserStore();
|
||||
|
||||
const state = reactive({
|
||||
loading: true,
|
||||
pageNumber: 1,
|
||||
pageSize: 20,
|
||||
list: [],
|
||||
});
|
||||
|
||||
const moreParams = reactive({
|
||||
loading: true,
|
||||
refreshing: false,
|
||||
finished: false,
|
||||
isNoData: false,
|
||||
error: false,
|
||||
isHigehtMax: false,
|
||||
});
|
||||
|
||||
// 获取话题
|
||||
const getList = async (type: any) => {
|
||||
try {
|
||||
let req = {
|
||||
pageNumber: state.pageNumber,
|
||||
pageSize: state.pageSize,
|
||||
type: 'tag',
|
||||
uid: userStore.userInfo.uid,
|
||||
};
|
||||
let res: any = await UserApi.queryCollectList(req);
|
||||
state.loading = false;
|
||||
moreParams.loading = false;
|
||||
moreParams.refreshing = false;
|
||||
|
||||
let list = res.list || [];
|
||||
if (type === 'refresh') {
|
||||
state.list = list;
|
||||
} else {
|
||||
state.list = state.list.concat(list);
|
||||
}
|
||||
if (state.pageNumber == 1 && state.list.length == 0) {
|
||||
moreParams.isNoData = true;
|
||||
}
|
||||
if (!res.hasNext) {
|
||||
moreParams.finished = true;
|
||||
}
|
||||
} catch (e) {
|
||||
moreParams.loading = false;
|
||||
moreParams.error = true;
|
||||
}
|
||||
};
|
||||
|
||||
nextTick(() => {
|
||||
getList();
|
||||
});
|
||||
|
||||
// 关注
|
||||
const followUp = async (data: any) => {
|
||||
try {
|
||||
let isCollect = data.hasCollected;
|
||||
let req = {
|
||||
isCollect: !isCollect,
|
||||
objID: data.id,
|
||||
type: 'tag',
|
||||
};
|
||||
await CommunityApi.collect(req);
|
||||
data.hasCollected = !isCollect;
|
||||
showToast(`${data.hasCollected ? '关注' : '取消'}成功`);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
};
|
||||
|
||||
const onLoad = () => {
|
||||
moreParams.loading = true;
|
||||
state.pageNumber++;
|
||||
getList(null);
|
||||
};
|
||||
|
||||
const onRefresh = () => {
|
||||
state.pageNumber = 1;
|
||||
moreParams.refreshing = true;
|
||||
moreParams.finished = false;
|
||||
getList('refresh');
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.postboxs {
|
||||
width: 100%;
|
||||
height: calc(100vh - 90px);
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
.post {
|
||||
width: 100%;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-column-gap: 20px;
|
||||
grid-auto-flow: row dense;
|
||||
}
|
||||
.boxs {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
margin-bottom: 15px;
|
||||
.bgbox {
|
||||
width: 100%;
|
||||
height: 99px;
|
||||
.avatar {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.dialog {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgb(0, 0, 0, 0.5);
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
font-size: 12px;
|
||||
p {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
// margin-bottom: 25px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
// .btn{
|
||||
// margin-top: 10px;
|
||||
// width: 82px;
|
||||
// height: 26px;
|
||||
// font-size: 14px;
|
||||
// border-radius: 20px;
|
||||
// background: linear-gradient(to right, rgb(132,164,249), rgb(43,93,222));
|
||||
// }
|
||||
.btn {
|
||||
margin-top: 10px;
|
||||
width: 108px;
|
||||
height: 27px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
border-radius: 15px;
|
||||
background: rgba(52, 118, 255, 1);
|
||||
// background: linear-gradient(to right, rgb(132,164,249), rgb(43,93,222));
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,161 @@
|
||||
<template>
|
||||
<div class="userboxs overflow-y-auto">
|
||||
<PullRefresh v-if="!state.loading" :params="moreParams" @onLoad="onLoad" @onRefresh="onRefresh">
|
||||
<div
|
||||
class="userList"
|
||||
v-for="(item, index) in state.list"
|
||||
:key="index"
|
||||
@click="$router.push({ path: '/userInfo', query: { uid: item.uid } })"
|
||||
>
|
||||
<div class="left">
|
||||
<lazyImg class="avatar" :src="item.portrait" round :key="item.portrait" />
|
||||
<div>
|
||||
<p>{{ item.name }}</p>
|
||||
<span>{{ item.summary || '-' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right flex-center-center">
|
||||
<div class="btn flex-center-center" @click.stop="followUp(item)">
|
||||
{{ item.hasFollow ? '取消关注' : '关注' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</PullRefresh>
|
||||
<Loading v-else />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, nextTick } from 'vue';
|
||||
import UserApi from '@/service/user';
|
||||
import CommunityApi from '@/service/community';
|
||||
import { showToast } from 'vant';
|
||||
|
||||
const state = reactive({
|
||||
loading: true,
|
||||
pageNumber: 1,
|
||||
pageSize: 10,
|
||||
list: [],
|
||||
});
|
||||
|
||||
const moreParams = reactive({
|
||||
loading: true,
|
||||
refreshing: false,
|
||||
finished: false,
|
||||
isNoData: false,
|
||||
error: false,
|
||||
isHigehtMax: false,
|
||||
});
|
||||
|
||||
// 获取话题
|
||||
const getList = async (type: any) => {
|
||||
try {
|
||||
let req = {
|
||||
pageNumber: state.pageNumber,
|
||||
pageSize: state.pageSize,
|
||||
};
|
||||
let res: any = await UserApi.queryFollowList(req);
|
||||
state.loading = false;
|
||||
moreParams.loading = false;
|
||||
moreParams.refreshing = false;
|
||||
let list = res.list || [];
|
||||
if (type === 'refresh') {
|
||||
state.list = list;
|
||||
} else {
|
||||
state.list = state.list.concat(list);
|
||||
}
|
||||
if (state.pageNumber == 1 && state.list.length == 0) {
|
||||
moreParams.isNoData = true;
|
||||
}
|
||||
if (!res.hasNext) {
|
||||
moreParams.finished = true;
|
||||
}
|
||||
} catch (e) {
|
||||
moreParams.loading = false;
|
||||
moreParams.error = true;
|
||||
}
|
||||
};
|
||||
|
||||
nextTick(() => {
|
||||
getList();
|
||||
});
|
||||
|
||||
const onLoad = () => {
|
||||
moreParams.loading = true;
|
||||
state.pageNumber++;
|
||||
getList(null);
|
||||
};
|
||||
|
||||
const onRefresh = () => {
|
||||
state.pageNumber = 1;
|
||||
moreParams.refreshing = true;
|
||||
moreParams.finished = false;
|
||||
getList('refresh');
|
||||
};
|
||||
|
||||
// 关注
|
||||
const followUp = async (data: any) => {
|
||||
try {
|
||||
let req = {
|
||||
isFollow: !data.hasFollow,
|
||||
followUID: data?.uid,
|
||||
};
|
||||
await CommunityApi.careOrcancle(req);
|
||||
data.hasFollow = !data.hasFollow;
|
||||
showToast(`${data.hasFollow ? '关注' : '取消'}成功`);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.userboxs {
|
||||
width: 100%;
|
||||
height: calc(100vh - 80px);
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
|
||||
.userList {
|
||||
width: 100%;
|
||||
margin-bottom: 30px;
|
||||
height: 50px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding-top: 20px;
|
||||
.left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.avatar {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
margin-right: 15px;
|
||||
}
|
||||
p {
|
||||
font-size: 16px;
|
||||
margin: 10px 0;
|
||||
width: 250px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
span {
|
||||
font-size: 14px;
|
||||
color: rgb(172, 186, 191);
|
||||
display: inline-block;
|
||||
width: 250px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
.btn {
|
||||
width: 82px;
|
||||
height: 26px;
|
||||
font-size: 14px;
|
||||
border-radius: 20px;
|
||||
background: linear-gradient(to right, rgb(132, 164, 249), rgb(43, 93, 222));
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,190 @@
|
||||
<template>
|
||||
<div class="userboxs overflow-y-auto">
|
||||
<PullRefresh v-if="!state.loading" :params="moreParams" @onLoad="onLoad" @onRefresh="onRefresh">
|
||||
<div
|
||||
class="userList"
|
||||
v-for="(item, index) in state.list"
|
||||
:key="index"
|
||||
@click="$router.push({ path: '/userInfo', query: { uid: item.uid } })"
|
||||
>
|
||||
<div class="left">
|
||||
<lazyImg class="avatar" round :src="item.portrait" :key="item.portrait" />
|
||||
<div class="box">
|
||||
<p>{{ item.name }}</p>
|
||||
<div class="follow-info">
|
||||
<span>{{ watchCount(item.totalWorks) }}作品</span>
|
||||
<span>{{ watchCount(item.fans) }}粉丝</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right flex-center-center">
|
||||
<div class="btn flex-center-center" @click.stop="followUp(item)">已关注</div>
|
||||
</div>
|
||||
</div>
|
||||
</PullRefresh>
|
||||
<Loading v-else />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, nextTick } from 'vue';
|
||||
import UserApi from '@/service/user';
|
||||
import CommunityApi from '@/service/community';
|
||||
import { showToast } from 'vant';
|
||||
import { watchCount } from '@/utils/index';
|
||||
|
||||
const state = reactive({
|
||||
loading: true,
|
||||
pageNumber: 1,
|
||||
pageSize: 10,
|
||||
list: <any>[],
|
||||
});
|
||||
|
||||
const moreParams = reactive({
|
||||
loading: true,
|
||||
refreshing: false,
|
||||
finished: false,
|
||||
isNoData: false,
|
||||
error: false,
|
||||
isHigehtMax: false,
|
||||
});
|
||||
|
||||
// 获取话题
|
||||
const getList = async (type: any) => {
|
||||
try {
|
||||
let req = {
|
||||
pageNumber: state.pageNumber,
|
||||
pageSize: state.pageSize,
|
||||
};
|
||||
let res: any = await UserApi.queryFollowList(req);
|
||||
state.loading = false;
|
||||
moreParams.loading = false;
|
||||
moreParams.refreshing = false;
|
||||
|
||||
let list = res.list || [];
|
||||
if (type === 'refresh') {
|
||||
state.list = list;
|
||||
} else {
|
||||
state.list = state.list.concat(list);
|
||||
}
|
||||
if (state.pageNumber == 1 && state.list.length == 0) {
|
||||
moreParams.isNoData = true;
|
||||
}
|
||||
if (!res.hasNext) {
|
||||
moreParams.finished = true;
|
||||
}
|
||||
} catch (e) {
|
||||
moreParams.loading = false;
|
||||
moreParams.error = true;
|
||||
}
|
||||
};
|
||||
|
||||
nextTick(() => {
|
||||
getList('');
|
||||
});
|
||||
|
||||
const onLoad = () => {
|
||||
moreParams.loading = true;
|
||||
state.pageNumber++;
|
||||
getList(null);
|
||||
};
|
||||
|
||||
const onRefresh = () => {
|
||||
state.pageNumber = 1;
|
||||
moreParams.refreshing = true;
|
||||
moreParams.finished = false;
|
||||
getList('refresh');
|
||||
};
|
||||
|
||||
// 关注
|
||||
const followUp = async (data: any) => {
|
||||
try {
|
||||
let req = {
|
||||
isFollow: !data.hasFollow,
|
||||
followUID: data?.uid,
|
||||
};
|
||||
await CommunityApi.careOrcancle(req);
|
||||
data.hasFollow = !data.hasFollow;
|
||||
showToast(`${data.hasFollow ? '关注' : '取消'}成功`);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.userboxs {
|
||||
width: 100%;
|
||||
height: calc(100vh - 90px);
|
||||
padding: 14px 0;
|
||||
box-sizing: border-box;
|
||||
|
||||
.userList {
|
||||
width: calc(100% - 32px);
|
||||
height: 66px;
|
||||
margin: 0 16px 12px;
|
||||
padding: 12px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 8px;
|
||||
|
||||
.left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
.avatar {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
margin-right: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.box {
|
||||
overflow: hidden;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
color: #fff;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.follow-info {
|
||||
font-size: 12px;
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
margin-top: 4px;
|
||||
|
||||
span {
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.right {
|
||||
flex-shrink: 0;
|
||||
margin-left: 8px;
|
||||
|
||||
.btn {
|
||||
width: 60px;
|
||||
height: 24px;
|
||||
border-radius: 12px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,63 @@
|
||||
<template>
|
||||
<div class="follow">
|
||||
<Header title="我的关注" />
|
||||
<userBox />
|
||||
<!-- <van-tabs v-model:active="state.tabActive" type="card">
|
||||
<van-tab title="用户">
|
||||
<userBox v-if="state.tabActive == 0" />
|
||||
</van-tab>
|
||||
|
||||
<van-tab title="圈子">
|
||||
<postBox v-if="state.tabActive == 1" />
|
||||
</van-tab>
|
||||
</van-tabs> -->
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'follow',
|
||||
};
|
||||
</script>
|
||||
<script lang="ts" setup>
|
||||
import { nextTick, reactive, computed, onActivated, onDeactivated } from 'vue';
|
||||
import postBox from './components/postBox.vue';
|
||||
import userBox from './components/userBox.vue';
|
||||
|
||||
const state = reactive({
|
||||
tabActive: 0,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.follow {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #000;
|
||||
:deep(.van-tabs__wrap) {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
:deep(.van-tabs__nav--card) {
|
||||
border-radius: 30px;
|
||||
width: 188px !important;
|
||||
background: rgb(32, 37, 47);
|
||||
// background: rgba(255, 255, 255, 0.05);
|
||||
border: none;
|
||||
}
|
||||
:deep(.van-tab--card) {
|
||||
background: rgb(32, 37, 47);
|
||||
// background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 30px;
|
||||
border: none;
|
||||
color: rgb(172, 186, 191);
|
||||
}
|
||||
:deep(.van-tab--card.van-tab--active) {
|
||||
// background: linear-gradient(to right, rgb(132,164,249), rgb(43,93,222));
|
||||
background: rgba(52, 118, 255, 1);
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user