|
- var httpData;
- var bakData;
- if (window.ActiveXObject) {
- var myreq = new ActiveXObject("Microsoft.XMLHTTP");
- } else {
- var myreq = new XMLHttpRequest();
- }
- var id = '';
- var run_id = '';
- var tableText = '';
- var numText = '';
- window.onload = function() {
- id = getPar("id");
- run_id = getPar("run_id");
- tableText = document.getElementById("tableInfo").innerHTML;
- numText = document.getElementById("number_select").innerHTML;
- if (id) {
- var tnowtime = getDateTime(4);
- //var myURL = "./test_html/create.html?tt=" + tnowtime+"&id"+id;
- var myURL = "./st-xm/Api/createOrderContrill.php?method=getTicketInfo&tt=" + tnowtime + "&user_id=" + id + "&run_id=" + run_id;
- method(myURL);
- } else {}
- }
-
- function method(myURL) {
- $.getJSON(myURL,function(res_data){
- httpData=res_data;
- console.log(myURL);
- console.log(httpData);
- bakData = httpData;
- var code = httpData.code;
- if (code == '0') {
- document.getElementById("line").innerText = httpData.line;
- //出发下拉框
- var startArea = document.getElementById("startArea");
- var newHtml = '';
- for (var i = 0; i < httpData.stratArea.length; i++) {
- var source = startArea.innerHTML;
- if (i != 0) {
- source = source.replace('selected="selected"', '');
- }
- source = source.replace('0', i);
- source = source.replace('startArea', httpData.stratArea[i].area + "(" + httpData.stratArea[i].start_time + ")");
- newHtml += source;
- }
- startArea.innerHTML = newHtml;
- //到达下拉框
- var endArea = document.getElementById("endArea");
- newHtml = '';
- for (var i = 0; i < httpData.endArea.length; i++) {
- var source = endArea.innerHTML;
- if (i != 0) {
- source = source.replace('selected="selected"', '');
- }
- source = source.replace('0', i);
- source = source.replace('endArea', httpData.endArea[i].area + "(" + httpData.endArea[i].start_time + ")");
- newHtml += source;
- }
- endArea.innerHTML = newHtml;
- //表格
- tableInfo = document.getElementById("tableInfo");
- newHtml = ""
- for (var i = 0; i < httpData.tickets.length; i++) {
- var source = tableText;
- source = source.replace('座位', httpData.tickets[i].seat);
- source = source.replace('人群', httpData.tickets[i].crowd);
- source = source.replace('价格', httpData.tickets[i].price);
- //source = source.replace('库存', httpData.tickets[i].stock);
- httpData.tickets[i].stock = 5;
- source = source.replace('number_select', "ticket_" + httpData.tickets[i].id);
- if (httpData.tickets[i].stock > 0) {
- var s = numText;
- s = s.replace('default', 0);
- s = s.replace('num', 0);
- for (var j = 0; j < httpData.tickets[i].stock; j++) {
- var bak = numText;
- bak = bak.replace('selected="selected"', '');
- bak = bak.replace('default', j + 1);
- bak = bak.replace('num', j + 1);
- s = s + bak;
- }
- if (s) {
- source = source.replace(numText, s);
- }
- } else {
- source = source.replace(numText, '');
- }
- newHtml += source;
- }
- tableInfo.innerHTML = newHtml;
- //订单来源下拉框
-
- var orderSource = document.getElementById("orderSource");
- $.getJSON('./st-xm/Api/createOrderContrill.php?method=orderChannel',function(res_data){
- var HTML='<option value="-2" selected="selected" style="font-size: 12px;">请选择</option>';
- for (var i = 0,m=res_data.orderSource.length;i<m;i++) {
- var source = '<option value="'+res_data.orderSource[i].org_id+'" style="font-size: 12px;">'+res_data.orderSource[i].soure+'</option>';
- HTML+=source;
- }
- orderSource.innerHTML=HTML;
- });
- } else {
- alert(httpData.info);
- return;
- }
- });
- }
-
- 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 false;
- }
- //截取字符串
- 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 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;
- default:
- cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
- break;
- }
-
- cNewTimeStr = cNewTimeStr.replace(/;/g, "");
-
- return cNewTimeStr;
-
- }
-
- $(document).ready(function() {
- var username = false;
- $("#username").on("blur", function() {
- if (/^[\u4e00-\u9fa5\w\s]+$/.test(this.value)) {
- $("#nameinfo").html("");
- username = true;
- } else {
- $("#nameinfo").html("*请输入正确的用户名");
- username = false;
- }
- });
- var usernum = false;
- $("#usernum").on("blur", function() {
- if (/^1[\d]{10}$/.test(this.value)) {
- $("#numinfo").html("");
- usernum = true;
- } else {
- $("#numinfo").html("*请输入正确的手机号码");
- usernum = false;
- }
- })
- var userid = false;
- $("#userid").on("blur", function() {
- if (/^[\d]{17}[xX0-9]$/.test(this.value)) {
- $("#idinfo").html("");
- userid = true;
- } else {
- $("#idinfo").html("*请输入正确的身份证号码");
- userid = false;
- }
- })
- var channelNum=false;
- $('#channelNum').on("blur",function(){
- var ch_num=$('#channelNum').val();
- if(ch_num.trim().length>0){
- $("#channel_num_info").html
- channelNum=true;
- }else{
- $("#channel_num_info").html("*请输入正确的渠道订单号");
- channelNum=false;
- }
- })
- $("#usersubmit").on("click", function() {
- if (username && usernum && userid && channelNum) {
-
- if($('#orderSource').val()=="-2"){
- $('#order_source').html('*请选择订单渠道');
- return;
- }
-
- var userName = document.getElementById("username").value;
- var userNum = document.getElementById("usernum").value;
- var userId = document.getElementById("userid").value;
- //alert(userName+"-"+userNum+"-"+userId);
- var start = parseInt(document.getElementById("startArea").value);
- var stratArea = bakData.stratArea[start].area;
- var stratTime = bakData.stratArea[start].start_time;
- var end = parseInt(document.getElementById("endArea").value);
- var endArea = bakData.endArea[end].area;
- var endTime = bakData.endArea[end].start_time;
-
- //订单渠道
- //...
- var order_from_org_id=$('#orderSource').val();
- var outside_order_id=$('#channelNum').val();
-
- var ticketText = '';
- for (var i = 0; i < bakData.tickets.length; i++) {
- var num = parseInt($("#ticket_" + bakData.tickets[i].id).val());
- if (num > 0) {
- if (ticketText) {
- var s = "{m" + bakData.tickets[i].prod_id + "p" + num + "|r" + run_id + "}";
- ticketText += s;
- } else {
- var s = "{m" + bakData.tickets[i].prod_id + "p" + num + "|r" + run_id + "}";
- ticketText += s;
- }
- }
- }
- var para_customer_info = "," + userName + ",1," + userNum + ",150," + userId + ",,,,";
-
- var myURL = "./st-xm/Api/add_new_order.php?prod=" + ticketText + "&customer={" + para_customer_info + "}&order_from_org_id="+order_from_org_id+"&outside_order_id="+outside_order_id;
- if (ticketText) {
- $.getJSON(myURL, function(res_data) {
- console.log(myURL);
- console.log(res_data);
- if (res_data["errcode"] != 0) {
- alert(res_data["errinfo"]);
- return;
- } else {
- var listURL = "./order_list.html";
- // 跳转前将URL编码
- listURL = encodeURI(listURL);
- window.location.href = listURL;
- var listURL = "./order_list.html";
- // 跳转前将URL编码
- listURL = encodeURI(listURL);
- window.location.href = listURL;
- }
- });
- } else {
- alert("请选择票种");
- return;
- }
-
-
-
- } else {
- if (username == false) {
- $("#usernum").blur();
- $("#userid").blur();
- $("#username").blur();
- $("#username").focus();
- } else if (usernum == false) {
- $("#usernum").blur();
- $("#userid").blur();
- $("#username").blur();
- $("#usernum").focus();
- } else if (userid == false) {
- $("#usernum").blur();
- $("#userid").blur();
- $("#username").blur();
- $("#userid").focus();
- } else {}
-
- }
- })
- })
|