You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

597 lines
20 KiB
HTML

5 years ago
<extend name="Public/base" />
<block name="body">
<link rel="stylesheet" href="__CSS__/select2.min.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="__CSS__/admin_table.css" media="all">
<link href="__STATIC__/icons_alibaba/iconfont.css" rel="stylesheet">
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<script type="text/javascript" src="__STATIC__/provincecityarea/AreaData_min.js"></script>
<script src="__STATIC__/layer/layer.js"></script>
<script type="text/javascript" src="__JS__/select2.min.js"></script>
<style>
.tabcon1711 input.time {
width: 150px;
}
#form .txt_area {
width: 300px;
height: 150px;
}
.tabcon1711 .form_unit {
margin-left: 2px;
}
.tabcon1711 .mustmark {
margin-left:-7px;
}
.list-ratio {
display: table;
}
.list-ratio .li-ratio {
display: flex;
margin-bottom: 20px;
align-items: center;
}
.list-ratio .li-ratio .turnover, .list-ratio .li-ratio .turnover-ratio {
position: relative;
}
.list-ratio .li-ratio .turnover span, .list-ratio .li-ratio .turnover-ratio .error-message {
color: red;
position: absolute;
left: 0;
top: 30px;
white-space: nowrap;
display: none;
}
.iconfont-btn {
cursor: pointer;
}
.iconfont-style {
font-size: 18px;
color: #fff;
border-radius: 4px;
border: 0;
padding: 5px;
margin-left: 10px;
}
.iconfont-selected {
background-color: #0A9AF2;
}
.iconfont-selected:hover {
background-color: #03a9f4;
}
.iconfont-unselected {
background-color: #999;
}
.iconfont-unselected:hover {
background-color: #ababab;
}
.tabcon1711 .submit_btn.small-btn {
float: none;
line-height: 25px;
width: 50px;
height: 25px;
font-size: 12px;
padding: 0px 8px 0px 0px;
}
.select2-container--default .select2-selection--multiple {
line-height: 22px;
}
.select2-container .select2-search--inline {
float: left;
height: 29px;
line-height: 29px;
}
.select2-container--default .select2-search--inline .select2-search__field {
height: 22px;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
height: 22px;
line-height: 22px;
}
</style>
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">{$meta_title}</h3>
<!-- <p class="description_text">说明:此功是创建推广员时所需填写信息</p>-->
</div>
<!-- 标签页导航 -->
<div class="tab-wrap">
<div class="tab-content tabcon1711">
<!-- 表单 -->
<form id="form" method="post" class="form-horizontal" style="margin-bottom: 40px;">
<!-- 基础文档模型 -->
<div id="tab1" class="tab-pane in tab1">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="l"><i class="mustmark">*</i>公司类型:</td>
<td class="r">
<select name="company_belong" id="company-belong-select" class="select_gallery">
<option value="-1">所有公司类型</option>
<?php foreach($companyBelongs as $key => $name):?>
<option value="<?=$key?>"><?=$name?></option>
<?php endforeach;?>
</select>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>推广公司:</td>
<td class="r">
<select name="company_id[]" id="company-select" class="select_gallery" multiple="multiple" style="width: 500px;">
<option value="0">所有公司</option>
<?php foreach($companies as $company):?>
<option value="<?=$company['id']?>"><?=$company['company_name']?></option>
<?php endforeach;?>
</select>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>游戏类型:</td>
<td class="r">
<select name="game_type_id" id="game-type-select" class="select_gallery">
<option value="0">所有游戏类型</option>
<?php foreach($gameTypes as $gameType):?>
<option value="<?=$gameType['id']?>"><?=$gameType['type_name']?></option>
<?php endforeach;?>
</select>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>游戏:</td>
<td class="r">
<select name="game_id" id="game-select" class="select_gallery" multiple="multiple" style="width: 500px;">
4 years ago
<option value="0">所有游戏</option>
5 years ago
<?php foreach($games as $game):?>
<option value="<?=$game['id']?>"><?=$game['name']?></option>
<?php endforeach;?>
</select>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>支付宝支付配置:</td>
<td class="r">
<select name="alipay_merchant_id" id="alipay-merchant-select" class="select_gallery">
<option value="0">跟随系统默认商户</option>
<?php foreach($aliMerchants as $merchant):?>
<option value="<?=$merchant['id']?>"><?=$merchant['name']?></option>
<?php endforeach;?>
</select>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>微信支付配置:</td>
<td class="r">
<select name="weixin_merchant_id" id="weixin-merchant-select" class="select_gallery">
<option value="0">跟随系统默认商户</option>
<?php foreach($weixinMerchants as $merchant):?>
<option value="<?=$merchant['id']?>"><?=$merchant['name']?></option>
<?php endforeach;?>
</select>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark">*</i>快捷支付配置:</td>
<td class="r">
<select name="express_merchant_id" id="express-merchant-select" class="select_gallery">
<option value="0">跟随系统默认商户</option>
<?php foreach($expressMerchants as $merchant):?>
<option value="<?=$merchant['id']?>"><?=$merchant['name']?></option>
<?php endforeach;?>
</select>
</td>
</tr>
<tr>
4 years ago
<td class="l"><i class="mustmark">*</i>生效时间(开始):</td>
5 years ago
<td class="r">
<input type="text" id="start_time" name="start_time" class="time" value="" autocomplete="off" placeholder="请选择生效时间(开始)" style="width: 200px"/>
</td>
</tr>
<tr>
<td class="l">生效时间(结束):</td>
<td class="r">
<input type="text" id="end_time" name="end_time" class="time" value="" autocomplete="off" placeholder="请选择生效时间(开始)" style="width: 200px"/>
</td>
</tr>
</tbody>
</table>
</div>
<div class="form-item cf">
<button class="submit_btn mlspacing" id="add-item" type="button" target-form="form-horizontal" style="margin-top: 10px;">
新增
</button>
</div>
</form>
<div class="data_list">
<div class="">
<table id="record-table">
<!-- 表头 -->
<thead>
<tr>
<th>公司类型</th>
<th>推广公司</th>
<th>游戏类型</th>
<th>游戏产品</th>
<th>支付宝支付配置</th>
<th>微信支付配置</th>
<th>快捷支付配置</th>
<th>生效时间</th>
<th>操作</th>
</tr>
</thead>
<!-- 列表 -->
<tbody>
</tbody>
</table>
</div>
</div>
<div style="margin-top: 30px; height: 35px; width: 100%;">
<a class="submit_btn" href="javascript:;" id="submit" style="margin: 0px auto; margin-left: 208px; ">全部提交</a>
</div>
</div>
</div>
<div class="common_settings">
<span class="plus_icon"><span><img src="__IMG__/zwmimages/icon_jia.png"></span></span>
<form class="addShortcutIcon">
<input type="hidden" name="title" value="{$m_title}">
<input type="hidden" name="url" value="Promote/lists/type/1">
</form>
<a class="ajax-post add-butn <notempty name='commonset'>addSIsetted</notempty>" href="javascript:;" target-form="addShortcutIcon" url="{:U('Think/addShortcutIcon')}"><img src="__IMG__/zwmimages/icon_jia.png"><span><notempty name='commonset'>已添加<else />添加至常用设置</notempty></span></a>
</div>
</block>
<block name="script">
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
//导航高亮
4 years ago
highlight_subnav("{:U('PaymentMerchant/rules')}");
5 years ago
$(".select_gallery").select2();
$(function(){
$('.time').datetimepicker({
format: 'yyyy-mm-dd',
language: "zh-CN",
autoclose: true,
scrollMonth: false,
scrollTime: false,
scrollInput: false,
startView: 'month',
minView:'month',
maxView:'month',
});
showTab();
$('#company-belong-select').on({
change: function() {
var companyBelong = $(this).val()
getCompaniesByBelong(companyBelong, function(companies) {
4 years ago
var html = '<option value="0">所有推广公司</option>'
5 years ago
for (var key in companies) {
html += '<option value="' +
companies[key].id +
'">' + companies[key].company_name + '</option>'
}
$('#company-select').html(html)
$('#company-select').select2()
})
}
})
$('#game-type-select').on({
change: function() {
var gameTypeId = $(this).val()
getGamesByType(gameTypeId, function(games) {
4 years ago
var html = '<option value="0">所有游戏</option>'
5 years ago
for (var key in games) {
html += '<option value="' +
games[key].id +
'">' + games[key].name + '</option>'
}
$('#game-select').html(html)
$('#game-select').select2()
})
}
})
function getCompaniesByBelong(companyBelong, callback) {
$.ajax({
url: '{:U("getCompaniesByBelong")}',
type: 'get',
dataType: 'json',
data: {company_belong: companyBelong},
success: function(result) {
if (result.status == 1) {
callback(result.data.companies)
} else {
layer.msg(result.message)
}
}
})
}
function getGamesByType(gameTypeId, callback) {
$.ajax({
url: '{:U("getGamesByType")}',
type: 'get',
dataType: 'json',
data: {game_type_id: gameTypeId},
success: function(result) {
if (result.status == 1) {
callback(result.data.games)
} else {
layer.msg(result.message)
}
}
})
}
function descartes(list) {
//parent上一级索引;count指针计数
var point = {};
var result = [];
var pIndex = null;
var tempCount = 0;
var temp = [];
//根据参数列生成指针对象
for(var index in list) {
if(typeof list[index] == 'object') {
point[index] = {'parent':pIndex,'count':0}
pIndex = index;
}
}
//单维度数据结构直接返回
if(pIndex == null) {
return list;
}
//动态生成笛卡尔积
while(true) {
for(var index in list) {
tempCount = point[index]['count'];
temp.push(list[index][tempCount]);
}
//压入结果数组
result.push(temp);
temp = [];
//检查指针最大值问题
while(true) {
if(point[index]['count']+1 >= list[index].length) {
point[index]['count'] = 0;
pIndex = point[index]['parent'];
if(pIndex == null) {
return result;
}
//赋值parent进行再次检查
index = pIndex;
} else {
point[index]['count']++;
break;
}
}
}
}
function getRangeTimeDisplay(startTime, endTime)
{
if (startTime === '' && endTime === '') {
return '永久';
}
if (startTime !== '' && endTime !== '') {
return startTime + ' 至 ' + endTime;
}
if (startTime === '' && endTime !== '') {
return '从前 至 ' + endTime;
}
if (startTime !== '' && endTime === '') {
return startTime + ' 至 永久';
}
}
function getCompanyName(id) {
return $("#company-select option[value=" + id + "]").html();
}
function getGameName(id) {
return $("#game-select option[value=" + id + "]").html();
}
4 years ago
function isUniqueKeyExists(uniqueKey) {
return ($("#record-table tr[data-key=" + uniqueKey + "]").length == 0 ? false : true);
}
function getUniqueKey(data) {
var startTime = data.start_time == '' ? '0' : data.start_time.replace(/-/g, "")
var endTime = data.end_time == '' ? '0' : data.end_time.replace(/-/g, "")
return data.company_belong + '_' + data.company_id + '_' + data.game_id + '_' + data.game_type_id + '_' + startTime + '_' + endTime
}
function getTodayValue() {
var now = new Date()
var year = now.getFullYear().toString()
var month = now.getMonth() + 1
var date = now.getDate()
if (month < 10) {
month = "0" + month;
}
if (date < 10) {
date = "0" + date;
}
return parseInt(year + month + date);
}
5 years ago
$('#add-item').on({
click: function () {
var companySelect = $("#company-select");
var companyIds = companySelect.val()
var companyBelongOption = $("#company-belong-select option:selected");
var companyBelongId = companyBelongOption.val()
var companyBelongName = companyBelongOption.text()
var gameTypeOption = $("#game-type-select option:selected");
var gameTypeId = gameTypeOption.val()
var gameTypeName = gameTypeOption.text()
var gameSelect = $("#game-select");
var gameIds = gameSelect.val()
var alipayOption = $("#alipay-merchant-select option:selected");
var alipayId = alipayOption.val()
var alipayName = alipayOption.text()
var weixinOption = $("#weixin-merchant-select option:selected");
var weixinId = weixinOption.val()
var weixinName = weixinOption.text()
var expressOption = $("#express-merchant-select option:selected");
var expressId = expressOption.val()
var expressName = expressOption.text()
var startTime = $("#start_time").val();
var endTime = $("#end_time").val();
4 years ago
if (companyIds == null || companyIds.length == 0) {
5 years ago
return layer.msg('请选择推广公司')
}
4 years ago
if (gameIds == null || gameIds.length == 0) {
return layer.msg('请选择游戏')
}
if (startTime == '') {
return layer.msg('开始生效时间必填')
}
var notValue = getTodayValue()
var startValue = parseInt(startTime.replace(/-/g, ""))
var endValue = parseInt(endTime.replace(/-/g, ""))
if (notValue >= startValue) {
return layer.msg('开始生效时间必须在今天之后')
5 years ago
}
4 years ago
if (endTime != '') {
var endValue = parseInt(endTime.replace(/-/g, ""))
if (notValue >= endValue) {
return layer.msg('最终生效时间必须在今天之后')
}
if (startValue > endValue) {
return layer.msg('开始生效时间不能大于最终生效时间')
}
5 years ago
}
4 years ago
var items = descartes([
[companyBelongId], companyIds, [gameTypeId], gameIds
])
var uniqueKeys = []
var records = []
5 years ago
for (var i in items) {
var data = {
company_belong: items[i][0],
company_id: items[i][1],
game_type_id: items[i][2],
game_id: items[i][3],
alipay_merchant_id: alipayId,
weixin_merchant_id: weixinId,
express_merchant_id: expressId,
start_time: startTime,
end_time: endTime,
}
4 years ago
console.log(data)
var uniqueKey = getUniqueKey(data)
if (isUniqueKeyExists(uniqueKey)) {
return layer.msg('已经添加相同配置,请检查')
}
data.unique_key = uniqueKey
records.push(data)
}
for (var i in records) {
var data = records[i]
var html = '<tr data-post=' + JSON.stringify(data) + ' data-key="' + data.unique_key + '"><td>' + companyBelongName + '</td>' +
'<td>' + getCompanyName(data.company_id) + '</td>' +
5 years ago
'<td>' + gameTypeName + '</td>' +
4 years ago
'<td>' + getGameName(data.game_id) + '</td>' +
5 years ago
'<td>' + alipayName + '</td>' +
'<td>' + weixinName + '</td>' +
'<td>' + expressName + '</td>' +
'<td>' + getRangeTimeDisplay(startTime, endTime) + '</td>' +
'<td><a class="delete-btn">删除</a></td>' +
'</tr>';
$('#record-table').find('tbody').append(html);
}
}
})
$('#record-table').on('click', '.delete-btn', function() {
var tr = $(this).parents('tr').eq(0)
tr.remove()
})
$('#submit').click(function (e) {
var records = []
$('#record-table').find('tbody').children('tr').each(function() {
records.push(JSON.parse($(this).attr('data-post')))
})
4 years ago
if (records.length == 0) {
return layer.msg('请添加配置数据')
}
var accessStatus = true
var checkStatus = true
$.ajax({
url: '{:U("checkRules")}',
type: 'post',
dataType: 'json',
async: false,
data: {records: records},
success: function(result) {
if (result.status == 1) {
if (result.data.is_repeat) {
checkStatus = false
}
} else {
accessStatus = false
layer.msg(result.message)
}
}
})
if (!accessStatus) {
return layer.msg('验证异常')
}
if (!checkStatus) {
layer.confirm('该时间段已有相同条件设置,是否设置?', {
title: "是否设置",
btn: ['确定', '取消']
}, function () {
saveRules(records)
});
} else {
saveRules(records)
}
});
function saveRules(records) {
5 years ago
$.ajax({
url: '{:U("saveRule")}',
type: 'post',
dataType: 'json',
data: {records: records},
success: function(result) {
if (result.status == 1) {
layer.msg(result.message)
setTimeout(function() {
window.location.href = '{:U("rules")}'
}, 200)
} else {
layer.msg(result.message)
}
}
})
4 years ago
}
5 years ago
});
</script>
</block>