/**
|
* 跨城站点管理管理初始化
|
*/
|
var TSite = {
|
id: "TSiteTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1,
|
picture:"",
|
fileUrl:"",
|
img:"",
|
plan:"",
|
goodsPicArray:[],
|
validateFields: {
|
}
|
};
|
var objectType =$("#objectType").val()
|
/**
|
* 初始化表格的列
|
*/
|
TSite.initColumn = function () {
|
return [
|
{field: 'selectItem', checkbox: true},
|
{title: '主键id', field: 'id', visible: false, align: 'center', valign: 'middle'},
|
{title: '闸机名称', field: 'name', visible: true, align: 'center', valign: 'middle',width:'20%'},
|
{title: '硬件编号', field: 'device', visible: true, align: 'center', valign: 'middle'},
|
{title: '所属运营商', field: 'operatorName', visible: true, align: 'center', valign: 'middle'},
|
{title: '所属门店', field: 'storeName', visible: true, align: 'center', valign: 'middle',},
|
{title: '所属场地', field: 'siteName', visible: true, align: 'center', valign: 'middle',},
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
TSite.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
TSite.seItem = selected[0];
|
return true;
|
}
|
};
|
/**
|
* 上架
|
*/
|
TSite.onShelf = function () {
|
if (this.check()){
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
const data1 = {
|
ids:[],
|
state:null
|
};
|
selected.forEach(function(obj) {
|
var id = obj.id;
|
data1.ids.push(id);
|
});
|
data1.state = 1;
|
$.ajax({
|
url: Feng.ctxPath + "/advertisement/changeState",
|
type: "POST",
|
contentType: "application/json", // 设置请求头的 Content-Type
|
data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
|
success: function(response) {
|
Feng.success("上架成功!");
|
TSite.search();
|
},
|
error: function(xhr, status, error) {
|
var errorMessage = xhr.responseText ? xhr.responseText : "上架失败!";
|
Feng.error("您的网络异常!");
|
}
|
});
|
}
|
};
|
|
/**
|
* 下架
|
*/
|
TSite.offShelf = function () {
|
if (this.check()){
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
const data1 = {
|
ids:[],
|
state:null
|
};
|
selected.forEach(function(obj) {
|
var id = obj.id;
|
data1.ids.push(id);
|
});
|
data1.state = 2;
|
$.ajax({
|
url: Feng.ctxPath + "/advertisement/changeState",
|
type: "POST",
|
contentType: "application/json", // 设置请求头的 Content-Type
|
data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
|
success: function(response) {
|
Feng.success("下架成功!");
|
TSite.search();
|
},
|
error: function(xhr, status, error) {
|
var errorMessage = xhr.responseText ? xhr.responseText : "下架失败!";
|
}
|
});
|
}
|
};
|
|
/**
|
* 跳转添加广告页面
|
*/
|
TSite.openAddTSite = function () {
|
var index = layer.open({
|
type: 2,
|
title: "添加广告",
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/gate/add'
|
});
|
this.layerIndex = index;
|
};
|
/**
|
* 跳转基础页面配置
|
*/
|
TSite.basic = function () {
|
var index = layer.open({
|
type: 2,
|
title: "基础页面配置",
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/gate/config'
|
});
|
this.layerIndex = index;
|
};
|
/**
|
* 跳转福利页面配置
|
*/
|
TSite.benefits = function () {
|
var index = layer.open({
|
type: 2,
|
title: "福利页面配置",
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/advertisement/benefits'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开查看详情页面
|
*/
|
TSite.openInfo = 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 + '/advertisement/update/' + TSite.seItem.id+'/1'
|
});
|
this.layerIndex = index;
|
}
|
}
|
};
|
/**
|
* 跳转编辑页面
|
*/
|
TSite.openEditTSite = 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 + '/gate/update/' + TSite.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
}
|
};
|
|
/**
|
* 关闭此对话框
|
*/
|
TSite.close = function() {
|
parent.layer.close(window.parent.TSite.layerIndex);
|
};
|
TSite.oneChange = function () {
|
var modelId = $('#model option:selected').val();
|
var pageSelect = document.getElementById("page");
|
var typeSelect = document.getElementById("type");
|
var ajax = new $ax(Feng.ctxPath + "/tSite/getCity", function(data){
|
if(data!=null){
|
var content='<option value="">选择跳转页面</option>';
|
$.each(data, function(k,v) {
|
content += "<option value='"+v.id+"'>"+v.name+"</option>";
|
});
|
$("#cCode").empty().append(content);
|
}
|
});
|
if (modelId === ""){
|
pageSelect.innerHTML = '<option value="">请先选择跳转模块</option>';
|
typeSelect.innerHTML = '<option value="">请先选择跳转模块</option>';
|
}
|
ajax.set("province",province);
|
ajax.start();
|
};
|
TSite.addConfig = function(){
|
$("#cover1").val();
|
$("#cover2").val();
|
$("#cover7").val();
|
var ajax = new $ax(Feng.ctxPath + "/advertisement/updateConfig", function (data) {
|
Feng.success("基础页面设置成功")
|
});
|
ajax.set("p1",$("#cover1").val())
|
ajax.set("p2",$("#cover2").val())
|
ajax.set("p7",$("#cover7").val())
|
ajax.start();
|
}
|
TSite.addBenefits = function(){
|
$("#cover3").val();
|
$("#cover4").val();
|
$("#cover5").val();
|
$("#cover6").val();
|
var ajax = new $ax(Feng.ctxPath + "/advertisement/updateBenefits", function (data) {
|
Feng.success("基础页面设置成功")
|
});
|
ajax.set("p3",$("#cover3").val())
|
ajax.set("p4",$("#cover4").val())
|
ajax.set("p5",$("#cover5").val())
|
ajax.set("p6",$("#cover6").val())
|
ajax.start();
|
}
|
TSite.delete = function () {
|
if (this.check()) {
|
let id = this.seItem.id
|
var operation = function(){
|
var ajax = new $ax(Feng.ctxPath + "/gate/deleteDevice", function (data) {
|
if (data.code!=200){
|
Feng.error(data.msg)
|
return
|
}else{
|
TSite.resetSearch();
|
Feng.success("删除成功")
|
}
|
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("gateId",id);
|
ajax.start();
|
}
|
Feng.confirm("确认删除该闸机?", operation);
|
}
|
};
|
|
TSite.addSubmit = function(){
|
var data1 = {
|
id:null,
|
position:null,
|
img:"",
|
jumpPage:null,
|
sort:null,
|
state:1,
|
name:"",
|
type:"",
|
page:"",
|
model:null,
|
typeId:null,
|
turnId:null,
|
};
|
let name = $("#model").val();
|
data1.name = $("#name").val();
|
data1.position = $("#position").val();
|
data1.img = $("#img").val();
|
data1.model = $('#model option:selected').text();
|
data1.page = $('#page option:selected').text();
|
data1.jumpPage = $("#page").val();
|
data1.typeId = $("#type").val();
|
data1.type = $('#type option:selected').text();
|
data1.turnId = $("#pageId").val();
|
data1.sort = $("#sort").val();
|
|
if ( $("#roleType").val()==1){
|
if($("#position").val()==''){
|
data1.position = $("#position").val();
|
Feng.info("请选择广告类型")
|
return;
|
}
|
}
|
if($("#name").val()==''){
|
|
Feng.info("请输入广告名称")
|
return;
|
}
|
if($("#img").val()=='' ){
|
Feng.info("请上传广告图片")
|
return;
|
}
|
if ( $("#roleType").val()==1) {
|
if ($("#model").val() == '') {
|
Feng.info("请选择跳转模块")
|
return;
|
}
|
}
|
if(name !='0'){
|
if($("#page").val()=='' ){
|
Feng.info("请选择跳转页面")
|
return;
|
}
|
}
|
console.log("====pagepagepage==============="+$("#page").val())
|
if(name !='0'){
|
if ($("#type").val() == ''&&$("#page").val()!=2&&$("#page").val()!=25&&$("#page").val()!=27&&$("#page").val()!=37&&$("#page").val()!=28) {
|
Feng.info("请选择跳转类型")
|
return;
|
}
|
|
}
|
if(name !='0') {
|
if ($("#roleType").val() == 1) {
|
if ($('#type option:selected').text() == "详情"&&$('#type option:selected').text() == "指定商品"&&$('#type option:selected').text() == "指定折扣") {
|
if ($("#pageId").val() == '') {
|
Feng.info("请输入跳转ID")
|
return;
|
}
|
}
|
}
|
}
|
if($("#sort").val()=='' ){
|
Feng.info("请输入排序")
|
return;
|
}
|
$.ajax({
|
url: Feng.ctxPath + "/advertisement/addAdvertisement",
|
type: "POST",
|
contentType: "application/json", // 设置请求头的 Content-Type
|
data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
|
success: function(response) {
|
window.parent.TSite.table.refresh();
|
TSite.close();
|
Feng.success("添加成功!");
|
},
|
error: function(xhr, status, error) {
|
var errorMessage = xhr.responseText ? xhr.responseText : "下架失败!";
|
Feng.error("您的网络异常!");
|
}
|
});
|
};
|
|
|
TSite.updateSubmit = function(){
|
|
console.log("kankan")
|
console.log($("#img").val())
|
var data1 = {
|
id:null,
|
position:null,
|
img:"",
|
jumpPage:null,
|
sort:null,
|
state:1,
|
name:"",
|
type:"",
|
page:"",
|
model:null,
|
typeId:null,
|
turnId:null,
|
};
|
let name = $("#model").val();
|
data1.name = $("#name").val();
|
data1.id = $("#id").val();
|
data1.position = $("#position").val();
|
data1.img = $("#img").val();
|
data1.model = $('#model option:selected').text();
|
data1.page = $('#page option:selected').text();
|
data1.jumpPage = $("#page").val();
|
data1.typeId = $("#type").val();
|
data1.type = $('#type option:selected').text();
|
data1.turnId = $("#pageId").val();
|
data1.sort = $("#sort").val();
|
|
if ( $("#roleType").val()==1){
|
if($("#position").val()==''){
|
data1.position = $("#position").val();
|
Feng.info("请选择广告类型")
|
return;
|
}
|
}
|
if($("#name").val()==''){
|
Feng.info("请输入广告名称")
|
return;
|
}
|
|
if ( $("#roleType").val()==1) {
|
if ($("#model").val() == '') {
|
Feng.info("请选择跳转模块")
|
return;
|
}
|
}
|
if(name !='0'){
|
if($("#page").val()=='' ){
|
Feng.info("请选择跳转页面")
|
return;
|
}
|
}
|
if(name !='0') {
|
if ($("#roleType").val() == 1) {
|
if ($("#type").val() == ''&&$("#page").val()!=2&&$("#page").val()!=25&&$("#page").val()!=27&&$("#page").val()!=37&&$("#page").val()!=28) {
|
Feng.info("请选择跳转类型")
|
return;
|
}
|
}
|
}
|
if(name !='0') {
|
if ($("#roleType").val() == 1) {
|
if ($('#type option:selected').text() == "详情"&&$('#type option:selected').text() == "指定商品"&&$('#type option:selected').text() == "指定折扣") {
|
if ($("#pageId").val() == '') {
|
Feng.info("请输入跳转ID")
|
return;
|
}
|
}
|
}
|
}
|
if($("#sort").val()=='' ){
|
Feng.info("请输入排序")
|
return;
|
}
|
$.ajax({
|
url: Feng.ctxPath + "/advertisement/updateAdvertisement",
|
type: "POST",
|
contentType: "application/json", // 设置请求头的 Content-Type
|
data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
|
success: function(response) {
|
window.parent.TSite.table.refresh();
|
TSite.close();
|
Feng.success("添加成功!");
|
|
},
|
error: function(xhr, status, error) {
|
var errorMessage = xhr.responseText ? xhr.responseText : "下架失败!";
|
Feng.error("您的网络异常!");
|
}
|
});
|
};
|
|
TSite.search = function () {
|
var queryData = {};
|
// 广告名称
|
queryData['name'] = $("#name").val();
|
// 跳转页面
|
queryData['device'] = $("#device").val();
|
// 状态
|
queryData['operatorName'] = $("#operatorName").val();
|
queryData['storeName'] = $("#storeName").val();
|
TSite.table.refresh({query: queryData});
|
};
|
|
TSite.resetSearch = function () {
|
$("#name").val("");
|
$("#device").val("");
|
$("#operatorName").val("");
|
$("#storeName").val("");
|
TSite.search();
|
};
|
|
function UploadFileFn(){
|
$('#upFile').click();
|
}
|
|
$(function () {
|
var defaultColunms = TSite.initColumn();
|
var table = new BSTable(TSite.id, "/gate/listAll", defaultColunms);
|
table.setPaginationType("client");
|
TSite.table = table.init();
|
});
|