/**
|
* 用户详情对话框(可用于添加和修改对话框)
|
*/
|
var WorldCupInfo = {
|
userInfoData: {},
|
stores:[],
|
goodsPicArray1: []
|
};
|
|
|
|
/**
|
* 关闭此对话框
|
*/
|
WorldCupInfo.close = function () {
|
parent.layer.close(window.parent.WorldCup.layerIndex);
|
};
|
|
|
|
|
/**
|
* 提交添加用户
|
*/
|
WorldCupInfo.addSubmit = function () {
|
let name = $('#name').val();
|
let startTime = $('#startTime').val();
|
let endTime = $('#endTime').val();
|
let registrationClosingTime = $('#registrationClosingTime').val();
|
let startAge = $('#startAge').val();
|
let endAge = $('#endAge').val();
|
let gender = $('#gender').val();
|
let payType = [];
|
let cash = $('#cash').val();
|
let paiCoin = $('#paiCoin').val();
|
let classHour = $('#classHour').val();
|
|
let maxPeople = $('#maxPeople').val();
|
let basePeople = $('#basePeople').val();
|
let participationIntegral = $('#participationIntegral').val();
|
let winIntegral = $('#winIntegral').val();
|
let address = $('#address').val();
|
let longitude = $('#longitude').val();
|
let latitude = $('#latitude').val();
|
let intro = $('#intro').val();
|
let coverImg = $('#coverImg').val();
|
let homeBackdropImg = $('#homeBackdropImg').val();
|
let content = editor.getContent();
|
if(null == name || '' == name){
|
Feng.error("请填写有效的比赛名称");
|
return
|
}
|
if(null == startTime || '' == startTime){
|
Feng.error("请选择有效的开始时间");
|
return
|
}
|
if(null == endTime || '' == endTime){
|
Feng.error("请选择有效的结束时间");
|
return
|
}
|
if(null == startAge || '' == startAge){
|
Feng.error("请填写有效的报名开始年龄");
|
return
|
}
|
if(null == endAge || '' == endAge){
|
Feng.error("请填写有效的报名结束年龄");
|
return
|
}
|
if(parseInt(startAge) > parseInt(endAge)){
|
Feng.error("报名开始年龄不能大于结束年龄");
|
return
|
}
|
$('#payType input[type="checkbox"]').each(function (i, e){
|
if($(e).is(":checked")){
|
payType.push($(e).val());
|
if($(e).val() == 1 && null == cash){
|
Feng.error("请输入有效的现金支付金额");
|
return
|
}
|
if($(e).val() == 2 && null == paiCoin){
|
Feng.error("请输入有效的玩湃币支付数量");
|
return
|
}
|
if($(e).val() == 3 && null == classHour){
|
Feng.error("请输入有效的课时支付数量");
|
return
|
}
|
}
|
})
|
if(null == maxPeople || '' == maxPeople){
|
Feng.error("请填写有效的报名人数");
|
return
|
}
|
if(null == basePeople || '' == basePeople){
|
basePeople = 0;
|
}
|
if(null == participationIntegral || '' == participationIntegral){
|
participationIntegral = 0;
|
}
|
if(null == winIntegral || '' == winIntegral){
|
winIntegral = 0;
|
}
|
if(null == address || '' == address){
|
Feng.error("请填写有效的比赛地点");
|
return
|
}
|
if(null == longitude || '' == longitude){
|
Feng.error("无效的坐标,请重新输入地址");
|
return
|
}
|
if(null == latitude || '' == latitude){
|
Feng.error("无效的坐标,请重新输入地址");
|
return
|
}
|
if(WorldCupInfo.stores.length == 0){
|
Feng.error("请选择参赛门店");
|
return
|
}
|
if(null == intro || '' == intro){
|
Feng.error("请填写有效的赛事简介");
|
return
|
}
|
if(null == coverImg || '' == coverImg){
|
Feng.error("请上传有效的比赛封面图");
|
return
|
}
|
if(null == homeBackdropImg || '' == homeBackdropImg){
|
Feng.error("请上传有效的首页默认背景图");
|
return
|
}
|
if(WorldCupInfo.goodsPicArray1 == 0){
|
Feng.error("请上传有效的比赛图片");
|
return
|
}
|
if(null == content || '' == content){
|
Feng.error("请填写有效的比赛详情");
|
return
|
}
|
let data = {
|
'name': name,
|
'startTime': new Date(startTime + " 00:00:00"),
|
'endTime': new Date(endTime + " 23:59:59"),
|
'startAge': startAge,
|
'endAge': endAge,
|
'gender': gender,
|
'payType': payType.toString(),
|
'cash': cash,
|
'paiCoin': paiCoin,
|
'classHour': classHour,
|
'maxPeople': maxPeople,
|
'basePeople': basePeople,
|
'participationIntegral' : participationIntegral,
|
'winIntegral' : winIntegral,
|
'address': address,
|
'lon': longitude,
|
'lat': latitude,
|
'coverImg': coverImg,
|
'homeBackdropImg': homeBackdropImg,
|
'infoImg': JSON.stringify(WorldCupInfo.goodsPicArray1),
|
'intro': intro,
|
'content': content,
|
'stores': JSON.stringify(WorldCupInfo.stores)
|
}
|
if(null != registrationClosingTime && '' != registrationClosingTime){
|
data.registrationClosingTime = new Date(registrationClosingTime + " 23:59:59");
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/worldCup/addWorldCup", function (res) {
|
if (res.code==200){
|
Feng.success("添加成功!");
|
WorldCupInfo.close();
|
window.parent.WorldCup.search();
|
}else{
|
Feng.error(res.msg);
|
}
|
}, function (data) {
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(data);
|
ajax.start();
|
};
|
|
/**
|
* 提交修改
|
*/
|
WorldCupInfo.editSubmit = function () {
|
let name = $('#name').val();
|
let startTime = $('#startTime').val();
|
let endTime = $('#endTime').val();
|
let registrationClosingTime = $('#registrationClosingTime').val();
|
let startAge = $('#startAge').val();
|
let endAge = $('#endAge').val();
|
let gender = $('#gender').val();
|
let payType = [];
|
let cash = $('#cash').val();
|
let paiCoin = $('#paiCoin').val();
|
let classHour = $('#classHour').val();
|
|
let maxPeople = $('#maxPeople').val();
|
let basePeople = $('#basePeople').val();
|
let participationIntegral = $('#participationIntegral').val();
|
let winIntegral = $('#winIntegral').val();
|
let address = $('#address').val();
|
let longitude = $('#longitude').val();
|
let latitude = $('#latitude').val();
|
let intro = $('#intro').val();
|
let coverImg = $('#coverImg').val();
|
let homeBackdropImg = $('#homeBackdropImg').val();
|
let content = editor.getContent();
|
if(null == name || '' == name){
|
Feng.error("请填写有效的比赛名称");
|
return
|
}
|
if(null == startTime || '' == startTime){
|
Feng.error("请选择有效的开始时间");
|
return
|
}
|
if(null == endTime || '' == endTime){
|
Feng.error("请选择有效的结束时间");
|
return
|
}
|
if(null == startAge || '' == startAge){
|
Feng.error("请填写有效的报名开始年龄");
|
return
|
}
|
if(null == endAge || '' == endAge){
|
Feng.error("请填写有效的报名结束年龄");
|
return
|
}
|
if(parseInt(startAge) > parseInt(endAge)){
|
Feng.error("报名开始年龄不能大于结束年龄");
|
return
|
}
|
$('#payType input[type="checkbox"]').each(function (i, e){
|
if($(e).is(":checked")){
|
payType.push($(e).val());
|
if($(e).val() == 1 && null == cash){
|
Feng.error("请输入有效的现金支付金额");
|
return
|
}
|
if($(e).val() == 2 && null == paiCoin){
|
Feng.error("请输入有效的玩湃币支付数量");
|
return
|
}
|
if($(e).val() == 3 && null == classHour){
|
Feng.error("请输入有效的课时支付数量");
|
return
|
}
|
}
|
})
|
if(null == maxPeople || '' == maxPeople){
|
Feng.error("请填写有效的报名人数");
|
return
|
}
|
if(null == basePeople || '' == basePeople){
|
basePeople = 0;
|
}
|
if(null == participationIntegral || '' == participationIntegral){
|
participationIntegral = 0;
|
}
|
if(null == winIntegral || '' == winIntegral){
|
winIntegral = 0;
|
}
|
if(null == address || '' == address){
|
Feng.error("请填写有效的比赛地点");
|
return
|
}
|
if(null == longitude || '' == longitude){
|
Feng.error("无效的坐标,请重新输入地址");
|
return
|
}
|
if(null == latitude || '' == latitude){
|
Feng.error("无效的坐标,请重新输入地址");
|
return
|
}
|
if(WorldCupInfo.stores.length == 0){
|
Feng.error("请选择参赛门店");
|
return
|
}
|
if(null == intro || '' == intro){
|
Feng.error("请填写有效的赛事简介");
|
return
|
}
|
if(null == coverImg || '' == coverImg){
|
Feng.error("请上传有效的比赛封面图");
|
return
|
}
|
if(null == homeBackdropImg || '' == homeBackdropImg){
|
Feng.error("请上传有效的首页默认背景图");
|
return
|
}
|
if(WorldCupInfo.goodsPicArray1 == 0){
|
Feng.error("请上传有效的比赛图片");
|
return
|
}
|
if(null == content || '' == content){
|
Feng.error("请填写有效的比赛详情");
|
return
|
}
|
let data = {
|
'id': $('#id').val(),
|
'name': name,
|
'startTime': new Date(startTime + " 00:00:00"),
|
'endTime': new Date(endTime + " 23:59:59"),
|
'startAge': startAge,
|
'endAge': endAge,
|
'gender': gender,
|
'payType': payType.toString(),
|
'cash': cash,
|
'paiCoin': paiCoin,
|
'classHour': classHour,
|
'maxPeople': maxPeople,
|
'basePeople': basePeople,
|
'participationIntegral' : participationIntegral,
|
'winIntegral' : winIntegral,
|
'address': address,
|
'lon': longitude,
|
'lat': latitude,
|
'coverImg': coverImg,
|
'homeBackdropImg': homeBackdropImg,
|
'infoImg': JSON.stringify(WorldCupInfo.goodsPicArray1),
|
'intro': intro,
|
'content': content,
|
'stores': JSON.stringify(WorldCupInfo.stores)
|
}
|
if(null != registrationClosingTime && '' != registrationClosingTime){
|
data.registrationClosingTime = new Date(registrationClosingTime + " 23:59:59");
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/worldCup/editWorldCup", function (res) {
|
if (res.code==200){
|
Feng.success("编辑成功!");
|
WorldCupInfo.close();
|
window.parent.WorldCup.search();
|
}else{
|
Feng.error(res.msg);
|
}
|
}, function (data) {
|
Feng.error("编辑失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(data);
|
ajax.start();
|
};
|
|
|
|
$(function () {
|
Feng.initValidator("userInfoForm", WorldCupInfo.validateFields);
|
|
// 初始化头像上传
|
var coverImg = new $WebUpload("coverImg");
|
coverImg.setUploadBarId("progressBar1");
|
coverImg.init();
|
|
var homeBackdropImg = new $WebUpload("homeBackdropImg");
|
homeBackdropImg.setUploadBarId("progressBar2");
|
homeBackdropImg.init();
|
|
$('#payType input[type="checkbox"]').click(function (){
|
let v = $(this).val();
|
if($(this).is(":checked")){
|
if(v == 0){
|
$('.cash').hide();
|
$('.classHour').hide();
|
$('.paiCoin').hide();
|
$('#payType input[item="cash"]').attr('checked', false);
|
$('#payType input[item="classHour"]').attr('checked', false);
|
$('#payType input[item="paiCoin"]').attr('checked', false);
|
$('#cash').val('');
|
$('#classHour').val('');
|
$('#paiCoin').val('');
|
}
|
if(v == 1){
|
$('#payType input[item="free"]').attr('checked', false);
|
$('.cash').show();
|
}
|
if(v == 2){
|
$('#payType input[item="free"]').attr('checked', false);
|
$('.paiCoin').show();
|
}
|
if(v == 3){
|
$('#payType input[item="free"]').attr('checked', false);
|
$('.classHour').show();
|
}
|
}else{
|
if(v == 0){
|
$('.cash').hide();
|
$('.classHour').hide();
|
$('.paiCoin').hide();
|
$('#payType input[item="cash"]').attr('checked', false);
|
$('#payType input[item="classHour"]').attr('checked', false);
|
$('#payType input[item="paiCoin"]').attr('checked', false);
|
$('#cash').val('');
|
$('#classHour').val('');
|
$('#paiCoin').val('');
|
}
|
if(v == 1){
|
$('.cash').hide();
|
}
|
if(v == 2){
|
$('.paiCoin').hide();
|
}
|
if(v == 3){
|
$('.classHour').hide();
|
}
|
}
|
|
});
|
|
if(null != $('#id').val() && '' != $('#id').val()){
|
WorldCupInfo.stores = JSON.parse($('#storeInfo').val());
|
WorldCupInfo.initStore();
|
let lng = $('#longitude').val();
|
let lat = $('#latitude').val();
|
// 地图实例
|
map = new AMap.Map('container', {
|
resizeEnable: true, // 允许缩放
|
center: [lng, lat], // 设置地图的中心点
|
zoom: 15 // 设置地图的缩放级别,0 - 20
|
});
|
//地图画点
|
addMarker(lng,lat);
|
}
|
});
|
|
|
var map = new AMap.Map('container', {
|
resizeEnable: true, // 允许缩放
|
zoom: 15 // 设置地图的缩放级别,0 - 20
|
});
|
var marker;
|
//搜索地图
|
WorldCupInfo.searchByStationName = function(e,type){
|
var keyword="";
|
if(type==2){
|
keyword = $(e).parent().prev().find("input").val();
|
}else {
|
if($("#address").val()!=null && $("#address").val()!=''){
|
keyword = $("#address").val();
|
}
|
}
|
type=1;
|
AMap.plugin('AMap.Geocoder', function() {
|
var geocoder = new AMap.Geocoder();
|
console.log(geocoder)
|
console.log(keyword)
|
geocoder.getLocation(keyword, function(status, result) {
|
console.log(status,result)
|
if (status === 'complete' && result.info === 'OK') {
|
// 经纬度
|
var lng = result.geocodes[0].location.lng;
|
var lat = result.geocodes[0].location.lat;
|
$("#longitude").val(lng)
|
$("#latitude").val(lat)
|
// 地图实例
|
map = new AMap.Map('container', {
|
resizeEnable: true, // 允许缩放
|
center: [lng, lat], // 设置地图的中心点
|
zoom: 15 // 设置地图的缩放级别,0 - 20
|
});
|
//地图画点
|
//addMarker(lng,lat);
|
if(type==1 || type==2){
|
showInfoClick();
|
if(lng == null){
|
}else{
|
addMarker(lng,lat);
|
}
|
}else{
|
|
}
|
} else {
|
console.log('定位失败!');
|
}
|
});
|
});
|
|
}
|
//地图点击事件
|
function showInfoClick(){
|
map.on('click', function (e) {
|
addMarker(e.lnglat.getLng(),e.lnglat.getLat());
|
});
|
}
|
//删除点
|
function removeMarkers(){
|
if(marker!=null){
|
map.remove(marker);
|
}
|
|
}
|
// 实例化点标记
|
function addMarker(lon,lat) {
|
removeMarkers();
|
marker = new AMap.Marker({
|
map: map,
|
position: new AMap.LngLat(lon, lat), // 经纬度
|
});
|
//加经纬度
|
$("#lon").val(lon);
|
$("#lat").val(lat);
|
var lnglatXY = [lon, lat];//地图上所标点的坐标
|
AMap.service('AMap.Geocoder',function() {//回调函数
|
geocoder = new AMap.Geocoder({
|
});
|
geocoder.getAddress(lnglatXY, function (status, result) {
|
if (status === 'complete' && result.info === 'OK') {
|
//获得了有效的地址信息:
|
//即,result.regeocode.formattedAddress
|
// alert(result.regeocode.formattedAddress)
|
//document.getElementById("address").value=result.regeocode.formattedAddress;//将获取到的地址信息赋值给文本框,保存进数据库
|
|
var address = result.regeocode.formattedAddress;
|
var city = result.regeocode.addressComponent.city;
|
var province = result.regeocode.addressComponent.province;
|
var district = result.regeocode.addressComponent.district;
|
$("#address").val(address);
|
} else {
|
//获取地址失败
|
}
|
});
|
})
|
}
|
|
|
WorldCupInfo.openStore = function () {
|
var index = layer.open({
|
type: 2,
|
title: '参与赛点',
|
area: ['80%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/worldCup/openStore'
|
});
|
this.layerIndex = index;
|
};
|
|
WorldCupInfo.initStore = function (){
|
let html = '';
|
let page = $('#page').val();
|
for (let i = 0; i < WorldCupInfo.stores.length; i++) {
|
let item = WorldCupInfo.stores[i];
|
html += '<tr><td>' + item.province + '</td><td>' + (typeof item.operator == "undefined" ? "" : item.operator) + '</td><td>' + item.name + '</td>';
|
if("info" != page){
|
html += '<td><button style="height: 30px;\n' +
|
' line-height: 30px;\n' +
|
' font-size: 14px;\n' +
|
' width: 50px" onclick="WorldCupInfo.delStore(' + item.id + ')">删除</button></td></tr>'
|
}else{
|
html += '</tr>';
|
}
|
}
|
$('#stores tbody').html(html);
|
}
|
|
WorldCupInfo.delStore = function (id){
|
let arr = [];
|
for (let i = 0; i < WorldCupInfo.stores.length; i++) {
|
let item = WorldCupInfo.stores[i];
|
if(id != item.id){
|
arr.push(item);
|
}
|
}
|
WorldCupInfo.stores = arr;
|
WorldCupInfo.initStore();
|
}
|
|
|
var editor = null;
|
$(function () {
|
//初始化编辑器
|
editor = UE.getEditor('content');
|
});
|