oneNews.vue 2.9 KB
<template>
	<view class="oneNews">
		<!-- 中志要闻 -->
		<view class="header-wrap"></view>
		<view class="news-wrap">
			<view class="news-item area flex" v-for="(item,index) in datas" :key="index"
				@tap="$service.jump" :data-url="'/pagesB/oneNewsDetails/oneNewsDetails?id='+item.id">

				<view>
					<view class="news-day flex">
						<view class="spot"></view>
						<view class="news-day-time">
							{{item.create_time}}
						</view>
					</view>
					<view class="news-text text-retain">
						{{item.title}}
					</view>
				</view>
			</view>
			<u-empty v-if="datas.length==0"
							mode="data"
							text="暂无记录"
							icon="/static/images/tch/img_blank.png"
			>
			</u-empty>
		</view>

	</view>
</template>

<script>
	import Vue from 'vue'
	import {
		mapState,
		mapMutations
	} from 'vuex'
	var that 
	export default {
		data() {
			return {
				datas: [],
				page:1
			}
		},
		onLoad() {
			that=this
			that.onRetry()
		},
		onShow() {
			
		},
		onReachBottom() {
			that.getdata()
		},
		methods: {
			onRetry(){
				that.page=1
				that.datas = []
				that.getdata()
			},
			getdata() {
			
				var datas = {
					page:that.page,
					limit:20
				}
				var jkurl = '/student/news'
				if (that.btnkg == 1) {
					return
				} else {
					that.btnkg = 1
				}
				var page_now=that.page
				that.$service.P_post(jkurl, datas).then(res => {
					that.btnkg = 0
					console.log(res)
					if (res.code == 1) {
						var datas = res.data
						console.log(typeof datas)
				
						if (typeof datas == 'string') {
							datas = JSON.parse(datas)
						}
					
						if (page_now == 1) {
						
							that.datas = datas.data
						
						} else {
							if (datas.data.length == 0) {
								that.data_last = true
								return
							}
							that.data_last = false
							that.datas = that.datas.concat(datas.data)
						}
						that.allnum=datas.allnum
						that.page++
				
					} else {
						if (res.msg) {
							uni.showToast({
								icon: 'none',
								title: res.msg
							})
						} else {
							uni.showToast({
								icon: 'none',
								title: '操作失败'
							})
						}
					}
				}).catch(e => {
					that.btnkg = 0
					console.log(e)
					uni.showToast({
						icon: 'none',
						title: '操作失败'
					})
				})
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	.oneNews {
		position: relative;
	}

	.news-wrap {
		position: absolute;
		top: 28rpx;
		left: 50%;
		transform: translate(-50%, 0);
	}

	.news-item {
		height: 196rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		margin-bottom: 20rpx;
		align-items: center;
		padding: 0 34rpx;

		.news-day {
			height: 28rpx;
			line-height: 28rpx;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #A9B1C0;
			margin-bottom: 20rpx;
			align-items: center;

			.news-day-time {
				margin-left: 12rpx;
			}
		}

		.news-text {
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #545D71;
		}
	}
</style>