调整
This commit is contained in:
@@ -17,6 +17,13 @@
|
||||
<uni-icons type="right" size="18"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class="cell1">
|
||||
<view>工号</view>
|
||||
<view class="right select">
|
||||
<input placeholder="请输入工号" v-model="userinfo.sn"></input>
|
||||
<uni-icons type="right" size="18"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="foot">
|
||||
<button class="btn" @click="bcFn">{{$t('button.save')}}</button>
|
||||
@@ -38,8 +45,7 @@
|
||||
userinfo:{
|
||||
nickname:'',
|
||||
avatar:'',
|
||||
company:'',
|
||||
phone:'',
|
||||
sn:''
|
||||
},
|
||||
|
||||
}
|
||||
@@ -87,7 +93,8 @@
|
||||
method:'POST',
|
||||
data:{
|
||||
nickname:this.userinfo.nickname,
|
||||
avatar:this.userinfo.avatar
|
||||
avatar:this.userinfo.avatar,
|
||||
sn:this.userinfo.sn
|
||||
}
|
||||
}).then(res => {
|
||||
uni.showToast({
|
||||
|
||||
+249
-12
@@ -1,7 +1,48 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<uni-nav-bar leftText=" " :fixed="true" :border="false" leftIcon="back" @clickLeft="leftClick" color="#000000" backgroundColor="#fff" :statusBar="true" title="我的发布"></uni-nav-bar>
|
||||
|
||||
<view class="search">
|
||||
<view class="search-input-wrapper">
|
||||
<view class="search-input-box">
|
||||
<view v-if="searchTag" class="search-tag">
|
||||
<text>{{searchTag}}</text>
|
||||
<uni-icons type="closeempty" size="14" color="#666" @click="removeSearchTag"></uni-icons>
|
||||
</view>
|
||||
<input
|
||||
class="search-input"
|
||||
:placeholder="searchTag ? '' : '请输入搜索内容'"
|
||||
v-model="searchKeyword"
|
||||
@confirm="handleSearch"
|
||||
@input="handleSearchInput"
|
||||
/>
|
||||
<uni-icons type="search" size="18" color="#909399" @click="handleSearch"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class="sort-options">
|
||||
<view
|
||||
class="sort-item"
|
||||
:class="{active: sortField === 'browse'}"
|
||||
@click="toggleSort('browse')"
|
||||
>
|
||||
<text>观看量</text>
|
||||
<view class="">
|
||||
<u-icon name="arrow-up-fill" size="8" :color="sortField === 'browse'&&sortOrder === 'asc' ? '#206ff4' : '#666'"></u-icon>
|
||||
<u-icon name="arrow-down-fill" size="8" :color="sortField === 'browse'&&sortOrder === 'desc' ? '#206ff4' : '#666'" ></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="sort-item"
|
||||
:class="{active: sortField === 'favorite'}"
|
||||
@click="toggleSort('favorite')"
|
||||
>
|
||||
<text>收藏量</text>
|
||||
<view class="">
|
||||
<u-icon name="arrow-up-fill" size="8" :color="sortField === 'favorite'&&sortOrder === 'asc' ? '#206ff4' : '#666'"></u-icon>
|
||||
<u-icon name="arrow-down-fill" size="8" :color="sortField === 'favorite'&&sortOrder === 'desc' ? '#206ff4' : '#666'" ></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="year-selector" @click="showYearPicker">
|
||||
<text class="year-text">{{selectedYear}}年</text>
|
||||
<uni-icons type="arrowdown" size="14" color="#666"></uni-icons>
|
||||
@@ -21,9 +62,15 @@
|
||||
<text class="date-month">{{group.month}}月</text>
|
||||
</view>
|
||||
<view class="posts-container">
|
||||
<view v-for="post in group.posts" :key="post.id" class="post-item" @click="viewPost(post)">
|
||||
<image class="post-image" :src="post.media && post.media[0] ? post.media[0].url_pull : '/static/image/placeholder.png'" mode="aspectFill"></image>
|
||||
<text class="post-tag">{{post.content || ''}}</text>
|
||||
<view v-for="post in group.posts" :key="post.id" class="post-item">
|
||||
<image @click="viewPost(post)" class="post-image" :src="post.media && post.media[0] ? post.media[0].url_pull : '/static/image/placeholder.png'" mode="aspectFill"></image>
|
||||
<view class="" style="flex: 1;display: flex;">
|
||||
|
||||
<view @click="viewPost(post)" class="post-tag">{{ formatContent(post.content) }}</view>
|
||||
<view class="" style="width: 80rpx;text-align: right;">
|
||||
<uni-icons @click="delpost(post.id)" type="trash" color="#999" size="20"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -86,6 +133,10 @@
|
||||
pageSize: 10, // 每页数量
|
||||
hasMore: true, // 是否还有更多数据
|
||||
total: 0, // 总数据量
|
||||
searchKeyword: '',
|
||||
searchTag: '', // 搜索标签(如 #包豪斯)
|
||||
sortField: '', // 排序字段:''(时间) 或 'browse'(观看量) 或 'favorite'(收藏量)
|
||||
sortOrder: 'desc', // 排序方向:'asc' 升序 或 'desc' 降序
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -100,6 +151,10 @@
|
||||
this.loadPostList();
|
||||
},
|
||||
methods: {
|
||||
formatContent(str) {
|
||||
if (!str) return '';
|
||||
return str.length > 30 ? str.slice(0, 30) + '...' : str;
|
||||
},
|
||||
leftClick() {
|
||||
// uni.navigateBack()
|
||||
uni.reLaunch({
|
||||
@@ -122,6 +177,101 @@
|
||||
this.loadPostList(false);
|
||||
}
|
||||
},
|
||||
//删除帖子
|
||||
delpost(item){
|
||||
const that = this;
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除当前帖子吗?',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
request({
|
||||
url:'common/post/destroy',
|
||||
method:'POST',
|
||||
data:{
|
||||
id:item
|
||||
}
|
||||
}).then(res => {
|
||||
if(res.data.code === 200){
|
||||
// 从帖子列表中移除
|
||||
const index = that.postList.findIndex(post => post.id === item);
|
||||
if(index > -1){
|
||||
that.postList.splice(index, 1);
|
||||
// 重新分组
|
||||
that.groupPostsByDate();
|
||||
// 更新总数
|
||||
that.total = Math.max(0, that.total - 1);
|
||||
}
|
||||
uni.showToast({
|
||||
title:res.data.message || '删除成功',
|
||||
icon: 'none'
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title:res.data.message || '删除失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
// 处理搜索输入
|
||||
handleSearchInput(e) {
|
||||
const value = e.detail.value;
|
||||
// 检测是否输入了标签格式(#开头)
|
||||
if(value.startsWith('#')){
|
||||
this.searchTag = value;
|
||||
this.searchKeyword = '';
|
||||
} else {
|
||||
this.searchKeyword = value;
|
||||
if(this.searchTag){
|
||||
this.searchTag = '';
|
||||
}
|
||||
}
|
||||
},
|
||||
// 处理搜索
|
||||
handleSearch() {
|
||||
if(this.searchKeyword && this.searchKeyword.startsWith('#')){
|
||||
this.searchTag = this.searchKeyword;
|
||||
this.searchKeyword = '';
|
||||
}
|
||||
// 重新加载数据
|
||||
this.page = 1;
|
||||
this.hasMore = true;
|
||||
this.postList = [];
|
||||
this.groupedPosts = {};
|
||||
this.loadPostList(false);
|
||||
},
|
||||
// 移除搜索标签
|
||||
removeSearchTag() {
|
||||
this.searchTag = '';
|
||||
this.searchKeyword = '';
|
||||
// 重新加载数据
|
||||
this.page = 1;
|
||||
this.hasMore = true;
|
||||
this.postList = [];
|
||||
this.groupedPosts = {};
|
||||
this.loadPostList(false);
|
||||
},
|
||||
// 切换排序
|
||||
toggleSort(field) {
|
||||
if(this.sortField === field){
|
||||
// 如果点击的是当前排序字段,切换排序方向
|
||||
this.sortOrder = this.sortOrder === 'asc' ? 'desc' : 'asc';
|
||||
} else {
|
||||
// 如果点击的是新字段,设置为降序
|
||||
this.sortField = field;
|
||||
this.sortOrder = 'desc';
|
||||
}
|
||||
// 重新加载数据
|
||||
this.page = 1;
|
||||
this.hasMore = true;
|
||||
this.postList = [];
|
||||
this.groupedPosts = {};
|
||||
this.loadPostList(false);
|
||||
},
|
||||
// 加载帖子列表
|
||||
loadPostList(isLoadMore = false) {
|
||||
// 防止重复请求
|
||||
@@ -144,17 +294,37 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 构建请求参数
|
||||
const params = {
|
||||
// 只获取当前用户发布的帖子,后端应该根据token自动过滤
|
||||
current: this.page,
|
||||
size: this.pageSize,
|
||||
scene:'self',
|
||||
year:this.selectedYear
|
||||
};
|
||||
|
||||
// 添加搜索参数
|
||||
if(this.searchTag){
|
||||
params.keyword = this.searchTag.replace('#', '');
|
||||
} else if(this.searchKeyword){
|
||||
params.keyword = this.searchKeyword;
|
||||
}
|
||||
|
||||
// 添加排序参数
|
||||
if(this.sortField){
|
||||
params.sort_by = this.sortField;
|
||||
params.order = this.sortOrder;
|
||||
} else {
|
||||
// 默认按时间排序
|
||||
params.sort_by = '';
|
||||
params.order = 'desc';
|
||||
}
|
||||
|
||||
// 获取当前用户发布的帖子列表
|
||||
request({
|
||||
url: 'common/post/list',
|
||||
method: 'GET',
|
||||
data: {
|
||||
// 只获取当前用户发布的帖子,后端应该根据token自动过滤
|
||||
current: this.page,
|
||||
size: this.pageSize,
|
||||
scene:'self',
|
||||
year:this.selectedYear
|
||||
}
|
||||
data: params
|
||||
}).then(res => {
|
||||
this.loading = false;
|
||||
this.loadingMore = false;
|
||||
@@ -255,6 +425,11 @@
|
||||
this.refreshing = false;
|
||||
return;
|
||||
}
|
||||
// 下拉刷新时重置为默认时间排序
|
||||
if(this.sortField !== ''){
|
||||
this.sortField = '';
|
||||
this.sortOrder = 'desc';
|
||||
}
|
||||
this.refreshing = true;
|
||||
this.page = 1;
|
||||
this.hasMore = true;
|
||||
@@ -284,7 +459,69 @@
|
||||
height: 100%;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.search{
|
||||
padding: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
background: #fff;
|
||||
}
|
||||
.search-input-wrapper{
|
||||
flex: 1;
|
||||
}
|
||||
.search-input-box{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #F5F6FA;
|
||||
border-radius: 10rpx;
|
||||
padding: 15rpx 24rpx;
|
||||
gap: 12rpx;
|
||||
}
|
||||
.search-tag{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 4rpx 12rpx;
|
||||
gap: 8rpx;
|
||||
font-size: 24rpx;
|
||||
color: #333;
|
||||
margin-right: 8rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.search-tag text{
|
||||
font-size: 24rpx;
|
||||
color: #333;
|
||||
}
|
||||
.search-input{
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
background: transparent;
|
||||
border: none;
|
||||
}
|
||||
.sort-options{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.sort-item{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6rpx;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
transition: color 0.3s;
|
||||
}
|
||||
.sort-item.active{
|
||||
color: #206ff4;
|
||||
font-weight: 500;
|
||||
}
|
||||
.sort-item text{
|
||||
font-size: 26rpx;
|
||||
}
|
||||
.year-selector {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
+173
-5
@@ -3,6 +3,48 @@
|
||||
<z-paging ref="paging" :auto="false" v-model="contList" @query="queryList" empty-view-text="暂无数据!">
|
||||
<template #top>
|
||||
<uni-nav-bar leftText=" " :fixed="true" :border="false" leftIcon="back" @clickLeft="leftClick" color="#000000" backgroundColor="#fff" :statusBar="true" title="我的收藏"></uni-nav-bar>
|
||||
<view class="search">
|
||||
<view class="search-input-wrapper">
|
||||
<view class="search-input-box">
|
||||
<view v-if="searchTag" class="search-tag">
|
||||
<text>{{searchTag}}</text>
|
||||
<uni-icons type="closeempty" size="14" color="#666" @click="removeSearchTag"></uni-icons>
|
||||
</view>
|
||||
<input
|
||||
class="search-input"
|
||||
:placeholder="searchTag ? '' : '请输入搜索内容'"
|
||||
v-model="searchKeyword"
|
||||
@confirm="handleSearch"
|
||||
@input="handleSearchInput"
|
||||
/>
|
||||
<uni-icons type="search" size="18" color="#909399" @click="handleSearch"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class="sort-options">
|
||||
<view
|
||||
class="sort-item"
|
||||
:class="{active: sortField === 'browse'}"
|
||||
@click="toggleSort('browse')"
|
||||
>
|
||||
<text>观看量</text>
|
||||
<view class="">
|
||||
<u-icon name="arrow-up-fill" size="8" :color="sortField === 'browse'&&sortOrder === 'asc' ? '#206ff4' : '#666'"></u-icon>
|
||||
<u-icon name="arrow-down-fill" size="8" :color="sortField === 'browse'&&sortOrder === 'desc' ? '#206ff4' : '#666'" ></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="sort-item"
|
||||
:class="{active: sortField === 'favorite'}"
|
||||
@click="toggleSort('favorite')"
|
||||
>
|
||||
<text>收藏量</text>
|
||||
<view class="">
|
||||
<u-icon name="arrow-up-fill" size="8" :color="sortField === 'favorite'&&sortOrder === 'asc' ? '#206ff4' : '#666'"></u-icon>
|
||||
<u-icon name="arrow-down-fill" size="8" :color="sortField === 'favorite'&&sortOrder === 'desc' ? '#206ff4' : '#666'" ></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<!-- 内容网格 -->
|
||||
<view class="content-grid">
|
||||
@@ -29,7 +71,11 @@
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
contList:[]
|
||||
contList:[],
|
||||
searchKeyword: '',
|
||||
searchTag: '', // 搜索标签(如 #包豪斯)
|
||||
sortField: '', // 排序字段:''(时间) 或 'browse'(观看量) 或 'favorite'(收藏量)
|
||||
sortOrder: 'desc', // 排序方向:'asc' 升序 或 'desc' 降序
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
@@ -54,13 +100,29 @@
|
||||
queryList(pageNo, pageSize) {
|
||||
this.loading = true;
|
||||
var that = this;
|
||||
const params = {
|
||||
current:pageNo,
|
||||
size:10
|
||||
};
|
||||
// 添加搜索参数
|
||||
if(this.searchTag){
|
||||
params.keyword = this.searchTag.replace('#', '');
|
||||
} else if(this.searchKeyword){
|
||||
params.keyword = this.searchKeyword;
|
||||
}
|
||||
// 添加排序参数(如果后端支持)
|
||||
if(this.sortField){
|
||||
params.sort_by = this.sortField;
|
||||
params.order = this.sortOrder;
|
||||
} else {
|
||||
// 默认按时间排序
|
||||
params.sort_by = '';
|
||||
params.order = 'desc';
|
||||
}
|
||||
request({
|
||||
url:'common/post/favorite/self',
|
||||
method:'get',
|
||||
data: {
|
||||
current:pageNo,
|
||||
size:10
|
||||
}
|
||||
data: params
|
||||
}).then(res => {
|
||||
|
||||
if(res.data.code ==200){
|
||||
@@ -74,6 +136,49 @@
|
||||
//
|
||||
})
|
||||
},
|
||||
// 处理搜索输入
|
||||
handleSearchInput(e) {
|
||||
const value = e.detail.value;
|
||||
// 检测是否输入了标签格式(#开头)
|
||||
if(value.startsWith('#')){
|
||||
this.searchTag = value;
|
||||
this.searchKeyword = '';
|
||||
} else {
|
||||
this.searchKeyword = value;
|
||||
if(this.searchTag){
|
||||
this.searchTag = '';
|
||||
}
|
||||
}
|
||||
},
|
||||
// 处理搜索
|
||||
handleSearch() {
|
||||
if(this.searchKeyword && this.searchKeyword.startsWith('#')){
|
||||
this.searchTag = this.searchKeyword;
|
||||
this.searchKeyword = '';
|
||||
}
|
||||
// 重新加载数据
|
||||
this.$refs.paging && this.$refs.paging.reload();
|
||||
},
|
||||
// 移除搜索标签
|
||||
removeSearchTag() {
|
||||
this.searchTag = '';
|
||||
this.searchKeyword = '';
|
||||
// 重新加载数据
|
||||
this.$refs.paging && this.$refs.paging.reload();
|
||||
},
|
||||
// 切换排序
|
||||
toggleSort(field) {
|
||||
if(this.sortField === field){
|
||||
// 如果点击的是当前排序字段,切换排序方向
|
||||
this.sortOrder = this.sortOrder === 'asc' ? 'desc' : 'asc';
|
||||
} else {
|
||||
// 如果点击的是新字段,设置为降序
|
||||
this.sortField = field;
|
||||
this.sortOrder = 'desc';
|
||||
}
|
||||
// 重新加载数据
|
||||
this.$refs.paging && this.$refs.paging.reload();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -86,6 +191,69 @@
|
||||
box-sizing: border-box;
|
||||
padding-bottom: 120rpx;
|
||||
}
|
||||
.search{
|
||||
padding: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
background: #fff;
|
||||
}
|
||||
.search-input-wrapper{
|
||||
flex: 1;
|
||||
}
|
||||
.search-input-box{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #F5F6FA;
|
||||
border-radius: 10rpx;
|
||||
padding: 15rpx 24rpx;
|
||||
gap: 12rpx;
|
||||
}
|
||||
.search-tag{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 4rpx 12rpx;
|
||||
gap: 8rpx;
|
||||
font-size: 24rpx;
|
||||
color: #333;
|
||||
margin-right: 8rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.search-tag text{
|
||||
font-size: 24rpx;
|
||||
color: #333;
|
||||
}
|
||||
.search-input{
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
background: transparent;
|
||||
border: none;
|
||||
}
|
||||
.sort-options{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.sort-item{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6rpx;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
transition: color 0.3s;
|
||||
}
|
||||
.sort-item.active{
|
||||
color: #206ff4;
|
||||
font-weight: 500;
|
||||
}
|
||||
.sort-item text{
|
||||
font-size: 26rpx;
|
||||
}
|
||||
.content-grid{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
Reference in New Issue
Block a user