1018 行
45 KiB
HTML
可执行文件
1018 行
45 KiB
HTML
可执行文件
<!DOCTYPE html>
|
||
<html>
|
||
<!--[1.4.13]-->
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||
<link rel="stylesheet" href="__PUBLIC__/vue/element-ui.css">
|
||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Retail/css/myscroll.css"/>
|
||
<link rel="stylesheet" href="__PUBLIC__/css/common-upload.css">
|
||
<title>大转盘活动编辑</title>
|
||
<style>
|
||
#app {
|
||
padding: 20px;
|
||
}
|
||
|
||
.item-inner {
|
||
display: flex;
|
||
align-items: center;
|
||
white-space: nowrap;
|
||
color: #606266;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.item-inner > span {
|
||
margin-right: 15px;
|
||
}
|
||
|
||
.item-inner .el-input-number {
|
||
margin-right: 15px;
|
||
}
|
||
|
||
#form .el-input, #form .el-textarea {
|
||
width: 330px;
|
||
}
|
||
|
||
#form .el-select .el-input {
|
||
width: 200px !important;
|
||
}
|
||
|
||
.el-input-number .el-input {
|
||
width: 130px !important;
|
||
}
|
||
|
||
.item-tips {
|
||
font-size: 12px;
|
||
color: rgb(153, 153, 153);
|
||
line-height: 20px;
|
||
}
|
||
|
||
.prize-box {
|
||
margin-left: 50px;
|
||
}
|
||
|
||
.avatar-uploader .el-upload {
|
||
border: 1px dashed #d9d9d9;
|
||
border-radius: 6px;
|
||
cursor: pointer;
|
||
position: relative;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.avatar-uploader .el-upload:hover {
|
||
border-color: #409EFF;
|
||
}
|
||
|
||
.avatar-uploader-icon {
|
||
font-size: 28px;
|
||
color: #8c939d;
|
||
width: 110px;
|
||
height: 110px;
|
||
line-height: 110px !important;
|
||
text-align: center;
|
||
}
|
||
|
||
.avatar {
|
||
width: 110px;
|
||
height: 110px;
|
||
display: block;
|
||
}
|
||
|
||
.cell {
|
||
text-align: center;
|
||
}
|
||
|
||
th {
|
||
padding: 5px !important;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<include file="./Application/Admin/View/Upload/index.html"/>
|
||
<div id="app" v-cloak>
|
||
<el-form id="form" label-width="120px">
|
||
<el-divider content-position="left">活动类型</el-divider>
|
||
<el-form-item label="选择类型">
|
||
<el-radio-group v-model="radio" @change='turntable_type'>
|
||
<el-radio :label="1" name='turntable_type'>公众号通知栏</el-radio>
|
||
<el-radio :label="2" name='turntable_type'>小程序商城</el-radio>
|
||
<el-radio :label="3" name='turntable_type'>线上支付</el-radio>
|
||
<el-radio :label="4" name='turntable_type'>线下支付</el-radio>
|
||
<el-radio :label="5" name='turntable_type'>任务</el-radio>
|
||
</el-radio-group>
|
||
</el-form-item>
|
||
|
||
<!-- 活动设置 start -->
|
||
<el-divider content-position="left">活动设置</el-divider>
|
||
<el-form-item label="活动名称">
|
||
<el-input type="text"
|
||
size="small"
|
||
placeholder="请输入活动名称"
|
||
v-model="active_name"
|
||
name='turntable_name'
|
||
maxlength="20" clearable
|
||
></el-input>
|
||
</el-form-item>
|
||
<el-form-item label="活动规则">
|
||
<el-input type="textarea"
|
||
placeholder="请输入活动规则"
|
||
v-model="active_rules"
|
||
name='strategy'
|
||
maxlength="200"
|
||
:rows="4"
|
||
clearable
|
||
></el-input>
|
||
</el-form-item>
|
||
<el-form-item label="活动说明">
|
||
<el-input name='explain'
|
||
maxlength="200"
|
||
type="textarea"
|
||
placeholder="请输入活动说明"
|
||
:rows="4"
|
||
v-model="active_instruction"
|
||
clearable></el-input>
|
||
</el-form-item>
|
||
<el-form-item label="活动时间">
|
||
<el-date-picker v-model="active_time"
|
||
size="small"
|
||
type="daterange"
|
||
start-placeholder="开始日期"
|
||
end-placeholder="结束日期"
|
||
value-format="timestamp"
|
||
:default-time="['00:00:00', '23:59:59']">
|
||
</el-date-picker>
|
||
</el-form-item>
|
||
<template v-if="radio==2||radio==3||radio==4">
|
||
<el-form-item label="活动门店">
|
||
<el-radio-group size="small" v-model="active_store" @change='shop_limit'>
|
||
<el-radio :label="0" name='shop_limit'>不限制门店</el-radio>
|
||
<el-radio :label="1" name='shop_limit'>限制门店</el-radio>
|
||
</el-radio-group>
|
||
<el-select
|
||
v-model="chooseStoreArr"
|
||
name='shop_id'
|
||
v-show="active_store==1"
|
||
@change="chooseShop"
|
||
multiple
|
||
size="small"
|
||
collapse-tags
|
||
style="margin-left: 15px;"
|
||
placeholder="请选择">
|
||
<el-option
|
||
v-for="item in options"
|
||
:key="item.id"
|
||
:label="item.storetag"
|
||
:value="item.id">
|
||
</el-option>
|
||
</el-select>
|
||
<div class="item-tips">注意:如果选择多店参与大转盘活动,在选择奖品时,不可选择门店商品!</div>
|
||
</el-form-item>
|
||
<el-form-item label="会员等级限制">
|
||
<el-radio-group v-model="vip_level">
|
||
<el-radio :label="0" name='vip_limit'>所有等级</el-radio>
|
||
<el-radio :label="1" name='vip_limit'>指定等级</el-radio>
|
||
</el-radio-group>
|
||
<el-select v-show="vip_level==1"
|
||
v-model="level"
|
||
multiple
|
||
size="small"
|
||
name='vip_level'
|
||
collapse-tags
|
||
style="margin-left: 20px;"
|
||
placeholder="请选择">
|
||
<el-option
|
||
v-for="item in levelArr"
|
||
:key="item.id"
|
||
:label="item.cardname"
|
||
:value="item.id">
|
||
</el-option>
|
||
</el-select>
|
||
</el-form-item>
|
||
</template>
|
||
<el-form-item label="限制次数">
|
||
<div class="item-inner">
|
||
<span>每人</span>
|
||
<el-input-number name='day_num' v-model="limit_num" :step="1" step-strictly
|
||
:min="1" :max="limit_titlenum" size="small" :precision="0"></el-input-number>
|
||
<span>次/天</span>
|
||
</div>
|
||
</el-form-item>
|
||
<el-form-item label="限制总数">
|
||
<div class="item-inner">
|
||
<el-input-number name='max_num' v-model="limit_titlenum" :step="2" step-strictly
|
||
:min="1" :max="9999" size="small" :precision="0"></el-input-number>
|
||
<span>次/人</span>
|
||
</div>
|
||
</el-form-item>
|
||
<el-form-item label="消费金额" v-show="radio==3||radio==4">
|
||
<div class="item-inner">
|
||
<span>消费满</span>
|
||
<el-input-number v-model="limit_titleprice" :min="1" size="small"
|
||
name='money_limit'></el-input-number>
|
||
<span>元,参与大转盘活动</span>
|
||
</div>
|
||
</el-form-item>
|
||
<el-form-item label="任务形式" v-show="radio==5">
|
||
<el-radio v-model="Taskform" label="1" name='task_type'>
|
||
<span>每笔消费满</span>
|
||
<el-input-number v-model="spend" name='one_consume1' :min="1"
|
||
size="small"></el-input-number>
|
||
<span>元,赠送一次</span>
|
||
</el-radio>
|
||
<el-radio v-model="Taskform" label="2" name='task_type'>
|
||
<span>单月消费累计</span>
|
||
<el-input-number name='one_month_num' v-model="accumulated" :min="1"
|
||
size="small"></el-input-number>
|
||
<span>次,且单次消费金额大于等于</span>
|
||
<el-input-number name='one_consume' v-model="once_price" :min="1"
|
||
size="small"></el-input-number>
|
||
<span>元,赠送一次</span>
|
||
</el-radio>
|
||
</el-form-item>
|
||
<div class="item-tips" v-show="radio==3||radio==4||radio==5">注意:会员退款后,活动奖励无法撤销</div>
|
||
<!-- 奖品设置 start -->
|
||
<el-divider content-position="left">奖品设置</el-divider>
|
||
<el-form-item label="奖品种类">
|
||
<el-select size="small" v-model="award_species" placeholder="请选择">
|
||
<el-option
|
||
v-for="item in AwardArr"
|
||
:key="item.value"
|
||
:label="item.label"
|
||
:value="item.value">
|
||
</el-option>
|
||
</el-select>
|
||
<div class="item-tips">注意:至少选择4件奖品,最多选择8件奖品!</div>
|
||
</el-form-item>
|
||
<div class="prize-box">
|
||
<el-tabs v-model="activeName">
|
||
<template v-if="index<award_species" v-for="(award,index) in prizeArr">
|
||
<el-tab-pane :key="index" :label="'奖品'+(index+1)" :name="''+index">
|
||
<el-form-item label="奖品类型">
|
||
<el-radio-group v-model="award.type">
|
||
<el-radio :label="1">实物</el-radio>
|
||
<el-radio :label="2" :disabled="chooseshoplength">门店商品</el-radio>
|
||
<el-radio :label="3">积分</el-radio>
|
||
<el-radio :label="4">余额</el-radio>
|
||
<el-radio :label="5">谢谢惠顾</el-radio>
|
||
</el-radio-group>
|
||
</el-form-item>
|
||
<el-form-item label="奖品名称" v-show="award.type==1||award.type==2">
|
||
<el-input type="text"
|
||
size="small"
|
||
placeholder="请输入奖品名称"
|
||
v-model="award.prize_name"
|
||
maxlength="20" clearable
|
||
></el-input>
|
||
</el-form-item>
|
||
<el-form-item label="奖品图片" v-show="award.type==1">
|
||
<el-button @click="selectImage(index)" size="mini" type="primary" plain>
|
||
图库图片
|
||
</el-button>
|
||
<el-upload
|
||
:data='{key:index}'
|
||
class="avatar-uploader"
|
||
action="{:U('turntableUploads')}"
|
||
:show-file-list="false"
|
||
:on-success="handleAvatarSuccess"
|
||
accept="image/png,image/jpeg"
|
||
:before-upload="beforeAvatarUpload">
|
||
<img v-if="award.prize_img" :src="award.prize_img" class="avatar">
|
||
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
||
</el-upload>
|
||
<div class="item-tips">建议图片大小为 2M 内,只能上传jpg、png格式图片</div>
|
||
<div class="item-tips">建议图片尺寸为 110px × 110px</div>
|
||
</el-form-item>
|
||
<el-form-item label="选择奖品" v-show="award.type==2">
|
||
<el-button @click="goods_prize_index=index;showChooseGoods = true"
|
||
size="small"
|
||
type="primary"
|
||
:disabled="award.goodsData.length?true:false"
|
||
plain>选择奖品
|
||
</el-button>
|
||
<el-table v-show="award.goodsData.length" border style="width: 500px;"
|
||
v-show="award.type==2"
|
||
:data="award.goodsData">
|
||
<el-table-column prop="id" label="商品ID" width="150"></el-table-column>
|
||
<el-table-column prop="goods_name" label="商品名称" width="150"></el-table-column>
|
||
<el-table-column label="操作">
|
||
<template slot-scope="scope">
|
||
<el-button
|
||
size="mini"
|
||
type="danger"
|
||
@click="handleDelete(scope.$index, scope.row,index)">删除
|
||
</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
</el-form-item>
|
||
<el-form-item label="奖品数量" v-show="award.type==1||award.type==2">
|
||
<el-input-number v-model="award.prize_num" :min="1" :max="9999"
|
||
size="small"></el-input-number>
|
||
<div class="item-tips">单次中奖获得的奖品数量(与奖品总量无关)</div>
|
||
</el-form-item>
|
||
<el-form-item label="中奖积分" v-if="award.type==3">
|
||
<el-input-number v-model="award.prize_num" :min="1" :max="9999"
|
||
size="small"></el-input-number>
|
||
<div class="item-tips">单次中奖获得的积分</div>
|
||
</el-form-item>
|
||
<el-form-item label="中奖金额" v-if="award.type==4">
|
||
<el-input-number v-model="award.prize_num" :min="1" :max="9999"
|
||
size="small"></el-input-number>
|
||
<div class="item-tips">单次中奖获得的金额</div>
|
||
</el-form-item>
|
||
<el-form-item label="奖品总量">
|
||
<el-input-number v-model="award.prize_total" :min="1" :max="9999"
|
||
size="small"></el-input-number>
|
||
<div class="item-tips">该奖品发放的总数量</div>
|
||
</el-form-item>
|
||
<el-form-item label="奖品概率">
|
||
<div class="item-inner">
|
||
<el-input-number v-model="award.prob" :min="0.01" :step-strictly="true" :max="max_probability"
|
||
size="small" :precision="2" :step='0.01'></el-input-number>
|
||
<span>%</span>
|
||
</div>
|
||
<div class="item-tips">取值0.01~{{max_probability}}</div>
|
||
</el-form-item>
|
||
<template v-if="award.type==1">
|
||
<el-form-item label="发放方式">
|
||
<el-radio-group size="small" v-model="award.grant_type" @change='launch_way(index,award.grant_type)'>
|
||
<el-radio :label="1">商户发放</el-radio>
|
||
<el-radio :label="2" :disabled="shop_launch">门店发放</el-radio>
|
||
</el-radio-group>
|
||
</el-form-item>
|
||
<el-form-item label="配送方式">
|
||
<el-radio-group size="small" v-model="award.delivery_type">
|
||
<el-radio :label="1">配送</el-radio>
|
||
<el-radio v-show="award.grant_type==2" :label="2">自提</el-radio>
|
||
<el-radio v-show="award.grant_type==2" :label="3">配送&自提</el-radio>
|
||
</el-radio-group>
|
||
</el-form-item>
|
||
<el-form-item label="领取时间">
|
||
<el-radio-group size="small" v-model="award.receive_auth">
|
||
<el-radio :label="1">无限制</el-radio>
|
||
<el-radio :label="2">规定时间
|
||
<el-date-picker v-show="award.receive_auth==2"
|
||
style="width: 250px;margin-left: 15px;"
|
||
v-model="award.get_time"
|
||
type="daterange"
|
||
size="small"
|
||
value-format="timestamp"
|
||
start-placeholder="开始日期"
|
||
end-placeholder="结束日期"
|
||
:default-time="['00:00:00', '23:59:59']">
|
||
</el-date-picker>
|
||
</el-radio>
|
||
</el-radio-group>
|
||
</el-form-item>
|
||
</template>
|
||
</el-tab-pane>
|
||
</template>
|
||
</el-tabs>
|
||
</div>
|
||
</el-form>
|
||
<div class="center">
|
||
<el-button type="primary" size="medium" @click="save">保存</el-button>
|
||
</div>
|
||
<el-dialog title="门店商品列表" :visible.sync="showChooseGoods" :top="'10px'" width="710px">
|
||
<el-input type="text" size="small" style="width: 190px" v-model="goodsKeyword"
|
||
placeholder="名称/货号/条码"></el-input>
|
||
<el-button type="primary" plain size="small" @click="searchGoods">搜索</el-button>
|
||
<el-table style="margin-top: 10px" :data="goodsList" border>
|
||
<el-table-column prop="id" label="商品ID" width="100"></el-table-column>
|
||
<el-table-column prop="goods_name" label="商品名称" min-width="150" show-overflow-tooltip></el-table-column>
|
||
<el-table-column label="操作" width="100">
|
||
<template slot-scope="scope">
|
||
<el-button
|
||
size="mini"
|
||
@click="handleEdit(scope.row)">选择
|
||
</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<el-pagination
|
||
@size-change="handleSizeChange"
|
||
@current-change="handleCurrentChange"
|
||
:current-page="currentPage"
|
||
:page-sizes="[10]"
|
||
:page-size="100"
|
||
layout="total, sizes, prev, pager, next, jumper"
|
||
:total="currentLen">
|
||
</el-pagination>
|
||
</el-dialog>
|
||
<el-dialog title="选择图片" :visible.sync="showSelectImage" custom-class="select-image-el-dialog" :top="'10px'">
|
||
<template-select-image :can-select-num="1" @selectfile="selectFile"></template-select-image>
|
||
</el-dialog>
|
||
</div>
|
||
</body>
|
||
<script type="text/javascript" src="__PUBLIC__/jquery/js/jquery-3.2.1.min.js"></script>
|
||
<script type="text/javascript">
|
||
var app = new Vue({
|
||
el: '#app',
|
||
data: function () {
|
||
return {
|
||
activeName: '',//点击的奖品下标
|
||
showSelectImage: false,
|
||
prizeKey: '',
|
||
radio: 0, //活动类型 1:公众号 2:小程序 3:线上 4:线下 5:任务
|
||
active_name: '', //活动名称
|
||
active_rules: '', //活动规则
|
||
active_instruction: '', //活动说明
|
||
active_time: '', //活动时间
|
||
active_store: 0, //活动门店 0:无限制,1:有限制
|
||
options: [], //活动门店选项
|
||
chooseStoreArr: '', //选中活动门店
|
||
vip_level: 0, //会员等级限制 0:无限制,1:有限制
|
||
levelArr: [], //会员限制选项数组
|
||
level: '', //选中限制会员
|
||
limit_num: 1, //奖品数量
|
||
limit_titlenum: 1, //限制总量
|
||
limit_titleprice: 1, //限制总金额
|
||
spend: 1, //消费满多少元
|
||
accumulated: 1, //累计消费多少次
|
||
once_price: 1, //单次消费满多少元
|
||
getactive: true, //非会员是否参与活动
|
||
Taskform: '1', //任务形式
|
||
AwardArr: [
|
||
{value: '4', label: '4'},
|
||
{value: '6', label: '6'},
|
||
{value: '8', label: '8'},
|
||
], //奖品种类选择数组
|
||
award_species: '', //奖品种类
|
||
max_probability: 99.97, //最大中奖概率
|
||
// 奖品设置数组 一个对象一个奖品
|
||
prizeObj: {
|
||
id: '', //奖品id
|
||
type: 1, //奖品类型
|
||
prize_name: '', //奖品名称
|
||
prize_img: '', //奖品图片
|
||
|
||
goodsData: [],//已选择的商品
|
||
|
||
prize_num: 1, //奖品数量
|
||
prize_total: 1, //奖品总量
|
||
prob: 0.01,//奖品概率
|
||
|
||
grant_type: 1, //发放方式
|
||
delivery_type: 1,//配送方式
|
||
receive_auth: 1, //领取时间限制
|
||
get_time: '', //领取时间数组
|
||
receive_start: '', //领取开始时间
|
||
receive_end: '' //领取结束时间
|
||
},//奖品模板
|
||
prizeArr: [],//奖品数组
|
||
showChooseGoods: false,//是否显示选择商品弹框
|
||
goods_prize_index: 0,//选择商品的奖品下标
|
||
chooseshoplength: true,
|
||
shop_launch: true,
|
||
goodsList: [],//门店商品列表
|
||
currentLen: 0,//商品总数量
|
||
currentPage: 1,//商品页
|
||
currentLimit: 10,//每页获取数量
|
||
goodsKeyword: '',//搜索商品关键词
|
||
}
|
||
},
|
||
watch: {
|
||
//监听奖品数量变化
|
||
award_species(newNum, oldNum) {
|
||
this.max_probability = Math.round(10001 - newNum)/100;
|
||
if (this.prizeArr.length > newNum) {
|
||
this.prizeArr.slice(0, newNum - 1);
|
||
this.activeName = parseInt(this.activeName) > this.prizeArr.length - 1 ? (this.prizeArr.length - 1) : this.activeName;
|
||
} else {
|
||
var len = this.prizeArr.length;
|
||
for (var i = 0; i < newNum - len; i++) {
|
||
this.prizeArr.push(JSON.parse(JSON.stringify(this.prizeObj)));
|
||
}
|
||
}
|
||
}
|
||
},
|
||
methods: {
|
||
//选择图库里的图片
|
||
selectFile: function (item) {
|
||
this.showSelectImage = false;
|
||
if (item.length) {
|
||
this.prizeArr[this.prizeKey]['prize_img'] = item[0].path;
|
||
}
|
||
},
|
||
//图库弹窗
|
||
selectImage: function (key) {
|
||
this.prizeKey = key;
|
||
this.showSelectImage = true;
|
||
},
|
||
//发放方式切换
|
||
launch_way(index,grant_type){
|
||
if(grant_type==1){
|
||
this.prizeArr[index]['delivery_type']=1;
|
||
}
|
||
|
||
},
|
||
//切换活动类型
|
||
turntable_type(e) {
|
||
this.shop_launch = true;
|
||
this.chooseshoplength = true;
|
||
|
||
this.active_store = 0;
|
||
this.chooseStoreArr = [];
|
||
this.prizeArr.forEach(data => {
|
||
data.type = 1;
|
||
data.grant_type = 1;
|
||
data.delivery_type=1;
|
||
data.goodsData = [];
|
||
})
|
||
},
|
||
//切换门店类型
|
||
shop_limit(e) {
|
||
this.chooseStoreArr = [];
|
||
if (e == 0) {
|
||
this.shop_launch = true;
|
||
this.chooseshoplength = true;
|
||
this.prizeArr.forEach(data => {
|
||
data.type = 1;
|
||
data.grant_type = 1;
|
||
})
|
||
} else {
|
||
this.chooseshoplength = false;
|
||
this.shop_launch = false;
|
||
}
|
||
},
|
||
//删除已选的商品
|
||
handleDelete(index, row, key) {
|
||
this.prizeArr[key]['goodsData'] = [];
|
||
this.prizeArr[key]['prize_name'] = '';
|
||
this.prizeArr[key]['prize_img'] = '';
|
||
},
|
||
// 选择门店商品
|
||
handleEdit(row) {
|
||
if (!this.prizeArr[this.goods_prize_index]['goodsData'].length) {
|
||
var sure_goods = {
|
||
'id': row.id,
|
||
'goods_name': row.goods_name,
|
||
};
|
||
this.prizeArr[this.goods_prize_index]['prize_name'] = row.goods_name;
|
||
this.prizeArr[this.goods_prize_index]['prize_img'] = '';
|
||
this.prizeArr[this.goods_prize_index]['goodsData'].push(sure_goods);
|
||
this.showChooseGoods = false;
|
||
|
||
} else {
|
||
alert('只能添加一个商品');
|
||
}
|
||
|
||
},
|
||
//上传商品图片
|
||
handleAvatarSuccess(res, file) {
|
||
this.prizeArr[res.data.key]['prize_img'] = res.data.uploads.file.path;
|
||
|
||
},
|
||
//门店选择
|
||
chooseShop(e) {
|
||
if (e.length > 1) {
|
||
this.chooseshoplength = true
|
||
this.prizeArr.forEach(res => {
|
||
if (res.type == 2) {
|
||
res.type = 1
|
||
}
|
||
})
|
||
} else {
|
||
this.chooseshoplength = false
|
||
var sel_shopId = e[0];
|
||
if (sel_shopId !== undefined) {
|
||
this.shop_goods();
|
||
}
|
||
}
|
||
},
|
||
//切换每页数量
|
||
handleSizeChange(val) {
|
||
this.currentLimit = val;
|
||
this.currentPage = 1;
|
||
this.shop_goods();
|
||
},
|
||
//切换页数
|
||
handleCurrentChange(val) {
|
||
this.currentPage = val;
|
||
this.shop_goods();
|
||
},
|
||
//搜索商品
|
||
searchGoods: function () {
|
||
this.currentPage = 1;
|
||
this.shop_goods();
|
||
},
|
||
//门店商品获取
|
||
shop_goods() {
|
||
var that = this;
|
||
$.ajax({
|
||
type: 'post',
|
||
url: '{:U("Retail/Turntable/turntableGetGoods")}',
|
||
dataType: 'json',
|
||
data: {
|
||
store_id: this.chooseStoreArr[0],
|
||
page: this.currentPage,
|
||
limit: this.currentLimit,
|
||
keyword: this.goodsKeyword
|
||
},
|
||
success: (res) => {
|
||
if(res.code == 0){
|
||
that.goodsList = [];
|
||
that.goodsList = res.data.list;
|
||
that.$nextTick(function () {
|
||
that.currentLen = res.data.page_info.count;
|
||
});
|
||
}
|
||
},
|
||
error: function () {
|
||
alert("数据请求失败")
|
||
}
|
||
});
|
||
},
|
||
beforeAvatarUpload(file) {
|
||
const isJPG = jQuery.inArray(file.type, ['image/png', 'image/jpeg']) != -1 ? true : false;
|
||
const isLt2M = file.size / 1024 / 1024 < 2;
|
||
if (!isJPG) {
|
||
this.$message.error('上传商品图片只能是 JPG、PNG 格式!');
|
||
}
|
||
if (!isLt2M) {
|
||
this.$message.error('上传商品图片大小不能超过 2MB!');
|
||
}
|
||
return isJPG && isLt2M;
|
||
},
|
||
save: function () {
|
||
var that = this;
|
||
//填写值判断
|
||
if (that.active_name == '') {
|
||
that.$message({
|
||
type: 'error',
|
||
message: '活动名称不能为空',
|
||
duration: 1500
|
||
});
|
||
return false;
|
||
}
|
||
if (that.active_rules == '') {
|
||
that.$message({
|
||
type: 'error',
|
||
message: '活动规则不能为空',
|
||
duration: 1500
|
||
});
|
||
return false;
|
||
}
|
||
if (that.active_instruction == '') {
|
||
that.$message({
|
||
type: 'error',
|
||
message: '活动说明不能为空',
|
||
duration: 1500
|
||
});
|
||
return false;
|
||
}
|
||
if (!that.active_time) {
|
||
that.$message({
|
||
type: 'error',
|
||
message: '活动时间不能为空',
|
||
duration: 1500
|
||
});
|
||
return false;
|
||
}
|
||
if (that.radio == 2 || that.radio == 3 || that.radio == 4) {
|
||
//限制门店
|
||
if (that.active_store == 1 && that.chooseStoreArr == '') {
|
||
that.$message({
|
||
type: 'error',
|
||
message: '门店未选择',
|
||
duration: 1500
|
||
});
|
||
return false;
|
||
}
|
||
//限制会员等级
|
||
if (that.vip_level == 1 && that.level == '') {
|
||
that.$message({
|
||
type: 'error',
|
||
message: '会员等级未选择',
|
||
duration: 1500
|
||
});
|
||
return false;
|
||
}
|
||
}
|
||
|
||
//奖品模块
|
||
var prizeArr = that.prizeArr.slice(0, that.award_species);
|
||
var total_prol = 0;
|
||
try {
|
||
prizeArr.forEach(function(data, index){
|
||
//计算奖品总概率
|
||
total_prol+=Number(data.prob);
|
||
//奖品类型为实物
|
||
if (data.type == 1) {
|
||
if (data.prize_name == '') {
|
||
throw new Error('prize_name')
|
||
}
|
||
if (data.prize_img == '') {
|
||
throw new Error('prize_img')
|
||
}
|
||
if (data.receive_auth == 2 && !data.get_time) {
|
||
throw new Error('get_time')
|
||
}
|
||
if(data.receive_auth == 2){
|
||
data.receive_start=data.get_time[0].toString().substring(0, 10);
|
||
data.receive_end=data.get_time[1].toString().substring(0, 10);
|
||
}
|
||
}
|
||
//奖品类型为门店商品
|
||
if (data.type == 2) {
|
||
if (data.prize_name == '') {
|
||
throw new Error('prize_name')
|
||
}
|
||
if (data.goodsData == '') {
|
||
throw new Error('goodsData')
|
||
}
|
||
}
|
||
|
||
//奖品类型为积分
|
||
if (data.type == 3) {
|
||
data.prize_name=data.prize_num+'积分';
|
||
}
|
||
//奖品类型为余额
|
||
if (data.type == 4) {
|
||
data.prize_name=data.prize_num+'余额';
|
||
}
|
||
//奖品类型为谢谢惠顾
|
||
if (data.type == 5) {
|
||
data.prize_name='谢谢惠顾';
|
||
}
|
||
|
||
})
|
||
} catch (e) {
|
||
if (e.message === 'prize_name') {
|
||
that.$message({
|
||
type: 'error',
|
||
message: '奖品名称不能为空',
|
||
duration: 1500
|
||
});
|
||
return false;
|
||
}
|
||
if (e.message === 'prize_img') {
|
||
that.$message({
|
||
type: 'error',
|
||
message: '奖品图片不能为空',
|
||
duration: 1500
|
||
});
|
||
return false;
|
||
}
|
||
if (e.message === 'get_time') {
|
||
that.$message({
|
||
type: 'error',
|
||
message: '奖品领取时间不能为空',
|
||
duration: 1500
|
||
});
|
||
return false;
|
||
}
|
||
if (e.message === 'goodsData') {
|
||
that.$message({
|
||
type: 'error',
|
||
message: '奖品未选择',
|
||
duration: 1500
|
||
});
|
||
return false;
|
||
}
|
||
}
|
||
|
||
//计算奖品中将总概率==100
|
||
if (total_prol-100 <=0.01) {
|
||
|
||
} else {
|
||
that.$message({
|
||
type: 'error',
|
||
message: '奖品中奖概率和必须等于100',
|
||
duration: 1500
|
||
});
|
||
return false;
|
||
}
|
||
|
||
//整理数据
|
||
var fd = new FormData(document.getElementById('form'));
|
||
//活动状态默认1
|
||
fd.append("status", 1);
|
||
fd.append("prizeArr", JSON.stringify(prizeArr));
|
||
//活动id
|
||
fd.append("turntable_id", {$id});
|
||
//任务类型
|
||
var task_type = fd.get("task_type");
|
||
if (task_type == 1 && this.radio==5) {
|
||
var one_consume1 = fd.get("one_consume1");
|
||
fd.set("one_consume", one_consume1);
|
||
}
|
||
if(this.radio!=5){
|
||
fd.append("task_type",'');
|
||
fd.append("one_consume",'');
|
||
fd.append("one_month_num",'');
|
||
}
|
||
//活动时间(不为空)
|
||
var activity_date = that.active_time;
|
||
var start_time = activity_date[0];
|
||
var end_time = activity_date[1];
|
||
fd.append("start_time", start_time.toString().substring(0, 10));
|
||
fd.append("end_time", end_time.toString().substring(0, 10));
|
||
|
||
//会员等级、门店类型
|
||
if (that.radio == 1 || that.radio == 5) {
|
||
fd.append("shop_limit", '');
|
||
fd.append("vip_limit", '');
|
||
fd.append("shop_id", '');
|
||
fd.append("vip_level", '');
|
||
}else{
|
||
//门店选择
|
||
var store = that.chooseStoreArr;
|
||
var store_selection = store.join(',');
|
||
fd.set("shop_id", store_selection);
|
||
//会员等级选择
|
||
var level = that.level;
|
||
var level_selection = level.join(',');
|
||
fd.set("vip_level", level_selection);
|
||
}
|
||
|
||
|
||
$.ajax({
|
||
url: "{:U('updateTurntable')}",
|
||
type: 'post',
|
||
data: fd,
|
||
processData: false, // jQuery不要去处理发送的数据
|
||
contentType: false, // jQuery不要去设置Content-Type请求头
|
||
success: function (res) {
|
||
if (res.code == 0) {
|
||
that.$message({
|
||
type: 'success',
|
||
message: '活动编辑成功',
|
||
duration: 1000,
|
||
onClose: function () {
|
||
var index = parent.layer.getFrameIndex(window.name);
|
||
parent.layer.close(index);
|
||
}
|
||
});
|
||
} else {
|
||
that.$message({
|
||
type: 'error',
|
||
message: '活动编辑失败',
|
||
duration: 1500
|
||
});
|
||
}
|
||
},
|
||
error: function (error) {
|
||
console.log(error);
|
||
}
|
||
})
|
||
}
|
||
},
|
||
created: function () {
|
||
//获取门店列表
|
||
$.ajax({
|
||
type: 'post',
|
||
url: '{:U("Retail/Turntable/storeList")}',
|
||
dataType: 'json',
|
||
success: (data) => {
|
||
var result = data
|
||
this.options = result.data;
|
||
},
|
||
error: function () {
|
||
alert("数据请求失败")
|
||
}
|
||
});
|
||
//获取会员等级列表
|
||
$.ajax({
|
||
type: 'post',
|
||
url: '{:U("Retail/Turntable/turntableGetVip")}',
|
||
dataType: 'json',
|
||
success: (data) => {
|
||
var result = data
|
||
this.levelArr = result.data;
|
||
},
|
||
error: function () {
|
||
alert("数据请求失败")
|
||
}
|
||
});
|
||
//获取活动详情
|
||
var turntable_id={$id};
|
||
$.ajax({
|
||
type: 'post',
|
||
url: '{:U("Retail/Turntable/TurntableDetailInfo")}',
|
||
dataType: 'json',
|
||
data:{turntable_id:turntable_id},
|
||
success: (data) => {
|
||
var result = data.data;
|
||
//.........活动基本设置..........//
|
||
|
||
//活动类型
|
||
this.radio=parseInt(result.turntable_type);
|
||
//活动名称
|
||
this.active_name=result.turntable_name;
|
||
//活动规则
|
||
this.active_rules=result.strategy;
|
||
//活动说明
|
||
this.active_instruction=result.explain;
|
||
//活动时间
|
||
var start_time=result.start_time+'000';
|
||
var end_time=result.end_time+'000';
|
||
this.active_time=[start_time,end_time];
|
||
|
||
//活动门店是否限制
|
||
this.active_store=parseInt(result.shop_limit);
|
||
//门店选择列表
|
||
if(parseInt(result.shop_limit)==1 && this.radio!=5 && this.radio!=1){
|
||
//限制门店
|
||
this.shop_launch = false;
|
||
this.chooseStoreArr=result.shop_id.split(',');
|
||
}
|
||
if(parseInt(result.shop_limit)==1 && this.chooseStoreArr.length==1 &&this.radio!=5 && this.radio!=1){
|
||
this.chooseshoplength = false;
|
||
}
|
||
|
||
//会员等级是否限制
|
||
this.vip_level=parseInt(result.vip_limit);
|
||
//会员等级选择列表
|
||
if(parseInt(result.vip_limit)==1){
|
||
this.level=result.vip_level.split(',');
|
||
}
|
||
|
||
|
||
if(this.radio==1 || this.radio==5){
|
||
this.level='';
|
||
this.chooseStoreArr='';
|
||
this.active_store=0;
|
||
this.vip_level=0;
|
||
}
|
||
|
||
//每人每天限制次数
|
||
this.limit_num=parseInt(result.day_num);
|
||
//每人限制总数
|
||
this.limit_titlenum=parseInt(result.max_num);
|
||
|
||
|
||
//消费满多少元,参与大转盘活动
|
||
this.limit_titleprice=parseInt(result.money_limit);
|
||
//任务形式
|
||
if(result.task_type){
|
||
this.Taskform=result.task_type;
|
||
}
|
||
//每笔消费满多少元,赠送一次
|
||
this.spend=parseInt(result.one_consume);
|
||
//单月消费累计多少次
|
||
this.accumulated=parseInt(result.one_month_num);
|
||
//单次消费金额大于等于多少元,赠送一次
|
||
this.once_price=parseInt(result.one_consume);
|
||
|
||
|
||
//.........奖品设置..........//
|
||
var that=this;
|
||
that.award_species=result.prize_list.length;
|
||
var prize_list=result.prize_list;
|
||
prize_list.forEach(function(currentValue, index){
|
||
currentValue.delivery_type=parseInt(prize_list[index]['delivery_type']);
|
||
currentValue.grant_type=parseInt(prize_list[index]['grant_type']);
|
||
|
||
currentValue.prize_num=parseInt(prize_list[index]['prize_num']);
|
||
currentValue.prize_total=parseInt(prize_list[index]['prize_total']);
|
||
currentValue.prob=parseFloat(prize_list[index]['prob']);
|
||
currentValue.receive_auth=parseInt(prize_list[index]['receive_auth']);
|
||
currentValue.type=parseInt(prize_list[index]['type']);
|
||
|
||
if (parseInt(prize_list[index]['type']) == 1 && parseInt(prize_list[index]['receive_auth']) == 2) {
|
||
var receive_start=prize_list[index]['receive_start']+'000';
|
||
var receive_end=prize_list[index]['receive_end']+'000';
|
||
currentValue.get_time=[receive_start,receive_end];
|
||
}
|
||
currentValue.id=index;
|
||
|
||
currentValue.goodsData=[];
|
||
if(parseInt(prize_list[index]['type'])==2){
|
||
var goodsData = {
|
||
'id': 1,
|
||
'goods_name': prize_list[index]['prize_name'],
|
||
};
|
||
currentValue.goodsData.push(goodsData);
|
||
}
|
||
|
||
//清空商品信息
|
||
if(parseInt(prize_list[index]['type']) != 2 && parseInt(prize_list[index]['type']) != 1){
|
||
currentValue.prize_img='';
|
||
currentValue.prize_name='';
|
||
}else{
|
||
currentValue.prize_img=prize_list[index]['prize_img'];
|
||
currentValue.prize_name=prize_list[index]['prize_name'];
|
||
}
|
||
|
||
that.prizeArr.push(currentValue);
|
||
})
|
||
|
||
|
||
},
|
||
error: function () {
|
||
alert("数据请求失败")
|
||
}
|
||
});
|
||
|
||
|
||
|
||
return false;
|
||
|
||
|
||
}
|
||
|
||
|
||
})
|
||
</script>
|
||
</html> |