256 lines
6.0 KiB
Vue
256 lines
6.0 KiB
Vue
<template>
|
|
<div class="main-content">
|
|
<!-- filter -->
|
|
<el-form
|
|
:inline="true"
|
|
class="filter"
|
|
>
|
|
<el-form-item label="平台">
|
|
<el-select
|
|
v-model="platform_id"
|
|
@change="changePlatform"
|
|
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="日期">
|
|
<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-form-item>
|
|
<el-form-item label="用户类型">
|
|
<el-select
|
|
v-model="isNew"
|
|
@change="changeNew"
|
|
placeholder="是否当日新用户"
|
|
class="w100"
|
|
>
|
|
<el-option
|
|
label="非当日新用户"
|
|
:value="0"
|
|
/>
|
|
<el-option
|
|
label="当日新用户"
|
|
:value="1"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form>
|
|
<!-- filter end -->
|
|
|
|
<!-- 占位 -->
|
|
<placeholder v-if="JSON.stringify(reportData) === '{}'" />
|
|
<!-- 占位 end -->
|
|
|
|
<!-- 数据面板 -->
|
|
<div class="data-panel">
|
|
<div
|
|
class="data-wrap"
|
|
v-for="(val, key) in reportData"
|
|
:key="key"
|
|
>
|
|
|
|
<h2 v-if="val.length > 0">{{key.toUpperCase()}}</h2>
|
|
<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'
|
|
import Placeholder from '@/components/Placeholder'
|
|
|
|
export default {
|
|
name: 'GameDetailsData',
|
|
data() {
|
|
return {
|
|
// common
|
|
uid: '',
|
|
token: '',
|
|
platform_id: '',
|
|
platformsArr: [],
|
|
gameInfo: {},
|
|
permEdit: false,
|
|
permPublish: false,
|
|
date: '',
|
|
isNew: 1,
|
|
reportData: {}
|
|
}
|
|
},
|
|
components: {
|
|
Placeholder
|
|
},
|
|
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() {
|
|
console.log({
|
|
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
|
|
})
|
|
getReport({
|
|
uid: this.uid,
|
|
game_id: 1004, // TODO: this.gameInfo.game_id
|
|
platform_id: 6001, // 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
|
|
}
|
|
})
|
|
.catch(err => {
|
|
this.reportData = {}
|
|
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 #ebeef5;
|
|
text-align: center;
|
|
cursor: pointer;
|
|
&:hover{
|
|
box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
|
|
}
|
|
.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>
|
|
|
|
|