MyRedPackageDetail.vue 4.0 KB
Newer Older
1 2 3 4 5 6
<template>
	<div>
		<el-button type="primary" plain size="medium" @click="goBack">后退</el-button>
		<h4 class="text-center">红包订单号{{ orderNo }}领取详情</h4>
		<el-container>
			<el-main>
7 8 9 10 11
				<el-form :inline="true" :model="formInline" class="demo-form-inline">
					<el-form-item>
						<el-button size="small" type="primary" @click="syncDetailInfo">同步详情</el-button>
					</el-form-item>
				</el-form>
12 13 14 15 16 17 18 19 20
				<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>

21 22 23 24 25 26
					<el-table-column prop="luckyName" label="幸运王" show-overflow-tooltip>
						<template slot-scope="scope">
							<el-tag :type="getTagType(scope.row.luckyName)">{{ scope.row.luckyName }}</el-tag>
						</template>
					</el-table-column>

27 28 29 30 31 32 33 34 35 36 37 38 39 40
					<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',
41
	props: ['id', 'orderNo', 'communityId', 'postId'],
42 43 44 45 46
	data() {
		return {
			csdnRedPackageDetailList: [],
			loading: false,
			elementui_page_component_key: 0,
47
			currentPage: 1,
48 49
			pageSize: 50,
			total: 0,
50 51 52 53 54 55 56 57 58 59
			allOptions: [
				{
					type: 0,
					name: '',
				},
				{
					type: 1,
					name: '',
				},
			],
60 61 62 63 64 65
		}
	},
	created() {
		// 调用请求数据的方法
		this.redPackageDetailList()
	},
66 67
	mounted() {
		this.currentPage = 1
68
		this.pageSize = 50
69
	},
70 71
	methods: {
		goBack() {
72 73 74 75 76
			// 传递参数到前一个页面
			const params = {
				// 参数名: 参数值
				back: 'back',
			}
77 78 79
			// 使用 $router.push() 导航到前一个页面
			this.$router.push({
				path: '/home/redPackage', // 前一个页面的路径
80
				query: params, // 参数对象
81 82
			})
		},
83

84 85 86 87 88 89
		// 封装请求列表数据的方法
		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
90 91 92 93 94 95 96 97

				const userWeightMap = {}
				this.allOptions.forEach((option) => {
					userWeightMap[option.type] = option.name
				})
				res.result.content.forEach((item) => {
					item.luckyName = userWeightMap[item.lucky]
				})
98 99 100 101 102
				this.csdnRedPackageDetailList = res.result.content
			}
			this.loading = false
		},

103 104 105 106 107 108 109 110 111
		async syncDetailInfo() {
			this.loading = true
			const { data: res } = await ApiService.syncDetailInfo(this.$route.params.id)
			if (res.code === 200) {
				this.redPackageDetailList()
			}
			this.loading = false
		},

112 113 114 115 116 117 118 119
		handleCurrentChange(currentPage) {
			this.currentPage = currentPage
			this.redPackageDetailList()
		},
		handleSizeChange(currentSize) {
			this.pageSize = currentSize
			this.redPackageDetailList()
		},
120 121 122 123 124 125 126
		getTagType(luckyName) {
			if (luckyName == '') {
				return 'danger'
			} else {
				return 'success'
			}
		},
127 128 129 130 131 132 133 134 135 136 137 138
	},
}
</script>

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