MyRedPackageDetail.vue 2.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
<template>
	<div>
		<el-button type="primary" plain size="medium" @click="goBack">后退</el-button>
		<h4 class="text-center">红包订单号{{ orderNo }}领取详情</h4>
		<el-container>
			<el-main>
				<el-table ref="multipleTable" v-loading="loading" :data="csdnRedPackageDetailList" tooltip-effect="dark" style="width: 100%">
					<el-table-column prop="id" label="序号" width="100" sortable></el-table-column>
					<el-table-column prop="orderNo" label="订单号" show-overflow-tooltip></el-table-column>
					<el-table-column prop="communityId" label="社区id" show-overflow-tooltip></el-table-column>
					<el-table-column prop="postId" label="发布id" show-overflow-tooltip></el-table-column>

					<el-table-column prop="receiverNickName" label="用户昵称" show-overflow-tooltip></el-table-column>
					<el-table-column prop="receivedMoney" label="抢到金额" sortable show-overflow-tooltip></el-table-column>

					<el-table-column label="领取时间">
						<template slot-scope="props">{{ props.row.receiveTime | dateFormat }}</template>
					</el-table-column>
				</el-table>
				<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[8, 10, 50, 100, 200, 400]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>
			</el-main>
		</el-container>
	</div>
</template>
<script>
// 导入 axios 请求库
import ApiService from '../../api/ApiService'
export default {
	name: 'MyRedPackageDetail',
	props: ['orderNo', 'communityId', 'postId'],
	data() {
		return {
			csdnRedPackageDetailList: [],
			loading: false,
			elementui_page_component_key: 0,
			currentPage: Number(localStorage.getItem('redPackagePage')) || 1,
			pageSize: 50,
			total: 0,
		}
	},
	watch: {
		// 监听currentPage的变化,将新值保存到localStorage中
		currentPage(newPage) {
			localStorage.setItem('redPackagePage', newPage.toString())
		},
	},
	created() {
		// 调用请求数据的方法
		this.redPackageDetailList()
	},
	methods: {
		goBack() {
			// 使用 $router.push() 导航到前一个页面
			this.$router.push({
				path: '/home/redPackage', // 前一个页面的路径
			})
		},
		// 封装请求列表数据的方法
		async redPackageDetailList() {
			this.loading = true
			const { data: res } = await ApiService.redPackageDetailList(this.currentPage, this.pageSize, this.$route.params.orderNo, this.$route.params.communityId, this.$route.params.postId)
			if (res.code === 200) {
				this.total = res.result.totalElements
				this.csdnRedPackageDetailList = res.result.content
			}
			this.loading = false
		},

		handleCurrentChange(currentPage) {
			this.currentPage = currentPage
			this.redPackageDetailList()
		},
		handleSizeChange(currentSize) {
			this.pageSize = currentSize
			this.redPackageDetailList()
		},
	},
}
</script>

<style lang="less" scoped>
.button-container {
	position: fixed;
	bottom: 0;
	right: 0;
	margin: 16px;
}
</style>