广告位、仓库修改

This commit is contained in:
yulixing 2019-09-16 15:24:19 +08:00
parent b92685537b
commit 8fd54f190f
2 changed files with 212 additions and 58 deletions

View File

@ -31,7 +31,7 @@
icon-class="del"
@click.stop="delPos(index)"
/>
{{ `[${index+1}]广告位:${item.area}${item.type}${item.mode}${item.coorX}${item.coorY}`}}
{{ `[${index+1}]广告位:${item.ld_property.title}`}}
</template>
<el-form
:ref="`adPos${index}`"
@ -41,6 +41,16 @@
label-width="100px"
class="mgt-20 mgb-20"
>
<el-form-item
label="名称"
prop="ld_property.title"
>
<el-input
v-model.number="item.ld_property.title"
style="width: 70%"
></el-input>
</el-form-item>
<el-form-item
label="区域"
prop="area"
@ -49,6 +59,7 @@
v-model="item.area"
placeholder="请选择广告投放区域"
style="width: 70%"
multiple
>
<el-option
v-for="(area, idx) in areaList"
@ -97,20 +108,20 @@
</el-form-item>
<el-form-item
label="坐标X"
prop="coorX"
prop="x"
>
<el-input
v-model.number="item.coorX"
v-model.number="item.x"
style="width: 70%"
></el-input>
<span class="ipt-tip">广告位中心点坐标x 取值0~15</span>
</el-form-item>
<el-form-item
label="坐标Y"
prop="coorY"
prop="y"
>
<el-input
v-model.number="item.coorY"
v-model.number="item.y"
style="width: 70%"
></el-input>
<span class="ipt-tip">广告位中心点坐标y 取值0~15</span>
@ -120,7 +131,7 @@
prop="offsetX"
>
<el-input
v-model.number="item.offsetX"
v-model.number="item.x_offset"
style="width: 70%"
></el-input>
</el-form-item>
@ -129,12 +140,87 @@
prop="offsetY"
>
<el-input
v-model.number="item.offsetY"
v-model.number="item.y_offset"
style="width: 70%"
></el-input>
</el-form-item>
<el-form-item label="实际坐标">
<span>x: {{perW * item.coorX + item.offsetX}},y: {{perH * item.coorY + item.offsetY}}</span>
<span>x: {{perW * item.x + item.x_offset}},y: {{perH * item.y + item.y_offset}}</span>
</el-form-item>
<el-form-item
label="广告位标题"
prop="ld_property.show_name"
>
<el-input
v-model="item.ld_property.show_name"
style="width: 70%"
placeholder="大家都在玩的爆款游戏"
></el-input>
</el-form-item>
<el-form-item
label="位置底图"
prop="ld_property.bg_img"
class="uploader-box"
>
<el-upload
class="uploader"
action="/api/common/upload"
:show-file-list="false"
:on-success="
(res, file, fileList) => {
return uploadSuccess(
res,
file,
fileList,
index
)
}
"
:on-error="uploadErr"
:headers="{
authorization: 'Bearer ' + token
}"
name="image-file"
:data="{ sub_path: '/ad_bg/', file_type: 'ad_bg' }"
>
<img
v-if="item.ld_property.bg_img"
:src="item.ld_property.bg_img"
class="uploader-img"
/>
<i
v-else
class="el-icon-plus uploader-icon"
/>
</el-upload>
</el-form-item>
<el-form-item
label="是否抖动"
prop="ld_property.is_shake"
>
<el-switch v-model="item.ld_property.is_shake"></el-switch>
</el-form-item>
<el-form-item
label="是否有红点"
prop="ld_property.has_dot"
>
<el-switch v-model="item.ld_property.has_dot"></el-switch>
</el-form-item>
<el-form-item
label="关闭时隐藏"
prop="ld_property.is_hide"
>
<el-switch v-model="item.ld_property.is_hide"></el-switch>
</el-form-item>
<el-form-item
label="播放状态"
prop="ld_property.status"
>
<el-radio-group v-model="item.ld_property.status">
<el-radio :label="0">正常</el-radio>
<el-radio :label="1">退出时播放</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item v-if="platform_id">
<el-button
@ -192,6 +278,7 @@ import getPageTitle from '@/utils/get-page-title'
import Coordinate from '@/components/Coordinate'
import Placeholder from '@/components/Placeholder'
import {reject, Promise} from 'q'
import {getToken} from '@/utils/auth'
export default {
name: 'GameDetailsAdPos',
@ -199,6 +286,7 @@ export default {
return {
// common
uid: '',
token: '',
type: 'normal',
platform_id: '',
platformsArr: [],
@ -217,9 +305,34 @@ export default {
value: 2,
},
{
name: '浮窗',
name: '抽屉-A',
value: 0,
},
{
name: '抽屉-B',
value: 3,
},
{
name: '弹窗-A',
value: 4,
},
{
name: '弹窗-B',
value: 5,
},
{
name: '浮层-A',
value: 6,
},
{
name: '浮层-B',
value: 7,
},
{
name: '浮层-C',
value: 8,
},
],
modeList: [
{
@ -236,6 +349,9 @@ export default {
// form
adPos: {},
adPosRules: {
'ld_property.title': [
{required: true, message: '请填写广告位名称', trigger: 'blur'},
],
area: [
{required: true, message: '请选择广告投放区域', trigger: 'blur'},
],
@ -243,7 +359,7 @@ export default {
mode: [
{required: true, message: '请选择广告播放类型', trigger: 'blur'},
],
coorX: [
x: [
{required: true, message: '请填写广告中心坐标 X', trigger: 'blur'},
{
type: 'number',
@ -253,7 +369,7 @@ export default {
trigger: 'blur',
},
],
coorY: [
y: [
{required: true, message: '请填写广告中心坐标 Y', trigger: 'blur'},
{
type: 'number',
@ -263,7 +379,7 @@ export default {
trigger: 'blur',
},
],
offsetX: [
x_offset: [
{
type: 'number',
@ -271,7 +387,7 @@ export default {
trigger: 'blur',
},
],
offsetY: [
y_offset: [
{
type: 'number',
message: '偏移量必须是数值',
@ -284,10 +400,19 @@ export default {
area: '',
type: '',
mode: '',
coorX: 0,
coorY: 0,
offsetX: 0,
offsetY: 0,
x: 0,
y: 0,
x_offset: 0,
y_offset: 0,
ld_property: {
title: '',
show_name: '',
bg_img: '',
has_dot: false,
is_shake: false,
is_hide: true,
status: 0,
},
},
allPos: [],
posNumList: [],
@ -303,6 +428,7 @@ export default {
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`) ||
@ -349,26 +475,28 @@ export default {
.then(res => {
const data = res.data
if (data.errcode === 0) {
this.allPos = data.message.map(item => {
const posArr = item.area.split(',')
return {
area: posArr[0],
channelid: item.channelid,
gameid: item.gameid,
id: item.id,
mode: item.mode,
type: item.type,
coorX: parseInt(posArr[1]),
coorY: parseInt(posArr[2]),
offsetX: parseInt(posArr[3]) || 0,
offsetY: parseInt(posArr[4]) || 0,
}
})
this.posNumList = this.allPos.map(item => {
return `${item.area}${item.type}${item.mode}${item.coorX}${
item.coorY
}`
this.allPos = data.message || []
this.allPos.map(item => {
item.area = JSON.parse(item.area)
item.ld_property = item.ld_property
? JSON.parse(item.ld_property)
: {
title: '',
show_name: '',
bg_img: '',
has_dot: false,
is_shake: false,
is_hide: true,
status: 0,
}
})
// TODO:
// this.posNumList = this.allPos.map(item => {
// return `${item.area}${item.type}${item.mode}${item.coorX}${
// item.coorY
// }`
// })
}
})
.catch(err => {
@ -394,6 +522,12 @@ export default {
changePlatform() {
this.getAdPosList()
},
uploadSuccess(res, file, fileList, index) {
this.allPos[index].ld_property.bg_img = res.url
},
uploadErr() {
this.$message.error('图片上传失败!')
},
addPos() {
const defaultPos = JSON.parse(JSON.stringify(this.defaultPos))
this.activeNames.push(this.allPos.length)
@ -428,30 +562,25 @@ export default {
async savePos(index) {
const valid = await this.validForm(`adPos${index}`)
if (valid) {
// TODO: form 广
const posInfo = JSON.parse(JSON.stringify(this.allPos[index]))
const adNum = `${posInfo.area}${posInfo.type}${posInfo.mode}${
posInfo.coorX
}${posInfo.coorY}`
posInfo.area = `${posInfo.area},${posInfo.coorX},${posInfo.coorY},${
posInfo.offsetX
},${posInfo.offsetY}`
delete posInfo.coorX
delete posInfo.coorY
delete posInfo.offsetX
delete posInfo.offsetY
if (this.allPos[index].id) {
//
const self = this
modifyAdPos({
uid: this.uid,
area: posInfo.area,
type: posInfo.type,
mode: posInfo.mode,
id: posInfo.id,
status: posInfo.status,
area: JSON.stringify(posInfo.area),
gameid: parseInt(this.gameInfo.game_id),
channelid: parseInt(this.platform_id),
id: parseInt(posInfo.id),
ld_property: JSON.stringify(posInfo.ld_property),
mode: parseInt(posInfo.mode),
type: parseInt(posInfo.type),
x: parseInt(posInfo.x),
y: parseInt(posInfo.x),
x_offset: parseInt(posInfo.x_offset),
y_offset: parseInt(posInfo.y_offset),
})
.then(res => {
const data = res.data
@ -466,20 +595,26 @@ export default {
})
} else {
//
if (this.posNumList.includes(adNum)) {
this.$message.error('已存在相同广告位!')
return
}
// TODO:
// if (this.posNumList.includes(adNum)) {
// this.$message.error('广')
// return
// }
const self = this
addAdPos({
uid: this.uid,
area: posInfo.area,
type: posInfo.type,
mode: posInfo.mode,
area: JSON.stringify(posInfo.area),
gameid: parseInt(this.gameInfo.game_id),
channelid: parseInt(this.platform_id),
ld_property: JSON.stringify(posInfo.ld_property),
mode: parseInt(posInfo.mode),
type: parseInt(posInfo.type),
x: parseInt(posInfo.x),
y: parseInt(posInfo.x),
x_offset: parseInt(posInfo.x_offset),
y_offset: parseInt(posInfo.y_offset),
})
.then(res => {
const data = res.data

View File

@ -185,6 +185,13 @@
</el-select>
</el-form-item>
<el-form-item
label="价格"
prop="extraData.price"
>
<el-input v-model.number="modalForm.extraData.price" />
<span class="ipt-tip">1元话费券则填写: 1</span>
</el-form-item>
<el-form-item
label="兑换券"
prop="codes"
@ -328,6 +335,9 @@ export default {
gift_url: '',
game_id: '',
type: 0,
extraData: {
price: 0,
},
},
modalRules: {
gift_id: [{required: true, message: '请填写物品 ID', trigger: 'blur'}],
@ -402,6 +412,12 @@ export default {
.then(res => {
const {data} = res
this.tableData = data.result
this.tableData.map(item => {
item.extraData = item.extraData || {
price: 0,
}
})
console.log(this.tableData)
this.isLoaded = false
})
.catch(err => {
@ -471,6 +487,9 @@ export default {
gift_url: '',
game_id: this.gameInfo.game_id,
type: 0,
extraData: {
price: 0,
},
}
this.codesStr = ''
this.usedCodesStr = ''