/**
|
* 跨城站点管理管理初始化
|
*/
|
var Vip = {
|
id: "VipTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1,
|
picture:"",
|
fileUrl:"",
|
img:"",
|
plan:"",
|
goodsPicArray:[],
|
validateFields: {
|
}
|
};
|
var objectType =$("#objectType").val()
|
/**
|
* 初始化表格的列
|
*/
|
Vip.initColumn = function () {
|
return [
|
{field: 'selectItem', checkbox: true},
|
{title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
|
{title: '会员卡名称', field: 'vipName', visible: true, align: 'center', valign: 'middle'},
|
{title: '价格', field: 'price', visible: true, align: 'center', valign: 'middle'},
|
{title: '时长', field: 'time', visible: true, align: 'center', valign: 'middle'},
|
{
|
title: '状态', field: 'status', visible: true, align: 'center', valign: 'middle',
|
formatter: function(data) {
|
return {1: '上架中', 2: '下架中'}[data];
|
}
|
}
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
Vip.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
Vip.seItem = selected[0];
|
return true;
|
}
|
};
|
/**
|
* 上架
|
*/
|
|
Vip.onShelf = function () {
|
if (this.check()){
|
var ajax = new $ax(Feng.ctxPath + "/vip/onShelf", function (data) {
|
Feng.success("上架成功!");
|
Vip.table.refresh();
|
}, function (data) {
|
Feng.error("上架失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id",this.seItem.id);
|
ajax.start();
|
}
|
};
|
Vip.offShelf = function () {
|
if (this.check()){
|
var ajax = new $ax(Feng.ctxPath + "/vip/offShelf", function (data) {
|
Feng.success("下架成功!");
|
Vip.table.refresh();
|
}, function (data) {
|
Feng.error("下架失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id",this.seItem.id);
|
ajax.start();
|
}
|
};
|
/**
|
* 下架
|
*/
|
Vip.offShelf = function () {
|
if (this.check()){
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
const data1 = {
|
siteIds:[],
|
type:null
|
};
|
selected.forEach(function(obj) {
|
var id = obj.id;
|
data1.siteIds.push(id);
|
});
|
data1.type = 2;
|
$.ajax({
|
url: Feng.ctxPath + "/tSite/changeState",
|
type: "POST",
|
contentType: "application/json", // 设置请求头的 Content-Type
|
data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
|
success: function(response) {
|
Feng.success("下架成功!");
|
Vip.search();
|
},
|
error: function(xhr, status, error) {
|
var errorMessage = xhr.responseText ? xhr.responseText : "下架失败!";
|
Feng.error("您的网络异常!");
|
}
|
});
|
}
|
};
|
/**
|
* 跳转添加场地页面
|
*/
|
Vip.add = function () {
|
|
var index = layer.open({
|
type: 2,
|
title: "添加会员卡",
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/vip/add'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开场地管理查看详情
|
*/
|
Vip.detail = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length >1 ){
|
Feng.info("只能选择一个会员卡查看!");
|
}else {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: "查看详情",
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/vip/detail/' + Vip.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
}
|
};
|
/**
|
* 打开场地管理编辑
|
*/
|
Vip.edit = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length >1 ){
|
Feng.info("只能选择一个会员卡进行编辑!");
|
}else {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: "编辑会员卡",
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/vip/edit/' + Vip.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
}
|
};
|
/**
|
* 关闭此对话框
|
*/
|
Vip.close = function() {
|
parent.layer.close(window.parent.Vip.layerIndex);
|
}
|
|
var sh = ""; // 门店经营开始时间:小时
|
var sm = "";// 门店经营开始时间:分钟
|
var eh = "";// 门店经营结束时间:小时
|
var em = "";// 门店经营结束时间:分钟
|
|
Vip.addSubmit = function(){
|
var data = {
|
province:"",
|
city:"",
|
cityManagerId:"",
|
storeId:"",
|
siteTypeId:null,
|
appointmentStartTime:"",
|
appointmentEndTime:"",
|
cashPrice:null,
|
playPaiCoin:null,
|
insuranceEndTime:"",
|
name:"",
|
insuranceImg:"",
|
managementPlan:"",
|
operatorId:"",
|
typeName:"",
|
nextName:"",
|
ishalf:"",
|
cashPriceOne:"",
|
playPaiCoinOne:"",
|
halfName:"",
|
introduce:"",
|
imgs:"",
|
reservation:"",
|
isCanBeBooked:"",
|
type:"",
|
|
};
|
data.province = $("#pCode").val()
|
data.city = $("#cCode").val()
|
data.cityManagerId = $("#account").val()
|
data.storeId = $("#store").val()
|
data.siteTypeId = $("#siteTypeId").val()
|
data.appointmentStartTime= $("#start-time").val()
|
data.appointmentEndTime = $("#end-time").val()
|
data.cashPrice = $("#cashPrice").val()
|
data.playPaiCoin = $("#playPaiCoin").val()
|
data.insuranceEndTime = $("#insuranceEndTime").val()
|
data.name = $("#name").val()
|
data.insuranceImg = $("#img").val()
|
data.managementPlan = $('#courseVideo').val()
|
data.typeName = $('#siteTypeOne').val()
|
var sh =data.appointmentStartTime.split(':')[0];
|
var sm =data.appointmentStartTime.split(':')[1];
|
var eh =data.appointmentEndTime.split(':')[0];
|
var em =data.appointmentEndTime.split(':')[1];
|
|
|
console.log(data.typeName)
|
|
var reservation= $("input[name='reservation']:checked").val();
|
data.reservation= reservation;
|
data.isCanBeBooked= reservation;
|
console.log("看看是否可预约值")
|
console.log(reservation);
|
var checkbox = document.querySelector('input[name="pt"]');
|
console.log(checkbox)
|
if (checkbox!=null){
|
if (checkbox.checked) {
|
data.type = 1
|
console.log("选中是平台");
|
data.operatorId = 0;
|
} else {
|
console.log("运营商");
|
data.type = 2;
|
}
|
}
|
|
if (reservation == 1) {
|
if (data.typeName === "智慧场地") {
|
console.log("===========这是智慧球场")
|
|
console.log("=====" + data.appointmentStartTime)
|
|
var value = data.appointmentStartTime;
|
var lastTwoDigits = value.slice(-2);
|
|
if (lastTwoDigits === "00" || lastTwoDigits === "15" || lastTwoDigits === "30" || lastTwoDigits === "45") {
|
console.log("Last two digits are 00, 15, 30, or 45");
|
} else {
|
Feng.error("智慧场地的可预约时间段是15分钟的倍数")
|
return;
|
|
}
|
|
|
var value1 = data.appointmentEndTime;
|
var lastTwoDigits1 = value1.slice(-2);
|
|
if (lastTwoDigits1 === "00" || lastTwoDigits1 === "15" || lastTwoDigits1 === "30" || lastTwoDigits1 === "45") {
|
console.log("Last two digits are 00, 15, 30, or 45");
|
} else {
|
Feng.error("智慧场地的可预约时间段是15分钟的倍数")
|
return;
|
|
}
|
|
|
} else {
|
console.log("===========这是普通球场")
|
|
console.log("=====" + data.appointmentStartTime)
|
var value = data.appointmentStartTime;
|
var lastTwoDigits = value.slice(-2);
|
|
if (lastTwoDigits === "00" || lastTwoDigits === "30") {
|
console.log("Last two digits are 00, 15, 30, or 45");
|
} else {
|
Feng.info("普通场地可预约时间段需是30分钟的倍数")
|
return;
|
}
|
|
|
var value1 = data.appointmentEndTime;
|
var lastTwoDigits1 = value1.slice(-2);
|
|
if (lastTwoDigits1 === "00" || lastTwoDigits1 === "30") {
|
console.log("Last two digits are 00, 15, 30, or 45");
|
} else {
|
Feng.info("普通场地可预约时间段需是30分钟的倍数")
|
return;
|
|
}
|
}
|
}
|
var SelectValue="";
|
var getSelectValueMenbers = $("input[name='pt']:checked").each(function(j) {
|
if (j >= 0) {
|
SelectValue += $(this).val()
|
}
|
});
|
if(SelectValue==''){
|
let yys = $("#yys").val()
|
if(yys==""){
|
Feng.info("请选择运营商")
|
return;
|
}
|
SelectValue= yys
|
}
|
data.operatorId= SelectValue;
|
let num24 = $('input[name="name1"]');
|
var nextName="";
|
for (let i = 0; i < num24.length; i++) {
|
if($(num24[i]).val()==''){
|
Feng.info("请填写场地名称")
|
return;
|
}
|
if(i==num24.length-1){
|
nextName += $(num24[i]).val()
|
}else {
|
nextName += $(num24[i]).val()+","
|
}
|
}
|
data.nextName= nextName;
|
var ishalf= $("input[name='ishalf']:checked").val();
|
data.ishalf= ishalf;
|
|
var halfName="";
|
if (reservation==1) {
|
if (ishalf == 1) {
|
let cashPriceOne = $("#cashPriceOne").val()
|
if (cashPriceOne == '') {
|
Feng.info("请填写现金价格")
|
return;
|
}
|
data.cashPriceOne = cashPriceOne;
|
|
let playPaiCoinOne = $("#playPaiCoinOne").val()
|
if (playPaiCoinOne == '') {
|
Feng.info("请填写玩湃币价格")
|
return;
|
}
|
|
data.playPaiCoinOne = playPaiCoinOne;
|
let num2 = $('input[name="name2"]');
|
for (let i = 0; i < num2.length; i++) {
|
if ($(num2[i]).val() == '') {
|
Feng.info("请填写半场名称")
|
return;
|
}
|
if (i == num2.length - 1) {
|
halfName += $(num2[i]).val()
|
} else {
|
halfName += $(num2[i]).val() + ","
|
}
|
}
|
}
|
}
|
|
|
data.halfName= halfName;
|
|
let introduce ;
|
if (objectType==1){
|
introduce = Vip.editor.getContent();
|
}
|
|
console.log(introduce)
|
if(introduce==""){
|
Feng.info("请输入公告内容")
|
return;
|
}
|
data.introduce= introduce;
|
|
|
var goodImgs = this.goodsPicArray;
|
if(objectType==1){
|
if(goodImgs.length==0){
|
Feng.info("请上传实景图")
|
return;
|
}
|
}
|
|
var imgOne ="";
|
for (let i = 0; i <goodImgs.length; i++) {
|
if(i==goodImgs.length-1){
|
imgOne += (goodImgs[i].response)
|
}else {
|
imgOne+=(goodImgs[i].response+",")
|
}
|
|
}
|
data.imgs = imgOne
|
|
|
|
if($("#store").val()=='' ){
|
Feng.info("请选择门店")
|
return;
|
}
|
if($("#siteTypeId").val()=='' ){
|
Feng.info("请选择场地分类")
|
return;
|
}
|
if($("#name").val()==''){
|
Feng.info("请输入场地名称")
|
return;
|
}
|
|
if (reservation==1){
|
if($("#start-time").val()=='' ){
|
Feng.info("请输入可预约时间段 开始时间")
|
return;
|
}
|
if($("#end-time").val()==''){
|
Feng.info("请输入可预约时间段 结束时间")
|
return;
|
}
|
if($("#cashPrice").val()==''){
|
Feng.info("请输入现金价格")
|
return;
|
}
|
if($("#playPaiCoin").val()==''){
|
Feng.info("请输入玩湃币价格")
|
return;
|
}
|
}
|
if($("#insuranceEndTime").val()==''){
|
Feng.info("请输入场地责任险有效期")
|
return;
|
}
|
if($("#img").val()==''){
|
Feng.info("请上传场地责任有效期图片")
|
return;
|
}
|
if($('#courseVideo').val()==''){
|
Feng.info("请上传消防及应急管理方案")
|
return;
|
}
|
var sTime = document.getElementById("start-time"); //获取输入的开始时间
|
var eTime = document.getElementById("end-time"); // 获取输入的结束时间
|
var rStime = ""; //门店的经营开始时间
|
var rEtime = ""; //门店的经营结束时间
|
var selectedText = $('#store option:selected').text();
|
$.ajax({
|
url: Feng.ctxPath + "/tSite/getTime/" + selectedText,
|
type: "GET",
|
contentType: "application/json", // 设置请求头的 Content-Type
|
success: function (response) {
|
if (reservation==1) {
|
rStime = response.startTime;
|
sh = rStime.split(':')[0];// 门店经营开始时间:小时
|
sm = rStime.split(':')[1];// 门店经营开始时间:分钟
|
|
rEtime = response.endTime;
|
eh = rEtime.split(':')[0];// 门店经营结束时间:小时
|
em = rEtime.split(':')[1];// 门店经营结束时间:分钟
|
|
var start = sTime.value;
|
var startHour = start.split(':')[0]; // 输入的可预约开始时间:小时
|
var startMinute = start.split(':')[1];// 输入的可预约开始时间:分钟
|
if (Number(sh) > Number(startHour)) {
|
Feng.error("预约的开始时间不应小于营业开始时间!")
|
return false;
|
} else if (Number(sh) === Number(startHour)) {
|
if (Number(sm) > Number(startMinute)) {
|
Feng.error("预约的开始时间不应大于营业开始时间!")
|
return false;
|
}
|
} else if (Number(eh) < Number(startHour)) {
|
Feng.error("预约的开始时间不应大于营业结束时间!")
|
return false;
|
} else if (Number(eh) === Number(startHour)) {
|
Feng.error("预约的开始时间不应大于等于营业结束时间!")
|
return false;
|
}
|
var end = eTime.value;
|
var endHour = end.split(':')[0]; // 输入的可预约结束时间:小时
|
var endMinute = end.split(':')[1];// 输入的可预约结束时间:分钟
|
if (Number(eh) < Number(endHour)) {
|
Feng.error("预约的结束时间不应大于营业结束时间!")
|
return;
|
} else if (Number(eh) === Number(endHour)) {
|
if (Number(em) < Number(endMinute)) {
|
Feng.error("预约的开始时间不应大于开始营业时间!")
|
return;
|
}
|
} else if (Number(sh) > Number(endHour)) {
|
Feng.error("预约的结束时间不应小于营业开始时间!")
|
return;
|
}
|
if (Number(endHour) === Number(sh)) {
|
if (Number(endMinute) < Number(sm)) {
|
Feng.error("预约结束时间不应小于营业开始时间");
|
return;
|
}
|
}
|
if (Number(startHour) === Number(endHour) && Number(startMinute) === Number(endMinute)) {
|
Feng.error("至少预约半个小时");
|
return;
|
}
|
}
|
$.ajax({
|
url: Feng.ctxPath + "/tSite/addSite" ,
|
type: "POST",
|
data: JSON.stringify(data),
|
contentType: "application/json",
|
success: function (response) {
|
window.parent.Vip.table.refresh();
|
Vip.close();
|
Feng.success("添加成功");
|
},
|
error: function (xhr, status, error) {
|
Feng.error("添加失败!" + error);
|
}
|
});
|
},
|
error: function (xhr, status, error) {
|
var errorMessage = xhr.responseText ? xhr.responseText : "上架失败!";
|
Feng.error("您的网络异常!");
|
return false;
|
}
|
});
|
};
|
|
Vip.search = function () {
|
var queryData = {};
|
queryData['vipName'] = $("#vipName").val();
|
queryData['status'] = $("#status").val();
|
Vip.table.refresh({query: queryData});
|
};
|
|
Vip.resetSearch = function () {
|
$("#vipName").val("");
|
$("#status").val("");
|
Vip.search();
|
};
|
|
function UploadFileFn(){
|
$('#upFile').click();
|
}
|
|
$(function () {
|
var defaultColunms = Vip.initColumn();
|
var table = new BSTable(Vip.id, "/vip/list", defaultColunms);
|
table.setPaginationType("client");
|
Vip.table = table.init();
|
});
|