移动兑换物品管理

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

View File

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

View File

@ -56,14 +56,19 @@
<!-- TODO: 开放图表 -->
<!-- <el-menu-item :index="`/games/details/${uid}/data/charts`">图表</el-menu-item> -->
</el-submenu>
<el-menu-item
<el-submenu
v-if="uid !== 'new'"
: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'"
:index="`/games/details/${uid}/order`"
>订单</el-menu-item>
>订单</el-menu-item> -->
</el-menu>
<router-view />
</div>