var httpData;
var pagesize = 10;
var tttHTML = '';
window.onload = function() {
tttHTML = document.getElementById("tableOrder").innerHTML;
var cur = "";
var currpage = getPar('currpage');
var timelimit = '';
var starttime = '';
var endtime = '';
var ordersource = '';
var moresearch = '';
var typelimit = '';
var ordersource_text = '';
if(!currpage) {
cur = 1;
$('#starttime').val(getDateTime(12));
$('#endtime').val(getDateTime(13));
}else{
cur = currpage;
timelimit = getPar('timelimit');
$('#timelimit').val(timelimit);
starttime = getPar('starttime');
$('#starttime').val(starttime);
endtime = getPar('endtime');
$('#endtime').val(endtime);
ordersource = getPar('ordersource');
$('#ordersource').attr('changeid',ordersource);
ordersource_text = getPar('ordersource_text');
$('#ordersource').val(ordersource_text);
moresearch = getPar('moresearch');
$('#moresearch').val(moresearch);
typelimit = getPar('typelimit');
$('#typelimit').val(typelimit);
}
searchBtnClicked(cur,timelimit,starttime,endtime,ordersource,moresearch,typelimit,ordersource_text);
}
function ordersourceSearch(value,self_id){
var ordersource = $("#ordersource").val();
$.ajax({
url:'./st-xm/control.php',
type: "post",
data: {
ordersource:ordersource,
type:"des_ordersource"
},
dataType: "json",
success: function (data) {
if(data.code == 0){
console.log(data);
createHtml(data.list,self_id)
}
},
fail: function (data) {
// 此处放失败后执行的代码
}
});
}
$(document).ready(function(){
$("#ordersource").click(function(e){
e.stopPropagation();
$("#select_ordersource").removeClass("hide1");
});
})
$(document).click(function(){
if(!$(".select_ordersource").hasClass("hide1")){
$(".select_ordersource").addClass("hide1");
}
})
//筛选列表
function createHtml(data,select_id){
var temp ='
所有渠道
';
for (var i = 0; i < data.length; i++) {
temp +=''+data[i].org_name+'
'
}
$(".select_ordersource").html(temp);
$(".content").click(function(){
var line = $(this).text();
var value = $(this).attr('org_id');
$("#"+select_id).val(line);
$("#"+select_id).attr('changeid',value);
})
}
function getDark(value){
$('#'+value).addClass("get_dark");
}
function getLight(value){
$('#'+value).removeClass("get_dark");
}
//查询按钮
function searchBtnClicked(cur,timelimit,starttime,endtime,ordersource,moresearch,typelimit,ordersource_text){
if(!cur){
cur = 1;
}
if(!timelimit||!starttime||!endtime||!ordersource||!moresearch||!typelimit){
timelimit = $('#timelimit').val();
starttime = $('#starttime').val();
endtime = $('#endtime').val();
ordersource = $('#ordersource').attr('changeid');
ordersource_text = $('#ordersource').val();
if(!ordersource){
ordersource = -1;
}
moresearch = $('#moresearch').val();
if(!moresearch){
moresearch = "";
}
typelimit = $('#typelimit').val();
}
$.ajax({
url:'./st-xm/control.php', //请求地址
type: "post", //请求方式
//data: data, //请求参数
data:{
type:"des_orderlist",
timelimit:timelimit,
starttime:starttime,
endtime:endtime,
ordersource:ordersource,
moresearch:moresearch,
typelimit:typelimit,
currpage:cur,
pagesize:pagesize
},
async:false,
dataType: "json",
success: function (data) {
console.log(data);
if(data.code == 0){
var sum = data.totalTickets;
var tag = "page";
var sendurl = './des_order_list.html?timelimit='+timelimit+'&starttime='+starttime+'&endtime='+endtime+'&ordersource='+ordersource+'&moresearch='+moresearch+'&typelimit='+typelimit+'&ordersource_text='+ordersource_text;
getPager(sendurl, sum, cur, pagesize,tag,'currpage');
$('#sum').html('共'+data.list_count+'条记录');
if(data.orderList.length > 0){
var temp = '';
$("#tableOrder").html('');
for (var i = 0; i < data.orderList.length; i++){
var ifzhouzhuang = data.orderList[i].ifzhouzhuang;
var str ="";
if (ifzhouzhuang == 0) {
str='-';
}else if(ifzhouzhuang == 1){
str = '退票';
}
temp += ''
+ ''+data.orderList[i].order_id+' | '
+ ''+data.orderList[i].create_time+' | '
+ ''+data.orderList[i].org_name+' | '
+ ''+data.orderList[i].outside_order_no+' | '
+ ''+data.orderList[i].product_info+' | '
+ ''+data.orderList[i].run_time+' | '
+ ''+data.orderList[i].customer_info+' | '
+ ''+data.orderList[i].order_status+' | '
+ ''+data.orderList[i].customer_memo+' | '
+ ''+str+' | '
+ '
'
}
}else{
}
$("#tableOrder").html(temp);
}else{
$("#tableOrder").html('');
$('#sum').html('共'+data.list_count+'条记录');
var sum = 0;
var tag = "page";
var sendurl = './des_order_list.html?timelimit='+timelimit+'&starttime='+starttime+'&endtime='+endtime+'&ordersource='+ordersource+'&moresearch='+moresearch+'&typelimit='+typelimit+'&ordersource_text='+ordersource_text;
getPager(sendurl, sum, cur, pagesize,tag,'currpage');
}
},
fail: function (data) {
}
});
if(cur!=1){
var cur = cur;
timelimit = getPar('timelimit');
$('#timelimit').val(timelimit);
var starttime = getPar('starttime');
$('#starttime').val(starttime);
var endtime = getPar('endtime');
$('#endtime').val(endtime);
var ordersource = getPar('ordersource');
$('#ordersource').attr('changeid',ordersource);
var ordersource_text = getPar('ordersource_text');
$('#ordersource').val(ordersource_text);
var moresearch = getPar('moresearch');
$('#moresearch').val(moresearch);
var typelimit = getPar('typelimit');
$('#typelimit').val(typelimit);
}
}
function refundTicket(order_id){
alert(order_id);
var result =confirm("是否决定退票?");
if(result ==true)
{
$.ajax({
url:'./zz-fx/Model/cancelzhoutickets.php', //请求地址
type: "post", //请求方式
data:{
order_id:order_id,
method:1
},
async:true,
dataType: "json",
success: function (data) {
console.log(data);
if(data.code == 0){
alert('退票成功!');
$('#caozuo'+order_id).html('-');
}else{
alert(data.info);
}
}
});
}
else
{
return;
}
}
function getDateTime(nTypeFlag) {
var tNowTime = new Date();
var myYear = ';' + tNowTime.getFullYear() + ';';
var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';';
var myDay = ';' + tNowTime.getDate() + ';';
var myHour = ';' + tNowTime.getHours() + ';';
var myMinu = ';' + tNowTime.getMinutes() + ';';
var mySecond = ';' + tNowTime.getSeconds() + ';';
if(myMonth.length < 4) myMonth = '0' + myMonth;
if(myDay.length < 4) myDay = '0' + myDay;
if(myHour.length < 4) myHour = '0' + myHour;
if(myMinu.length < 4) myMinu = '0' + myMinu;
if(mySecond.length < 4) mySecond = '0' + mySecond;
var cNewTimeStr;
//alert(tNowTime);
switch(nTypeFlag + 1 - 1) {
case 0:
cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
break;
case 1:
cNewTimeStr = myYear + myMonth + myDay;
break;
case 2:
cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
break;
case 3:
cNewTimeStr = myHour + myMinu + mySecond;
break;
case 4:
cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
break;
case 5:
cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
break;
case 6:
cNewTimeStr = myYear;
break;
case 7:
cNewTimeStr = myYear + '-' + myMonth;
break;
case 8: //得到上一个月的今天
var date = getDateTime(0);
var arr = date.split('-');
var year = arr[0]; //获取当前日期的年份
var month = arr[1]; //获取当前日期的月份
var day = arr[2]; //获取当前日期的日
var days = new Date(year, month, 0);
days = days.getDate(); //获取当前日期中月的天数
var year2 = year;
var month2 = parseInt(month) - 1;
if(month2 == 0) {
year2 = parseInt(year2) - 1;
month2 = 12;
}
var day2 = day;
var days2 = new Date(year2, month2, 0);
days2 = days2.getDate();
if(day2 > days2) {
day2 = days2;
}
if(month2 < 10) {
month2 = '0' + month2;
}
cNewTimeStr = year2 + '-' + month2 + '-' + day2;
break;
case 9: //得到下一个月的今天
var date = getDateTime(0);
var arr = date.split('-');
var year = arr[0]; //获取当前日期的年份
var month = arr[1]; //获取当前日期的月份
var day = arr[2]; //获取当前日期的日
var days = new Date(year, month, 0);
days = days.getDate(); //获取当前日期中的月的天数
var year2 = year;
var month2 = parseInt(month) + 1;
if(month2 == 13) {
year2 = parseInt(year2) + 1;
month2 = 1;
}
var day2 = day;
var days2 = new Date(year2, month2, 0);
days2 = days2.getDate();
if(day2 > days2) {
day2 = days2;
}
if(month2 < 10) {
month2 = '0' + month2;
}
var t2 = year2 + '-' + month2 + '-' + day2;
return t2;
break;
default:
cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
break;
case 12: //本周起始日期
return getWeekStartDate()
function getWeekStartDate() {
var now = new Date(); //当前日期
var nowDayOfWeek = now.getDay(); //今天本周的第几天
var nowDay = now.getDate(); //当前日
var nowMonth = now.getMonth(); //当前月
var nowYear = now.getYear(); //当前年
nowYear += (nowYear < 2000) ? 1900 : 0; //
var lastMonthDate = new Date(); //上月日期
lastMonthDate.setDate(1);
lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
var lastYear = lastMonthDate.getYear();
var lastMonth = lastMonthDate.getMonth();
var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek);
return formatDate(weekStartDate);
}
break;
case 13: //本周结束日期
return getWeekEndDate()
function getWeekEndDate() {
var now = new Date(); //当前日期
var nowDayOfWeek = now.getDay(); //今天本周的第几天
var nowDay = now.getDate(); //当前日
var nowMonth = now.getMonth(); //当前月
var nowYear = now.getYear(); //当前年
nowYear += (nowYear < 2000) ? 1900 : 0; //
var lastMonthDate = new Date(); //上月日期
lastMonthDate.setDate(1);
lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
var lastYear = lastMonthDate.getYear();
var lastMonth = lastMonthDate.getMonth();
var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek));
return formatDate(weekEndDate);
}
break;
case 14: //本月开始日期
return getMonthStartDate()
function getMonthStartDate() {
var now = new Date(); //当前日期
var nowDayOfWeek = now.getDay(); //今天本周的第几天
var nowDay = now.getDate(); //当前日
var nowMonth = now.getMonth(); //当前月
var nowYear = now.getYear(); //当前年
nowYear += (nowYear < 2000) ? 1900 : 0; //
var lastMonthDate = new Date(); //上月日期
lastMonthDate.setDate(1);
lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
var lastYear = lastMonthDate.getYear();
var lastMonth = lastMonthDate.getMonth();
var monthStartDate = new Date(nowYear, nowMonth, 1);
return formatDate(monthStartDate);
}
break;
}
cNewTimeStr = cNewTimeStr.replace(/;/g, "");
return cNewTimeStr;
}
function getPar(par) {
//获取当前URL
var local_url = document.location.href;
local_url = decodeURI(local_url);
//获取要取得的get参数位置
var get = local_url.indexOf(par + "=");
if(get == -1) {
return "";
}
//截取字符串
var get_par = local_url.slice(par.length + get + 1);
//判断截取后的字符串是否还有其他get参数
var nextPar = get_par.indexOf("&");
if(nextPar != -1) {
get_par = get_par.slice(0, nextPar);
}
return get_par;
}
//获取当前时间
function CurrentTime() {
var now = new Date();
var year = now.getFullYear(); //年
var month = now.getMonth() + 1; //月
var day = now.getDate(); //日
var hh = now.getHours(); //时
var mm = now.getMinutes(); //分
var ss = now.getSeconds(); //秒
var clock = year + "-";
if (month < 10)
clock += "0";
clock += month + "-";
if (day < 10)
clock += "0";
clock += day + " ";
if (hh < 10)
clock += "0";
clock += hh + ":";
if (mm < 10) clock += '0';
clock += mm + ":";
if (ss < 10) clock += '0';
clock += ss;
return (clock);
}