兑换记录

This commit is contained in:
yulixing 2019-09-18 15:37:27 +08:00
parent f2c6c5ce5e
commit 2cc8f2ed06
6 changed files with 401 additions and 18 deletions

View File

@ -1,6 +1,6 @@
import request from '@/utils/request'
/* ---------------查询兑换物品 ----------------- */
/* ---------------兑换物品 ----------------- */
export function getGifts(params) {
return request({
url: '/games/gift',
@ -32,7 +32,7 @@ export function delGift(data) {
})
}
/* ---------------查询游戏兑换物品配置------------------ */
/* ---------------游戏兑换物品配置------------------ */
export function getGiftList(params) {
return request({
@ -73,7 +73,7 @@ export function delGiftList(data) {
})
}
/* ---------------查询兑换物品记录------------------ */
/* ---------------物品兑换记录------------------ */
export function getGiftRecords(params) {
return request({
url: '/games/gift/record',
@ -81,3 +81,12 @@ export function getGiftRecords(params) {
params,
})
}
export function updateGiftRecord(data) {
return request({
url: '/games/gift/record',
method: 'put',
data,
})
}

View File

@ -167,6 +167,12 @@ const gamesRouter = {
name: 'GameDetailsGift',
meta: {title: '仓库'},
},
{
path: 'gift/record',
component: () => import('@/views/games/details/gift/record'),
name: 'GameDetailsRecord',
meta: {title: '记录'},
},
{
path: 'order',
component: () => import('@/views/games/details/order'),

View File

@ -316,31 +316,31 @@ export default {
value: 2,
},
{
name: '抽屉-A',
name: '抽屉-普通',
value: 0,
},
{
name: '抽屉-B',
name: '抽屉-详细',
value: 3,
},
{
name: '弹窗-A',
name: '弹窗-',
value: 4,
},
{
name: '弹窗-B',
name: '弹窗-',
value: 5,
},
{
name: '浮层-A',
name: '滚动-横向',
value: 6,
},
{
name: '浮层-B',
name: '滚动-横向(小)',
value: 7,
},
{
name: '浮层-C',
name: '滚动-竖向',
value: 8,
},
{
@ -498,6 +498,7 @@ export default {
this.allPos = data.message || []
this.allPos.map(item => {
item.area = JSON.parse(item.area)
item.area = item.area.map(item => parseInt(item))
item.ld_property = item.ld_property
? JSON.parse(item.ld_property)
: {
@ -521,10 +522,7 @@ export default {
.then(res => {
const {data} = res
if (data.errcode === 0) {
this.areaList = data.adAreaList.map(item => {
item.area_id = item.area_id.toString()
return item
})
this.areaList = data.adAreaList
}
})
.catch(err => {

View File

@ -0,0 +1,369 @@
<template>
<div class="main-content">
<!-- filter -->
<el-form
:inline="true"
class="filter"
>
<el-form-item label="平台">
<el-select
v-model="platform_id"
placeholder="请选择平台"
class="w100"
>
<el-option
v-for="item in platformsArr"
:key="item.platform.platform_id"
:label="item.platform.name"
:value="item.platform.platform_id"
/>
</el-select>
</el-form-item>
<el-form-item label="物品ID">
<el-input
v-model="gift_id"
placeholder="请输入物品ID"
></el-input>
</el-form-item>
<el-form-item label="类型">
<el-select
v-model="type"
placeholder="请选择物品类型"
class="w100"
>
<el-option
label="所有"
:value="''"
/>
<el-option
v-for="(val,key) in typeList"
:key="key"
:label="val"
:value="key"
/>
</el-select>
</el-form-item>
<el-form-item label="使用状态">
<el-select
v-model="used"
placeholder="请选择状态"
class="w100"
>
<el-option
label="所有"
:value="''"
/>
<el-option
label="已使用"
:value="true"
/>
<el-option
label="未使用"
:value="false"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button
type="primary"
@click="search"
>查询</el-button>
</el-form-item>
</el-form>
<!-- filter end -->
<span
class="ipt-class"
style="color: #aaa; font-size: 12px;"
>物品类型为话费或实物时code字段包含用户手机号</span>
<el-table
v-loading="isLoaded"
:data="tableData"
style="width: 100%"
class="table mgt-20 mgb-20"
>
<el-table-column
type="index"
width="50"
/>
<el-table-column
prop="user_id"
label="用户ID"
show-overflow-tooltip
/>
<el-table-column
prop="gift_info.gift_name"
label="物品名称"
show-overflow-tooltip
width="200"
/>
<el-table-column
prop="gift_info.gift_id"
label="物品ID"
show-overflow-tooltip
width="180"
/>
<el-table-column
prop="gift_info.type"
label="物品类型"
show-overflow-tooltip
:formatter="formatType"
width="100"
/>
<el-table-column
prop="code"
label="code"
show-overflow-tooltip
/>
<el-table-column
prop="used"
label="兑换状态"
show-overflow-tooltip
:formatter="formatUsed"
width="100"
/>
<el-table-column
prop="createdAt"
label="兑换日期"
show-overflow-tooltip
:formatter="formatDate"
width="200"
/>
<el-table-column
label="操作"
fixed="right"
width="126"
>
<template slot-scope="scope">
<el-button
v-if="permEdit && !scope.row.used"
type="text"
size="small"
@click.stop="useCode(scope.row)"
>确认完成</el-button>
</template>
</el-table-column>
</el-table>
<!-- pagination -->
<el-pagination
class="al-r"
layout="total, sizes, prev, pager, next, jumper"
:hide-on-single-page="true"
:current-page="currentPage"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="total"
@size-change="sizeChange"
@current-change="pageChange"
/>
</div>
</template>
<script>
import {mapGetters} from 'vuex'
import {getGame, updateRC} from '@/api/games'
import {getGiftRecords, updateGiftRecord} from '@/api/gift'
import getPageTitle from '@/utils/get-page-title'
import {reject, Promise} from 'q'
import moment from 'moment'
export default {
name: 'GameDetailsData',
data() {
return {
// common
uid: '',
token: '',
platform_id: '',
gift_id: '',
used: '',
type: '',
platformsArr: [],
gameInfo: {},
permEdit: false,
typeList: {
'0': '其他',
'1': '话费',
'2': '实物',
},
// table
isLoaded: false,
tableData: [],
// pagination
currentPage: 1,
pageSize: 10,
total: 0,
}
},
computed: {
...mapGetters(['userInfo']),
},
mounted() {
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: {
getGameInfo(cb) {
const dataType = this.isDev ? 'dev' : 'pro'
getGame({uid: this.uid, data_type: dataType})
.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
: ''
}
if (cb && cb instanceof Function) cb()
}
})
.catch(err => {
console.log(err)
})
},
getData() {
this.isLoaded = true
getGiftRecords({
uid: this.uid,
platform_id: this.platform_id,
game_id: this.gameInfo.game_id,
used: this.used,
gift_id: this.gift_id,
type: this.type,
currentPage: this.currentPage,
pageSize: this.pageSize,
})
.then(res => {
const data = res.data
if (data.errcode === 0) {
this.isLoaded = false
this.tableData = data.result
console.log(this.tableData)
}
})
.catch(err => {
console.log(err)
})
},
search() {
this.getData()
},
// table
formatType(row, column, cellValue, index) {
return this.typeList[cellValue]
},
formatUsed(row, column, cellValue, index) {
return cellValue ? '已使用' : '未使用'
},
formatDate(row, column, cellValue, index) {
return cellValue ? moment(cellValue).format('YYYY-MM-DD HH:MM:SS') : '-'
},
useCode(row) {
this.$confirm('是否修改该记录使用状态为已完成?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
updateGiftRecord({
uid: this.uid,
_id: row._id,
used: true,
}).then(res => {
const data = res.data
if (data.errcode === 0) {
this.$message.success('操作成功!')
this.getData()
}
})
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消操作',
})
})
},
// pagination
sizeChange(val) {
this.pageSize = val
this.getData()
},
pageChange(val) {
this.currentPage = val
this.getData()
},
},
}
</script>
<style lang="scss" scoped>
.data-panel {
padding: 0 20px 20px 20px;
.part {
margin-bottom: 20px;
border-bottom: 1px solid #f5f7fa;
color: #606266;
.title {
font-weight: 700;
}
.data {
padding-left: 20px;
li {
list-style: none;
}
span {
display: inline-block;
box-sizing: border-box;
width: 200px;
padding: 0 20px;
}
.row {
height: 30px;
line-height: 30px;
font-size: 12px;
overflow: hidden;
&.hd {
font-size: 14px;
font-weight: 700;
&:hover {
background-color: #fff;
}
}
&:hover {
background-color: #f5f7fa;
}
}
}
}
}
</style>
<style scoped>
.btn-group >>> .el-button + .el-button {
margin-left: 0;
}
</style>

View File

@ -224,7 +224,7 @@
disabled
/>
</el-form-item>
<el-form-item
<!-- <el-form-item
label="兑换记录"
v-if="!isNew"
>
@ -232,7 +232,7 @@
@click="viewRecord(modalForm.gift_id)"
size="mini"
>兑换记录</el-button>
</el-form-item>
</el-form-item> -->
</el-form>
<div slot="footer">
<el-button @click="closeModal"> </el-button>

View File

@ -63,6 +63,7 @@
<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-menu-item :index="`/games/details/${uid}/gift/record`">记录</el-menu-item>
</el-submenu>
<!-- TODO: 开放订单页 -->
<!-- <el-menu-item