Skip to content
关注公众号,获取新课通知

礼物列表


控制器:app/controller/admin/gift.js

js
	async index() {
        const { ctx, app } = this;

        let data = await ctx.page('Gift')

        await ctx.renderTemplate({
            title: "礼物管理",
            tempType: "table",
            table: {
                // 按钮
                buttons: {
                    add: "/admin/gift/create"
                },
                // 表头
                columns: [{
                    title: '礼物图标',
                    fixed: 'left',
                    render(item) {
                        return `
                        <h2 class="table-avatar">
                            <a class="avatar avatar-sm mr-2"><img class="avatar-img rounded-circle bg-light" src="${item.image}"></a>
                        </h2>`
                    },
                }, {
                    title: '礼物名称',
                    key: 'name',
                    width: 180,
                    fixed: 'center'
                },{
                    title: '金币',
                    key: 'coin',
                    width: 180,
                    fixed: 'center'
                },{
                    title: "操作",
                    width: 200,
                    fixed: 'center',
                    action:{
                        edit:function(id){
                            return `/admin/gift/edit/${id}`
                        },
                        delete:function(id){
                            return `/admin/gift/delete/${id}`
                        },
                    }
                }],
                data
            }
        })
    }

路由:app/router.js

js
router.get("/admin/gift", controller.admin.gift.index);