广告位、仓库修改

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" icon-class="del"
@click.stop="delPos(index)" @click.stop="delPos(index)"
/> />
{{ `[${index+1}]广告位:${item.area}${item.type}${item.mode}${item.coorX}${item.coorY}`}} {{ `[${index+1}]广告位:${item.ld_property.title}`}}
</template> </template>
<el-form <el-form
:ref="`adPos${index}`" :ref="`adPos${index}`"
@ -41,6 +41,16 @@
label-width="100px" label-width="100px"
class="mgt-20 mgb-20" 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 <el-form-item
label="区域" label="区域"
prop="area" prop="area"
@ -49,6 +59,7 @@
v-model="item.area" v-model="item.area"
placeholder="请选择广告投放区域" placeholder="请选择广告投放区域"
style="width: 70%" style="width: 70%"
multiple
> >
<el-option <el-option
v-for="(area, idx) in areaList" v-for="(area, idx) in areaList"
@ -97,20 +108,20 @@
</el-form-item> </el-form-item>
<el-form-item <el-form-item
label="坐标X" label="坐标X"
prop="coorX" prop="x"
> >
<el-input <el-input
v-model.number="item.coorX" v-model.number="item.x"
style="width: 70%" style="width: 70%"
></el-input> ></el-input>
<span class="ipt-tip">广告位中心点坐标x 取值0~15</span> <span class="ipt-tip">广告位中心点坐标x 取值0~15</span>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
label="坐标Y" label="坐标Y"
prop="coorY" prop="y"
> >
<el-input <el-input
v-model.number="item.coorY" v-model.number="item.y"
style="width: 70%" style="width: 70%"
></el-input> ></el-input>
<span class="ipt-tip">广告位中心点坐标y 取值0~15</span> <span class="ipt-tip">广告位中心点坐标y 取值0~15</span>
@ -120,7 +131,7 @@
prop="offsetX" prop="offsetX"
> >
<el-input <el-input
v-model.number="item.offsetX" v-model.number="item.x_offset"
style="width: 70%" style="width: 70%"
></el-input> ></el-input>
</el-form-item> </el-form-item>
@ -129,12 +140,87 @@
prop="offsetY" prop="offsetY"
> >
<el-input <el-input
v-model.number="item.offsetY" v-model.number="item.y_offset"
style="width: 70%" style="width: 70%"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="实际坐标"> <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>
<el-form-item v-if="platform_id"> <el-form-item v-if="platform_id">
<el-button <el-button
@ -192,6 +278,7 @@ import getPageTitle from '@/utils/get-page-title'
import Coordinate from '@/components/Coordinate' import Coordinate from '@/components/Coordinate'
import Placeholder from '@/components/Placeholder' import Placeholder from '@/components/Placeholder'
import {reject, Promise} from 'q' import {reject, Promise} from 'q'
import {getToken} from '@/utils/auth'
export default { export default {
name: 'GameDetailsAdPos', name: 'GameDetailsAdPos',
@ -199,6 +286,7 @@ export default {
return { return {
// common // common
uid: '', uid: '',
token: '',
type: 'normal', type: 'normal',
platform_id: '', platform_id: '',
platformsArr: [], platformsArr: [],
@ -217,9 +305,34 @@ export default {
value: 2, value: 2,
}, },
{ {
name: '浮窗', name: '抽屉-A',
value: 0, 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: [ modeList: [
{ {
@ -236,6 +349,9 @@ export default {
// form // form
adPos: {}, adPos: {},
adPosRules: { adPosRules: {
'ld_property.title': [
{required: true, message: '请填写广告位名称', trigger: 'blur'},
],
area: [ area: [
{required: true, message: '请选择广告投放区域', trigger: 'blur'}, {required: true, message: '请选择广告投放区域', trigger: 'blur'},
], ],
@ -243,7 +359,7 @@ export default {
mode: [ mode: [
{required: true, message: '请选择广告播放类型', trigger: 'blur'}, {required: true, message: '请选择广告播放类型', trigger: 'blur'},
], ],
coorX: [ x: [
{required: true, message: '请填写广告中心坐标 X', trigger: 'blur'}, {required: true, message: '请填写广告中心坐标 X', trigger: 'blur'},
{ {
type: 'number', type: 'number',
@ -253,7 +369,7 @@ export default {
trigger: 'blur', trigger: 'blur',
}, },
], ],
coorY: [ y: [
{required: true, message: '请填写广告中心坐标 Y', trigger: 'blur'}, {required: true, message: '请填写广告中心坐标 Y', trigger: 'blur'},
{ {
type: 'number', type: 'number',
@ -263,7 +379,7 @@ export default {
trigger: 'blur', trigger: 'blur',
}, },
], ],
offsetX: [ x_offset: [
{ {
type: 'number', type: 'number',
@ -271,7 +387,7 @@ export default {
trigger: 'blur', trigger: 'blur',
}, },
], ],
offsetY: [ y_offset: [
{ {
type: 'number', type: 'number',
message: '偏移量必须是数值', message: '偏移量必须是数值',
@ -284,10 +400,19 @@ export default {
area: '', area: '',
type: '', type: '',
mode: '', mode: '',
coorX: 0, x: 0,
coorY: 0, y: 0,
offsetX: 0, x_offset: 0,
offsetY: 0, y_offset: 0,
ld_property: {
title: '',
show_name: '',
bg_img: '',
has_dot: false,
is_shake: false,
is_hide: true,
status: 0,
},
}, },
allPos: [], allPos: [],
posNumList: [], posNumList: [],
@ -303,6 +428,7 @@ export default {
mounted() { mounted() {
this.uid = this.$route.params.uid this.uid = this.$route.params.uid
this.type = this.$route.query.type ? this.$route.query.type : 'normal' this.type = this.$route.query.type ? this.$route.query.type : 'normal'
this.token = getToken()
this.permEdit = this.permEdit =
this.userInfo.permissions.includes(`${this.uid}-edit`) || this.userInfo.permissions.includes(`${this.uid}-edit`) ||
this.userInfo.permissions.includes(`${this.uid}-publish`) || this.userInfo.permissions.includes(`${this.uid}-publish`) ||
@ -349,26 +475,28 @@ export default {
.then(res => { .then(res => {
const data = res.data const data = res.data
if (data.errcode === 0) { if (data.errcode === 0) {
this.allPos = data.message.map(item => { this.allPos = data.message || []
const posArr = item.area.split(',') this.allPos.map(item => {
return { item.area = JSON.parse(item.area)
area: posArr[0], item.ld_property = item.ld_property
channelid: item.channelid, ? JSON.parse(item.ld_property)
gameid: item.gameid, : {
id: item.id, title: '',
mode: item.mode, show_name: '',
type: item.type, bg_img: '',
coorX: parseInt(posArr[1]), has_dot: false,
coorY: parseInt(posArr[2]), is_shake: false,
offsetX: parseInt(posArr[3]) || 0, is_hide: true,
offsetY: parseInt(posArr[4]) || 0, status: 0,
} }
})
this.posNumList = this.allPos.map(item => {
return `${item.area}${item.type}${item.mode}${item.coorX}${
item.coorY
}`
}) })
// TODO:
// this.posNumList = this.allPos.map(item => {
// return `${item.area}${item.type}${item.mode}${item.coorX}${
// item.coorY
// }`
// })
} }
}) })
.catch(err => { .catch(err => {
@ -394,6 +522,12 @@ export default {
changePlatform() { changePlatform() {
this.getAdPosList() this.getAdPosList()
}, },
uploadSuccess(res, file, fileList, index) {
this.allPos[index].ld_property.bg_img = res.url
},
uploadErr() {
this.$message.error('图片上传失败!')
},
addPos() { addPos() {
const defaultPos = JSON.parse(JSON.stringify(this.defaultPos)) const defaultPos = JSON.parse(JSON.stringify(this.defaultPos))
this.activeNames.push(this.allPos.length) this.activeNames.push(this.allPos.length)
@ -428,30 +562,25 @@ export default {
async savePos(index) { async savePos(index) {
const valid = await this.validForm(`adPos${index}`) const valid = await this.validForm(`adPos${index}`)
if (valid) { if (valid) {
// TODO: form 广
const posInfo = JSON.parse(JSON.stringify(this.allPos[index])) 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) { if (this.allPos[index].id) {
// //
const self = this const self = this
modifyAdPos({ modifyAdPos({
uid: this.uid, uid: this.uid,
area: posInfo.area, area: JSON.stringify(posInfo.area),
type: posInfo.type,
mode: posInfo.mode,
id: posInfo.id,
status: posInfo.status,
gameid: parseInt(this.gameInfo.game_id), gameid: parseInt(this.gameInfo.game_id),
channelid: parseInt(this.platform_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 => { .then(res => {
const data = res.data const data = res.data
@ -466,20 +595,26 @@ export default {
}) })
} else { } else {
// //
if (this.posNumList.includes(adNum)) { // TODO:
this.$message.error('已存在相同广告位!') // if (this.posNumList.includes(adNum)) {
return // this.$message.error('广')
} // return
// }
const self = this const self = this
addAdPos({ addAdPos({
uid: this.uid, uid: this.uid,
area: posInfo.area, area: JSON.stringify(posInfo.area),
type: posInfo.type,
mode: posInfo.mode,
gameid: parseInt(this.gameInfo.game_id), gameid: parseInt(this.gameInfo.game_id),
channelid: parseInt(this.platform_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 => { .then(res => {
const data = res.data const data = res.data

View File

@ -185,6 +185,13 @@
</el-select> </el-select>
</el-form-item> </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 <el-form-item
label="兑换券" label="兑换券"
prop="codes" prop="codes"
@ -328,6 +335,9 @@ export default {
gift_url: '', gift_url: '',
game_id: '', game_id: '',
type: 0, type: 0,
extraData: {
price: 0,
},
}, },
modalRules: { modalRules: {
gift_id: [{required: true, message: '请填写物品 ID', trigger: 'blur'}], gift_id: [{required: true, message: '请填写物品 ID', trigger: 'blur'}],
@ -402,6 +412,12 @@ export default {
.then(res => { .then(res => {
const {data} = res const {data} = res
this.tableData = data.result this.tableData = data.result
this.tableData.map(item => {
item.extraData = item.extraData || {
price: 0,
}
})
console.log(this.tableData)
this.isLoaded = false this.isLoaded = false
}) })
.catch(err => { .catch(err => {
@ -471,6 +487,9 @@ export default {
gift_url: '', gift_url: '',
game_id: this.gameInfo.game_id, game_id: this.gameInfo.game_id,
type: 0, type: 0,
extraData: {
price: 0,
},
} }
this.codesStr = '' this.codesStr = ''
this.usedCodesStr = '' this.usedCodesStr = ''