MyRedPackageDetail.vue 4.7 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
				<el-form-item>
					<el-button size="small" type="primary" @click="syncDetailInfo">同步详情</el-button>
				</el-form-item>

11 12 13 14 15 16 17 18 19
				<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>

20 21 22 23 24 25
					<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>

26 27 28 29 30 31 32 33 34 35 36 37 38
					<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 {
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
    name: 'MyRedPackageDetail',
    props: ['id', 'orderNo', 'communityId', 'postId'],
    data() {
        return {
            csdnRedPackageDetailList: [],
            loading: false,
            elementui_page_component_key: 0,
            currentPage: 1,
            pageSize: 50,
            total: 0,
            allOptions: [
                {
                    type: 0,
                    name: '',
                },
                {
                    type: 1,
                    name: '',
                },
            ],
        }
    },
    created() {
        // 调用请求数据的方法
        this.redPackageDetailList()
    },
    mounted() {
        this.currentPage = 1
        this.pageSize = 50
    },
    methods: {
        goBack() {
            // 传递参数到前一个页面
            const params = {
                // 参数名: 参数值
                back: 'back',
            }
            // 使用 $router.push() 导航到前一个页面
            this.$router.push({
                path: '/home/redPackage', // 前一个页面的路径
                query: params, // 参数对象
            })
        },
82

83 84 85 86 87 88
        // 封装请求列表数据的方法
        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
89

90 91 92 93 94 95 96 97 98 99 100
                const userWeightMap = {}
                this.allOptions.forEach((option) => {
                    userWeightMap[option.type] = option.name
                })
                res.result.content.forEach((item) => {
                    item.luckyName = userWeightMap[item.lucky]
                })
                this.csdnRedPackageDetailList = res.result.content
            }
            this.loading = false
        },
101

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

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

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