2025-02-17 19:07:07 +08:00

354 lines
9.2 KiB
Vue

<template>
<view class="main">
<scroll-view scroll-y class="scrollContent">
<view
class="scrollItem"
v-for="(item, index) in postList"
:key="index"
@click="handleEditPost(item)"
>
<view class="itemTop">
<view class="topLeft">
<view class="profileBox">
<image
class="profile"
src="/static/images/home/defaultUser.png"
/>
</view>
<view class="otherBox">
<view class="userName">{{ item.AUTHOR_NAME || "-" }}</view>
<view class="timeBox">{{ item.PUBLISH_TIME || "-" }}</view>
</view>
</view>
<view class="rightBox">
<view class="commentBox">
<image
class="commentIcon"
src="/static/images/home/commentIcon.svg"
/>
<span class="commentText">
{{ item.POST_COMMENTCOUNT || 0 }}</span
>
</view>
<view class="commentBox">
<image
class="commentIcon"
src="/static/images/home/thumbsUp.svg"
/>
<span class="thumbsUp">{{ item.POST_LIKECOUNT || 0 }}</span>
</view>
</view>
</view>
<view class="itemContent">{{ item.POST_CONTENT || "" }}</view>
<view
class="imageList"
v-if="item.ImageList && item.ImageList.length > 0"
>
<view
class="imageItem"
v-for="(subItem, subIndex) in item.ImageList"
:key="subIndex"
>
<image class="image" :src="subItem.ImageUrl" />
</view>
</view>
<view class="optionBox">
<span class="label">{{
item.POST_TAG && tabObj ? `#${tabObj[item.POST_TAG] || ""}` : ""
}}</span>
<view>
<span class="edit" @click.stop="handleEditPost(item)">编辑</span>
<span
class="edit"
style="color: #000; margin-left: 8rpx"
@click.stop="handleDeletePost(item)"
>删除</span
>
</view>
</view>
</view>
</scroll-view>
</view>
</template>
<script>
import { mapGetters } from "vuex";
export default {
data() {
return {
postList: [], // 发帖列表
tabObj: {}, // 标签的枚举
};
},
onLoad() {
console.log("user", this.user);
this.handleGetTypeList();
},
onShow() {
this.handleGetMyPost();
},
computed: {
...mapGetters({
user: "user",
}),
},
methods: {
// 删除发帖
async handleDeletePost(obj) {
let _this = this;
uni.showModal({
title: "提示",
content: "确认删除?",
success: async function (res) {
uni.showLoading({
title: "删除中...",
});
console.log("obj", obj);
let req = {
...obj,
POST_STATE: 0,
};
const data = await _this.$api.$post("/Member/SynchroPOST", req);
if (data.Result_Code === 100) {
uni.showToast({
title: data.Result_Desc || "更新成功",
icon: "success",
});
uni.hideLoading();
_this.handleGetMyPost();
} else {
uni.showToast({
title: data.Result_Desc || "请求失败",
icon: "none",
});
uni.hideLoading();
}
},
});
},
// 编辑发帖内容
handleEditPost(obj) {
console.log("obj", obj);
uni.navigateTo({ url: `/pages/community/addNewPost?id=${obj.POST_ID}` });
},
// 拿到我的发帖列表
async handleGetMyPost() {
uni.showLoading({
title: "加载中...",
});
const req = {
searchParameter: {
WECHATAPP_APPID: "wx4c497eddcec4a0e7",
POST_STATE: 1,
MEMBERSHIP_ID: this.user.MEMBERSHIP_ID,
},
PageIndex: 1,
PageSize: 10,
};
console.log("handleGetNowPostListREq");
const data = await this.$api.$post("/Member/GetPOSTList", req);
let list = data.Result_Data.List;
this.postList = list;
console.log("handleGetNowPostList", this.postList);
uni.hideLoading();
},
// 拿到类型枚举
async handleGetTypeList() {
uni.showLoading({
title: "加载中...",
});
const data = await this.$api.$get(
"/EShangApiMain/FrameWork/GetFieldEnumTree",
{ FieldExplainField: "business_target" }
);
let list = this.$utils.wrapTreeNode(data.Result_Data.List);
console.log("listlistlist", list);
let typeList = [];
let typeObj = {};
// 拿到发帖的枚举
if (list && list.length > 0) {
list.forEach((item) => {
if (item.value === 7000) {
console.log("item", item);
if (item.children && item.children.length > 0) {
item.children.forEach((subItem) => {
typeList.push(subItem);
typeObj[subItem.value] = subItem.label;
});
}
}
});
}
this.tabObj = typeObj;
uni.hideLoading();
},
},
};
</script>
<style lang="less" scoped>
.main {
width: 100vw;
height: 100vh;
box-sizing: border-box;
padding: 16rpx 32rpx;
.scrollContent {
width: 100%;
height: 100%;
.scrollItem {
width: 100%;
border-bottom: 1px solid #f5f6f7;
box-sizing: border-box;
padding: 16rpx 0;
.itemTop {
display: flex;
align-items: center;
justify-content: space-between;
.topLeft {
width: calc(100% - 190rpx);
display: flex;
align-items: center;
.profileBox {
width: 72rpx;
height: 72rpx;
margin-right: 16rpx;
.profile {
width: 100%;
height: 100%;
}
}
.otherBox {
width: calc(100% - 88rpx);
.userName {
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: 28rpx;
color: #130f05;
line-height: 40rpx;
text-align: left;
font-style: normal;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.timeBox {
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: 24rpx;
color: #716f69;
line-height: 36rpx;
text-align: left;
font-style: normal;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
}
}
.rightBox {
width: 180rpx;
display: flex;
align-items: center;
justify-content: space-between;
.commentBox {
display: flex;
align-items: center;
.commentIcon {
width: 32rpx;
height: 32rpx;
margin-right: 4rpx;
}
.commentText {
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: 24rpx;
color: #716f69;
line-height: 36rpx;
text-align: left;
font-style: normal;
}
.thumbsUp {
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: 24rpx;
color: #ba922f;
line-height: 36rpx;
text-align: left;
font-style: normal;
}
}
}
}
.itemContent {
width: 100%;
margin-top: 16rpx;
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: 28rpx;
color: #130f05;
line-height: 40rpx;
text-align: justify;
font-style: normal;
}
.imageList {
width: 100%;
margin-top: 24rpx;
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
.imageItem {
width: 218rpx;
height: 218rpx;
border-radius: 8rpx;
overflow: hidden;
margin-right: 8rpx;
margin-bottom: 8rpx;
.image {
width: 100%;
height: 100%;
}
}
}
.optionBox {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
.label {
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: 26rpx;
color: #ba922f;
line-height: 36rpx;
text-align: left;
font-style: normal;
}
.edit {
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: 26rpx;
color: #ba922f;
line-height: 36rpx;
text-align: left;
font-style: normal;
}
}
}
}
.scrollContent ::-webkit-scrollbar {
width: 0;
}
}
</style>