修改
This commit is contained in:
+163
-6
@@ -13,10 +13,41 @@
|
||||
<view class="cell1">
|
||||
<view>{{$t('mine.nickname')}}</view>
|
||||
<view class="right select">
|
||||
<input :placeholder="$t('mine.nickinput')" v-model="userinfo.nickname"></input>
|
||||
<input :placeholder="$t('mine.nickinput')" v-model="userinfo.nickname" />
|
||||
<uni-icons type="right" size="18"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class="cell1">
|
||||
<view>店铺名称</view>
|
||||
<view class="right select">
|
||||
<input placeholder="请填写名称" v-model="userinfo.shop_name" />
|
||||
<uni-icons type="right" size="18"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class="cell1">
|
||||
<view>店铺电话</view>
|
||||
<view class="right select">
|
||||
<input placeholder="请填写店铺电话" v-model="userinfo.mobile" />
|
||||
<uni-icons type="right" size="18"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class="cell1">
|
||||
<view>店铺位置</view>
|
||||
<view class="right select">
|
||||
<input placeholder="请选择店铺位置" v-model="userinfo.location_name" disabled="disabled" @focus="showMap = true" @click="showMap = true" />
|
||||
<uni-icons type="right" size="18"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view v-show="showMap" style="height: 300px; margin: 0 20px 20px 20px;">
|
||||
<map
|
||||
style="width: 100%; height: 100%;"
|
||||
:latitude="centerLat"
|
||||
:longitude="centerLng"
|
||||
:markers="markers"
|
||||
scale="14"
|
||||
@tap="onMapTap"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="foot">
|
||||
<button class="btn" @click="bcFn">{{$t('button.save')}}</button>
|
||||
@@ -28,6 +59,12 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
centerLat: 39.9042,
|
||||
centerLng: 116.4074,
|
||||
markers: [],
|
||||
// 若需逆地理,请配置腾讯地图 key(可存储在此或通过 storage 注入)
|
||||
qqMapKey: 'HQBBZ-SC76W-YUNRZ-34IAD-ARN6K-TZBZ4',
|
||||
showMap: false,
|
||||
imageStyles: {
|
||||
width: 40,
|
||||
height: 40,
|
||||
@@ -38,8 +75,12 @@
|
||||
userinfo:{
|
||||
nickname:'',
|
||||
avatar:'',
|
||||
company:'',
|
||||
phone:'',
|
||||
shop_name:'',
|
||||
mobile:'',
|
||||
location_name:'',
|
||||
latitude: null,
|
||||
longitude: null
|
||||
},
|
||||
|
||||
}
|
||||
@@ -48,13 +89,124 @@
|
||||
this.getinfo()
|
||||
},
|
||||
methods: {
|
||||
getFuzzy() {
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.getSetting({
|
||||
success: (st) => {
|
||||
const ok = st.authSetting['scope.userFuzzyLocation'];
|
||||
const run = () => wx.getFuzzyLocation({
|
||||
type: 'wgs84',
|
||||
success: resolve,
|
||||
fail: reject
|
||||
});
|
||||
|
||||
if (ok) return run();
|
||||
|
||||
wx.authorize({
|
||||
scope: 'scope.userFuzzyLocation',
|
||||
success: run,
|
||||
fail: () => wx.openSetting({ success: () => reject(new Error('未授权')) })
|
||||
});
|
||||
},
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
},
|
||||
// 地图点选:更新“选点位置”marker
|
||||
onMapTap(e) {
|
||||
const { latitude, longitude } = e.detail || {};
|
||||
if (typeof latitude !== 'number' || typeof longitude !== 'number') return;
|
||||
|
||||
// 用 id 2 表示“选点”
|
||||
const picked = {
|
||||
id: 2,
|
||||
latitude,
|
||||
longitude,
|
||||
title: '选点位置'
|
||||
};
|
||||
|
||||
// 只保留当前选点作为唯一标记
|
||||
this.markers = [picked];
|
||||
|
||||
// 也可以把地图中心移动到选点
|
||||
this.centerLat = latitude;
|
||||
this.centerLng = longitude;
|
||||
this.userinfo.latitude = latitude
|
||||
this.userinfo.longitude = longitude
|
||||
this.reverseGeocode(latitude, longitude)
|
||||
},
|
||||
getinfo(){
|
||||
var that= this;
|
||||
request({
|
||||
url:'common/user/info',
|
||||
method:'POST',
|
||||
}).then(res => {
|
||||
this.userinfo=res.data.data.user
|
||||
this.userinfo = res.data.data.user || {}
|
||||
|
||||
const lat = parseFloat(this.userinfo.latitude)
|
||||
const lng = parseFloat(this.userinfo.longitude)
|
||||
|
||||
if (!isNaN(lat) && !isNaN(lng)) {
|
||||
this.centerLat = lat
|
||||
this.centerLng = lng
|
||||
this.markers = [{
|
||||
id: 1,
|
||||
latitude: lat,
|
||||
longitude: lng,
|
||||
title: this.userinfo.location_name || '店铺位置'
|
||||
}]
|
||||
} else {
|
||||
this.initFuzzyLocation()
|
||||
}
|
||||
}).catch(() => {
|
||||
this.initFuzzyLocation()
|
||||
})
|
||||
},
|
||||
// 优先使用接口位置,没有时回退到模糊定位
|
||||
initFuzzyLocation() {
|
||||
try {
|
||||
this.getFuzzy().then(res => {
|
||||
this.centerLat = res.latitude;
|
||||
this.centerLng = res.longitude;
|
||||
console.log(res)
|
||||
// 默认给一个“当前位置(模糊)”标记
|
||||
this.markers = [{
|
||||
id: 1,
|
||||
latitude: res.latitude,
|
||||
longitude: res.longitude,
|
||||
title: '当前位置(模糊)'
|
||||
}];
|
||||
}).catch(err => console.error(err));
|
||||
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
},
|
||||
// 逆地理:将经纬度转为位置文本,失败则回退为经纬度字符串
|
||||
reverseGeocode(lat, lng) {
|
||||
const key = this.qqMapKey || uni.getStorageSync('qqMapKey') || ''
|
||||
if (!key) {
|
||||
this.userinfo.location_name = `${lat.toFixed(6)}, ${lng.toFixed(6)}`
|
||||
return
|
||||
}
|
||||
uni.request({
|
||||
url: 'https://apis.map.qq.com/ws/geocoder/v1/',
|
||||
method: 'GET',
|
||||
data: {
|
||||
location: `${lat},${lng}`,
|
||||
key
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.data && res.data.status === 0) {
|
||||
const result = res.data.result || {}
|
||||
const formatted = (result.formatted_addresses && result.formatted_addresses.recommend) || result.address
|
||||
this.userinfo.location_name = formatted || `${lat.toFixed(6)}, ${lng.toFixed(6)}`
|
||||
} else {
|
||||
this.userinfo.location_name = `${lat.toFixed(6)}, ${lng.toFixed(6)}`
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
this.userinfo.location_name = `${lat.toFixed(6)}, ${lng.toFixed(6)}`
|
||||
}
|
||||
})
|
||||
},
|
||||
uploadfn(imgUrl){
|
||||
@@ -71,7 +223,7 @@
|
||||
});
|
||||
},
|
||||
delfn(){
|
||||
that.userinfo.avatar =''
|
||||
this.userinfo.avatar =''
|
||||
},
|
||||
select(e){
|
||||
const tempFilePaths = e.tempFilePaths;
|
||||
@@ -87,7 +239,12 @@
|
||||
method:'POST',
|
||||
data:{
|
||||
nickname:this.userinfo.nickname,
|
||||
avatar:this.userinfo.avatar
|
||||
avatar:this.userinfo.avatar,
|
||||
mobile:this.userinfo.mobile,
|
||||
shop_name:this.userinfo.shop_name,
|
||||
location_name:this.userinfo.location_name,
|
||||
latitude:this.userinfo.latitude,
|
||||
longitude:this.userinfo.longitude
|
||||
}
|
||||
}).then(res => {
|
||||
uni.showToast({
|
||||
|
||||
+221
-396
@@ -1,407 +1,232 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<view class="page">
|
||||
<uni-nav-bar leftText=" " :fixed="true" :border="false" leftIcon="back" @clickLeft="leftClick" color="#000000" backgroundColor="#fff" :statusBar="true" title="我的发布"></uni-nav-bar>
|
||||
|
||||
<view class="year-selector" @click="showYearPicker">
|
||||
<text class="year-text">{{selectedYear}}年</text>
|
||||
<uni-icons type="arrowdown" size="14" color="#666"></uni-icons>
|
||||
</view>
|
||||
|
||||
<scroll-view scroll-y class="scroll-container"
|
||||
refresher-enabled
|
||||
:refresher-triggered="refreshing"
|
||||
@refresherrefresh="onRefresh"
|
||||
:lower-threshold="100"
|
||||
@scrolltolower="onLoadMore">
|
||||
<view class="post-list">
|
||||
<view v-for="(group, dateKey) in groupedPosts" :key="dateKey" class="date-group">
|
||||
<view class="date-item">
|
||||
<view class="date-label">
|
||||
<text class="date-day">{{group.day}}</text>
|
||||
<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>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多提示 -->
|
||||
<view v-if="hasMore && postList.length > 0" class="load-more">
|
||||
<text v-if="loadingMore">加载中...</text>
|
||||
<text v-else>上拉加载更多</text>
|
||||
</view>
|
||||
<view v-else-if="!hasMore && postList.length > 0" class="load-more">
|
||||
<text>没有更多了</text>
|
||||
</view>
|
||||
|
||||
<view v-if="postList.length === 0 && !loading && !loadingMore" class="empty-view">
|
||||
<text>暂无发布内容</text>
|
||||
</view>
|
||||
<view>
|
||||
<view class="tabs">
|
||||
<u-tabs :list="list1" @click="click" lineColor="#3BC6BD" :scrollable="false"></u-tabs>
|
||||
</view>
|
||||
<scroll-view
|
||||
scroll-y
|
||||
class="list-scroll"
|
||||
refresher-enabled
|
||||
:refresher-triggered="refreshing"
|
||||
@refresherrefresh="onRefresh"
|
||||
:lower-threshold="100"
|
||||
@scrolltolower="onLoadMore"
|
||||
>
|
||||
<view class="feed-list">
|
||||
<post-card
|
||||
v-for="sitem in slist"
|
||||
:key="sitem.id"
|
||||
:item="sitem"
|
||||
:ismysq="true"
|
||||
@userClick="goto"
|
||||
@view="goto"
|
||||
@contact="handleContact"
|
||||
@comment="handleComment">
|
||||
</post-card>
|
||||
|
||||
<!-- 状态提示 -->
|
||||
<view v-if="hasMore" class="load-more">
|
||||
<text v-if="loadingMore">加载中...</text>
|
||||
<text v-else>上拉加载更多</text>
|
||||
</view>
|
||||
<view v-else-if="slist.length > 0" class="load-more">
|
||||
<text>没有更多了</text>
|
||||
</view>
|
||||
<view class="empty" v-if="slist.length === 0 && !loading">
|
||||
<image src="/static/image/empty.png" mode="aspectFit"></image>
|
||||
<view>暂无数据!</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 加载提示 -->
|
||||
<view v-if="loading" class="loading-mask">
|
||||
<view class="loading-text">加载中...</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 年份选择器 -->
|
||||
<u-picker
|
||||
:show="showYearSelect"
|
||||
:columns="yearColumns"
|
||||
:defaultIndex="defaultYearIndex"
|
||||
keyName="label"
|
||||
@confirm="onYearConfirm"
|
||||
@cancel="showYearSelect = false"
|
||||
title="选择年份">
|
||||
</u-picker>
|
||||
|
||||
<!-- 加载提示 -->
|
||||
<view v-if="loading" class="loading-mask">
|
||||
<view class="loading-text">加载中...</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { request } from '@/api/apiT.js'
|
||||
export default {
|
||||
data() {
|
||||
// 生成年份列表(当前年份前后5年)
|
||||
const currentYear = new Date().getFullYear();
|
||||
const years = [];
|
||||
for (let i = currentYear - 5; i <= currentYear + 5; i++) {
|
||||
years.push({ label: i.toString(), value: i });
|
||||
}
|
||||
|
||||
return {
|
||||
selectedYear: currentYear,
|
||||
showYearSelect: false,
|
||||
yearColumns: [years],
|
||||
postList: [],
|
||||
groupedPosts: {},
|
||||
loading: false,
|
||||
refreshing: false,
|
||||
loadingMore: false, // 上拉加载状态
|
||||
page: 1, // 当前页码
|
||||
pageSize: 10, // 每页数量
|
||||
hasMore: true, // 是否还有更多数据
|
||||
total: 0, // 总数据量
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 计算当前年份在选择器中的默认索引
|
||||
defaultYearIndex() {
|
||||
const currentYear = new Date().getFullYear();
|
||||
const startYear = currentYear - 5;
|
||||
return [currentYear - startYear]; // 当前年份在数组中的索引
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.loadPostList();
|
||||
},
|
||||
methods: {
|
||||
leftClick() {
|
||||
// uni.navigateBack()
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/mine',// 替换为你要跳转的页面路径
|
||||
});
|
||||
},
|
||||
showYearPicker() {
|
||||
this.showYearSelect = true;
|
||||
},
|
||||
onYearConfirm(e) {
|
||||
if (e.value && e.value[0]) {
|
||||
const selectedItem = typeof e.value[0] === 'object' ? e.value[0] : { value: e.value[0], label: e.value[0].toString() };
|
||||
this.selectedYear = selectedItem.value || parseInt(selectedItem.label);
|
||||
this.showYearSelect = false;
|
||||
// 切换年份时重置分页
|
||||
this.page = 1;
|
||||
this.hasMore = true;
|
||||
this.postList = [];
|
||||
this.groupedPosts = {};
|
||||
this.loadPostList(false);
|
||||
}
|
||||
},
|
||||
// 加载帖子列表
|
||||
loadPostList(isLoadMore = false) {
|
||||
// 防止重复请求
|
||||
if (isLoadMore) {
|
||||
if (this.loadingMore || this.loading || this.refreshing || !this.hasMore) {
|
||||
return;
|
||||
}
|
||||
this.loadingMore = true;
|
||||
this.page += 1;
|
||||
} else {
|
||||
if (this.loading && !this.refreshing) {
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
this.page = 1;
|
||||
this.hasMore = true;
|
||||
if (!isLoadMore && !this.refreshing) {
|
||||
this.postList = [];
|
||||
this.groupedPosts = {};
|
||||
}
|
||||
}
|
||||
|
||||
// 获取当前用户发布的帖子列表
|
||||
request({
|
||||
url: 'common/post/list',
|
||||
method: 'GET',
|
||||
data: {
|
||||
// 只获取当前用户发布的帖子,后端应该根据token自动过滤
|
||||
current: this.page,
|
||||
size: this.pageSize,
|
||||
scene:'self',
|
||||
year:this.selectedYear
|
||||
}
|
||||
}).then(res => {
|
||||
this.loading = false;
|
||||
this.loadingMore = false;
|
||||
this.refreshing = false;
|
||||
|
||||
if (res.data.code == 200) {
|
||||
const records = res.data.data.records || [];
|
||||
const total = res.data.data.total || 0;
|
||||
this.total = total;
|
||||
|
||||
// 过滤出当前年份的数据
|
||||
const yearFilteredRecords = records.filter(post => {
|
||||
if (!post.created_at) return false;
|
||||
const dateStr = post.created_at;
|
||||
const postYear = new Date(dateStr).getFullYear();
|
||||
return postYear === this.selectedYear;
|
||||
});
|
||||
|
||||
if (isLoadMore) {
|
||||
// 上拉加载更多,追加数据并去重
|
||||
const existingIds = new Set(this.postList.map(item => item.id));
|
||||
const newRecords = yearFilteredRecords.filter(item => !existingIds.has(item.id));
|
||||
this.postList = [...this.postList, ...newRecords];
|
||||
} else {
|
||||
// 下拉刷新或初次加载,替换数据
|
||||
this.postList = yearFilteredRecords;
|
||||
}
|
||||
|
||||
// 重新分组
|
||||
this.groupPostsByDate();
|
||||
|
||||
// 判断是否还有更多数据
|
||||
// 如果当前页返回的原始数据少于pageSize,说明没有更多了
|
||||
// 或者已经加载到最后一页
|
||||
if (records.length < this.pageSize) {
|
||||
this.hasMore = false;
|
||||
} else {
|
||||
// 计算理论上最多能加载多少页
|
||||
const maxPages = Math.ceil(total / this.pageSize);
|
||||
this.hasMore = this.page < maxPages;
|
||||
}
|
||||
}
|
||||
}).catch(() => {
|
||||
this.loading = false;
|
||||
this.loadingMore = false;
|
||||
this.refreshing = false;
|
||||
if (isLoadMore) {
|
||||
this.page -= 1; // 加载失败,页码回退
|
||||
}
|
||||
});
|
||||
},
|
||||
// 按日期分组帖子
|
||||
groupPostsByDate() {
|
||||
const grouped = {};
|
||||
|
||||
this.postList.forEach(post => {
|
||||
const dateStr = post.created_at || post.create_time || post.createdAt;
|
||||
if (!dateStr) return;
|
||||
|
||||
const date = new Date(dateStr);
|
||||
const month = date.getMonth() + 1; // 月份从0开始,需要+1
|
||||
const day = date.getDate();
|
||||
|
||||
// 生成日期key,格式:MM-DD,用于排序
|
||||
const dateKey = `${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
|
||||
|
||||
if (!grouped[dateKey]) {
|
||||
grouped[dateKey] = {
|
||||
day: day,
|
||||
month: month,
|
||||
posts: []
|
||||
};
|
||||
}
|
||||
|
||||
grouped[dateKey].posts.push(post);
|
||||
});
|
||||
|
||||
// 按日期倒序排序(最新的在前)
|
||||
const sortedKeys = Object.keys(grouped).sort((a, b) => {
|
||||
// 按完整日期排序(年-月-日)
|
||||
const dateA = new Date(this.selectedYear, parseInt(a.split('-')[0]) - 1, parseInt(a.split('-')[1]));
|
||||
const dateB = new Date(this.selectedYear, parseInt(b.split('-')[0]) - 1, parseInt(b.split('-')[1]));
|
||||
return dateB - dateA; // 倒序:最新的在前
|
||||
});
|
||||
|
||||
// 重新构建分组对象,保持顺序
|
||||
const sortedGrouped = {};
|
||||
sortedKeys.forEach(key => {
|
||||
sortedGrouped[key] = grouped[key];
|
||||
});
|
||||
|
||||
this.groupedPosts = sortedGrouped;
|
||||
},
|
||||
// 下拉刷新
|
||||
onRefresh() {
|
||||
// 如果正在加载中,不执行刷新
|
||||
if (this.loading || this.loadingMore) {
|
||||
this.refreshing = false;
|
||||
return;
|
||||
}
|
||||
this.refreshing = true;
|
||||
this.page = 1;
|
||||
this.hasMore = true;
|
||||
this.loadPostList(false);
|
||||
},
|
||||
// 上拉加载更多
|
||||
onLoadMore() {
|
||||
if (!this.hasMore || this.loadingMore || this.loading || this.refreshing) {
|
||||
return;
|
||||
}
|
||||
this.loadPostList(true);
|
||||
},
|
||||
// 查看帖子详情
|
||||
viewPost(post) {
|
||||
// TODO: 跳转到帖子详情页
|
||||
uni.navigateTo({
|
||||
url: '/pages/square/detiles?id='+post.id
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
import { request } from '@/api/apiT.js'
|
||||
import PostCard from '@/components/PostCard.vue'
|
||||
import uTabs from '@/uni_modules/uview-ui/components/u-tabs/u-tabs.vue'
|
||||
export default {
|
||||
components: { PostCard,uTabs },
|
||||
data() {
|
||||
return {
|
||||
list1: [{
|
||||
name: '全部',
|
||||
value:''
|
||||
}, {
|
||||
name: '已发布',
|
||||
value:'1'
|
||||
}, {
|
||||
name: '审核中',
|
||||
value:'2'
|
||||
}, {
|
||||
name: '未通过',
|
||||
value:'3'
|
||||
}, {
|
||||
name: '已过期',
|
||||
value:'4'
|
||||
}],
|
||||
status:'',
|
||||
slist:[],
|
||||
loading: false,
|
||||
refreshing: false,
|
||||
loadingMore: false,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
hasMore: true,
|
||||
defaultTags: ['样机机', '9成新']
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
this.loadList()
|
||||
// this.syncTabbar()
|
||||
},
|
||||
methods: {
|
||||
leftClick() {
|
||||
// uni.navigateBack()
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/mine',// 替换为你要跳转的页面路径
|
||||
});
|
||||
},
|
||||
goto(item){
|
||||
uni.navigateTo({
|
||||
url: '/pages/square/detiles?id='+item.id
|
||||
});
|
||||
},
|
||||
click(item) {
|
||||
this.page = 1
|
||||
this.hasMore = true
|
||||
this.slist = []
|
||||
this.status=item.value
|
||||
this.loadList()
|
||||
},
|
||||
loadList(isLoadMore = false) {
|
||||
if (isLoadMore) {
|
||||
if (this.loadingMore || this.loading || this.refreshing || !this.hasMore) return
|
||||
this.loadingMore = true
|
||||
this.page += 1
|
||||
} else {
|
||||
if (this.loading || this.loadingMore) return
|
||||
this.loading = true
|
||||
this.page = 1
|
||||
this.hasMore = true
|
||||
this.slist = []
|
||||
}
|
||||
request({
|
||||
url: 'common/post/list',
|
||||
method: 'GET',
|
||||
data: {
|
||||
current: this.page,
|
||||
size: this.pageSize,
|
||||
status: this.status
|
||||
}
|
||||
}).then(res => {
|
||||
this.loading = false
|
||||
this.loadingMore = false
|
||||
this.refreshing = false
|
||||
if (res.data.code === 200) {
|
||||
const records = res.data.data.records || []
|
||||
const total = res.data.data.total || 0
|
||||
if (isLoadMore) {
|
||||
this.slist = [...this.slist, ...records]
|
||||
} else {
|
||||
this.slist = records
|
||||
}
|
||||
this.hasMore = this.slist.length < total
|
||||
}
|
||||
}).catch(() => {
|
||||
this.loading = false
|
||||
this.loadingMore = false
|
||||
this.refreshing = false
|
||||
if (isLoadMore) {
|
||||
this.page -= 1
|
||||
}
|
||||
})
|
||||
},
|
||||
onRefresh() {
|
||||
if (this.loading || this.loadingMore) {
|
||||
this.refreshing = false
|
||||
return
|
||||
}
|
||||
this.refreshing = true
|
||||
this.loadList(false)
|
||||
},
|
||||
onLoadMore() {
|
||||
this.loadList(true)
|
||||
},
|
||||
navToList(item) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/square/detiles?id=' + item.id
|
||||
})
|
||||
},
|
||||
leftClick() {
|
||||
uni.navigateBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page,
|
||||
.content {
|
||||
height: 100%;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.year-selector {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 20rpx 30rpx;
|
||||
background-color: #F5F5F5;
|
||||
|
||||
.year-text {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.arrow-icon {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.scroll-container {
|
||||
height: calc(100% - 168rpx); // 减去导航栏和年份选择器高度
|
||||
}
|
||||
|
||||
.post-list {
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.date-group {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.date-item {
|
||||
display: flex;
|
||||
padding: 0 30rpx;
|
||||
}
|
||||
|
||||
.date-label {
|
||||
display: flex;
|
||||
// flex-direction: column;
|
||||
// align-items: center;
|
||||
margin-right: 30rpx;
|
||||
min-width: 120rpx;
|
||||
|
||||
.date-day {
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.date-month {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.posts-container {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.post-item {
|
||||
display: flex;
|
||||
// align-items: center;
|
||||
margin-bottom: 30rpx;
|
||||
|
||||
.post-image {
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
background-color: #E5E5E5;
|
||||
border-radius: 10rpx;
|
||||
margin-right: 30rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.post-tag {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.empty-view {
|
||||
text-align: center;
|
||||
padding: 100rpx 0;
|
||||
color: #999;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.load-more {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
padding: 30rpx 0;
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.loading-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.3);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 999;
|
||||
|
||||
.loading-text {
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
background-color: rgba(0, 0, 0, 0.7);
|
||||
padding: 20rpx 40rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
}
|
||||
page,
|
||||
.page {
|
||||
height: 100%;
|
||||
background: #f8f8f8;
|
||||
}
|
||||
|
||||
.tabs{
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.list-scroll {
|
||||
height: calc(100vh - 120rpx);
|
||||
}
|
||||
|
||||
.feed-list {
|
||||
// padding: 20rpx;
|
||||
margin: 20rpx 30rpx;
|
||||
}
|
||||
.load-more {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
padding: 30rpx 0;
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
}
|
||||
.empty {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
padding: 100rpx 0;
|
||||
}
|
||||
.empty image {
|
||||
width: 252rpx;
|
||||
height: 164rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.loading-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.3);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 999;
|
||||
|
||||
.loading-text {
|
||||
color: #fff;
|
||||
font-size: 28upx;
|
||||
background-color: rgba(0, 0, 0, 0.7);
|
||||
padding: 20upx 40upx;
|
||||
border-radius: 8upx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+20
-15
@@ -2,21 +2,23 @@
|
||||
<view class="home-page">
|
||||
<z-paging ref="paging" 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>
|
||||
<uni-nav-bar leftText=" " :fixed="true" :border="false" leftIcon="back" @clickLeft="leftClick" color="#000000" backgroundColor="#fff" :statusBar="true" title="我的信息"></uni-nav-bar>
|
||||
</template>
|
||||
<view class="msg-list">
|
||||
<view class="msg-item" v-for="item in contList" :key="item.id">
|
||||
<image class="msg-avatar" :src="item.sender_user.avatar_pull" mode="aspectFill"></image>
|
||||
<view class="msg-body">
|
||||
<view class="msg-header">
|
||||
<text class="msg-name">{{item.sender_user.nickname}}</text>
|
||||
<text class="msg-time">{{item.created_at}}</text>
|
||||
<view class="msg-cont">
|
||||
<image class="msg-avatar" :src="item.sender_user.avatar_pull" mode="aspectFill"></image>
|
||||
<view class="msg-body">
|
||||
<view class="msg-header">
|
||||
<text class="msg-name">{{item.sender_user.nickname}}</text>
|
||||
<!-- <text class="msg-time">{{item.created_at}}</text> -->
|
||||
</view>
|
||||
</view>
|
||||
<text class="msg-text">
|
||||
<text>{{ item.type==1?'点赞了': item.type==2?'收藏了':'评论了' }} </text>
|
||||
<text>{{ formatContent(item.post && item.post.content) }}</text>
|
||||
</text>
|
||||
</view>
|
||||
<view class="msg-text">
|
||||
<text>{{ formatContent(item.post && item.post.content) }}</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</z-paging>
|
||||
@@ -80,15 +82,18 @@
|
||||
padding: 20rpx;
|
||||
}
|
||||
.msg-item{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 24rpx 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
border-bottom: 1px solid #e4e4e4;
|
||||
background: #fff;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
.msg-cont{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.msg-avatar{
|
||||
width: 96rpx;
|
||||
height: 96rpx;
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
border-radius: 50%;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
@@ -6,15 +6,12 @@
|
||||
</template>
|
||||
<!-- 内容网格 -->
|
||||
<view class="content-grid">
|
||||
<square-post-card
|
||||
class="grid-item"
|
||||
v-for="sitem in contList"
|
||||
:key="sitem.id"
|
||||
:item="sitem.post"
|
||||
:isshow="false"
|
||||
@view="navToList"
|
||||
@comment="viewPost"
|
||||
@like="viewPost" />
|
||||
<classify-card
|
||||
v-for="item in contList"
|
||||
:key="item.id"
|
||||
:item="item.post"
|
||||
@view="navToList"
|
||||
/>
|
||||
</view>
|
||||
</z-paging>
|
||||
</view>
|
||||
@@ -22,10 +19,10 @@
|
||||
|
||||
<script>
|
||||
import { request,showToast } from '@/api/apiT.js'
|
||||
import SquarePostCard from '@/components/SquarePostCard.vue'
|
||||
import ClassifyCard from '@/components/ClassifyCard.vue'
|
||||
export default {
|
||||
components: {
|
||||
SquarePostCard
|
||||
ClassifyCard
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -87,11 +84,7 @@
|
||||
padding-bottom: 120rpx;
|
||||
}
|
||||
.content-grid{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding: 20rpx;
|
||||
justify-content: space-between;
|
||||
background: #fff;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.grid-item{
|
||||
width: 48%;
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<uni-nav-bar leftText=" " :fixed="true" :border="false" leftIcon="back" @clickLeft="leftClick" color="#000000" backgroundColor="#fff" :statusBar="true" title="回复我的"></uni-nav-bar>
|
||||
|
||||
<view class="reply-list">
|
||||
<view class="reply-card" v-for="(reply, index) in replyList" :key="index">
|
||||
<!-- 主回复 -->
|
||||
<view class="reply-item">
|
||||
<view class="reply-heard">
|
||||
<image :src="reply.avatar" class="avatar"></image>
|
||||
<view class="reply-content">
|
||||
<view class="username">{{ reply.username }}</view>
|
||||
<view class="time">{{ reply.time }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="reply-content">
|
||||
<text class="reply-text">{{ reply.content }}</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<!-- 子回复 -->
|
||||
<view class="sub-reply" v-for="(subReply, subIndex) in reply.subReplies" :key="subIndex">
|
||||
<view class="reply-heard">
|
||||
<image :src="subReply.avatar" class="avatar"></image>
|
||||
<view class="reply-header">
|
||||
<view class="username">{{ subReply.username }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="reply-content">
|
||||
<text class="reply-text">{{ subReply.content }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
replyList: [
|
||||
{
|
||||
avatar: '/static/image/user.png',
|
||||
username: '用户名用户名',
|
||||
time: '2025年12月04日10:56:44',
|
||||
content: '这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复',
|
||||
subReplies: [
|
||||
{
|
||||
avatar: '/static/image/user.png',
|
||||
username: '田户名田户名',
|
||||
time: '2025年12月04日10:56:44',
|
||||
content: '西门子全新款饮机品牌西门子全新款饮机品牌西门子全新...'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
avatar: '/static/image/user.png',
|
||||
username: '用户名用户名',
|
||||
time: '2025年12月04日10:56:44',
|
||||
content: '这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复',
|
||||
subReplies: [
|
||||
{
|
||||
avatar: '/static/image/user.png',
|
||||
username: '用户名用户名',
|
||||
time: '2025年12月04日10:56:44',
|
||||
content: '西门子全新款饮机品牌西门子全新款饮机品牌西门子全新...'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
leftClick() {
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/mine',// 替换为你要跳转的页面路径
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.reply-list {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.reply-card {
|
||||
background-color: #fff;
|
||||
margin: 10px;
|
||||
border-radius: 8px;
|
||||
padding: 12px;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.reply-item {
|
||||
/* display: flex; */
|
||||
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.reply-heard{
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.sub-reply {
|
||||
/* margin-left: 30px; */
|
||||
padding:8px 12px;
|
||||
background-color: #F5F6FA;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.reply-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.reply-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.username {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.time {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.reply-text {
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
line-height: 1.5;
|
||||
word-break: break-all;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user