myPublish.vue 8.9 KB
<template>
	<view class="page">
		<!-- <view class="searchbox">
			<view class="flexone">
				<text class="tipsword">开始日期</text>
				<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
					<view class="fill">{{date}}</view>
				</picker>
			</view>
			<view class="flexone">
				<text class="tipsword">结束日期</text>
				<picker mode="date" :value="dateone" :start="startDate" :end="endDate" @change="bindendDateChange">
					<view class="fill">{{dateone}}</view>
				</picker>
			</view>

			<view class="searchbtn" @click="search">搜索</view>
		</view> -->

		<view class="nodata" v-if="publishlist.length==0">暂无数据</view>
		<view class="box" v-else>
			<view class="item" v-for="(item,index) in publishlist" :key="index" @click="luntandetail(item)">
				<view class="titlebox">
					<view class="type" v-if="item.status==1">审核中</view>
					<view class="type" v-if="item.status==2">审核通过</view>
					<view class="type" v-if="item.status==3">审未通过</view>
					<view class="type" v-if="item.status==4">管理员已删除</view>
					<view class="word">{{item.title}}</view>
					<image src="../../static/del.png" mode="widthFix" class="del" @click.stop="del(item)"></image>
				</view>
				<view class="wordarea">
					
					{{item.content}}
				</view>
				<view class="numbox">
					<view class="time">{{item.creatssssetime}}</view>
					<view class="btnbox">
						<view class="zan">
							<image src="../../static/zan.png" mode="widthFix" class="icon"></image>{{item.praise}}
						</view>
						<view class="people">
							<image src="../../static/people.png" mode="widthFix" class="icon"></image>{{item.view}}
						</view>
					</view>
				</view>
			</view>

			<!-- <view class="item">
				<view class="titlebox">
					<view class="type">审核中</view>
					<view class="word">帖子标题帖子标题帖子标题帖子帖...</view>
					<image src="../../static/del.png" mode="widthFix" class="del"></image>
				</view>
				<view class="wordarea">
					帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容...
				</view>
				<view class="numbox">
					<view class="time">2019-10-10 15:30:30</view>
					<view class="btnbox">
						<view class="zan">
							<image src="../../static/zan.png" mode="widthFix" class="icon"></image>399
						</view>
						<view class="people">
							<image src="../../static/people.png" mode="widthFix" class="icon"></image>399
						</view>
					</view>
				</view>
			</view>
			<view class="item">
				<view class="titlebox">
					<view class="type">审核中</view>
					<view class="word">帖子标题帖子标题帖子标题帖子帖...</view>
					<image src="../../static/del.png" mode="widthFix" class="del"></image>
				</view>
				<view class="wordarea">
					帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容帖子内容...
				</view>
				<view class="numbox">
					<view class="time">2019-10-10 15:30:30</view>
					<view class="btnbox">
						<view class="zan">
							<image src="../../static/zan.png" mode="widthFix" class="icon"></image>399
						</view>
						<view class="people">
							<image src="../../static/people.png" mode="widthFix" class="icon"></image>399
						</view>
					</view>
				</view>
			</view>
		 -->

		</view>
	</view>
</template>

<script>
	import app from "../../App.vue";

	export default {

		data() {
			const currentDate = this.getDate({
				format: true
			})
			console.log(currentDate)
			return {
				page: 1,
				publishlist: [],
				date: currentDate,
				dateone: currentDate,
			}
		},
		onLoad() {


			this.getpublish()
		},
		computed: {
			startDate() {
				return this.getDate('start');
			},
			endDate() {
				return this.getDate('end');
			}
		},
		methods: {
			CompareDate(d1,d2)
			{
			  return ((new Date(d1.replace(/-/g,"\/"))) > (new Date(d2.replace(/-/g,"\/"))));
			},
			// 获取发布列表
			getpublish() {
				let that = this;
				// 将时间转换成时间戳
				// if(that.CompareDate(that.date,that.dateone)==true){
				// 	uni.showToast({
				// 		title:'结束日期要大于开始日期',
				// 		icon:"none"
				// 	})
					
				// 	return false
				// }
				
				var url = 'forum/get_my_forum';
				var params = {
					starttime:'',
					endtime: '',
					user_id: uni.getStorageSync("user_id"),
					page: '',
					pageNum: ''
				}
				console.log('7766554', params)
				app.post(url, params).then((res) => {
					console.log(res);
					that.publishlist = that.publishlist.concat(res.data.data);
					console.log(that.publishlist)
				}).catch((err) => {
					console.log(err)
				})
			},
			del(item) {
				console.log(3443893489809)
				uni.showModal({
					title: '提示',
					content: '是否删除帖子',
					success: function(res) {
						if (res.confirm) {
							let that = this;
							var url = 'forum/delete_forum';
							var params = {
								forum_id: item.id
							}
							console.log('7766554', params)
							app.post(url, params).then((res) => {
								console.log(res);
								uni.showToast({
									title: '删除成功',
									icon: 'none'
								})
								that.page = 1;
								that.publishlist = [];
								that.getpublish()

							}).catch((err) => {
								console.log(err)

							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},

			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
			bindDateChange: function(e) {
				console.log(e)
				this.date = e.target.value
			},
			bindendDateChange(e) {
				this.dateone = e.target.value
			},
			// 论坛详情
			luntandetail(item) {
				uni.navigateTo({
					url: '/pages/luntan/luntandetail?id=' + item.id
				})
			},
			// 搜索
			search() {
				this.page = 1;
				this.publishlist = [];
				this.getpublish();

			}
		},
		onReachBottom() {
			let newpage = this.page;
			newpage++;;
			this.page = newpage;
			this.getpublish()
		}
	}
</script>

<style>
	page {
		background: #F7F7F7;
	}

	.searchbox {
		padding: 0 32rpx;
		box-sizing: border-box;
		background: #fff;
		height: 88rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.tipsword {
		font-size: 28rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: rgba(61, 69, 76, 1);
	}

	.searchbox .fill {
		width: 182rpx;
		height: 60rpx;
		line-height: 60rpx;
		padding: 0 24rpx;
		box-sizing: border-box;
		background: rgba(249, 249, 249, 1);
		border-radius: 32rpx;
		border: 2rpx solid rgba(238, 238, 238, 1);
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(189, 196, 206, 1);
		margin-left: 10rpx;
	}

	.searchbtn {
		font-size: 28rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: rgba(61, 69, 76, 1);
	}

	.box {
		background: #fff;
		padding: 0 32rpx;
		box-sizing: border-box;
		margin-top:20rpx;
	}

	.item {
		padding: 32rpx 0;
		border-bottom: 1px solid #EEEEEE;
		box-sizing: border-box;
	}

	.titlebox {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.type {
		width: 100rpx;
		height: 36rpx;
		background: rgba(255, 255, 255, 1);
		border-radius: 4rpx;
		border: 2rpx solid rgba(194, 148, 69, 1);
		font-size: 22rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: rgba(194, 148, 69, 1);
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.word {
		font-size: 32rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 600;
		color: rgba(6, 18, 32, 1);
		width: 508rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.del {
		width: 32rpx;
		height: 32rpx;
	}

	.wordarea {
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(60, 68, 76, 1);
		margin-top: 12rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 3;
		overflow: hidden;
		height: auto;
	}

	.numbox {
		margin-top: 18rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.time {
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(91, 94, 100, 1);
	}

	.btnbox {
		display: flex;
		align-items: center;
	}

	.zan,
	.people {
		display: flex;
		align-items: center;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(91, 94, 100, 1);
	}

	.zan {
		margin-right: 32rpx;
	}

	.icon {
		width: 28rpx;
		margin-right: 8rpx;
	}
</style>