移动兑换物品管理

This commit is contained in:
yulixing 2019-08-30 14:29:47 +08:00
parent c853520ed2
commit 00d4302df0
4 changed files with 85 additions and 40 deletions

View File

@ -42,12 +42,6 @@ const gamesRouter = {
name: 'GameAdArea', name: 'GameAdArea',
meta: {title: '广告区域管理'}, meta: {title: '广告区域管理'},
}, },
{
path: 'gift',
component: () => import('@/views/games/gift'), // Parent router-view
name: 'GameGift',
meta: {title: '兑换物品管理'},
},
{ {
path: 'details/:uid?', path: 'details/:uid?',
@ -162,10 +156,16 @@ const gamesRouter = {
meta: {title: '道具'}, meta: {title: '道具'},
}, },
{ {
path: 'gift', path: 'gift/cfg',
component: () => import('@/views/games/details/gift'), component: () => import('@/views/games/details/gift/cfg'),
name: 'GameDetailsGift', name: 'GameDetailsGift',
meta: {title: '兑换'}, meta: {title: '配置'},
},
{
path: 'gift/store',
component: () => import('@/views/games/details/gift/store'),
name: 'GameDetailsGift',
meta: {title: '仓库'},
}, },
{ {
path: 'order', path: 'order',

View File

@ -1,10 +1,10 @@
<template> <template>
<div class="app-container"> <div class="main-content">
<!-- toolbar --> <!-- toolbar -->
<div class="toolbar clearfix"> <div class="toolbar clearfix">
<div class="l fl"> <div class="l fl">
<el-button <el-button
v-if="permWriteable" v-if="permEdit"
type="primary" type="primary"
@click="addGift" @click="addGift"
>新增</el-button> >新增</el-button>
@ -25,14 +25,14 @@
@row-click="rowClick" @row-click="rowClick"
> >
<el-table-column <el-table-column
prop="gift_id" prop="game_id"
label="物品ID" label="游戏ID"
show-overflow-tooltip show-overflow-tooltip
sortable sortable
/> />
<el-table-column <el-table-column
prop="game_id" prop="gift_id"
label="游戏ID" label="物品ID"
show-overflow-tooltip show-overflow-tooltip
sortable sortable
/> />
@ -52,7 +52,7 @@
<el-image <el-image
:src="scope.row.gift_url" :src="scope.row.gift_url"
fit="cover" fit="cover"
style="width: 50px;height: 50px" style="width: 50px;height: 50px; vertical-align: middle;"
></el-image> ></el-image>
</template> </template>
</el-table-column> </el-table-column>
@ -71,7 +71,7 @@
:formatter="formUsed" :formatter="formUsed"
/> />
<el-table-column <el-table-column
v-if="permWriteable" v-if="permEdit"
label="操作" label="操作"
fixed="right" fixed="right"
> >
@ -105,16 +105,20 @@
<el-form-item <el-form-item
label="游戏ID" label="游戏ID"
prop="game_id" prop="game_id"
> >
<el-input v-model="modalForm.game_id" :disabled="!isNew" /> <el-input
v-model="modalForm.game_id"
disabled
/>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
label="物品ID" label="物品ID"
prop="gift_id" prop="gift_id"
> >
<el-input v-model="modalForm.gift_id" :disabled="!isNew" /> <el-input
v-model="modalForm.gift_id"
:disabled="!isNew"
/>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
label="物品名称" label="物品名称"
@ -163,13 +167,19 @@
/> />
<span class="ipt-tip">多个兑换券使用','分隔</span> <span class="ipt-tip">多个兑换券使用','分隔</span>
</el-form-item> </el-form-item>
<el-form-item label="已兑换" v-if="!isNew"> <el-form-item
label="已兑换"
v-if="!isNew"
>
<el-input <el-input
:value="modalForm.used_codes.length" :value="modalForm.used_codes.length"
disabled disabled
/> />
</el-form-item> </el-form-item>
<el-form-item label="兑换记录" v-if="!isNew"> <el-form-item
label="兑换记录"
v-if="!isNew"
>
<el-button <el-button
@click="viewRecord(modalForm.gift_id)" @click="viewRecord(modalForm.gift_id)"
size="mini" size="mini"
@ -181,7 +191,7 @@
<el-button <el-button
type="primary" type="primary"
@click="saveEdit" @click="saveEdit"
v-if="permWriteable" v-if="permEdit"
> </el-button> > </el-button>
</div> </div>
</el-dialog> </el-dialog>
@ -247,6 +257,7 @@
<script> <script>
import {mapGetters} from 'vuex' import {mapGetters} from 'vuex'
import {getGame} from '@/api/games'
import { import {
getGifts, getGifts,
addGift, addGift,
@ -254,6 +265,7 @@ import {
delGift, delGift,
getGiftRecords, getGiftRecords,
} from '@/api/gift' } from '@/api/gift'
import getPageTitle from '@/utils/get-page-title'
import {getToken} from '@/utils/auth' import {getToken} from '@/utils/auth'
export default { export default {
@ -261,7 +273,11 @@ export default {
data() { data() {
return { return {
// common // common
permWriteable: false, uid: '',
platform_id: '',
platformsArr: [],
gameInfo: {},
permEdit: false,
token: '', token: '',
// table // table
isLoaded: false, isLoaded: false,
@ -275,7 +291,7 @@ export default {
gift_id: '', gift_id: '',
gift_name: '', gift_name: '',
gift_url: '', gift_url: '',
game_id: '' game_id: '',
}, },
modalRules: { modalRules: {
gift_id: [{required: true, message: '请填写物品 ID', trigger: 'blur'}], gift_id: [{required: true, message: '请填写物品 ID', trigger: 'blur'}],
@ -301,11 +317,41 @@ export default {
...mapGetters(['userInfo']), ...mapGetters(['userInfo']),
}, },
mounted() { mounted() {
this.getData()
this.token = getToken() this.token = getToken()
this.permWriteable = this.userInfo.permissions.includes(`gift-writeable`) this.uid = this.$route.params.uid
this.permEdit =
this.userInfo.permissions.includes(`${this.uid}-edit`) ||
this.userInfo.permissions.includes(`${this.uid}-publish`) ||
this.userInfo.permissions.includes(`games-writeable`)
this.getGameInfo(this.getData)
}, },
methods: { methods: {
// common
getGameInfo(cb) {
getGame({uid: this.uid})
.then(res => {
const {data} = res
if (data.errcode === 0) {
this.gameInfo = data.gameInfo
this.platformsArr = data.gameInfo.platforms
this.$route.meta.title = this.gameInfo.game_name
document.title = getPageTitle(this.gameInfo.game_name)
if (this.$route.query.platform_id) {
this.platform_id = this.$route.query.platform_id
} else {
this.platform_id = this.platformsArr[0]
? this.platformsArr[0].platform.platform_id
: ''
}
this.modalForm.game_id = this.gameInfo.game_id
if (cb && cb instanceof Function) cb()
}
})
.catch(err => {
console.log(err)
})
},
// toolbar // toolbar
addGift() { addGift() {
this.openModal(true) this.openModal(true)
@ -316,7 +362,7 @@ export default {
// table // table
getData() { getData() {
this.isLoaded = true this.isLoaded = true
getGifts() getGifts({game_id: this.gameInfo.game_id})
.then(res => { .then(res => {
const {data} = res const {data} = res
this.tableData = data.result this.tableData = data.result
@ -371,13 +417,7 @@ export default {
openModal(isNew, data) { openModal(isNew, data) {
if (isNew) { if (isNew) {
this.isNew = true this.isNew = true
this.modalForm = { this.modalForm = JSON.parse(JSON.stringify(this.modalForm))
codes: [],
used_codes: [],
gift_id: '',
gift_name: '',
gift_url: '',
}
this.codesStr = '' this.codesStr = ''
this.usedCodesStr = '' this.usedCodesStr = ''
} else { } else {

View File

@ -56,14 +56,19 @@
<!-- TODO: 开放图表 --> <!-- TODO: 开放图表 -->
<!-- <el-menu-item :index="`/games/details/${uid}/data/charts`">图表</el-menu-item> --> <!-- <el-menu-item :index="`/games/details/${uid}/data/charts`">图表</el-menu-item> -->
</el-submenu> </el-submenu>
<el-menu-item <el-submenu
v-if="uid !== 'new'" v-if="uid !== 'new'"
:index="`/games/details/${uid}/gift`" :index="`/games/details/${uid}/gift`"
>兑换</el-menu-item> >
<el-menu-item <template slot="title">兑换</template>
<el-menu-item :index="`/games/details/${uid}/gift/cfg`">配置</el-menu-item>
<el-menu-item :index="`/games/details/${uid}/gift/store`">仓库</el-menu-item>
</el-submenu>
<!-- TODO: 开放订单页 -->
<!-- <el-menu-item
v-if="uid !== 'new'" v-if="uid !== 'new'"
:index="`/games/details/${uid}/order`" :index="`/games/details/${uid}/order`"
>订单</el-menu-item> >订单</el-menu-item> -->
</el-menu> </el-menu>
<router-view /> <router-view />
</div> </div>