You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

815 lines
22 KiB

  1. //记录添加的信息
  2. var i = 0;
  3. //author:
  4. //update by : fuhc
  5. var order_from_id = "-1";
  6. var returnStartArea = ""
  7. var returnEndArea = "";
  8. //fancheng prod_id
  9. var back_prod_id = '';
  10. var back_run_id = ''; //返程run_id
  11. var checkedValue = ''; //是否是返程
  12. //
  13. var start_date = '';
  14. if(window.ActiveXObject) {
  15. var myreq = new ActiveXObject("Microsoft.XMLHTTP");
  16. } else {
  17. var myreq = new XMLHttpRequest();
  18. }
  19. var ticketArray = new Array();
  20. var m_runid = 0;
  21. function ZZLog(str){
  22. var isLog=true;
  23. if(isLog){
  24. console.log(str);
  25. }
  26. }
  27. $(document).ready(function(){
  28. id = getPar("id");
  29. var run_id = getPar("run_id");
  30. m_runid = run_id;
  31. start_date = getPar('run_date');
  32. $('#start_date').html(start_date);
  33. $('#id-date-picker-1').val(after(start_date));
  34. document.getElementById('tableInfo').innerHTML = '';
  35. var tnowtime = getDateTime(4);
  36. //var myURL = "./st-xm/Api/get_run_sale_ticket.php?tt=" + tnowtime + "&runid=" + run_id;
  37. $.ajax({
  38. url:'./st-xm/Api/get_run_sale_ticket.php', //请求地址
  39. type: "get", //请求方式
  40. data:{
  41. tt: tnowtime,
  42. runid: run_id
  43. },
  44. async:false,
  45. dataType: "json",
  46. success: function (myJson){
  47. console.log(myJson);
  48. var myTicket = myJson.ticket_list;
  49. var num1 = myTicket.length;
  50. p_cirname = myTicket[0].circuitry_name;
  51. document.getElementById('line').innerHTML = p_cirname;
  52. for(var i = 0; i < num1; i++) {
  53. ticketArray[i] = new Array();
  54. ticketArray[i][0] = myTicket[i].prod_id;
  55. ticketArray[i][1] = myTicket[i].prod_name;
  56. ticketArray[i][2] = myTicket[i].start_station_res_id;
  57. ticketArray[i][3] = myTicket[i].start_station_res_name;
  58. ticketArray[i][4] = myTicket[i].end_station_res_id;
  59. ticketArray[i][5] = myTicket[i].end_station_res_name;
  60. ticketArray[i][6] = myTicket[i].prod_price;
  61. ticketArray[i][7] = myTicket[i].seat_type;
  62. ticketArray[i][8] = myTicket[i].seat_type_name;
  63. }
  64. var myOrg = myJson.sale_org;
  65. num1 = myOrg.length;
  66. var temp = '<li value="0" class="filter-item items" data-filter="请选择">请选择</li>';
  67. for (var i=0;i<myOrg.length;i++) {
  68. temp += '<li value="'+myOrg[i].org_id+'" class="filter-item items" data-filter="'+myOrg[i].soure+'">'+myOrg[i].soure+'</li>'
  69. }
  70. $("#orderSource").html(temp);
  71. $(".filter-item").click(function() {
  72. order_from_id = $(this).val();
  73. });
  74. show_start_station();
  75. }
  76. });
  77. })
  78. function show_start_station() {
  79. var num1 = ticketArray.length;
  80. var n_old_station_res_id = 0;
  81. var n_now_station_res_id = 0;
  82. var staArray = new Array();
  83. var num2 = 0;
  84. var nflag = 0;
  85. for(var i = 0; i < num1; i++) {
  86. n_now_station_res_id = ticketArray[i][2];
  87. nflag = 0;
  88. num2 = staArray.length;
  89. for(var j = 0; j < num2; j++) {
  90. n_old_station_res_id = staArray[j][0];
  91. if(n_old_station_res_id - n_now_station_res_id == 0) nflag = 1;
  92. }
  93. if(nflag == 0) {
  94. staArray[num2] = new Array();
  95. staArray[num2][0] = ticketArray[i][2];
  96. staArray[num2][1] = ticketArray[i][3];
  97. }
  98. }
  99. num1 = staArray.length;
  100. if(num1 > 0) {
  101. var obj1 = document.getElementById('startArea');
  102. obj1.length = 0;
  103. for(var i = 0; i < num1; i++) {
  104. var myOption = new Option(staArray[i][1], staArray[i][0]);
  105. obj1.options[obj1.options.length] = myOption;
  106. }
  107. obj1.options.selectedIndex = 0;
  108. show_end_station();
  109. }
  110. }
  111. function show_end_station() {
  112. var obj2 = document.getElementById('startArea');
  113. var start_res_id = obj2.options[obj2.options.selectedIndex].value;
  114. var num1 = ticketArray.length;
  115. var n_old_station_res_id = 0;
  116. var n_now_station_res_id = 0;
  117. var n_now_start_res_id = 0;
  118. var staArray = new Array();
  119. var num2 = 0;
  120. var nflag = 0;
  121. for(var i = 0; i < num1; i++) {
  122. n_now_station_res_id = ticketArray[i][4];
  123. n_now_start_res_id = ticketArray[i][2];
  124. if(n_now_start_res_id - start_res_id == 0) {
  125. nflag = 0;
  126. num2 = staArray.length;
  127. for(var j = 0; j < num2; j++) {
  128. n_old_station_res_id = staArray[j][0];
  129. if(n_old_station_res_id - n_now_station_res_id == 0) nflag = 1;
  130. }
  131. if(nflag == 0) {
  132. staArray[num2] = new Array();
  133. staArray[num2][0] = ticketArray[i][4];
  134. staArray[num2][1] = ticketArray[i][5];
  135. }
  136. }
  137. }
  138. num1 = staArray.length;
  139. if(num1 > 0) {
  140. var obj1 = document.getElementById('endArea');
  141. obj1.length = 0;
  142. for(var i = 0; i < num1; i++) {
  143. var myOption = new Option(staArray[i][1], staArray[i][0]);
  144. obj1.options[obj1.options.length] = myOption;
  145. }
  146. obj1.options.selectedIndex = 0;
  147. }
  148. show_ticket_list();
  149. }
  150. function show_ticket_list() {
  151. var obj1 = document.getElementById('startArea');
  152. var obj2 = document.getElementById('endArea');
  153. var obj3 = document.getElementById('tableInfo');
  154. obj3.innerHTML = '';
  155. var start_res_id = obj1.options[obj1.options.selectedIndex].value;
  156. var end_res_id = obj2.options[obj2.options.selectedIndex].value;
  157. var num1 = ticketArray.length;
  158. var cstr1 = '';
  159. for(var i = 0; i < num1; i++) {
  160. var now_start_res_id = ticketArray[i][2];
  161. var now_end_res_id = ticketArray[i][4];
  162. if((now_start_res_id - start_res_id == 0) && (now_end_res_id - end_res_id == 0)) {
  163. if(ticketArray[i][1].indexOf('往返') != -1) {
  164. cstr1 += '<tr id ="back_back">';
  165. } else {
  166. cstr1 += '<tr id ="go_go">';
  167. }
  168. cstr1 += '<td style="width:80px;">' + ticketArray[i][8] + '</td>';
  169. cstr1 += '<td id="back" style="width:90px;">' + ticketArray[i][1] + '</td>';
  170. cstr1 += '<td style="width:90px;"><input type="text" style="width:90px" id="price' + i + '" value=' + ticketArray[i][6] + '>' + '</td>';
  171. cstr1 += '<td style="width: 105px;"><select id="ticket_count_' + i + '" style="font-size: 12px; width: 60px;">';
  172. for(var j = 0; j <= 55; j++) {
  173. cstr1 += '<option value=' + j + '>' + j + '</option>';
  174. }
  175. cstr1 += '</select></td>';
  176. }
  177. }
  178. obj3.innerHTML = cstr1;
  179. var t_back_select = $('#ifback').val();
  180. if(t_back_select == 1) {
  181. var t_checked = true;
  182. } else {
  183. var t_checked = false;
  184. }
  185. ifbackSelected(t_checked);
  186. }
  187. //添加乘客人信息
  188. function addLine() {
  189. var addInfo = document.getElementById('addInfo');
  190. //tr
  191. var div = document.createElement("div");
  192. div.id = "newInfo" + i;
  193. // div.style({"width":'300px'},{"height":'100px'});
  194. div.style.height = '100px';
  195. div.style.width = '350px';
  196. var newInfo = $('#left').html();
  197. newInfo += newInfo.replace('delBtn', 'delBtn' + i);
  198. div.innerHTML = newInfo;
  199. addInfo.appendChild(div);
  200. i++;
  201. }
  202. //删除乘客人信息
  203. function delOneLine(sender) {
  204. $('#' + sender).parent().parent().remove();
  205. }
  206. //选中返回的日期date
  207. var end_list2=null;
  208. var start_list2=null;
  209. function selectDate(value) {
  210. var obj1 = document.getElementById("startAreaback");
  211. obj1.innerHTML = "";
  212. obj1.innerText = "";
  213. var obj2 = document.getElementById("endAreaback");
  214. obj2.innerHTML = "";
  215. obj2.innerText = "";
  216. if(value == null) {
  217. return;
  218. }
  219. if(checkedValue=="0"){
  220. return;
  221. }
  222. // 判断日期是否合理
  223. var date1 = new Date(start_date.replace(/\-/g, '/'));
  224. var date2 = new Date(value.replace(/\-/g, '/'));
  225. if(date2 < date1) {
  226. $('#id-date-picker-1').val('');
  227. return;
  228. }
  229. var url = "./st-xm/Api/returnInfoSee.php?method=get_run_back_station&cur_run_id=" + m_runid + "&date_f=" + value;
  230. ZZLog(url);
  231. var endArea_html = '<option value="0" style="font-size: 12px;">选择班次</option>'
  232. $.getJSON(url, function(res_data) {
  233. ZZLog(res_data);
  234. if(res_data['code'] != "0") {
  235. swal(
  236. '订单提交失败',
  237. res_data['info'],
  238. 'error'
  239. );
  240. return;
  241. }
  242. if(res_data['start_station_list'].length <= 0) {
  243. swal(
  244. '订单提交失败',
  245. '无相关班次',
  246. 'error'
  247. );
  248. obj1.innerHTML = "";
  249. obj2.innerHTML = "";
  250. document.getElementById('ifback').checked=false;
  251. ifbackSelected(false);
  252. }else{
  253. back_run_id = res_data.start_station_list[0].run_id;
  254. var start_list = res_data.start_station_list;
  255. start_list2=start_list;
  256. var end_list = res_data.end_station_list;
  257. end_list2=end_list;
  258. if(checkedValue != "1") {
  259. return;
  260. }
  261. if(start_list.length == 0) {
  262. $('#selected').val('无相关班次');
  263. } else {
  264. for(var i = 0, m = start_list.length; i < m; i++) {
  265. var dict = start_list[i];
  266. var myOption = new Option(dict.start_station_res_name + "-" + dict.start_time, dict.start_station_res_id);
  267. obj1.options[obj1.options.length] = myOption;
  268. }
  269. obj1.options.selectedIndex = 0;
  270. // 默认给第一个
  271. // show_f_station2(end_list,start_list[0]['run_id']);
  272. show_f_station2();
  273. }
  274. }
  275. });
  276. }
  277. function show_f_station2(){
  278. var start_f_index=document.getElementById("startAreaback").selectedIndex;
  279. show_f_station(end_list2,start_list2[start_f_index]['run_id']);
  280. }
  281. // 显示返程的目的地站
  282. function show_f_station(end_list,run_id){
  283. back_run_id=run_id;
  284. var obj2 = document.getElementById("endAreaback");
  285. obj2.innerHTML = "";
  286. for(var i = 0, m = end_list.length; i < m; i++) {
  287. var dict = end_list[i];
  288. if(dict['run_id']!=run_id){
  289. continue;
  290. }
  291. var myOption = new Option(dict.end_station_res_name + "-" + dict.end_time, dict.end_station_res_id);
  292. obj2.options[obj2.options.length] = myOption;
  293. }
  294. obj2.options.selectedIndex = 0;
  295. choose_f_station();
  296. }
  297. //选中返回的时间time
  298. function select_run_time(sender) {}
  299. //选择返程的上下车站点
  300. function choose_f_station() {
  301. var start_f_res_id = $('#startAreaback').val();
  302. var end_f_res_id = $('#endAreaback').val();
  303. if(start_f_res_id=="" || start_f_res_id==null || start_f_res_id==undefined
  304. || end_f_res_id=="" || end_f_res_id==null || end_f_res_id==null){
  305. swal(
  306. '订单提交失败',
  307. '出发站或目的地为空则不能下往返程订单',
  308. 'error'
  309. );
  310. return;
  311. }
  312. if(start_f_res_id==end_f_res_id){
  313. swal(
  314. '订单提交失败',
  315. '出发站与目的地不能相同',
  316. 'error'
  317. );
  318. return;
  319. }
  320. var url = "./st-xm/Api/returnInfoSee.php?method=get_run_back_info&f_run_id=" + back_run_id + "&f_st_res_id=" + start_f_res_id + "&f_end_res_id=" + end_f_res_id;
  321. ZZLog(url);
  322. $.getJSON(url, function(res_data) {
  323. ZZLog(res_data);
  324. if(res_data['code'] != "0") {
  325. swal(
  326. '订单提交失败',
  327. res_data['info'],
  328. 'error'
  329. );
  330. return;
  331. }
  332. back_prod_id = res_data['prod_id'];
  333. if(back_prod_id==null || back_prod_id==undefined || back_prod_id==""){
  334. swal(
  335. '订单提交失败',
  336. '没有该返程的票种,不允许下往返程订单',
  337. 'error'
  338. );
  339. return;
  340. }
  341. back_run_id = res_data['run_id'];
  342. });
  343. }
  344. function submit_order() {
  345. if($("#usersubmit").html() == "保存中...") {
  346. return;
  347. }
  348. $("#usersubmit").removeClass("btn-info");
  349. $("#usersubmit").html("保存中...");
  350. if(checkedValue == "1" && $('#id-date-picker-1').val().length <= 0) {
  351. swal(
  352. '订单提交失败',
  353. '请填写正确',
  354. 'error'
  355. );
  356. $("#usersubmit").addClass("btn-info");
  357. $("#usersubmit").html("提交");
  358. return;
  359. }
  360. var num1 = ticketArray.length;
  361. var num2 = 0;
  362. var f_ticket_count = 0; //返程票只有一条数据
  363. var cstr1 = ''; //单程的
  364. var cstr_f = ''; //返程的
  365. var u_prod = '';
  366. var u_prod_list = '';//单程修改价格
  367. var f_u_prod_list='';//返程修改价格
  368. var u_price = '';
  369. checkedValue = $('#ifback').val();
  370. // 1=true 0=false // 返程
  371. if( checkedValue == 1 ) {
  372. if (back_prod_id == null || back_prod_id == undefined || back_prod_id == "") {
  373. swal(
  374. '订单提交失败',
  375. '没有该返程的票种,不允许下往返程订单',
  376. 'error'
  377. );
  378. $("#usersubmit").addClass("btn-info");
  379. $("#usersubmit").html("提交");
  380. return;
  381. }
  382. }
  383. for(var i = 0; i < num1; i++) {
  384. var obj1 = document.getElementById('ticket_count_' + i);
  385. if(obj1) {
  386. var num3 = obj1.options[obj1.options.selectedIndex].value;
  387. f_ticket_count = num3;
  388. if(num3 - 0 > 0) {
  389. // 如果是往返就不添加到此参数中
  390. cstr1 += '{m' + ticketArray[i][0] + 'p' + num3 + '|r' + m_runid + '}';
  391. cstr_f += '{m' + back_prod_id + 'p' + num3 + '|r' + back_run_id + '}';
  392. num2 += parseInt(num3);
  393. u_prod += ticketArray[i][0] + ',';
  394. u_price = $('#price' + i).val();
  395. u_prod_list += ticketArray[i][0] + ',' + u_price + '*';
  396. f_u_prod_list+=back_prod_id+','+u_price;
  397. }
  398. }
  399. }
  400. if(num2 == 0) {
  401. swal(
  402. '订单提交失败',
  403. '请选择购买票张数',
  404. 'error'
  405. );
  406. $("#usersubmit").addClass("btn-info");
  407. $("#usersubmit").html("提交");
  408. return;
  409. }
  410. var c_cusname = document.getElementById('username').value;
  411. var c_cusmobile = document.getElementById('usernum').value;
  412. var c_cusidno = document.getElementById('userid').value;
  413. var c_ordersource = order_from_id;
  414. var c_channelno = document.getElementById('channelNum').value;
  415. if(c_ordersource == "-1") {
  416. swal(
  417. '订单提交失败',
  418. '请选择订单渠道',
  419. 'error'
  420. );
  421. $("#usersubmit").addClass("btn-info");
  422. $("#usersubmit").html("提交");
  423. return;
  424. }
  425. if(c_cusname == '') {
  426. swal(
  427. '订单提交失败',
  428. '请输入联系人姓名',
  429. 'error'
  430. );
  431. $("#usersubmit").addClass("btn-info");
  432. $("#usersubmit").html("提交");
  433. return;
  434. }
  435. if(c_cusmobile == '') {
  436. swal(
  437. '订单提交失败',
  438. '请输入联系人手机',
  439. 'error'
  440. );
  441. $("#usersubmit").addClass("btn-info");
  442. $("#usersubmit").html("提交");
  443. return;
  444. }
  445. if(checkPhone(c_cusmobile)==false){
  446. $("#usersubmit").addClass("btn-info");
  447. $("#usersubmit").html("提交");
  448. return;
  449. }
  450. if(isCardNo(c_cusidno) == false) {
  451. $("#usersubmit").addClass("btn-info");
  452. $("#usersubmit").html("提交");
  453. return;
  454. }
  455. //订单备注
  456. // $("#accuracy").val($("#accuracy").val().replace(/\ +/g,""));//去掉空格
  457. //$("#content").val($("#content").val().replace(/[ ]/g,"")); //去掉空格
  458. //$("#content").val($("#content").val().replace(/[\r\n]/g,""));//去掉回车换行
  459. var order_comment=$('#order_remark').val();
  460. // order_comment=order_comment.replace(/\ +/g,"");
  461. // order_comment=order_comment.replace(/[ ]/g,"");
  462. order_comment=order_comment.replace(/[\r\n]/g,"");
  463. if(order_comment.length>500){
  464. $("#usersubmit").addClass("btn-info");
  465. $("#usersubmit").html("提交");
  466. swal(
  467. '订单提交失败',
  468. '订单备注超出字数限制,限500字',
  469. 'error'
  470. );
  471. return;
  472. }
  473. // {prod_id,姓名 ,性别,手机 ,证件类型,证件号 ,地址,地址对应地区ID,邮编,备注}
  474. // var cstr2 = '{,' + c_cusname + ',1,' + c_cusmobile + ',150,' + c_cusidno + ',,0,,'+order_comment+'}';
  475. // 不用逗号连接 因为后端存储过程是以,分割获取参数
  476. // 决定用^
  477. var cstr2 = '{^' + c_cusname + '^1^' + c_cusmobile + '^150^' + c_cusidno + '^^0^^'+order_comment+'}';
  478. var tnowtime = getDateTime(4);
  479. var cstr3 = '';
  480. for(var i = 0; i < num1; i++) {
  481. var u_num = $('#ticket_count_' + i).val();
  482. if(u_num > 0) {
  483. var price = $('#price' + i).val();
  484. cstr3 = cstr3 + price + ',';
  485. }
  486. }
  487. cstr3 = cstr3.substr(0, cstr3.length - 1);
  488. //var u_price=cstr3;
  489. cstr3 = '{' + cstr3 + '}';
  490. //alert(u_prod_list);
  491. u_prod_list = u_prod_list.substr(0, u_prod_list.length - 1);
  492. u_prod = u_prod.substr(0, u_prod.length - 1);
  493. var doorPrice = $('#doorPrice').val();
  494. var hotelPrice = $('#hotelPrice').val();
  495. var myURL = '';
  496. if(checkedValue == "1") {
  497. // var start_f_res_id = $('#startAreaback').val();
  498. // var end_f_res_id = $('#endAreaback').val();
  499. // if(start_f_res_id==end_f_res_id){
  500. // alert('出发站与目的地不能相同!!!');
  501. // $("#usersubmit").addClass("btn-info");
  502. // $("#usersubmit").html("提交");
  503. // return;
  504. // }
  505. var backDate = $('#id-date-picker-1').val();
  506. var backTime = $('#select_time').val();
  507. var startAreaback = $('#startAreaback').val();
  508. var endAreaback = $('#endAreaback').val();
  509. if(startAreaback==endAreaback){
  510. swal(
  511. '订单提交失败',
  512. '出发站与目的地不能相同',
  513. 'error'
  514. );
  515. $("#usersubmit").addClass("btn-info");
  516. $("#usersubmit").html("提交");
  517. return;
  518. }
  519. if(backDate == "" || backTime == "" || startAreaback == "" || endAreaback == "") {
  520. swal(
  521. '订单提交失败',
  522. '返程信息输入不完整',
  523. 'error'
  524. );
  525. $("#usersubmit").addClass("btn-info");
  526. $("#usersubmit").html("提交");
  527. return;
  528. }
  529. }
  530. myURL = '/st-xm/Api/add_new_order.php?prod=' + cstr1 + '&customer=' + cstr2 + '&order_from_org_id=' + c_ordersource + '&outside_order_id=' + c_channelno + '&tt=' + tnowtime + '&u_prod_list='+u_prod_list+'&f_u_prod_list='+f_u_prod_list+'&price=' + cstr3 + "&doorPrice=" + doorPrice + "&hotelPrice=" + hotelPrice + "&ifcheck=" + checkedValue + "&back_prod=" + cstr_f;
  531. ZZLog(myURL);
  532. //得到返程的prod_id
  533. $.getJSON(myURL, function(date) {
  534. ZZLog(date);
  535. if(checkedValue == "0") {
  536. if(date.errcode != "0") {
  537. swal(
  538. '订单提交失败',
  539. date.errinfo,
  540. 'error'
  541. );
  542. $("#usersubmit").addClass("btn-info");
  543. $("#usersubmit").html("提交");
  544. return;
  545. } else {
  546. swal({
  547. title: '订单提交成功',
  548. text: '订单号:' + date.order_id,
  549. type: 'success',
  550. timer: 20000,
  551. confirmButtonText: 'OK'
  552. }).then(
  553. function () { location.href = '/order_list.html'; },
  554. // handling the promise rejection
  555. function (dismiss) {
  556. location.href = '/order_list.html';
  557. }
  558. )
  559. }
  560. } else {
  561. if(date.errcode != "0") {
  562. swal(
  563. '订单提交失败',
  564. '返程:' + date.errinfo,
  565. 'error'
  566. );
  567. $("#usersubmit").addClass("btn-info");
  568. $("#usersubmit").html("提交");
  569. return;
  570. } else {
  571. if(date.errcode_f != "0") {
  572. swal(
  573. '订单提交失败',
  574. '返程:' + date.errinfo_f,
  575. 'error'
  576. );
  577. $("#usersubmit").addClass("btn-info");
  578. $("#usersubmit").html("提交");
  579. return;
  580. } else {
  581. swal({
  582. title: '订单提交成功',
  583. text: '去程订单号:' + date.order_id + ",返程订单号:" + date.order_id_f,
  584. type: 'success',
  585. timer: 20000,
  586. confirmButtonText: 'OK'
  587. }).then(
  588. function () { location.href = '/order_list.html'; },
  589. // handling the promise rejection
  590. function (dismiss) {
  591. location.href = '/order_list.html';
  592. }
  593. )
  594. }
  595. }
  596. }
  597. });
  598. }
  599. //返程信息选中
  600. function ifbackSelected(value) {
  601. if(value == true) {
  602. var yes = $('#ifback').val('1');
  603. $('#back_back').show();
  604. $('#go_go').hide();
  605. checkedValue = "1";
  606. selectDate($('#id-date-picker-1').val());
  607. var num1 = ticketArray.length;
  608. for(var i = 0; i < num1; i++) {
  609. var obj1 = document.getElementById('ticket_count_' + i);
  610. if(obj1) {
  611. var num3 = obj1.options[obj1.options.selectedIndex].value;
  612. if(num3 - 0 > 0) {
  613. obj1.selectedIndex=0;
  614. }
  615. }
  616. }
  617. } else {
  618. var no = $('#ifback').val('0');
  619. $('#back_back').hide();
  620. $('#go_go').show();
  621. checkedValue = "0";
  622. selectDate(null);
  623. }
  624. }
  625. function isCardNo(card) {
  626. if(card) {
  627. // 身份证号码为15位或者18位,15位时全为数字,18位前17位为数字,最后一位是校验位,可能为数字或字符X
  628. var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
  629. if(reg.test(card) === false) {
  630. alert("身份证输入不合法");
  631. return false;
  632. } else {
  633. return true;
  634. }
  635. }
  636. }
  637. //验证手机号
  638. function checkPhone(phone) {
  639. if(!(/^1[3|4|5|7|8]\d{9}$/.test(phone))) {
  640. swal(
  641. '订单提交失败',
  642. '手机号码有误,请重填',
  643. 'error'
  644. );
  645. return false;
  646. } else {
  647. return true;
  648. }
  649. }
  650. function after(d) {
  651. if(d) {
  652. d = new Date(d);
  653. d = +d + 1000*60*60*24;
  654. d = new Date(d);
  655. //return d;
  656. //格式化
  657. var year = ";" + d.getFullYear() + ";";
  658. var month = ";" + (d.getMonth()+0+1) + ";";
  659. var day = ";" + d.getDate() + ";";
  660. if(year.length < 4) {
  661. year = "0" + year;
  662. }
  663. if(month.length < 4) {
  664. month = "0" + month;
  665. }
  666. if(day.length < 4) {
  667. day = "0" + day;
  668. }
  669. var datestr = year + "-" + month + "-" + day;
  670. datestr = datestr.replace(/;/g, "");
  671. return datestr;
  672. } else {
  673. return "";
  674. }
  675. }
  676. function ConvertDateFromString(dateString) {
  677. if(dateString) {
  678. var sdate = dateString.split('-');
  679. var date = new Date(sdate[0], sdate[1], sdate[2]);
  680. return date;
  681. }
  682. }
  683. function getPar(par) {
  684. //获取当前URL
  685. var local_url = document.location.href;
  686. local_url = decodeURI(local_url);
  687. //获取要取得的get参数位置
  688. var get = local_url.indexOf(par + "=");
  689. if(get == -1) {
  690. return "";
  691. }
  692. //截取字符串
  693. var get_par = local_url.slice(par.length + get + 1);
  694. //判断截取后的字符串是否还有其他get参数
  695. var nextPar = get_par.indexOf("&");
  696. if(nextPar != -1) {
  697. get_par = get_par.slice(0, nextPar);
  698. }
  699. return get_par;
  700. }
  701. function getDateTime(nTypeFlag) {
  702. var tNowTime = new Date();
  703. var myYear = ';' + tNowTime.getFullYear() + ';';
  704. var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';';
  705. var myDay = ';' + tNowTime.getDate() + ';';
  706. var myHour = ';' + tNowTime.getHours() + ';';
  707. var myMinu = ';' + tNowTime.getMinutes() + ';';
  708. var mySecond = ';' + tNowTime.getSeconds() + ';';
  709. if(myMonth.length < 4) myMonth = '0' + myMonth;
  710. if(myDay.length < 4) myDay = '0' + myDay;
  711. if(myHour.length < 4) myHour = '0' + myHour;
  712. if(myMinu.length < 4) myMinu = '0' + myMinu;
  713. if(mySecond.length < 4) mySecond = '0' + mySecond;
  714. var cNewTimeStr;
  715. //alert(tNowTime);
  716. switch(nTypeFlag + 1 - 1) {
  717. case 0:
  718. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  719. break;
  720. case 1:
  721. cNewTimeStr = myYear + myMonth + myDay;
  722. break;
  723. case 2:
  724. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  725. break;
  726. case 3:
  727. cNewTimeStr = myHour + myMinu + mySecond;
  728. break;
  729. case 4:
  730. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  731. break;
  732. case 5:
  733. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  734. break;
  735. case 6:
  736. cNewTimeStr = myYear;
  737. break;
  738. case 7:
  739. cNewTimeStr = myYear + '-' + myMonth;
  740. break;
  741. default:
  742. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  743. break;
  744. }
  745. cNewTimeStr = cNewTimeStr.replace(/;/g, "");
  746. return cNewTimeStr;
  747. }
  748. //function update_order_price(order_id,price){
  749. // //修改价格信息
  750. // $.ajax({
  751. // url: './st-xm/Api/change_price.php', //请求地址
  752. // type: "post", //请求方式
  753. // data: {
  754. // ordid: order_id,
  755. // prod_list: price
  756. // }, //请求参数
  757. // async: false,
  758. // dataType: "json",
  759. // success: function(date) {
  760. // ZZLog('修改订单价格');
  761. // ZZLog(date);
  762. // },
  763. // fail: function(date) {
  764. // // 此处放失败后执行的代码
  765. // }
  766. // });
  767. //}