admin_praise.vue 2.7 KB
<template>
	<view class="admin_praise">
		<view class="tel_index_bg"></view>
		<view class="admin_praise-main">
			<public-switching :option="option" :current="current" @change="changeSwitching"></public-switching>
			<scroll-view :scroll-y="true" class="praise_andLike-list"  @scrolltolower="getData">
				<view v-if="dataList.length">
					<praise-item :type="LIKETYPE.ADMINEND" :info="item" v-for="item in dataList" :key="item.id" @success="success"></praise-item>
				</view>
				<u-empty v-else mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" ></u-empty>
			</scroll-view>
		</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.PENDINGREVIEW
					}
				],
				current: PRAISEANDLIKE.WHOLE,
				total: 0,
				dataList: [],
				page: 1
			}
		},
		onLoad() {
			this.getData()
		},
		methods: {
			success(e) {
				this.dataList = this.dataList.filter(item => item.id !== e)
			},
			changeSwitching(e) {
				this.current = e
				this.page = 1
				this.total = 0
				this.dataList = []
				this.getData()
			},
			getData() {
				var datas = {
					is_uncheck: this.current,
					page: this.page,
					limit: 10
				}
				var jkurl = '/admin/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
							console.log('res====>', res)
						} else {
							
							this.dataList.push(...result)
						}
						this.page++
					}
					if(this.current === PRAISEANDLIKE.PENDINGREVIEW) {
						this.dataList = this.dataList.map(item => {
							return {
								...item,
								showOperation: true
							}
						})
					}
					console.log('dataList====>', this.dataList)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.admin_praise{
		.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%);
		}
		.admin_praise-main{
			position: relative;
			z-index: 1;
			padding: 0rpx 25rpx;
			.praise_andLike-list{
				margin-top: 30rpx;
				height: calc(100vh - 152rpx);
			}
		}
	}
</style>