praise_andLike.vue 2.9 KB
<template>
	<view class="praise_andLike">
		<public-switching :option="option" :current="current" @change="changeSwitching"></public-switching>
		<view class="praise_andLike-main">
			<scroll-view :scroll-y="true" class="praise_andLike-list">
				<view v-if="dataList.length">
					<praise-item :type="LIKETYPE.STUDENTEND" v-for="item in dataList" :info="item" :key="item.id"></praise-item>
				</view>
				<u-empty v-else mode="data" icon="/static/imagesV2/icon24.png" ></u-empty>
			</scroll-view>
		</view>
		<view class="operation"  @click="$service.jump" data-url="/page_admin/add_praise/add_praise">
			添加表扬
		</view>
	</view>
</template>

<script>
	import public_switching from "@/components/public_switching/public_switching.vue"
	import praise_item from "@/components/praise_item/praise_item.vue"
	import { PRAISEANDLIKE } from "./emit.js"
	import { LIKETYPE } from "@/emit/index.js"
	export default {
		components: {
			PublicSwitching: public_switching,
			PraiseItem: praise_item
		},
		data() {
			return {
				LIKETYPE,
				option: [
					{
						lable: '全部表扬',
						value: PRAISEANDLIKE.WHOLE
					},
					{
						lable: '我的表扬',
						value: PRAISEANDLIKE.MY
					}
				],
				current: PRAISEANDLIKE.WHOLE,
				page: 1,
				dataList: [],
				total: 0
			};
		},
		onShow() {
			this.page = 1
			this.total = 0
			this.dataList = []
			this.getData()
		},
		methods: {
			getData() {
				var datas = {
					is_my: this.current,
					page: this.page,
					limit: 10
				}
				var jkurl = '/praise'
				this.$service.P_post(jkurl, datas).then(res => {
					this.total = res.data.total
					if(this.dataList.length < this.total) {
						if(this.page === 1) {
							this.dataList = res.data.data
						} else {
							this.dataList.push(...res.data.data)
						}
						this.page++
					}
					if(this.current === PRAISEANDLIKE.MY) {
						this.dataList = this.dataList.map(item => {
							return {
								...item,
								is_my: true
							}
						})
					}
					console.log('dataList====>', this.dataList)
				})
			},
			changeSwitching(e) {
				this.current = e
				this.page = 1
				this.total = 0
				this.dataList = []
				this.getData()
			}
		}
	}
</script>

<style lang="scss">
.praise_andLike{
	.tel_index_bg{
		position: absolute;
		top: 0;
		z-index: 1;
		width: 100%;
		min-height: 220rpx;
		background: linear-gradient(0deg, #f8f8f8 0%, #ffffff 25%, #5D9DFD 60%, #428EFE 70%, #2D81FF 100%);
	}
	.praise_andLike-main{
		position: relative;
		z-index: 1;
		padding: 0rpx 25rpx;
		.praise_andLike-list{
			margin-top: 30rpx;
			height: calc(100vh - 152rpx);
		}
	}
	.operation{
		position: absolute;
		bottom: 150rpx;
		left: 50%;
		width: 700rpx;
		transform: translateX(-50%);
		z-index: 1;
		height: 88rpx;
		line-height: 88rpx;
		background-color: #2D81FF;
		border-radius: 200rpx;
		text-align: center;
		font-size: 34rpx;
		color: #fff;
		margin-top: 53rpx;
	}
}
</style>