Commit 43b6a05d by chenxin

update: 所有的游戏配置增加分享和参与门槛,并且将分享和参与门槛组件提取出来

parent 078e913d
<template>
<section class="dm-form__wrap">
<!-- TODO: 1接口没有这个参数 -->
<h3 class="dm-title__label">分享设置</h3>
<el-form-item label="分享到朋友圈" class="width50 is-required">
<el-radio-group v-model="shareGroup">
<el-form-item label="分享设置" class="width50 is-required">
<el-radio-group v-model="form.shareFlag">
<el-radio :label="1">可分享</el-radio>
<el-radio :label="2">不可分享</el-radio>
<el-radio :label="0">不可分享</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="分享给朋友" class="width50 is-required">
<el-radio-group v-model="shareFriend">
<el-radio :label="1">可分享</el-radio>
<el-radio :label="2">不可分享</el-radio>
</el-radio-group>
<el-form-item v-if="form.shareFlag === 1" label="分享图" prop="shareImg.imgUrl" class="width50" :rules="{ required: true, message: '请上传分享图片', trigger: 'blur' }">
<dm-upload-avatar :model.sync="form.shareImg" fileType="fileShare" label="上传图片" tips="图片建议尺寸:高度200px*200px" :disabled="isInfo"></dm-upload-avatar>
</el-form-item>
<el-form-item label="分享图" class="width50 is-required">
<dm-upload-avatar :model.sync="shareImg" fileType="fileShare" label="上传图片" tips="图片建议尺寸:高度200px*200px" :disabled="isInfo"></dm-upload-avatar>
<el-form-item v-if="form.shareFlag === 1" label="分享标题" prop="shareTitle" class="width50" :rules="{ required: true, message: '标题不能为空', trigger: 'blur' }">
<dm-input v-model="form.shareTitle" class="w400" placeholder="请输入分享标题" :disabled="isInfo" :maxlength="20"></dm-input>
</el-form-item>
<el-form-item label="分享标题" prop="shareTitle" class="width50">
<dm-input v-model="shareTitle" class="w400" placeholder="请输入分享标题" :disabled="isInfo" :maxlength="20"></dm-input>
</el-form-item>
<el-form-item label="分享描述" prop="shareTextInfo" class="width50">
<dm-input type="textarea" class="w400" :rows="4" v-model="shareTextInfo" placeholder="请输入分享描述" :disabled="isInfo" :maxlength="50"></dm-input>
<el-form-item v-if="form.shareFlag === 1" label="分享描述" prop="shareTextInfo" class="width50" :rules="{ required: true, message: '描述不能为空', trigger: 'blur' }">
<dm-input type="textarea" class="w400" :rows="4" v-model="form.shareTextInfo" placeholder="请输入分享描述" :disabled="isInfo" :maxlength="50"></dm-input>
</el-form-item>
</section>
</template>
<script>
import dmUploadAvatar from '@/components/upload/avatar';
export default {
props: {
shareGroup: {
type: Number,
default: 1
},
shareFriend: {
type: Number,
default: 1
},
shareImg: {
form: {
type: Object,
default() {
return {
imgUrl: '',
code: ''
shareFlag: 1,
shareTitle: '',
shareTextInfo: '',
shareImg: {
code: '',
imgUrl: require("./img/default-share.png"), // eslint-disable-line
wxImg: ''
}
};
}
},
shareTitle: {
type: String,
default: ''
},
shareTextInfo: {
type: String,
default: ''
ruleShareChange: {
type: Function
},
isInfo: {
type: Boolean,
......@@ -59,10 +48,15 @@ export default {
}
},
watch: {
childData: {
handler(val) {},
deep: true
}
// childData: {
// handler(val) {
// console.log(val);
// },
// deep: true
// }
},
components: {
dmUploadAvatar
}
};
</script>
......@@ -168,18 +168,10 @@
</div>
</el-form-item>
</section>
<section class="dm-form__wrap">
<h3 class="dm-title__label">分享设置</h3>
<el-form-item label="分享图片" class="width50">
<dm-upload-avatar :model.sync="form.shareImg" label="上传图片" tips="图片建议尺寸:高度200*200"></dm-upload-avatar>
</el-form-item>
<el-form-item label="分享标题" prop="shareTitle" class="width50">
<dm-input class="w400" v-model="form.shareTitle" :maxlength="20"></dm-input>
</el-form-item>
<el-form-item label="分享描述" prop="shareTextInfo" class="width50">
<dm-input class="w400" type="textarea" :rows="4" v-model="form.shareTextInfo" :maxlength="50"></dm-input>
</el-form-item>
</section>
<!-- 分享设置 -->
<dm-share :form="form"></dm-share>
<!-- 参与门槛 -->
<dm-threshold :form="form" :isAdd="isAdd" :thresholdData="thresholdData" ref="threshold"></dm-threshold>
<div class="btn-wrap_fixed" :class="{ on: asideShow }">
<el-button type="primary" @click="klflSave('form')" v-if="!isInfo">保 存</el-button>
<el-button @click="$router.go(-1)">返 回</el-button>
......@@ -202,6 +194,8 @@ import codeDialog from './codeDialog';
import editAlertMixin from '../common/editAlertMixin.js';
import axios from 'axios';
import config from '@/config';
import dmShare from '../common/share.vue';
import dmThreshold from '../common/threshold.vue';
let result = {};
export default {
mixins: [editAlertMixin],
......@@ -211,6 +205,15 @@ export default {
loading: false,
tableLoading: false,
prizeLoading: false,
// 参与门槛组件传递的数据
thresholdData: {
searchParams: '', // 会员筛选
hasSearchData: '', // 反显数据保存
getSaveData: '', // 会员筛选回显保存的数据
useId: '', // 会员筛选filter
memberGroupIds: '', // 会员分组
defaltSelected: [] // 会员分组默认穿梭窗已选入数据
},
form: {
gameActivityId: this.$route.params.id,
gameName: '',
......@@ -224,14 +227,6 @@ export default {
},
dateTime: [],
gameIntroduction: '',
//分享
shareTitle: '',
shareTextInfo: '',
shareImg: {
code: '',
imgUrl: '',
wxImg: ''
},
codeType: 1,
singleCode: '',
gameActivityCustomId: '',
......@@ -239,7 +234,25 @@ export default {
winRecordTitleFontColor: '', // 15.中奖记录文案色
tipFontColor: '', // 9.口令提示文案色
errorTipType: 1, // 16.报错提示色 黑底白字: 1; 红底白字: 2
tipUrl: ''
tipUrl: '',
// 分享
shareFlag: 1,
GameShareSettingId: '',
shareTitle: '大转盘中大奖',
shareTextInfo: '玩游戏,赢大奖~',
shareImg: {
code: '',
imgUrl: require("../common/img/default-share.png"), // eslint-disable-line
wxImg: ''
},
// 参与门槛
memberType: 0,
gameActivityAttendConditionId: '',
tipTitle: '尚未满足游戏参与条件,请多多努力。',
tipsImg: {
imgUrl: require('../common/img/default-attention.png'), // eslint-disable-line
code: ''
}
},
rules: {
gameName: { type: 'string', required: true, message: '游戏标题不能为空', trigger: 'blur' },
......@@ -288,7 +301,9 @@ export default {
dmUploadAvatar,
strategy,
calculate,
codeDialog
codeDialog,
dmShare,
dmThreshold
},
computed: {
asideShow() {
......@@ -478,14 +493,52 @@ export default {
this.form.gameName = result.game && result.game.gameName;
this.form.dateTime = result.game && [result.game.gameStartTime || '', result.game.gameEndTime || ''];
this.form.gameIntroduction = result.game && result.game.gameIntroduction;
//分享
this.form.shareTitle = result.game && result.game.shareTitle;
this.form.shareTextInfo = result.game && result.game.shareTextInfo;
this.form.shareImg = result.game && {
code: result.game.shareImgFieldCode,
imgUrl: result.game.shareImgUrl,
wxImg: result.game.shareImgUrlWX
};
this.form.shareFlag = result.game.shareFlag || 0;
// 分享
if (result.game.shareFlag === 1) {
const { shareTitle, shareTextInfo, shareImgFieldCode, shareImgUrl, shareImgUrlWX, gameShareSettingId } = result.game;
this.form = Object.assign(this.form, {
shareTitle,
shareTextInfo,
gameShareSettingId,
shareImg: {
code: shareImgFieldCode,
imgUrl: shareImgUrl,
wxImg: shareImgUrlWX
}
});
}
// 参与门槛
if (result.game.attendCondition) {
const { memberType, tipTitle, tipImageFieldCode, tipImageUrl, searchParams, gameActivityAttendConditionId } = result.game.attendCondition;
this.form = Object.assign(this.form, {
memberType,
tipTitle,
tipsImg: {
code: tipImageFieldCode,
imgUrl: tipImageUrl,
wxImg: ''
},
gameActivityAttendConditionId
});
if (memberType === 1) {
// 会员分组
this.thresholdData.searchParams = searchParams;
this.thresholdData.hasSearchData = searchParams;
this.thresholdData.getSaveData = searchParams || ''; // searchJson
if (res.result.searchId) {
this.thresholdData.useId = res.result.searchId || '';
this.thresholdData.hasSearchData = searchParams || '{}';
}
} else if (memberType === 2) {
// 会员筛选
this.thresholdData.defaltSelected = res.result.tagGroupList || [];
this.thresholdData.memberGroupIds = searchParams;
}
}
this.form.backgroudImg = {
imgUrl: result.game.backgroudImgUrl,
code: result.game.backgroudImgFieldCode
......@@ -524,10 +577,18 @@ export default {
},
//提交保存
async klflSave(formName) {
if (this.form.dateTime[0] < Date.now() && this.isAdd) {
this.$tips({ type: 'warning', message: `开始时间不能小于当前时间` });
if (this.form.memberType === 1 && !this.thresholdData.getSaveData) {
this.$tips({ type: 'warning', message: '会员筛选不能为空' });
return;
}
if (this.form.memberType === 2 && !this.thresholdData.memberGroupIds) {
this.$tips({ type: 'warning', message: '会员分组不能为空' });
return;
}
// if (this.form.dateTime[0] < Date.now() && this.isAdd) {
// this.$tips({ type: 'warning', message: `开始时间不能小于当前时间` });
// return;
// }
// 编辑弹窗提示
if (await this.editAlert()) return;
this.$refs[formName].validate(valid => {
......@@ -558,8 +619,39 @@ export default {
errorTipType: this.form.errorTipType,
gameActivityCustomId: this.form.gameActivityCustomId // get-game-klfl-edit编辑回显的 游戏自定义配置表主键ID
},
tempActivityId: this.isAdd ? this.form.gameActivityId : '' // 与上面新建不同, 这个没
tempActivityId: this.isAdd ? this.form.gameActivityId : '', // 与上面新建不同, 这个没
shareFlag: this.form.shareFlag || 0
};
// 游戏分享
let shareSetting = {};
if (this.form.shareFlag) {
const { shareTitle, shareTextInfo, shareImg, GameShareSettingId } = this.form;
shareSetting = {
shareTitle,
shareTextInfo,
shareImgUrl: shareImg.imgUrl,
shareImgFieldCode: shareImg.code,
shareImgUrlWX: shareImg.wxImg
};
if (this.isEdit) {
shareSetting.GameShareSettingId = GameShareSettingId;
}
}
// attendCondition 参与门槛
const { memberType, tipTitle, tipsImg } = this.form;
let attendCondition = {
memberType: memberType || 0,
searchJson: memberType === 1 ? this.thresholdData.getSaveData : '',
searchParams: memberType === 1 ? this.thresholdData.searchParams : this.thresholdData.memberGroupIds,
tipTitle: tipTitle,
tipImageUrl: tipsImg.imgUrl || '',
tipImageFieldCode: tipsImg.code || ''
};
if (this.isEdit) {
attendCondition.gameActivityAttendConditionId = this.form.gameActivityAttendConditionId;
}
let gameCodePrizeList = [];
this.prizeList.map((v, i) => {
if (v.prizeReferType == 1) {
......@@ -606,7 +698,13 @@ export default {
}
});
params.gameCodePrizeList = gameCodePrizeList;
klflSave({ reqData: JSON.stringify(params) }).then(res => {
const postParam = {
reqData: JSON.stringify(params),
attendCondition: JSON.stringify(attendCondition),
shareSetting: JSON.stringify(shareSetting)
};
klflSave(postParam).then(res => {
if (res.errorCode === 0) {
this.$tips({ type: 'success', message: this.isAdd ? '新增成功' : '编辑成功' });
if (this.isAdd) {
......
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