ad uid
This commit is contained in:
parent
1cb51ef60b
commit
866bc5f3fe
@ -62,3 +62,36 @@ export function delAdArea(data) {
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export function getAdUidList(params) {
|
||||
return request({
|
||||
url: '/games/ad/get-uid',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
export function saveAdUid(data) {
|
||||
return request({
|
||||
url: '/games/ad/save-uid',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export function editAdUid(data) {
|
||||
return request({
|
||||
url: '/games/ad/edit-uid',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export function delAdUid(data) {
|
||||
return request({
|
||||
url: '/games/ad/del-uid',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
@ -140,7 +140,13 @@ const gamesRouter = {
|
||||
path: 'ad-pos',
|
||||
component: () => import('@/views/games/details/adPos'),
|
||||
name: 'GameDetailsAdPos',
|
||||
meta: {title: '广告位置'},
|
||||
meta: {title: '广告位'},
|
||||
},
|
||||
{
|
||||
path: 'ad-uid',
|
||||
component: () => import('@/views/games/details/adUid'),
|
||||
name: 'GameDetailsAdUid',
|
||||
meta: {title: '广告码'},
|
||||
},
|
||||
// {
|
||||
// path: 'gm/servers',
|
||||
|
@ -64,3 +64,8 @@
|
||||
min-width: 100px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
.el-input.is-disabled .el-input__inner {
|
||||
cursor: default;
|
||||
}
|
||||
|
342
src/views/games/details/adUid.vue
Normal file
342
src/views/games/details/adUid.vue
Normal file
@ -0,0 +1,342 @@
|
||||
<template>
|
||||
<div class="main-content">
|
||||
<div style="width: 60%;">
|
||||
<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-collapse
|
||||
v-model="activeNames"
|
||||
v-if="allUid.length > 0"
|
||||
>
|
||||
<el-collapse-item
|
||||
:name="index"
|
||||
v-for="(item, index) in allUid"
|
||||
:key="index"
|
||||
>
|
||||
<template slot="title">
|
||||
<svg-icon
|
||||
style="margin-right: 20px;"
|
||||
icon-class="del"
|
||||
@click.stop="delUid(index)"
|
||||
/>
|
||||
{{ `[${index+1}]${item.channel_name || '渠道'}-${item.channel_id || '待生成'}`}}
|
||||
</template>
|
||||
<el-form
|
||||
:ref="`adUid${index}`"
|
||||
:model="item"
|
||||
:rules="adUidRules"
|
||||
style="width: 100%"
|
||||
label-width="100px"
|
||||
class="mgt-20 mgb-20"
|
||||
>
|
||||
<el-form-item
|
||||
label="游戏名称"
|
||||
prop="game_name"
|
||||
>
|
||||
<el-input
|
||||
v-model.number="item.game_name"
|
||||
style="width: 70%"
|
||||
disabled
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="渠道名称"
|
||||
prop="channel_name"
|
||||
>
|
||||
<el-input
|
||||
v-model.number="item.channel_name"
|
||||
style="width: 70%"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="跳转路径"
|
||||
prop="path"
|
||||
>
|
||||
<el-input
|
||||
v-model.number="item.path"
|
||||
style="width: 70%"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="ChannelID"
|
||||
prop="channel_id"
|
||||
>
|
||||
<el-input
|
||||
v-model.number="item.channel_id"
|
||||
style="width: 70%"
|
||||
disabled
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="platform_id">
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="saveUid(index)"
|
||||
>保存</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
@click="delUid(index)"
|
||||
>删除</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
|
||||
<div
|
||||
class="tip "
|
||||
v-else
|
||||
>
|
||||
<placeholder />
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="btn-group"
|
||||
v-if="platform_id"
|
||||
>
|
||||
<el-button
|
||||
class="mgt-20 w100"
|
||||
@click="addUid"
|
||||
v-if="permEdit"
|
||||
>新增</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
import { getGame } from '@/api/games'
|
||||
import { getAdUidList, saveAdUid, editAdUid, delAdUid } from '@/api/ad'
|
||||
import getPageTitle from '@/utils/get-page-title'
|
||||
import Coordinate from '@/components/Coordinate'
|
||||
import Placeholder from '@/components/Placeholder'
|
||||
import { reject, Promise } from 'q'
|
||||
|
||||
export default {
|
||||
name: 'GameDetailsAdUid',
|
||||
data() {
|
||||
return {
|
||||
// common
|
||||
uid: '',
|
||||
type: 'normal',
|
||||
platform_id: '',
|
||||
platformsArr: [],
|
||||
gameInfo: {},
|
||||
permEdit: false,
|
||||
permPublish: false,
|
||||
hasList: false,
|
||||
// form
|
||||
adUid: {},
|
||||
adUidRules: {
|
||||
game_name: [
|
||||
{ required: true, message: '请填写游戏名称', trigger: 'blur' }
|
||||
],
|
||||
channel_name: [
|
||||
{ required: true, message: '请填写渠道名称', trigger: 'blur' }
|
||||
],
|
||||
path: [{ required: true, message: '请填写路径', trigger: 'blur' }],
|
||||
channel_id: [
|
||||
{ required: true, message: '请填写 channelID', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
activeNames: [],
|
||||
defaultUid: {
|
||||
platform_id: '',
|
||||
game_id: '',
|
||||
game_name: '',
|
||||
channel_name: '',
|
||||
channel_id: '',
|
||||
path: ''
|
||||
},
|
||||
allUid: []
|
||||
}
|
||||
},
|
||||
components: {
|
||||
Coordinate,
|
||||
Placeholder
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['userInfo'])
|
||||
},
|
||||
mounted() {
|
||||
this.uid = this.$route.params.uid
|
||||
this.type = this.$route.query.type ? this.$route.query.type : 'normal'
|
||||
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`)
|
||||
this.getGameInfo(this.getAdUidList)
|
||||
},
|
||||
methods: {
|
||||
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.defaultUid.game_id = this.gameInfo.game_id
|
||||
this.defaultUid.game_name = this.gameInfo.game_name
|
||||
this.defaultUid.platform_id = this.platform_id
|
||||
if (cb && cb instanceof Function) cb()
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
getAdUidList() {
|
||||
getAdUidList({
|
||||
platform_id: this.platform_id,
|
||||
game_id: this.gameInfo.game_id
|
||||
})
|
||||
.then(res => {
|
||||
const data = res.data
|
||||
if (data.errcode === 0) {
|
||||
this.allUid = data.adUidList
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
changePlatform() {
|
||||
this.getAdUidList()
|
||||
},
|
||||
addUid() {
|
||||
const defaultUid = JSON.parse(JSON.stringify(this.defaultUid))
|
||||
defaultUid.channel_id = this.generateUid(10)
|
||||
this.activeNames.push(this.allUid.length)
|
||||
this.allUid.push(defaultUid)
|
||||
},
|
||||
delUid(index) {
|
||||
this.$confirm('是否要删除该ChannelId?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
delAdUid({
|
||||
_id: this.allUid[index]._id
|
||||
})
|
||||
.then(res => {
|
||||
const data = res.data
|
||||
if (data.errcode === 0) {
|
||||
this.$message.success('成功删除ChannelId!')
|
||||
this.allUid.splice(index, 1)
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message.info('已取消删除!')
|
||||
})
|
||||
},
|
||||
async saveUid(index) {
|
||||
const valid = await this.validForm(`adUid${index}`)
|
||||
if (valid) {
|
||||
const channelidInfo = JSON.parse(JSON.stringify(this.allUid[index]))
|
||||
|
||||
if (this.allUid[index]._id) {
|
||||
// 更新
|
||||
const self = this
|
||||
editAdUid({
|
||||
uid: this.uid,
|
||||
_id: channelidInfo._id,
|
||||
game_name: channelidInfo.game_name,
|
||||
game_id: channelidInfo.game_id,
|
||||
path: channelidInfo.path,
|
||||
platform_id: channelidInfo.platform_id,
|
||||
channel_name: channelidInfo.channel_name,
|
||||
channel_id: channelidInfo.channel_id
|
||||
})
|
||||
.then(res => {
|
||||
const data = res.data
|
||||
if (data.errcode === 0) {
|
||||
this.$message.success('ChannelId修改成功!')
|
||||
this.$refs[`adUid${index}`][0].clearValidate()
|
||||
this.getAdUidList()
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
} else {
|
||||
// 新增
|
||||
|
||||
const self = this
|
||||
|
||||
saveAdUid({
|
||||
uid: this.uid,
|
||||
game_name: channelidInfo.game_name,
|
||||
game_id: channelidInfo.game_id,
|
||||
path: channelidInfo.path,
|
||||
platform_id: channelidInfo.platform_id,
|
||||
channel_name: channelidInfo.channel_name,
|
||||
channel_id: channelidInfo.channel_id
|
||||
})
|
||||
.then(res => {
|
||||
const data = res.data
|
||||
if (data.errcode === 0) {
|
||||
this.$message.success('ChannelId新增成功!')
|
||||
this.$refs[`adUid${index}`][0].clearValidate()
|
||||
this.getAdUidList()
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this.$message.error('请按要求填写表单!')
|
||||
}
|
||||
},
|
||||
generateUid(len) {
|
||||
return Math.random()
|
||||
.toString(36)
|
||||
.substr(3, len)
|
||||
},
|
||||
validForm(formName) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.$refs[formName][0].validate(valid => {
|
||||
valid ? resolve(true) : reject()
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
.btn-group >>> .el-button + .el-button {
|
||||
margin-left: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
@ -10,34 +10,27 @@
|
||||
<el-menu-item :index="`/games/details/${uid}/info`">详情</el-menu-item>
|
||||
<!-- TODO: 开放数据页 -->
|
||||
<!-- <el-menu-item :index="`/games/details/${uid}/data`">数据</el-menu-item> -->
|
||||
<el-submenu :index="`/games/details/${uid}/settings/index`">
|
||||
<el-submenu v-if="uid !== 'new'" :index="`/games/details/${uid}/settings/index`">
|
||||
<template slot="title">配置</template>
|
||||
<el-menu-item
|
||||
v-if="uid !== 'new'"
|
||||
:index="`/games/details/${uid}/settings/index`"
|
||||
>所有</el-menu-item>
|
||||
<el-menu-item
|
||||
v-if="uid !== 'new'"
|
||||
:index="`/games/details/${uid}/settings/achievement`"
|
||||
>成就</el-menu-item>
|
||||
<el-menu-item
|
||||
v-if="uid !== 'new'"
|
||||
:index="`/games/details/${uid}/settings/invitation`"
|
||||
>邀请</el-menu-item>
|
||||
<el-menu-item
|
||||
v-if="uid !== 'new'"
|
||||
:index="`/games/details/${uid}/settings/red-envelope`"
|
||||
>红包</el-menu-item>
|
||||
<el-menu-item
|
||||
v-if="uid !== 'new'"
|
||||
:index="`/games/details/${uid}/settings/sign`"
|
||||
>签到</el-menu-item>
|
||||
<el-menu-item
|
||||
v-if="uid !== 'new'"
|
||||
:index="`/games/details/${uid}/settings/online`"
|
||||
>在线</el-menu-item>
|
||||
<el-menu-item
|
||||
v-if="uid !== 'new'"
|
||||
:index="`/games/details/${uid}/settings/banner`"
|
||||
>banner</el-menu-item>
|
||||
</el-submenu>
|
||||
@ -45,20 +38,17 @@
|
||||
v-if="uid !== 'new'"
|
||||
:index="`/games/details/${uid}/share`"
|
||||
>分享</el-menu-item>
|
||||
<!-- <el-menu-item
|
||||
v-if="uid !== 'new'"
|
||||
:index="`/games/details/${uid}/achievement`"
|
||||
>成就</el-menu-item> -->
|
||||
<!-- <el-menu-item
|
||||
v-if="uid !== 'new'"
|
||||
:index="`/games/details/${uid}/invitation`"
|
||||
>邀请</el-menu-item> -->
|
||||
<el-menu-item
|
||||
v-if="uid !== 'new'"
|
||||
:index="`/games/details/${uid}/reward`"
|
||||
>客服奖励</el-menu-item>
|
||||
<el-menu-item :index="`/games/details/${uid}/recommendation`">推荐</el-menu-item>
|
||||
<el-menu-item :index="`/games/details/${uid}/ad-pos`">广告位</el-menu-item>
|
||||
<el-menu-item v-if="uid !== 'new'" :index="`/games/details/${uid}/recommendation`">推荐</el-menu-item>
|
||||
|
||||
<el-submenu v-if="uid !== 'new'" :index="`/games/details/${uid}/ad-pos`">
|
||||
<template slot="title">广告</template>
|
||||
<el-menu-item :index="`/games/details/${uid}/ad-pos`">广告位</el-menu-item>
|
||||
<el-menu-item :index="`/games/details/${uid}/ad-uid`">广告码</el-menu-item>
|
||||
</el-submenu>
|
||||
|
||||
<!-- <el-menu-item :index="`/games/details/${uid}/recommendation`">推荐</el-menu-item>
|
||||
<el-menu-item :index="`/games/details/${uid}/reward`">奖励</el-menu-item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user