1155 lines
62 KiB
Vue
1155 lines
62 KiB
Vue
<template>
|
||
<section class="content">
|
||
<div class="box box-primary">
|
||
<div class="box-body">
|
||
<section class="content-header">
|
||
<h1 id="itemTitle"></h1>
|
||
</section>
|
||
<!-- .content -->
|
||
<section class="content">
|
||
<div id="table"></div>
|
||
<div id="toolbar">
|
||
名称:<input type="text" name="name" id="name" placeholder="请输入活动名称">
|
||
|
||
状态:
|
||
<select name="status" id="seachStatus" class="input-m">
|
||
<option value="">--全部--</option>
|
||
<option value="1">展示</option>
|
||
<option value="2">已删除</option>
|
||
</select>
|
||
|
||
app:
|
||
<select name="searchAppId" id="searchAppId" class="input-m">
|
||
<option value="">--全部--</option>
|
||
</select>
|
||
|
||
上架状态:
|
||
<select name="upStatus" id="upStatus" class="input-m">
|
||
<option value="">--全部--</option>
|
||
<option value="1">已上架</option>
|
||
<option value="2">待上架</option>
|
||
<option value="3">已下架</option>
|
||
</select>
|
||
|
||
<button class="btn btn-default" id="search">
|
||
<i class="glyphicon glyphicon-wrench"></i>查询
|
||
</button>
|
||
|
||
<button class="btn btn-primary" id="add">
|
||
<i class="glyphicon glyphicon-plus"></i>增加
|
||
</button>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
|
||
</div>
|
||
</section>
|
||
|
||
<!-- 弹窗 -->
|
||
<div class="modal fade" id="chargeActivityModal" rabindex='-1' role="dialog" aria-labelledby="modalLabel">
|
||
<div class="modal-dialog" role="document">
|
||
<div class="modal-content">
|
||
|
||
<div class="modal-header">
|
||
<button class="close" type="button" data-dismiss="modal" aria-label="Close">
|
||
<span aria-hidden="true">x</span>
|
||
</button>
|
||
|
||
<div class="modal-title" id="chargeActivityModalLabel">充值活动配置</div>
|
||
</div>
|
||
|
||
<div class="modal-body">
|
||
<form action="" id="addForm" class="form-horizontal">
|
||
<input type="hidden" id="module_id">
|
||
<div class="form-group">
|
||
<label for="modal_platform" class="col-sm-3 control-label">选择系统:</label>
|
||
<div class="col-sm-8">
|
||
<label><input class="validate[minCheckbox[1]]" id="platform_1" name="platform"
|
||
type="checkbox" value="1" />安卓</label>
|
||
|
||
<label><input class="validate[minCheckbox[1]]" id="platform_2" name="platform"
|
||
type="checkbox" value="2" />ios</label>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="modal_type" class="col-sm-3 control-label">入口选项:</label>
|
||
<div class="col-sm-8">
|
||
<label><input id="type_1" class="validate[minCheckbox[1]]" name="type" type="checkbox"
|
||
value="1" />首页</label>
|
||
|
||
<label><input id="type_2" class="validate[minCheckbox[1]]" name="type" type="checkbox"
|
||
value="2" />房间</label>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group" id="div_room_show" style="display: none;">
|
||
<div class="col-sm-12">
|
||
<label for="modal_roomShow" class="col-sm-3 control-label">展示房间:</label>
|
||
<div class="col-sm-8">
|
||
<label><input class="validate[required]" id="roomShow_0" name="roomShow" type="radio"
|
||
value="0" checked="true" />全平台</label>
|
||
|
||
<label><input class="validate[required]" id="roomShow_1" name="roomShow" type="radio"
|
||
value="1" />指定</label>
|
||
</div>
|
||
</div>
|
||
<div id="div_room_assign" class="col-sm-12">
|
||
<label for="" class="col-sm-3 control-label"></label>
|
||
<div class="col-sm-8">
|
||
<textarea id="module_roomRule" rows="3" cols="50"
|
||
class="form-control validate[required]"
|
||
placeholder="填写房主平台号(多个平台号请用英文逗号隔开)"></textarea>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="modal_entrancePosition" class="col-sm-3 control-label">入口位置:</label>
|
||
<div class="col-sm-8">
|
||
<select id="modal_entrancePosition" name="entrancePosition"
|
||
class="form-control validate[required]">
|
||
<option value="1">右下角</option>
|
||
<option value="2">左上角</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<div class="col-sm-12">
|
||
<label for="modal_userShow" class="col-sm-3 control-label">可见用户:</label>
|
||
<div class="col-sm-8">
|
||
<label><input class="validate[required]" id="userShow_0" name="userShow" type="radio"
|
||
value="0" />全平台</label>
|
||
|
||
<label><input class="validate[required]" id="userShow_1" name="userShow" type="radio"
|
||
value="1" />指定</label>
|
||
</div>
|
||
</div>
|
||
<div id="div_user_assign">
|
||
<div class="col-sm-12">
|
||
<label class="col-sm-8 col-sm-offset-3">
|
||
<input id="userShow_1_user" name="userShow_1_assign" type="radio"
|
||
value="user" />指定用户ID
|
||
</label>
|
||
</div>
|
||
<div class="col-sm-12">
|
||
<div class="col-sm-8 col-sm-offset-3">
|
||
<textarea id="module_userShow_assgin" rows="3" cols="50"
|
||
class="form-control validate[required]"
|
||
placeholder="指定用户耳畔号(多个用户请用英文逗号隔开)"></textarea>
|
||
</div>
|
||
</div>
|
||
<div class="col-sm-12">
|
||
<label class="col-sm-8 col-sm-offset-3">
|
||
<input id="userShow_1_condition" name="userShow_1_assign" type="radio"
|
||
value="condition" />指定条件(充值、注册)
|
||
</label>
|
||
</div>
|
||
<div class="col-sm-12">
|
||
<div class="col-sm-2 col-sm-offset-3">充值次数</div>
|
||
<div class="col-sm-6">
|
||
<span>从<input type="text" class="validate[custom[integer]] validate[required]"
|
||
id="min_charge_time" size="1">次</span>
|
||
|
||
<span>到<input type="text" class="validate[custom[integer]] validate[required]"
|
||
id="max_charge_time" size="1">次</span>
|
||
</div>
|
||
</div>
|
||
<div class="col-sm-12">
|
||
<div class="col-sm-2 col-sm-offset-3">注册时长</div>
|
||
<div class="col-sm-6">
|
||
<span>从<input type="text" class="validate[custom[integer]] validate[required]"
|
||
id="min_reg_time" size="1">天</span>
|
||
|
||
<span>到<input type="text" class="validate[custom[integer]] validate[required]"
|
||
id="max_reg_time" size="1">天</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="modal_seqNo" class="col-sm-3 control-label">轮播序号:</label>
|
||
<div class="col-sm-8">
|
||
<input type="text" class="form-control validate[required]" name="seqNo" id="modal_seqNo"
|
||
placeholder="轮播顺序">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="modal_actName" class="col-sm-3 control-label">活动名称:</label>
|
||
<div class="col-sm-8">
|
||
<input type="text" class="form-control validate[required]" name="actName" id="modal_actName"
|
||
placeholder="输入活动名称">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label class="col-sm-3 control-label">活动图标:</label>
|
||
<div class="col-sm-8">
|
||
<img src="" alt="" id="imgUrl" style="width: 50px; height: 50px;">
|
||
<input type="file" id="uploadFile" name="uploadFile" accept="*">
|
||
<button class="btn btn-success" type="button" id="uploadBtn">上传</button>
|
||
<div class="tips">
|
||
<i class="glyphicon glyphicon-info-sign"></i>
|
||
<font color="red">图片后缀名仅支持"png"、"svga"</font>
|
||
</div>
|
||
<input type="hidden" id="modal_imageType" name="imageType"
|
||
class="form-control validate[required]">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label class="col-sm-3 control-label">开始时间:</label>
|
||
<div class="col-sm-8">
|
||
<input type="text" name="startTime" id="modal_startTime"
|
||
class="form-control input-sm validate[required]" placeholder="活动开始时间">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label class="col-sm-3 control-label">结束时间:</label>
|
||
<div class="col-sm-8">
|
||
<input type="text" name="endTime" id="modal_endTime"
|
||
class="form-control input-sm validate[required]" placeholder="活动结束时间">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="modal_packName" class="col-sm-3 control-label">礼包:</label>
|
||
<div class="col-sm-8">
|
||
<select id="modal_packName" name="packName" class="form-control validate[required]">
|
||
<option value="">请选择...</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="modal_skipType" class="col-sm-3 control-label">跳转类型:</label>
|
||
<div class="col-sm-8">
|
||
<select id="modal_skipType" name="skipType" class="form-control validate[required]">
|
||
<option value="">请选择...</option>
|
||
<option value="1">房间ID</option>
|
||
<option value="2">h5链接</option>
|
||
<option value="5">充值页</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group" id="showTypeDiv" style="display:none;">
|
||
<label for="showType" class="col-sm-3 control-label">h5展示:</label>
|
||
<select name="showType" id="showType" class="col-sm-2">
|
||
<option value="1">全屏</option>
|
||
<option value="2">半屏</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="appId" class="col-sm-3 control-label">app:</label>
|
||
<select name="appId" id="appId" class="col-sm-2">
|
||
<option value="">请选择</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="modal_skipUrl" class="col-sm-3 control-label">跳转地址:</label>
|
||
<div class="col-sm-8">
|
||
<input type="text" class="form-control" name="skipUrl" id="modal_skipUrl"
|
||
placeholder="输入跳转地址">
|
||
<br />
|
||
<div class="tips">
|
||
<i class="glyphicon glyphicon-info-sign"></i>
|
||
<font color="red">请根据跳转类型,输入正确的跳转地址,否则会造成异常</font>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
|
||
<button type="button" class="btn btn-primary" data-primary="addSave" id="save">保存</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import TableHelper from '@/utils/bootstrap-table-helper';
|
||
var fileType = ['svga', 'png'];
|
||
var app = {};
|
||
var validApp = {};
|
||
|
||
export default {
|
||
name: "ChargeActivityAdminView",
|
||
setup() {
|
||
return {};
|
||
},
|
||
created() {
|
||
this.$nextTick(function () {
|
||
this.initData();
|
||
});
|
||
},
|
||
methods: {
|
||
initData() {
|
||
$(function () {
|
||
// 处理app
|
||
$.get('/admin/appName/listAll', {}, function (res) {
|
||
if (res.rows.length > 0) {
|
||
var rows = res.rows;
|
||
renderSelect1(rows);
|
||
for (var i = 0; i < rows.length; i++) {
|
||
var row = rows[i];
|
||
app[row.app] = row.appName;
|
||
// 有效的app
|
||
if (row.status == 1) {
|
||
validApp[row.app] = row.appName;
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
function renderSelect1(data) {
|
||
$('#searchAppId').empty();
|
||
$('#searchAppId').append('<option value="">--全部--</option>');
|
||
for (var i = 0; i < data.length; i++) {
|
||
$('#searchAppId').append('<option value="' + data[i].app + '">' + data[i].appName + '</option>');
|
||
}
|
||
}
|
||
|
||
var picker1 = $('#modal_startTime').datetimepicker({
|
||
format: 'yyyy-mm-dd hh:ii:00',
|
||
autoclose: true
|
||
});
|
||
var picker2 = $('#modal_endTime').datetimepicker({
|
||
format: 'yyyy-mm-dd hh:ii:00',
|
||
autoclose: true
|
||
});
|
||
picker1.on('changeDate', function () {
|
||
var date = $('#modal_startTime').datetimepicker('getDate');
|
||
picker2.datetimepicker('setStartDate', date);
|
||
});
|
||
picker2.on('changeDate', function () {
|
||
var date = $('#modal_endTime').datetimepicker('getDate');
|
||
picker1.datetimepicker('setEndDate', date);
|
||
});
|
||
|
||
$('#table').bootstrapTable('destroy');
|
||
$('#table').bootstrapTable({
|
||
columns: [
|
||
{ field: 'actId', title: '活动ID', align: 'center', valign: 'middle', width: '5%' },
|
||
{ field: 'actName', title: '活动名称', align: 'center', valign: 'middle', width: '10%' },
|
||
{
|
||
field: 'platform', title: '系统', align: 'center', valign: 'middle', width: '10%',
|
||
formatter: function (val, row, index) {
|
||
if (val == null && val == '') {
|
||
return '-';
|
||
}
|
||
var result = '';
|
||
var arrs = val.split(',');
|
||
arrs.forEach(function (item, index) {
|
||
if (null != item && item != '') {
|
||
result += formatPlatform(item) + ",";
|
||
}
|
||
});
|
||
if (result.length > 0) {
|
||
result = result.substr(0, result.length - 1);
|
||
}
|
||
return result;
|
||
}
|
||
},
|
||
{
|
||
field: 'type', title: '入口', align: 'center', valign: 'middle', width: '10%',
|
||
formatter: function (val, row, index) {
|
||
if (val == null && val == '') {
|
||
return '-';
|
||
}
|
||
var result = '';
|
||
var arrs = val.split(',');
|
||
arrs.forEach(function (item, index) {
|
||
if (null != item && item != '') {
|
||
result += formatType(item) + ",";
|
||
}
|
||
});
|
||
if (result.length > 0) {
|
||
result = result.substr(0, result.length - 1);
|
||
}
|
||
return result;
|
||
}
|
||
},
|
||
{
|
||
field: 'entrancePosition', title: '入口位置', align: 'center', valign: 'middle', width: '5%',
|
||
formatter: function (val, row, index) {
|
||
if (null == val) {
|
||
return '-';
|
||
}
|
||
if (val == 1) {
|
||
return '右下角';
|
||
}
|
||
if (val == 2) {
|
||
return '左上角';
|
||
}
|
||
return val;
|
||
}
|
||
},
|
||
{
|
||
field: 'seqNo', title: '排序序号', align: 'center', valign: 'middle', width: '5%',
|
||
formatter: function (val, row, index) {
|
||
return '<span style="color: red">' + val + '</span>';
|
||
}
|
||
},
|
||
{
|
||
field: 'alertWinPic', title: '活动图片', align: 'center', valign: 'middle', width: '10%',
|
||
formatter: function (val, row, index) {
|
||
if (null != val && val != '') {
|
||
return '<img src="' + val + '" alt="" style="width: 30px; height: 30px;">';
|
||
}
|
||
return '-';
|
||
}
|
||
},
|
||
{ field: 'packName', title: '发送礼包', align: 'center', valign: 'middle', width: '10%' },
|
||
{
|
||
field: 'roomShow', title: '展示房间', align: 'center', valign: 'middle', width: '5%',
|
||
formatter: function (val, row, index) {
|
||
if (val == 0) {
|
||
return '全平台';
|
||
} else if (val == 1) {
|
||
return '指定';
|
||
}
|
||
return val;
|
||
}
|
||
},
|
||
{
|
||
field: 'userShow', title: '可见用户', align: 'center', valign: 'middle', width: '5%',
|
||
formatter: function (val, row, index) {
|
||
if (val == 0) {
|
||
return '全平台';
|
||
} else if (val == 1) {
|
||
return '指定';
|
||
}
|
||
return val;
|
||
}
|
||
},
|
||
{
|
||
field: 'skipType', title: '跳转类型', align: 'center', valign: 'middle', width: '5%',
|
||
formatter: function (val, row, index) {
|
||
if (null == val || val == '') {
|
||
return '-';
|
||
}
|
||
if (val == 1) {
|
||
return '房间ID';
|
||
} else if (val == 2) {
|
||
return 'h5链接';
|
||
} else if (val == 5) {
|
||
return '充值页';
|
||
}
|
||
return val;
|
||
}
|
||
},
|
||
{
|
||
field: 'showType', title: '展示类型', align: 'center', valign: 'middle', width: '5%',
|
||
formatter: function (val, row, index) {
|
||
if (row.skipType == 2) {
|
||
if (null == val || val == '') {
|
||
return '-';
|
||
} else if (val == 1) {
|
||
return '全屏';
|
||
} else if (val == 2) {
|
||
return '半屏';
|
||
} else {
|
||
return val;
|
||
}
|
||
} else {
|
||
return '-';
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'appId',
|
||
title: 'app',
|
||
align: 'center',
|
||
width: '10%',
|
||
valign: 'middle',
|
||
formatter: function (val, row, index) {
|
||
var name = app[val];
|
||
if (name != null) {
|
||
return name;
|
||
}
|
||
return val;
|
||
}
|
||
},
|
||
{
|
||
field: 'skipUrl', title: '跳转地址', align: 'center', valign: 'middle', width: '5%',
|
||
formatter: function (val, row, index) {
|
||
if (null == val || val == '') {
|
||
return '-';
|
||
}
|
||
if (row.skipType == 1) {
|
||
return val.split(":")[0];
|
||
} else if (row.skipType == 2) {
|
||
return '<a target="blank" href="' + val + '">查看</a>';
|
||
}
|
||
return val;
|
||
}
|
||
},
|
||
{
|
||
field: 'startTime', title: '上架时间', align: 'center', valign: 'middle', width: '10%', formatter: function (val, row, index) {
|
||
if (val) {
|
||
var date = new Date(val);
|
||
return date.format('yyyy-MM-dd hh:mm:ss');
|
||
} else {
|
||
return '-';
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'endTime', title: '下架时间', align: 'center', valign: 'middle', width: '10%', formatter: function (val, row, index) {
|
||
if (val) {
|
||
var date = new Date(val);
|
||
return date.format('yyyy-MM-dd hh:mm:ss');
|
||
} else {
|
||
return '-';
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: '', title: '状态', align: 'center', valign: 'middle', width: '5%',
|
||
formatter: function (val, row, index) {
|
||
if (row.status == 2) {
|
||
return '<label class="label label-danger">已删除</label>';
|
||
}
|
||
var date = new Date().getTime();
|
||
if (date >= row.startTime && date < row.endTime) {
|
||
return '<label class="label label-success">已上架</label>';
|
||
} else if (date < row.startTime) {
|
||
return '<label class="label label-primary">待上架</label>';
|
||
} else if (date >= row.endTime) {
|
||
return '<label class="label label-warning">已下架</label>';
|
||
} else {
|
||
return '无效';
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'createTime', title: '生成时间', align: 'center', valign: 'middle', width: '10%', formatter: function (val, row, index) {
|
||
if (val) {
|
||
var date = new Date(val);
|
||
return date.format('yyyy-MM-dd hh:mm:ss');
|
||
} else {
|
||
return '-';
|
||
}
|
||
}
|
||
},
|
||
{ field: 'operator', title: '操作人', align: 'center', valign: 'middle', width: '10%' },
|
||
{
|
||
field: 'tmp', title: '操作', align: 'center', valign: 'middle', width: '10%', formatter: function (val, row, index) {
|
||
var key = row.actId;
|
||
var status = row.status;
|
||
var str = '<button class="btn btn-primary btn-sm opt-edit" data-id="' + key + '">编辑</button>';
|
||
if (status != 2) {
|
||
str += '<button class="btn btn-danger btn-sm opt-remove" data-id="' + key + '">删除</button>';
|
||
}
|
||
return str;
|
||
}
|
||
}
|
||
],
|
||
cache: false,
|
||
striped: true,
|
||
showRefresh: false,
|
||
pageSize: 10,
|
||
pagination: true,
|
||
pageList: [10, 20, 30, 50],
|
||
sidePagination: 'server',
|
||
queryParamsType: 'undefined',
|
||
queryParams: function queryParams(params) {
|
||
var param = {
|
||
pageSize: params.pageSize,
|
||
pageNumber: params.pageNumber,
|
||
name: $('#name').val(),
|
||
appId: ($('#searchAppId').val()) ? $('#searchAppId').val() : null,
|
||
status: $('#seachStatus').val(),
|
||
upStatus: $('#upStatus').val()
|
||
};
|
||
return param;
|
||
},
|
||
uniqueId: 'actId',
|
||
toolbar: '#toolbar',
|
||
url: '/admin/charge/activity/list',
|
||
onLoadSuccess: function () {
|
||
console.log('load success');
|
||
},
|
||
onLoadError: function () {
|
||
console.log('load fail');
|
||
}
|
||
});
|
||
|
||
// 编辑按钮点击事件
|
||
$('#table').on('click', '.opt-edit', function () {
|
||
clearModal();
|
||
// 处理appId
|
||
$('#appId').empty();
|
||
$('#appId').append('<option value="">请选择</option>');
|
||
for (var key in app) {
|
||
$('#appId').append('<option value="' + key + '">' + app[key] + '</option>');
|
||
}
|
||
var id = $(this).data('id');
|
||
$.ajax({
|
||
type: "get",
|
||
url: "/admin/charge/activity/getById",
|
||
data: { id: id },
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (json && json.code == 200) {
|
||
var data = json.data;
|
||
$("#module_id").val(id);
|
||
$('#modal_seqNo').val(data.seqNo);
|
||
$('#modal_actName').val(data.actName);
|
||
$('#imgUrl').attr('src', data.alertWinPic);
|
||
$('#modal_imageType').val(data.imageType);
|
||
$('#appId').val(data.appId);
|
||
$('#modal_startTime').val(new Date(data.startTime).format("yyyy-MM-dd hh:mm:ss"));
|
||
$('#modal_endTime').val(new Date(data.endTime).format("yyyy-MM-dd hh:mm:ss"));
|
||
$('#modal_skipType').val(data.skipType);
|
||
$('#modal_entrancePosition').val(data.entrancePosition);
|
||
$('#modal_skipUrl').attr("placeholder", "");
|
||
if (data.skipType == 1) {
|
||
$('#modal_skipUrl').removeAttr('readonly');
|
||
$('#modal_skipUrl').val(data.skipUrl.split(":")[0]);
|
||
} else if (data.skipType == 2) {
|
||
$('#modal_skipUrl').removeAttr('readonly');
|
||
$('#modal_skipUrl').val(data.skipUrl);
|
||
$('#showTypeDiv').removeAttr('style');
|
||
$('#showType').val(data.showType);
|
||
} else if (data.skipType == 5) {
|
||
$('#modal_skipUrl').attr('readonly', 'readonly');
|
||
$('#modal_skipUrl').val('');
|
||
}
|
||
//platform选中
|
||
var platformChecked = data.platform;
|
||
if (null != platformChecked) {
|
||
var platformCheckedArray = platformChecked.split(",");
|
||
platformCheckedArray.forEach(function (item, index) {
|
||
if (item.trim() != '') {
|
||
$("#platform_" + item.trim()).prop("checked", true);
|
||
}
|
||
})
|
||
}
|
||
//type选中
|
||
var typeChecked = data.type;
|
||
if (null != typeChecked) {
|
||
var typeCheckedArray = typeChecked.split(",");
|
||
for (var i = 0; i < typeCheckedArray.length; i++) {
|
||
var item = typeCheckedArray[i];
|
||
if (item.trim() != '') {
|
||
$("#type_" + item.trim()).prop("checked", true);
|
||
}
|
||
}
|
||
if ($("#type_2").prop("checked")) {
|
||
$('#div_room_show').removeAttr("style");
|
||
$('#div_room_assign').attr("style", "display:none");
|
||
$('#div_room_assign').attr("disabled", "disabled");
|
||
}
|
||
}
|
||
//展示房间
|
||
var roomShow = data.roomShow;
|
||
if (roomShow == 0) {
|
||
$("#roomShow_0").prop("checked", "checked");
|
||
} else if (roomShow == 1) {
|
||
$("#roomShow_1").prop("checked", "checked");
|
||
$('#div_room_assign').removeAttr("style");
|
||
$('#module_roomShow_assgin').removeAttr("disabled");
|
||
var roomRule = data.roomRule;
|
||
var roomRuleStr = '';
|
||
var obj = JSON.parse(roomRule);
|
||
if (null != obj && obj.erbanNo instanceof Array) {
|
||
var roomErbanNoArray = obj.erbanNo;
|
||
var len = roomErbanNoArray.length;
|
||
for (let i = 0; i < len; i++) {
|
||
roomRuleStr += roomErbanNoArray[i];
|
||
if (i < len - 1) {
|
||
roomRuleStr += ",";
|
||
}
|
||
}
|
||
}
|
||
$('#module_roomRule').val(roomRuleStr);
|
||
}
|
||
//用户可见
|
||
var userShow = data.userShow;
|
||
if (userShow == 0) {
|
||
$("#userShow_0").prop("checked", "checked");
|
||
} else if (userShow == 1) {
|
||
$("#userShow_1").prop("checked", "checked");
|
||
$('#div_user_assign').removeAttr("style");
|
||
var userRule = JSON.parse(data.userRule);
|
||
if (userRule.assign == 'user') {
|
||
$("input[type='radio'][name='userShow_1_assign'][value='user']").prop("checked", true);
|
||
$('#module_userShow_assgin').removeAttr("disabled");
|
||
var erbanNoStr = '';
|
||
var erbanNo = userRule.erbanNo;
|
||
if (null != erbanNo && erbanNo instanceof Array) {
|
||
len = erbanNo.length;
|
||
for (let i = 0; i < len; i++) {
|
||
erbanNoStr += erbanNo[i];
|
||
if (i < len - 1) {
|
||
erbanNoStr += ",";
|
||
}
|
||
}
|
||
}
|
||
$('#module_userShow_assgin').val(erbanNoStr);
|
||
} else if (userRule.assign == 'condition') {
|
||
$("input[type='radio'][name='userShow_1_assign'][value='condition']").prop("checked", true);
|
||
$('#min_charge_time').removeAttr("disabled");
|
||
$('#max_charge_time').removeAttr("disabled");
|
||
$('#min_reg_time').removeAttr("disabled");
|
||
$('#max_reg_time').removeAttr("disabled");
|
||
$('#min_charge_time').val(userRule.condition.minChargeTime);
|
||
$('#max_charge_time').val(userRule.condition.maxChargeTime);
|
||
$('#min_reg_time').val(userRule.condition.minRegTime);
|
||
$('#max_reg_time').val(userRule.condition.maxRegTime);
|
||
|
||
}
|
||
}
|
||
//礼包
|
||
$("#modal_packName").empty();
|
||
$('#modal_packName').append('<option value="">请选择...</option>');
|
||
$.ajax({
|
||
type: "get",
|
||
url: "/admin/activity/pack/list",
|
||
data: {
|
||
status: 1
|
||
},
|
||
dataType: "json",
|
||
success: function (json) {
|
||
var packHtml = '';
|
||
console.log(data.packId);
|
||
if (json && json.total > 0) {
|
||
$.each(json.rows, function (index, item) {
|
||
if (item.id == data.packId) {
|
||
packHtml += '<option value="' + item.id + '" data-name="' + item.name + '" selected="selected">'
|
||
+ item.name + '(' + new Date(item.beginTime).format('yyyy-MM-dd hh:mm:ss')
|
||
+ '~' + new Date(item.endTime).format('yyyy-MM-dd hh:mm:ss') + ')</option>';
|
||
} else {
|
||
packHtml += '<option value="' + item.id + '" data-name="' + item.name + '">'
|
||
+ item.name + '(' + new Date(item.beginTime).format('yyyy-MM-dd hh:mm:ss')
|
||
+ '~' + new Date(item.endTime).format('yyyy-MM-dd hh:mm:ss') + ')</option>';
|
||
}
|
||
});
|
||
$("#modal_packName").append(packHtml);
|
||
}
|
||
}
|
||
});
|
||
} else {
|
||
$("#tipMsg").text("获取菜单信息出错");
|
||
$("#tipModal").modal('show');
|
||
}
|
||
}
|
||
});
|
||
$("#chargeActivityModalLabel").text("编辑充值活动");
|
||
$("#chargeActivityModal").modal('show');
|
||
});
|
||
|
||
$("#table").on("click", '.opt-remove', function () {
|
||
var id = $(this).attr("data-id");
|
||
if (id == 'undefined') {
|
||
$("#tipMsg").text("id参数有误");
|
||
$("#tipModal").modal('show');
|
||
return;
|
||
}
|
||
if (confirm("你确认删除该记录吗? \r\n 删除后再也不能找回,请谨慎操作!")) {
|
||
$.ajax({
|
||
type: 'post',
|
||
url: "/admin/charge/activity/delete",
|
||
data: { id: id },
|
||
dataType: "json",
|
||
success: function (json) {
|
||
console.log(json);
|
||
if (json.code == 200) {
|
||
$("#tipMsg").text("删除成功");
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh("#table");
|
||
} else {
|
||
$("#tipMsg").text("删除失败");
|
||
$("#tipModal").modal('show');
|
||
}
|
||
}
|
||
});
|
||
}
|
||
});
|
||
|
||
// 添加事件
|
||
$('#add').on('click', function () {
|
||
clearModal();
|
||
$('#modal_packName').empty('');
|
||
$('#modal_packName').append('<option value="" selected="selected">请选择...</option>');
|
||
// 处理appId
|
||
$('#appId').empty();
|
||
$('#appId').append('<option value="">请选择</option>');
|
||
for (var key in validApp) {
|
||
$('#appId').append('<option value="' + key + '">' + validApp[key] + '</option>');
|
||
}
|
||
$.ajax({
|
||
type: "get",
|
||
url: "/admin/activity/pack/list",
|
||
data: {
|
||
status: 1
|
||
},
|
||
dataType: "json",
|
||
success: function (json) {
|
||
var packHtml = '';
|
||
if (json && json.total > 0) {
|
||
$.each(json.rows, function (index, item) {
|
||
packHtml += '<option value="' + item.id + '" data-name="' + item.name + '">'
|
||
+ item.name + '(' + new Date(item.beginTime).format('yyyy-MM-dd hh:mm:ss')
|
||
+ '~' + new Date(item.endTime).format('yyyy-MM-dd hh:mm:ss') + ')</option>';
|
||
});
|
||
$("#modal_packName").append(packHtml);
|
||
}
|
||
}
|
||
});
|
||
$('#chargeActivityModal').modal('show');
|
||
});
|
||
|
||
// 上传图片
|
||
$('#uploadBtn').on('click', function () {
|
||
if ($('#uploadFile').val() == '') {
|
||
$('#tipMsg').text('上传图片为空');
|
||
$('#tipModal').modal('show');
|
||
return;
|
||
}
|
||
//验证图片格式是否正确
|
||
var filename = $('#uploadFile').val();
|
||
var fileSuffix = getFileSuffix(filename);
|
||
if (fileType.indexOf(fileSuffix) == -1) {
|
||
$('#tipMsg').text('图片格式不正确,当前仅支持png、svg格式图片');
|
||
$('#tipModal').modal('show');
|
||
return;
|
||
}
|
||
|
||
var options = {
|
||
type: 'post',
|
||
url: '/admin/upload/img',
|
||
dataType: 'json',
|
||
success: function (res) {
|
||
if (res.path) {
|
||
$('#imgUrl').attr('src', res.path);
|
||
$('#modal_imageType').val(fileSuffix);
|
||
} else {
|
||
$('#tipMsg').text(res.msg);
|
||
$('#tipModal').modal('show');
|
||
}
|
||
}
|
||
}
|
||
$('#addForm').ajaxSubmit(options);
|
||
});
|
||
|
||
// 保存
|
||
$('#save').on('click', function () {
|
||
if ($('#modal_imageType').val() == '') {
|
||
$("#tipMsg").text("失败,请上传图片!");
|
||
$("#tipModal").modal('show');
|
||
return;
|
||
}
|
||
if (!$('#appId').val()) {
|
||
$("#tipMsg").text("请选择app");
|
||
$("#tipModal").modal('show');
|
||
return;
|
||
}
|
||
if ($('#addForm').validationEngine('validate')) {
|
||
var param = {};
|
||
param.actId = $('#module_id').val();
|
||
//平台
|
||
var platform = ',';
|
||
$("input[name='platform']:checked").each(function (i) {
|
||
platform += $(this).val() + ",";
|
||
});
|
||
param.platform = platform;
|
||
//入口
|
||
var type = ',';
|
||
$("input[name='type']:checked").each(function (i) {
|
||
type += $(this).val() + ",";
|
||
});
|
||
param.type = type;
|
||
// 入口位置
|
||
param.entrancePosition = $('#modal_entrancePosition').val();
|
||
//展示房间
|
||
var roomShow = $("input[name='roomShow']:checked").val();
|
||
var roomRule = new Object();
|
||
var roomErbanNo = [];
|
||
if (roomShow == 1) {
|
||
var roomErbanNoStr = $('#module_roomRule').val();
|
||
if (roomErbanNoStr.trim() == '') {
|
||
$("#tipMsg").text("失败,房间id不能为空!");
|
||
$("#tipModal").modal('show');
|
||
return;
|
||
}
|
||
var roomErbanNoArray = roomErbanNoStr.split(",");
|
||
for (var i = 0; i < roomErbanNoArray.length; i++) {
|
||
var val = roomErbanNoArray[i].trim();
|
||
if (val != '') {
|
||
if (!/^\+?[1-9][0-9]*$/.test(val)) {
|
||
$("#tipMsg").text("失败,错误的房间id:" + val + ", 请输入正确的房间id,多个使用英文逗号分开!");
|
||
$("#tipModal").modal('show');
|
||
return;
|
||
}
|
||
roomErbanNo.push(parseInt(val));
|
||
}
|
||
}
|
||
}
|
||
roomRule.erbanNo = roomErbanNo;
|
||
param.roomRule = JSON.stringify(roomRule);
|
||
param.roomShow = roomShow;
|
||
//可见用户
|
||
var userShow = $("input[name='userShow']:checked").val();
|
||
var userRule = new Object();
|
||
var erbanNo = [];
|
||
var condition = new Object();
|
||
var assign = '';
|
||
if (userShow == 1) {
|
||
var userShowAssign = $("input[name='userShow_1_assign']:checked").val();
|
||
if (userShowAssign == '') {
|
||
$("#tipMsg").text("失败,请选择用户指定方式!");
|
||
$("#tipModal").modal('show');
|
||
return;
|
||
}
|
||
if (userShowAssign == 'user') {
|
||
var erbanNoStr = $('#module_userShow_assgin').val();
|
||
if (erbanNoStr.trim() == '') {
|
||
$("#tipMsg").text("失败,房间id不能为空!");
|
||
$("#tipModal").modal('show');
|
||
return;
|
||
}
|
||
var erbanNoArray = erbanNoStr.split(",");
|
||
for (let i = 0; i < erbanNoArray.length; i++) {
|
||
val = erbanNoArray[i].trim();
|
||
if (val != '') {
|
||
if (!/^\+?[1-9][0-9]*$/.test(val)) {
|
||
$("#tipMsg").text("失败,错误的用户id:" + val + ", 请输入正确的用户id,多个使用英文逗号分开!");
|
||
$("#tipModal").modal('show');
|
||
return;
|
||
}
|
||
erbanNo.push(parseInt(val));
|
||
}
|
||
}
|
||
assign = 'user';
|
||
} else if (userShowAssign == 'condition') {
|
||
var minChargeTime = parseInt($('#min_charge_time').val());
|
||
var maxChargeTime = parseInt($('#max_charge_time').val());
|
||
var minRegTime = parseInt($('#min_reg_time').val());
|
||
var maxRegTime = parseInt($('#max_reg_time').val());
|
||
if (minChargeTime > maxChargeTime) {
|
||
$("#tipMsg").text("失败,充值次数大小颠倒");
|
||
$("#tipModal").modal('show');
|
||
return;
|
||
}
|
||
if (minRegTime > maxRegTime) {
|
||
$("#tipMsg").text("失败,注册时长大小颠倒");
|
||
$("#tipModal").modal('show');
|
||
return;
|
||
}
|
||
condition.minChargeTime = minChargeTime;
|
||
condition.maxChargeTime = maxChargeTime;
|
||
condition.minRegTime = minRegTime;
|
||
condition.maxRegTime = maxRegTime;
|
||
assign = 'condition';
|
||
}
|
||
}
|
||
userRule.assign = assign;
|
||
userRule.erbanNo = erbanNo;
|
||
userRule.condition = condition;
|
||
param.userShow = userShow;
|
||
param.userRule = JSON.stringify(userRule);
|
||
param.seqNo = $('#modal_seqNo').val();
|
||
param.actName = $('#modal_actName').val();
|
||
param.alertWinPic = $('#imgUrl').attr('src');
|
||
param.imageType = $('#modal_imageType').val();
|
||
param.startTime = $('#modal_startTime').val();
|
||
param.endTime = $('#modal_endTime').val();
|
||
param.packId = $('#modal_packName').val();
|
||
param.appId = $('#appId').val();
|
||
param.packName = $('#modal_packName').find('option:selected').attr('data-name');
|
||
var skipType = $('#modal_skipType').val();
|
||
var skipUrl = $('#modal_skipUrl').val();
|
||
// 跳转类型,1-房间id,2-h5链接,5-充值页
|
||
if (skipType == 1) {
|
||
if (!/^\+?[1-9][0-9]*$/.test(skipUrl)) {
|
||
$("#tipMsg").text("失败,房间id应为整数");
|
||
$("#tipModal").modal('show');
|
||
return;
|
||
}
|
||
} else if (skipType == 2) {
|
||
if (!skipUrl.startsWith("http://") && !skipUrl.startsWith("https://")) {
|
||
$("#tipMsg").text("失败,请输入正确的跳转链接,http或https开头");
|
||
$("#tipModal").modal('show');
|
||
return;
|
||
}
|
||
param.showType = $('#showType').val();
|
||
}
|
||
param.skipType = skipType;
|
||
param.skipUrl = skipUrl;
|
||
|
||
$.ajax({
|
||
type: 'post',
|
||
url: '/admin/charge/activity/saveOrUpdate',
|
||
data: param,
|
||
dataType: 'json',
|
||
success: function (res) {
|
||
if (res.code == 200) {
|
||
$('#chargeActivityModal').modal('hide');
|
||
$('#tipMsg').text('保存成功');
|
||
$('#tipModal').modal('show');
|
||
TableHelper.doRefresh('#table')
|
||
} else {
|
||
$('#tipMsg').text('保存失败,错误码:' + res.message);
|
||
$('#tipModal').modal('show');
|
||
}
|
||
}
|
||
})
|
||
}
|
||
});
|
||
|
||
$("#search").on('click', function () {
|
||
TableHelper.doRefresh('#table');
|
||
});
|
||
|
||
function clearModal() {
|
||
$('#addForm')[0].reset();
|
||
$('#addForm').validationEngine('hideAll');
|
||
$('#module_id').val('');
|
||
$('#div_room_assign').attr("style", "display:none");
|
||
$('#div_user_assign').attr("style", "display:none");
|
||
$('#module_roomShow_assgin').attr("disabled", "disabled");
|
||
$('#module_userShow_assgin').attr("disabled", "disabled");
|
||
$('#min_charge_time').attr('disabled', 'disabled');
|
||
$('#max_charge_time').attr('disabled', 'disabled');
|
||
$('#min_reg_time').attr('disabled', 'disabled');
|
||
$('#max_reg_time').attr('disabled', 'disabled');
|
||
$('#addForm').find('img').attr('src', '');
|
||
$('#modal_alertWinPic').val('');
|
||
$('#modal_imageType').val('');
|
||
$('#showTypeDiv').attr('style', 'display:none;');
|
||
// 处理appId
|
||
$('#appId').empty();
|
||
}
|
||
|
||
$("input[name='type']").on('change', function () {
|
||
if ($("#type_2").prop("checked")) {
|
||
$('#div_room_show').removeAttr("style");
|
||
$('#div_room_assign').attr("style", "display:none");
|
||
$('#div_room_assign').attr("disabled", "disabled");
|
||
$('#roomShow_0').prop('checked', true);
|
||
} else {
|
||
$('#div_room_show').attr("style", "display: none;");
|
||
$('#div_room_assign').removeAttr("style");
|
||
$('#div_room_assign').removeAttr("disabled");
|
||
$('#roomShow_0').prop('checked', true);
|
||
}
|
||
});
|
||
|
||
$("input[name='roomShow']").on('change', function () {
|
||
var checked = $("input[name='roomShow']:checked").val();
|
||
if (checked == 0) {
|
||
$('#div_room_assign').attr("style", "display:none");
|
||
$('#div_room_assign').attr("disabled", "disabled");
|
||
} else if (checked == 1) {
|
||
$('#div_room_assign').removeAttr("style");
|
||
$('#div_room_assign').removeAttr("disabled");
|
||
}
|
||
});
|
||
|
||
$("input[name='userShow']").on('change', function () {
|
||
var checked = $("input[name='userShow']:checked").val();
|
||
if (checked == 0) {
|
||
$('#div_user_assign').attr("style", "display:none");
|
||
} else if (checked == 1) {
|
||
$('#div_user_assign').removeAttr("style");
|
||
}
|
||
});
|
||
|
||
$("input[name='userShow_1_assign']").on('change', function () {
|
||
var checked = $("input[name='userShow_1_assign']:checked").val();
|
||
if (checked == 'user') {
|
||
$('#module_userShow_assgin').removeAttr("disabled");
|
||
$('#min_charge_time').attr('disabled', 'disabled');
|
||
$('#max_charge_time').attr('disabled', 'disabled');
|
||
$('#min_reg_time').attr('disabled', 'disabled');
|
||
$('#max_reg_time').attr('disabled', 'disabled');
|
||
} else if (checked == 'condition') {
|
||
$('#module_userShow_assgin').attr("disabled", "disabled");
|
||
$('#min_charge_time').removeAttr("disabled");
|
||
$('#max_charge_time').removeAttr("disabled");
|
||
$('#min_reg_time').removeAttr("disabled");
|
||
$('#max_reg_time').removeAttr("disabled");
|
||
}
|
||
});
|
||
|
||
$('#modal_skipType').on('change', function () {
|
||
var val = $('#modal_skipType').val();
|
||
if (val == 1) {
|
||
$('#modal_skipUrl').val('');
|
||
$('#modal_skipUrl').attr("placeholder", "请输入房主平台号");
|
||
$('#modal_skipUrl').removeAttr('readonly');
|
||
$('#showTypeDiv').attr('style', 'display:none;');
|
||
} else if (val == 2) {
|
||
$('#modal_skipUrl').val('');
|
||
$('#modal_skipUrl').attr("placeholder", "请输入跳转url,http或https开头");
|
||
$('#modal_skipUrl').removeAttr('readonly');
|
||
$('#showTypeDiv').removeAttr('style');
|
||
} else if (val == 5) {
|
||
$('#modal_skipUrl').val('');
|
||
$('#modal_skipUrl').attr("placeholder", "");
|
||
$('#modal_skipUrl').attr('readonly', 'readonly');
|
||
$('#showTypeDiv').attr('style', 'display:none;');
|
||
}
|
||
});
|
||
|
||
/**
|
||
* 渲染平台
|
||
*/
|
||
function formatPlatform(val) {
|
||
if (null == val && val == '') {
|
||
return '';
|
||
}
|
||
if (val == 1) {
|
||
return '安卓';
|
||
}
|
||
if (val == 2) {
|
||
return 'ios';
|
||
}
|
||
return '';
|
||
}
|
||
|
||
/**
|
||
* 渲染入口
|
||
*/
|
||
function formatType(val) {
|
||
if (null == val && val == '') {
|
||
return '';
|
||
}
|
||
if (val == 1) {
|
||
return '首页';
|
||
}
|
||
if (val == 2) {
|
||
return '房间';
|
||
}
|
||
return '';
|
||
}
|
||
|
||
/**
|
||
* 获取文件后缀名
|
||
*/
|
||
function getFileSuffix(filename) {
|
||
var fileExtension = filename.substring(filename.lastIndexOf('.') + 1).toLowerCase();
|
||
return fileExtension;
|
||
}
|
||
|
||
})
|
||
}
|
||
},
|
||
|
||
};
|
||
</script>
|
||
|
||
<style scoped>
|
||
</style> |