var page_size = 10;
var list_HTML = '';
$(document).ready(function() {
list_HTML = $('#order_list').html();
var or_fr_url = "./st-xm/Api/disney_get_org_list.php";
get_order_from(or_fr_url); //订单源
var cur_page = getPar('cur_page');
if (!cur_page) {
click_search();
} else {
var order_id = getPar('search_order_no');
var pay_order_id = getPar('search_pay_no');
var order_from = getPar('search_org_id');
var start_date = getPar('search_create_date');
var us_name = getPar('search_cus_name');
var us_mobile = getPar('search_cus_mobile');
$('#order_id').val(order_id);
$('#pay_order_id').val(pay_order_id);
$('#id-date-picker-1').val(start_date);
$('#order_from').val(order_from);
$('#us_name').val(us_name);
$('#us_mobile').val(us_mobile);
var URL1 = './st-xm/Api/disney_get_order_list.php?cur_page=' + cur_page + '&page_size=10&search_order_no=' + order_id +
"&search_pay_no=" + pay_order_id +
"&search_org_id=" + order_from +
"&search_create_date=" + start_date +
"&search_cus_name=" + us_name +
"&search_cus_mobile=" + us_mobile;
var URL2 = './distribution_order_list.html?page_size=10&search_order_no=' + order_id +
"&search_pay_no=" + pay_order_id +
"&search_org_id=" + order_from +
"&search_create_date=" + start_date +
"&search_cus_name=" + us_name +
"&search_cus_mobile=" + us_mobile;
get_order_list(URL1, URL2)
}
});
//订单源
function get_order_from(URL) {
var or_from_HTML = '';
$.getJSON(URL, function(res_data) {
var HTML = or_from_HTML;
for (var i = 0, m = res_data.length; i < m; i++) {
var tempHTML = or_from_HTML;
tempHTML = tempHTML.replace('0', res_data[i]['org_id']);
tempHTML = tempHTML.replace('请选择', res_data[i]['org_name']);
HTML += tempHTML;
}
$('#order_from').html(HTML);
});
}
//表格list
function get_order_list(URL1, URL2) {
$.getJSON(URL1, function(res_data) {
if (!res_data) {
alert("出现问题,自己查找!!!");
}
var order_list = res_data['order_list'];
var HTML = '';
for (var i = 0, m = order_list.length; i < m; i++) {
var dict = order_list[i];
var tempHTML = list_HTML;
tempHTML = tempHTML.replace('[订单编号]', dict['order_serial_no']);
if( dict['prod_id'] == 1 ) {
tempHTML = tempHTML.replace('[订单内容]', dict['prod_name'] + "
" + dict['start_day'] + " " + dict['start_time'] + " ~ " + dict['end_day'] + " " + dict['end_time'] );
} else if( dict['prod_id'] == 2 ){
var disp_prod = dict['prod_name'] + "
" + dict['start_day'] + " " + dict['start_time'] + " ~ " + dict['end_day'] + " " + dict['end_time'];
if( dict['start_day2'].length > 0 ) {
disp_prod = disp_prod + "
" + dict['start_day2'] + " " + dict['start_time2'] + " ~ " + dict['end_day2'] + " " + dict['end_time2'];
}
tempHTML = tempHTML.replace('[订单内容]', disp_prod );
} else if( dict['prod_id'] >= 9 && dict['prod_id'] <= 15) {
tempHTML = tempHTML.replace('[订单内容]', dict['prod_name'] + "
" + dict['start_day'] + " " + dict['start_time'] );
}else {
tempHTML = tempHTML.replace('[订单内容]', dict['prod_name'] + "
" + dict['start_day'] );
}
tempHTML = tempHTML.replace('[订单金额]', dict['order_price']);
tempHTML = tempHTML.replace('[订单源]', dict['org_name']);
tempHTML = tempHTML.replace('[下单时间]', dict['create_time']);
var payinfo = dict['pay_status'].replace('[br /]', '
')
tempHTML = tempHTML.replace('[支付信息]', payinfo);
var userinfo = dict['cus_name'] + "
" + dict['cus_mobile'] + "
" + dict['cus_iden'];
tempHTML = tempHTML.replace('[用户信息]', userinfo);
tempHTML = tempHTML.replace('[textarea-value]', dict['comment']);
tempHTML = tempHTML.replace('[comment]', 'comment_' + dict['id']);
tempHTML = tempHTML.replace('[param1]', dict['id']);
tempHTML = tempHTML.replace('[param2]', dict['order_serial_no']);
HTML += tempHTML;
}
if (HTML) {
$('#order_list').html(HTML);
var currpage = getPar("cur_page");
if (!currpage) {
currpage = 1
}
var sum = parseInt(res_data['total_page'] * 10);
var size = page_size;
var tag = "test";
getPager(URL2, sum, currpage, size, tag, 'cur_page');
} else {
$('#order_list').html("");
$('#test').html("");
}
});
}
//点击搜索
function click_search() {
var order_id = $('#order_id').val();
var pay_order_id = $('#pay_order_id').val();
var start_date = $('#id-date-picker-1').val();
var order_from = $('#order_from').val();
var us_name = $('#us_name').val();
var us_mobile = $('#us_mobile').val();
var url = './st-xm/Api/disney_get_order_list.php?cur_page=1&page_size=10&search_order_no=' + order_id +
"&search_pay_no=" + pay_order_id +
"&search_org_id=" + order_from +
"&search_create_date=" + start_date +
"&search_cus_name=" + us_name +
"&search_cus_mobile=" + us_mobile;
var URL2 = './distribution_order_list.html?page_size=10&search_order_no=' + order_id +
"&search_pay_no=" + pay_order_id +
"&search_org_id=" + order_from +
"&search_create_date=" + start_date +
"&search_cus_name=" + us_name +
"&search_cus_mobile=" + us_mobile;
get_order_list(url, URL2);
}
function update_order_comment(index,order_serial_no) {
var comment_id = "comment_" + index;
var comment_txt = document.getElementById(comment_id).value;
comment_txt=encodeURI(encodeURI(comment_txt));
if (window.ActiveXObject) {
var request = new ActiveXObject("Microsoft.XMLHTTP");
} else {
var request = new XMLHttpRequest();
}
// var url = "http://wx.zhizhuchuxing.com/update_order_comment.php?odr=" + order_serial_no;
var url = "./st-xm/Api/disney_update_org_comment.php?odr=" + index+"&odc="+comment_txt;
console.log(url);
var postData = "";
postData = "odc=" + comment_txt;
request.open("POST", url, true);
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.onreadystatechange = function() {
if (request.readyState == 4 && request.status == 200) {
if (request.responseText == '0') {
} else {
}
}
}
// request.send(postData);
request.send(postData);
}
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;
}