game-data
This commit is contained in:
parent
854170d25e
commit
6fad3f7488
9
src/api/data.js
Normal file
9
src/api/data.js
Normal file
@ -0,0 +1,9 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function getReport(params) {
|
||||
return request({
|
||||
url: '/games/data/report',
|
||||
method: 'get',
|
||||
params,
|
||||
})
|
||||
}
|
@ -56,6 +56,12 @@ const gamesRouter = {
|
||||
name: 'GameDetailsInfo',
|
||||
meta: { title: '详细信息' }
|
||||
},
|
||||
{
|
||||
path: 'data',
|
||||
component: () => import('@/views/games/details/data'),
|
||||
name: 'GameDetailsData',
|
||||
meta: { title: '数据' }
|
||||
},
|
||||
{
|
||||
path: 'settings/index',
|
||||
component: () => import('@/views/games/details/settings/index'),
|
||||
|
234
src/views/games/details/data.vue
Normal file
234
src/views/games/details/data.vue
Normal file
@ -0,0 +1,234 @@
|
||||
<template>
|
||||
<div class="main-content">
|
||||
<!-- 筛选 -->
|
||||
<el-row :gutter="32">
|
||||
<el-col :span="6">
|
||||
<el-select
|
||||
v-model="platform_id"
|
||||
@change="changePlatform"
|
||||
placeholder="请选择平台"
|
||||
class="w100 mgb-20"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in platformsArr"
|
||||
:key="item.platform.platform_id"
|
||||
:label="item.platform.name"
|
||||
:value="item.platform.platform_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-date-picker
|
||||
v-model="date"
|
||||
align="right"
|
||||
type="date"
|
||||
placeholder="选择日期"
|
||||
style="width: 100%"
|
||||
value-format="yyyy-MM-dd"
|
||||
@change="changeDate"
|
||||
>
|
||||
</el-date-picker>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-select
|
||||
v-model="isNew"
|
||||
@change="changeNew"
|
||||
placeholder="是否当日新用户"
|
||||
class="w100 mgb-20"
|
||||
>
|
||||
<el-option
|
||||
label="非当日新用户"
|
||||
:value="0"
|
||||
/>
|
||||
<el-option
|
||||
label="当日新用户"
|
||||
:value="1"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<!-- 筛选 end -->
|
||||
|
||||
<!-- 数据面板 -->
|
||||
<div class="data-panel">
|
||||
<div
|
||||
class="data-wrap"
|
||||
v-for="(val, key) in reportData"
|
||||
:key="key"
|
||||
>
|
||||
|
||||
<el-divider v-if="val.length > 0">{{key.toUpperCase()}}</el-divider>
|
||||
<el-row :gutter="16">
|
||||
<el-col
|
||||
:span="6"
|
||||
v-for="(item, index) in val"
|
||||
:key="index"
|
||||
>
|
||||
<div class="data-box">
|
||||
<span class="title c-t-3">{{item.explan}}</span>
|
||||
<span class="key c-t-4">{{item.name}}</span>
|
||||
<span class="num">{{item.value}}</span>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 数据面板 end -->
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
import { getGame, updateRC } from '@/api/games'
|
||||
import { getReport } from '@/api/data'
|
||||
import getPageTitle from '@/utils/get-page-title'
|
||||
import { reject, Promise } from 'q'
|
||||
import { getToken } from '@/utils/auth'
|
||||
|
||||
export default {
|
||||
name: 'GameDetailsData',
|
||||
data() {
|
||||
return {
|
||||
// common
|
||||
uid: '',
|
||||
token: '',
|
||||
platform_id: '',
|
||||
platformsArr: [],
|
||||
gameInfo: {},
|
||||
permEdit: false,
|
||||
permPublish: false,
|
||||
date: '',
|
||||
isNew: 1,
|
||||
reportData: {}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['userInfo'])
|
||||
},
|
||||
mounted() {
|
||||
this.uid = this.$route.params.uid
|
||||
this.type = this.$route.query.type ? this.$route.query.type : 'normal'
|
||||
this.token = getToken()
|
||||
this.permEdit =
|
||||
this.userInfo.permissions.includes(`${this.uid}-edit`) ||
|
||||
this.userInfo.permissions.includes(`${this.uid}-publish`) ||
|
||||
this.userInfo.permissions.includes(`games-writeable`)
|
||||
this.permPublish =
|
||||
this.userInfo.permissions.includes(`${this.uid}-publish`) ||
|
||||
this.userInfo.permissions.includes(`games-writeable`)
|
||||
|
||||
const now = new Date()
|
||||
const before = new Date(now.getTime() - 24 * 60 * 60 * 1000)
|
||||
|
||||
this.date = `${before.getFullYear()}-${(before.getMonth() + 1)
|
||||
.toString()
|
||||
.padStart(2, '0')}-${before
|
||||
.getDate()
|
||||
.toString()
|
||||
.padStart(2, '0')}`
|
||||
|
||||
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() {
|
||||
getReport({
|
||||
uid: this.uid,
|
||||
game_id: 1004, // TODO: this.gameInfo.game_id
|
||||
platform_id: this.platform_id, // TODO: this.platform_id
|
||||
date: this.date, // TODO: this.date
|
||||
isNew: this.isNew
|
||||
})
|
||||
.then(res => {
|
||||
const { data } = res
|
||||
if (data.errcode === 0) {
|
||||
this.reportData = data.result
|
||||
|
||||
console.log(data)
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
changePlatform() {
|
||||
this.getData()
|
||||
},
|
||||
changeDate() {
|
||||
this.getData()
|
||||
},
|
||||
changeNew() {
|
||||
this.getData()
|
||||
},
|
||||
validForm(formName) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.$refs[formName][0].validate(valid => {
|
||||
valid ? resolve() : reject()
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.data-box {
|
||||
box-sizing: border-box;
|
||||
padding: 16px;
|
||||
margin-bottom: 16px;
|
||||
border: 1px solid #dcdfe6;
|
||||
text-align: center;
|
||||
.title,
|
||||
.key,
|
||||
.num {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 16px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.key {
|
||||
font-size: 14px;
|
||||
}
|
||||
.num {
|
||||
font-size: 72px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<style scoped>
|
||||
.btn-group >>> .el-button + .el-button {
|
||||
margin-left: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
>
|
||||
<!-- <el-menu-item v-if="uid !== 'new'" :index="`/games/details/${uid}/profile`">简介</el-menu-item> -->
|
||||
<el-menu-item :index="`/games/details/${uid}/info`">详情</el-menu-item>
|
||||
<el-menu-item :index="`/games/details/${uid}/data`">数据</el-menu-item>
|
||||
<el-submenu :index="`/games/details/${uid}/settings/index`">
|
||||
<template slot="title">配置</template>
|
||||
<el-menu-item
|
||||
|
Loading…
x
Reference in New Issue
Block a user