Commit d2b60e3e by crushh

Merge branch 'feature/游戏营销' into dev

parents c2ce1874 2cfa7f67
......@@ -158,7 +158,7 @@ export const getCouponStock = params => requests(PREFIX + 'get-coupon-stock', pa
export const getGameDataUpdatetime = params => requests(PREFIX + 'get-game-data-updatetime', params);
//游戏营销--拆盲盒游戏分页列表
export const cmhPage = params => requests(PREFIX + '/game-pro/page', params, true, false, 'post');
export const cmhPage = params => requests(PREFIX + '/game-pro/page', params, true);
//游戏营销--拆盲盒游戏统计数据
export const cmhStatistics = params => requests(PREFIX + '/game-pro/page-statistics', params);
......@@ -176,4 +176,4 @@ export const getGameTemplateByType = params => requests(PREFIX + '/game-pro/get-
export const generateMiniProgramLink = params => requests('api-admin/get-page-link-game', params);
//卡券回显 key 卡券ID ; value 卡券状态 0正常 1删除 2失效
export const cardView = params => requests(PREFIX + '/game-pro/card-view', params);
export const cardView = params => requests(PREFIX + '/game-pro/card-view', params, true);
......@@ -3,13 +3,13 @@
<dm-sub-title type="line">基本信息</dm-sub-title>
<div class="mt20">
<el-form-item label="游戏名称" prop="gameName"> <el-input maxlength="10" class="w382" @change="handleNameChange" v-model.trim="baseForm.gameName" show-word-limit :disabled="isDisabled" placeholder="请输入游戏名称" /> </el-form-item>
<el-form-item label="游戏时间" prop="gameTime"><el-date-picker class="w382" v-model="baseForm.gameTime" :picker-options="pickerOptions" value-format="yyyy-MM-dd" @change="refresh" type="daterange" range-separator="~" start-placeholder="开始日期" end-placeholder="结束日期"> </el-date-picker></el-form-item>
<el-form-item label="游戏说明" prop="gameRule"> <el-input maxlength="500" class="w382" v-model.trim="baseForm.gameRule" show-word-limit :disabled="isDisabled" :autosize="{ minRows: 4 }" type="textarea" /> </el-form-item>
<el-form-item label="游戏时间" prop="gameTime"><el-date-picker class="w382" v-model="baseForm.gameTime" :disabled="isDisabled" :picker-options="pickerOptions" value-format="timestamp" @change="refresh" type="daterange" range-separator="~" start-placeholder="开始日期" end-placeholder="结束日期"> </el-date-picker></el-form-item>
<el-form-item label="游戏说明" prop="gameRule"> <el-input maxlength="500" class="w382" v-model.trim="baseForm.gameRule" show-word-limit :autosize="{ minRows: 4 }" type="textarea" /> </el-form-item>
</div>
<dm-sub-title type="line">展示信息配置</dm-sub-title>
<div class="mt20">
<el-form-item label="游戏模板" prop="templateId">
<el-radio-group @change="handleTemplateChange" v-model="baseForm.templateId">
<el-radio-group @change="handleTemplateChange" v-model="baseForm.templateId" :disabled="isDisabled">
<el-radio v-for="item in templateData" :label="item.templateId" :key="item.templateId">{{ item.templateName }}</el-radio>
</el-radio-group>
</el-form-item>
......@@ -133,7 +133,7 @@ export default {
isPlay: false,
backMusicOptions: [],
customMusicOptions: [],
isDisabled: false,
templateData: [],
api: config.api,
prizeStyleJson: [], // 抽奖样式
......@@ -156,6 +156,7 @@ export default {
};
},
props: {
gameStatus: 0,
templateArr: {
type: Array,
default: () => []
......@@ -178,11 +179,13 @@ export default {
} else {
return this.backMusicOptions;
}
},
isDisabled() {
return this.gameStatus == 1;
}
},
watch: {
templateArr(val) {
console.log(val);
this.templateData = val;
const data = val[0];
......@@ -194,34 +197,31 @@ export default {
},
echoData(val) {
console.log(val);
if (Object.keys(val).length) {
let { gameExt } = val;
this.baseForm = Object.assign(this.baseForm, val);
this.handleTemplateArr(Object.values(gameExt), true);
this.adsImageUrl = { imgUrl: this.baseForm.adsImageUrl, code: this.baseForm.adsImageUrl };
console.log(this.adsImageUrl);
const currentTemp = this.templateData.filter(item => item.templateId == this.baseForm.templateId)[0];
currentTemp.gameTemplateMaterialList.forEach(item => {
if (item.materialKey == 'backMusicUrl') {
this.backMusicOptions.push(item);
}
});
console.log(this.baseForm);
this.$emit('change', this.baseForm);
}
let { gameExt } = val;
this.baseForm = Object.assign(this.baseForm, val);
this.handleTemplateArr(Object.values(gameExt), true);
this.adsImageUrl = { imgUrl: this.baseForm.adsImageUrl, code: this.baseForm.adsImageUrl };
const currentTemp = this.templateData.filter(item => item.templateId == this.baseForm.templateId)[0];
currentTemp.gameTemplateMaterialList.forEach(item => {
if (item.materialKey == 'backMusicUrl') {
this.backMusicOptions.push(item);
}
});
this.selectLink.linkData = this.baseForm.mpUrlView ? JSON.parse(this.baseForm.mpUrlView) : {};
this.$emit('change', this.baseForm);
}
},
methods: {
handleTemplateChange(val) {
console.log(val);
this.baseForm.templateId = val;
const data = this.templateArr.filter(item => item.templateId == val)[0].gameTemplateMaterialList;
this.customMusicOptions = [];
this.backMusicOptions = [];
this.handleTemplateArr(data);
this.$emit('change', this.baseForm);
},
beforeAvatarUpload(file, key, size1 = 1) {
console.log(file);
console.log(size1);
const arr = ['image/gif', 'image/jpeg', 'image/png'];
const limit = file.size / 1024 / 1024 < 2;
if (!arr.includes(file.type)) {
......@@ -247,7 +247,6 @@ export default {
this.baseForm[key] = data.result.qcloudImageUrl;
}
this.baseForm = Object.assign({}, this.baseForm);
console.log(this.baseForm);
this.$message({
type: 'success',
message: '上传成功'
......@@ -264,10 +263,8 @@ export default {
return true;
},
handleTemplateArr(data, echo) {
console.log(data);
this.gameExt = data;
data.forEach(item => {
console.log(item.materialKey);
if (item.materialSize) {
const { width, height, size } = JSON.parse(item.materialSize);
this.baseForm[item.materialKey + 'Size0'] = width + '*' + height + 'px';
......@@ -292,33 +289,11 @@ export default {
this.baseForm.backMusicUrlObj = this.backMusicOptions[0];
}
}
// if (key.indexOf('Image') > -1) {
// let obj = data.materialMap[key][0];
// this.baseForm[key] = obj.materialValue;
// if (obj.materialSize) {
// const { width, height, size } = JSON.parse(obj.materialSize);
// this.baseForm[key + 'Size0'] = width + '*' + height + 'px';
// this.baseForm[key + 'Size1'] = size;
// }
// } else {
// this.backMusicOptions = data.materialMap['backMusicUrl'];
// if (data.materialMap['backMusicUrl'] && data.materialMap['backMusicUrl'].length) {
// this.baseForm.backMusicUrlObj = data.materialMap['backMusicUrl'][0];
// }
// const prizeStyle = data.materialMap['prizeStyleJson'][0];
// this.prizeStyleJson = JSON.parse(prizeStyle.materialValue);
// this.baseForm['prizeStyleJson'] = JSON.parse(prizeStyle.materialValue);
// this.baseForm['adsLinkUrl'] = data.materialMap['adsLinkUrl'][0].materialValue;
// this.baseForm['shareCard'] = data.materialMap['shareCard'][0].materialValue;
// this.baseForm['shareReport'] = data.materialMap['shareReport'][0].materialValue;
// }
});
console.log(this.baseForm);
},
handleListen() {
this.isPlay = !this.isPlay;
console.log(this.isPlay);
this.backMusicOptions.forEach(item => {
if (item.materialValue == this.baseForm.backMusicUrlObj.materialValue) {
music.src = this.baseForm.backMusicUrlObj.materialValue;
......@@ -331,7 +306,6 @@ export default {
this.baseForm.backMusicUrlObj = this.backMusicOptions[0];
},
setAudioList(obj) {
console.log(obj);
const { name, url } = obj;
this.customMusicOptions = [
{
......@@ -344,23 +318,24 @@ export default {
this.baseForm.backMusicUrlObj = this.customMusicOptions[0];
},
handleAdsChange(obj) {
console.log(obj);
this.baseForm.adsImageUrl = obj.imgUrl;
this.$emit('change', this.baseForm);
},
replace(type, index) {
this.baseForm.prizeStyleJson[index][type] = this.prizeStyleJson[index][type];
const currentTemp = this.templateData.filter(item => item.templateId == this.baseForm.templateId)[0];
let prizeStyleJson = currentTemp.gameTemplateMaterialList.filter(item => item.materialKey == 'prizeStyleJson')[0];
prizeStyleJson = prizeStyleJson ? JSON.parse(prizeStyleJson.materialValue) : [];
this.baseForm.prizeStyleJson[index][type] = prizeStyleJson[index][type];
this.baseForm = Object.assign({}, this.baseForm);
this.$emit('change', this.baseForm);
},
// 保存链接小工具返回的链接数据
onSaveLink(linkData) {
console.log(linkData);
this.selectLink.linkData = linkData;
this.baseForm.mpUrlView = JSON.stringify(linkData);
this.baseForm.adsLinkUrl = linkData.url;
},
handleNameChange(val) {
console.log(val);
this.$emit('change', this.baseForm);
},
submit() {
......@@ -379,7 +354,6 @@ export default {
obj.backMusicUrl = data.backMusicUrlObj;
data.gameExt = obj;
data.gameExt.prizeStyleJson.materialValue = JSON.stringify(data.gameExt.prizeStyleJson.materialValue);
console.log(data);
this.$emit('nextStep', data);
} else {
this.scrollToError(this);
......
......@@ -33,9 +33,9 @@
<dm-step title="3.规则配置" @click.native="active = 2"></dm-step>
</dm-steps>
<div class="formContent">
<baseConfig :templateArr="templateData" :echoData="baseForm" v-show="active == 0" @change="handleBaseConfigChange" @nextStep="data => nextStep(1, data)" />
<prizeConfig :prizeMax="prizeMax" :prizeMin="prizeMin" v-show="active == 1" @nextStep="data => nextStep(2, data)" />
<ruleConfig :shareCard="shareCard" :shareReport="shareReport" v-show="active == 2" @nextStep="data => submit(3, data)" :btnLoading="btnLoading" />
<baseConfig :gameStatus="gameStatus" :templateArr="templateData" :echoData="baseForm" v-show="active == 0" @change="handleBaseConfigChange" @nextStep="data => nextStep(1, data)" />
<prizeConfig :gameStatus="gameStatus" :invalidCard="invalidCard" :prizeMax="prizeMax" :echoData="prizeForm" :prizeMin="prizeMin" v-show="active == 1" @nextStep="data => nextStep(2, data)" @prevStep="step => (active = step)" />
<ruleConfig :gameStatus="gameStatus" :shareCard="shareCard" :shareReport="shareReport" :echoData="ruleForm" v-show="active == 2" @nextStep="data => submit(3, data)" @prevStep="step => (active = step)" :btnLoading="btnLoading" />
</div>
</div>
</div>
......@@ -48,7 +48,7 @@ import step from '@/views/game/dm-step/step';
import baseConfig from './base-config.vue';
import prizeConfig from './prize-config.vue';
import ruleConfig from './rule-config.vue';
import { getGameTemplateByType, initActivity, getGameDetail } from '@/service/api/gameApi.js';
import { getGameTemplateByType, initActivity, getGameDetail, cardView } from '@/service/api/gameApi.js';
import gameTemplate from './gameTemplate';
export default {
data() {
......@@ -70,7 +70,12 @@ export default {
isEdit: this.$route.meta.type === 'edit',
isAdd: this.$route.meta.type === 'add',
isCopy: this.$route.meta.type === 'copy',
baseForm: {}
baseForm: {},
prizeForm: {},
ruleForm: {},
gameId: '',
gameStatus: 0,
invalidCard: {}
};
},
computed: {
......@@ -94,6 +99,7 @@ export default {
ruleConfig
},
mounted() {
console.log('form----->mounted');
this.getGameTemplateByType();
},
destroyed() {
......@@ -101,7 +107,6 @@ export default {
},
watch: {
templateId(val) {
console.log(val);
const data = this.templateData.filter(item => item.templateId == val)[0];
console.log(data);
const { prizeMax, prizeMin } = data;
......@@ -111,8 +116,7 @@ export default {
},
methods: {
getGameDetail(id) {
getGameDetail({ gameId: id }).then(res => {
console.log(res);
getGameDetail({ gameId: id }).then(async res => {
const { result } = res;
const {
gameRuleInfo, // 游戏规则信息
......@@ -128,13 +132,31 @@ export default {
gameRule,
startDate,
endDate,
gameName
gameName,
memberWeightView,
creatorId,
gameId,
status
} = result;
const { winChance, filterJson, memberDesc, memberType, playConditionFlag, playTimes, shareFlag, shareImageUrl, shareRuleDesc } = gameRuleInfo;
if (this.isEdit) {
this.gameId = gameId;
this.gameStatus = status;
}
const { winChance, filterJson, filterJsonView, memberDesc, memberType, playConditionFlag, playTimes, shareFlag, shareImageUrl, shareRuleDesc } = gameRuleInfo;
gameRuleConditionList.forEach(item => {
item.conditionJson = JSON.parse(item.conditionJson);
});
this.ruleForm = { filterJson, gameRuleConditionList, memberDesc, memberType, playConditionFlag, playTimes, shareFlag, shareImageUrl, shareRuleDesc };
let cardIdArr = [];
gamePrizeList.forEach(item => {
if (item.prizeType == 2) {
cardIdArr.push(item.prizeRelationId);
}
});
if (cardIdArr.length) {
const { result } = await cardView({ ids: cardIdArr.join(',') });
this.invalidCard = result; // 1删除 2失效
}
this.ruleForm = { filterJson, gameRuleConditionList, memberDesc, memberType, playConditionFlag, playTimes, shareFlag, shareImageUrl, shareRuleDesc, memberWeightView, creatorId, filterJsonView };
this.prizeForm = { winChance, prizeNoticeStock, gamePrizeList, prizeNoticeFlag };
this.baseForm = { adsFlag, backMusicFlag, bulletFlag, templateId, gameTime: [startDate, endDate], gameName, gameRule, gameExt };
});
......@@ -182,18 +204,39 @@ export default {
nextStep(step, data) {
this.active = step;
console.log(data);
this.submitData = { ...data, ...this.submitData };
this.submitData = { ...this.submitData, ...data };
},
submit(step, data) {
this.submitData = { ...data, ...this.submitData };
async submit(step, data) {
this.submitData = { ...this.submitData, ...data };
console.log(this.submitData);
this.submitData = JSON.parse(JSON.stringify(this.submitData));
const { winChance, filterJson, memberDesc, memberType, playConditionFlag, playTimes, shareFlag, shareImageUrl, gameRuleConditionList, gameName, gamePrizeList, prizeNoticeStock, prizeNoticeFlag, adsFlag, bulletFlag, backMusicFlag, templateId, gameRule, gameTime, gameExt } = this.submitData;
const gameRuleInfo = { winChance, filterJson, memberDesc, memberType, playConditionFlag, playTimes, shareFlag, shareImageUrl, shareRuleDesc: gameName };
const { winChance, filterJson, filterJsonView, memberDesc, memberType, playConditionFlag, playTimes, shareFlag, shareImageUrl, gameRuleConditionList, gameName, gamePrizeList, prizeNoticeStock, prizeNoticeFlag, adsFlag, bulletFlag, backMusicFlag, templateId, gameRule, gameTime, gameExt } = this.submitData;
const gameRuleInfo = { winChance, filterJson, filterJsonView, memberDesc, memberType, playConditionFlag, playTimes, shareFlag, shareImageUrl, shareRuleDesc: gameName };
gameRuleConditionList.forEach(item => {
delete item.index;
item.conditionJson = JSON.stringify(item.conditionJson);
});
let cardIdArr = [];
gamePrizeList.forEach(item => {
if (item.prizeType == 2) {
cardIdArr.push(item.prizeRelationId);
}
});
if (cardIdArr.length) {
const { result } = await cardView({ ids: cardIdArr.join(',') });
this.invalidCard = result; // 1删除 2失效
if (Object.values(result).map(item => item.invalid != 0) && this.gameStatus == 0) {
this.$message.error('存在异常状态的卡券,请返回上一步修改卡券后再提交');
return;
}
gamePrizeList.forEach(item => {
if (item.prizeType == 2 && item.prizeStock > result[item.prizeRelationId].stock) {
this.$message.error(`${item.prizeName}奖品数量高于关联库存,请修改奖品数量`);
return;
}
});
}
let submitData = {
gameRuleInfo, // 游戏规则信息
gameRuleConditionList, // 游戏规则-参与门槛
......@@ -211,7 +254,9 @@ export default {
endDate: gameTime[1],
gameName
};
console.log(submitData);
if (this.isEdit) {
submitData.gameId = this.gameId;
}
this.btnLoading = true;
initActivity(submitData)
.then(res => {
......
......@@ -42,7 +42,7 @@
<el-option v-for="(v, i) in gameStatusOptions" :key="i" :label="v.label" :value="v.value"></el-option>
</el-select>
<el-checkbox class="vertical-middle ml0" v-if="$store.state.marketing.isShowSelf" v-model="listParams.createMe" :true-label="1" :false-label="0" label="仅看本人" border @change="refresh" />
<el-button class="fr" type="primary" @click="addGame">新建游戏</el-button>
<el-button class="fr" type="primary" @click="addGame" v-if="$getButtonLimit($buttonCode.marketingCmhAdd)" :limit-code="$buttonCode.marketingCmhAdd">新建游戏</el-button>
</div>
<el-table tooltipEffect="light" :data="tableList" style="width:100%">
<el-table-column label="游戏名称" min-width="183px" prop="gameName" show-overflow-tooltip :formatter="(row, col, val) => val || '--'"></el-table-column>
......@@ -148,7 +148,6 @@ export default {
limitCode: this.$buttonCode.marketingCmhInfo
},
visible: row => {
return true;
return this.$getButtonLimit(this.$buttonCode.marketingCmhInfo);
},
handler: row => this.$router.push('/game/cmh/info/' + row.gameId)
......@@ -159,7 +158,6 @@ export default {
limitCode: this.$buttonCode.marketingCmhEdit
},
visible: row => {
return true;
return (row.status === 1 || row.status === 0) && this.$getButtonLimit(this.$buttonCode.marketingCmhEdit);
},
handler: row => this.$router.push(`/game/cmh/edit/${row.gameId}`)
......@@ -170,7 +168,6 @@ export default {
limitCode: this.$buttonCode.marketingCmhCopy
},
visible: row => {
return true;
return this.$getButtonLimit(this.$buttonCode.marketingCmhCopy);
},
handler: row => this.$router.push('/game/cmh/copy/' + row.gameId)
......@@ -181,7 +178,6 @@ export default {
limitCode: this.$buttonCode.marketingCmhUrl
},
visible: row => {
return true;
return (row.status === 1 || row.status === 0) && this.$getButtonLimit(this.$buttonCode.marketingCmhUrl);
},
handler: row => this.setLinks(row, 6)
......@@ -192,7 +188,6 @@ export default {
limitCode: this.$buttonCode.marketingCmhStop
},
visible: row => {
return true;
return row.status === 1 && this.$getButtonLimit(this.$buttonCode.marketingCmhStop);
},
handler: row => this.stopPlan(row)
......@@ -203,7 +198,6 @@ export default {
limitCode: this.$buttonCode.marketingCmhStatistics
},
visible: row => {
return true;
return (row.status === 1 || row.status === 2 || row.status === 3) && this.$getButtonLimit(this.$buttonCode.marketingCmhStatistics);
},
handler: row => this.$router.push('/cmh/statistics/' + row.gameId)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment