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.
 
 
 
 

740 lines
21 KiB

  1. //每页显示的数据个数
  2. var pagesize = 10;
  3. var tttHTML = '';
  4. var order_status = 0;
  5. var goHTML = '';
  6. var backHTML = '';
  7. var gosuccessHTML = '';
  8. var backsuccessHTML = '';
  9. window.onload = function (){
  10. iflogin();
  11. var paceker1 = getDateTime(0);
  12. $('#id-date-picker-2').val(paceker1);
  13. for (var i = 0 ; i < 6 ; i ++) {
  14. paceker1 = before(paceker1)
  15. }
  16. $('#id-date-picker-1').val(paceker1);
  17. $('#order_style_parent').children().removeClass('order_style_selected');
  18. var cur = "";
  19. var currpage = getPar("currpage");
  20. var time_style = '';
  21. var start_time = '';
  22. var end_time = '';
  23. var start_area = '';
  24. var end_area = '';
  25. var product_type = '';
  26. //更多查询
  27. var order_id = '';
  28. var condition = '';
  29. // var order_status = '';
  30. if(!currpage){
  31. cur = 1;
  32. time_style = $('#order_time').val();
  33. start_time = $('#id-date-picker-1').val();
  34. end_time = $('#id-date-picker-2').val();
  35. start_area = $('#start_area').val();
  36. end_area = $('#end_area').val();
  37. product_type = $('#order_product').val();
  38. order_id = $('#order_condition').val();
  39. condition = $('#more_search_input').val();
  40. order_status = order_status;
  41. switch (order_status){
  42. case 0:
  43. $('#all').addClass('order_style_selected');
  44. break;
  45. case 146:
  46. $('#out_ticket').addClass('order_style_selected');
  47. break;
  48. case 147:
  49. $('#all').addClass('order_style_selected');
  50. break;
  51. case 148:
  52. $('#cansel').addClass('order_style_selected');
  53. break;
  54. default:
  55. break;
  56. }
  57. // order_status = '';
  58. }else{
  59. cur = currpage;
  60. time_style = getPar('time_style');
  61. $('#order_time').val(time_style);
  62. start_time = getPar('start_time');
  63. $('#id-date-picker-1').val(start_time);
  64. end_time = getPar('end_time');
  65. $('#id-date-picker-2').val(end_time);
  66. start_area = getPar('start_area');
  67. $('#start_area').val(start_area);
  68. end_area = getPar('end_area');
  69. $('#end_area').val(end_area);
  70. product_type = getPar('product_type');
  71. $('#order_product').val(product_type);
  72. order_id = getPar('order_id');
  73. $('#order_condition').val(order_id);
  74. more_search_input = getPar('more_search_input');
  75. $('#more_search_input').val(more_search_input);
  76. order_status = getPar('order_status');
  77. switch (order_status){
  78. case '0':
  79. $('#all').addClass('order_style_selected');
  80. break;
  81. case '146':
  82. $('#out_ticket').addClass('order_style_selected');
  83. break;
  84. case '147':
  85. $('#all').addClass('order_style_selected');
  86. break;
  87. case '148':
  88. $('#cansel').addClass('order_style_selected');
  89. break;
  90. default:
  91. break;
  92. }
  93. }
  94. tttHTML = $('#list').html();
  95. searchBtnDidClicked(cur,time_style,start_time,end_time,start_area,end_area,product_type,order_id,more_search_input,order_status);
  96. goHTML = $('#refund_ticket_go').html();
  97. gosuccessHTML = $('#refund_ticket_go_success').html();
  98. backHTML = $('#refund_ticket_back').html();
  99. backsuccessHTML = $('#refund_ticket_back_success').html();
  100. }
  101. //查询按钮
  102. function searchBtnDidClicked(cur,time_style,start_time,end_time,start_area,end_area,product_type,order_id,more_search_input,order_status1){
  103. if(!cur){
  104. cur = 1;
  105. }
  106. if(!time_style||!start_time||!end_time||!start_area||!end_area||!product_type||!order_id||!more_search_input){
  107. time_style = $('#order_time').val();
  108. start_time = $('#id-date-picker-1').val();
  109. end_time = $('#id-date-picker-2').val();
  110. start_area = $('#start_area').val();
  111. end_area = $('#end_area').val();
  112. product_type = $('#order_product').val();
  113. order_id = $('#order_condition').val();
  114. more_search_input = $('#more_search_input').val();
  115. order_status = order_status;
  116. }
  117. $.ajax({
  118. url:'./zz-fx/control.php', //请求地址
  119. type: "post", //请求方式
  120. data:{
  121. type:"distribut_OrderList",
  122. time_style:time_style,
  123. start_time:start_time,
  124. end_time:end_time,
  125. start_area:start_area,
  126. end_area:end_area,
  127. product_type:product_type,
  128. order_id:order_id,
  129. condition:more_search_input,
  130. order_status:order_status,
  131. currpage:cur,
  132. pagesize:pagesize
  133. },
  134. async:false,
  135. dataType: "json",
  136. success: function (data) {
  137. if(data.code == 0){
  138. console.log(data.info);
  139. var sum = data.list_count;
  140. if (sum==0) {
  141. window.wxc.xcConfirm("没有相关订单信息!", window.wxc.xcConfirm.typeEnum.info);
  142. }
  143. var tag = "test";
  144. var sendurl = './order_list.html?time_style='+time_style+'&start_time='+start_time+'&end_time='+end_time+'&start_area='+start_area+'&end_area='+end_area+'&product_type='+product_type+'&order_id='+order_id+'&more_search_input='+more_search_input+'&order_status='+order_status;
  145. getPager(sendurl, sum, cur, pagesize,tag,'currpage');
  146. reloadInfo(data);
  147. }
  148. },
  149. fail: function (date) {
  150. window.wxc.xcConfirm("数据加载失败!", window.wxc.xcConfirm.typeEnum.info);
  151. }
  152. });
  153. if(cur!=1){
  154. time_style = getPar('time_style');
  155. $('#order_time').val(time_style);
  156. start_time = getPar('start_time');
  157. $('#id-date-picker-1').val(start_time);
  158. end_time = getPar('end_time');
  159. $('#id-date-picker-2').val(end_time);
  160. start_area = getPar('start_area');
  161. $('#start_area').val(start_area);
  162. end_area = getPar('end_area');
  163. $('#end_area').val(end_area);
  164. product_type = getPar('product_type');
  165. $('#order_product').val(product_type);
  166. order_id = getPar('order_id');
  167. $('#order_condition').val(order_id);
  168. more_search_input = getPar('more_search_input');
  169. $('#more_search_input').val(more_search_input);
  170. order_status = order_status1;
  171. }
  172. }
  173. //订单状态的筛选
  174. function orderStyleDidClicked(selectID){
  175. $('#order_style_parent').children().removeClass('order_style_selected');
  176. $('#'+selectID).addClass('order_style_selected');
  177. switch (selectID){
  178. case "all":
  179. order_status = 0;
  180. searchBtnDidClicked();
  181. break;
  182. case "out_ticket":
  183. order_status = 146;
  184. searchBtnDidClicked();
  185. break;
  186. case "out_go":
  187. order_status = 147;
  188. searchBtnDidClicked();
  189. break;
  190. default:
  191. order_status = 148;
  192. searchBtnDidClicked();
  193. break;
  194. }
  195. }
  196. //加载数据
  197. function reloadInfo(data){
  198. console.log(data);
  199. var list = data.searchInfo;
  200. //console.log(tttHTML)
  201. var newHTML='';
  202. for(var i=0;i<list.length;i++){
  203. var tempHTML=tttHTML;
  204. tempHTML=tempHTML.replace('[订单编号]',list[i].order_id);
  205. tempHTML=tempHTML.replace('[下单时间]',list[i].create_time);
  206. tempHTML=tempHTML.replace('[预订产品]',list[i].product_info);
  207. tempHTML=tempHTML.replace('[出发时间]',list[i].run_time);
  208. tempHTML=tempHTML.replace('[联系人]',list[i].customer_info);
  209. tempHTML=tempHTML.replace('[订单金额]',list[i].order_pay);
  210. tempHTML=tempHTML.replace('[支付方式]',list[i].order_pay_type);
  211. tempHTML=tempHTML.replace('[状态]',list[i].order_status);
  212. tempHTML=tempHTML.replace('[order_pay_style]','order_pay_style'+list[i].order_id);
  213. tempHTML=tempHTML.replace('[use]','use'+list[i].order_id);
  214. var nowDay = getDateTime(0);
  215. var nowHour = getDateTime(2);
  216. var newTimeStr = nowDay+" "+nowHour
  217. var ifTime = judgFailTime(list[i].run_time);
  218. //现在时间转换
  219. var time = new Date(newTimeStr.replace("-","/"));
  220. // var time = new Date(newTimeStr.replace("-","/"));
  221. time.setMinutes(time.getMinutes() - 0, time.getSeconds(), 0);
  222. // var subTime = ifTime.toString();
  223. // subTime = subTime.substring(16,21);
  224. //
  225. // var order_day = list[i].run_time.substring(0,10);
  226. // var now_day = getDateTime(0);
  227. // var now_hour = getDateTime(2);
  228. // now_hour = now_hour.substring(0,5);
  229. // var end_date1 = new Date(subTime);
  230. // var end_date2 = new Date(now_hour);
  231. if (list[i].ifdisney == 0) {
  232. tempHTML=tempHTML.replace('[操作]','-');
  233. }
  234. if (list[i].order_status == '已取消' || list[i].order_status == '已出行') {
  235. tempHTML=tempHTML.replace('[操作]','-');
  236. }
  237. if (time>ifTime) {
  238. var str = '<span onclick="refundTicket('+list[i].order_id+')" style="color:gray">退票</span>';
  239. tempHTML=tempHTML.replace('[操作]',str);
  240. } else{
  241. var str = '<span onclick="refundTicket('+list[i].order_id+')" style="cursor:pointer;color:rgb(66,142,210)">退票<input id="ifbackstyle'+list[i].order_id+'" type="hidden" value="'+list[i].ifback+'"></span>';
  242. tempHTML=tempHTML.replace('[操作]',str);
  243. }
  244. newHTML+=tempHTML;
  245. }
  246. $('#list').html(newHTML);
  247. }
  248. //时间加减
  249. function judgFailTime(agoTime) {
  250. var x = agoTime; // 取得的TextBox中的时间
  251. var time = new Date(x.replace("-","/"));
  252. var b = 30; //分钟数
  253. time.setMinutes(time.getMinutes() - b, time.getSeconds(), 0);
  254. return(time);
  255. }
  256. //点击退票
  257. function refundTicket(orderId){
  258. var ifback = $('#ifbackstyle'+orderId).val();
  259. $.ajax({
  260. url:'./zz-fx/control.php', //请求地址
  261. type: "post", //请求方式
  262. data:{
  263. type:"distribut_DropOrder",
  264. order_id:orderId,
  265. iffirst:1
  266. },
  267. async:false,
  268. dataType: "json",
  269. success: function (data) {
  270. if(data.code == 0){
  271. console.log(data);
  272. //展示退单信息
  273. showRefundOrder(data.ifback,data,orderId);
  274. }else{
  275. window.wxc.xcConfirm(data.massge, window.wxc.xcConfirm.typeEnum.info);
  276. }
  277. },
  278. fail: function (date) {
  279. window.wxc.xcConfirm("数据加载失败!", window.wxc.xcConfirm.typeEnum.info);
  280. }
  281. });
  282. }
  283. //展示退单信息
  284. function showRefundOrder(ifback,data,orderId){
  285. if (ifback == 0) {
  286. //去程退票
  287. center_show($('.refund_ticket_go'));
  288. refundOrderGo(data,orderId,ifback);
  289. } else{
  290. //往返退票
  291. center_show($('.refund_ticket_back'));
  292. refundOrderBack(data,orderId,ifback);
  293. }
  294. }
  295. //填充去程退单数据
  296. function refundOrderGo(data,orderId,ifback){
  297. var tempHTML = goHTML;
  298. var list = data.list;
  299. tempHTML=tempHTML.replace('[去程出发地]',list.start_station);
  300. tempHTML=tempHTML.replace('去程出发地站点',list.start_res_name);
  301. tempHTML=tempHTML.replace('[去程目的地]',list.end_station);
  302. tempHTML=tempHTML.replace('去程目的地站点',list.end_res_name);
  303. tempHTML=tempHTML.replace('[yyyy-mm-dd][mm:ss]',list.run_time);
  304. tempHTML=tempHTML.replace('[座位等级]x[数量]',list.count);
  305. tempHTML=tempHTML.replace('[订单总额]',list.order_price);
  306. tempHTML=tempHTML.replace('[true]',orderId);
  307. tempHTML=tempHTML.replace('[0]',ifback);
  308. $('#refund_ticket_go').html(tempHTML);
  309. }
  310. //填充往返退单数据
  311. function refundOrderBack(data,orderId,ifback){
  312. var tempHTML = backHTML;
  313. var listgo = data.list.to;
  314. var listback = data.list.back;
  315. //去程
  316. tempHTML=tempHTML.replace('[去程出发地]',listgo.start_station);
  317. tempHTML=tempHTML.replace('去程出发地站点',listgo.start_res_name);
  318. tempHTML=tempHTML.replace('[去程目的地]',listgo.end_station);
  319. tempHTML=tempHTML.replace('去程目的地站点',listgo.end_res_name);
  320. tempHTML=tempHTML.replace('[yyyy-mm-dd][mm:ss]',listgo.run_time);
  321. tempHTML=tempHTML.replace('[座位等级]x[数量]',listgo.count);
  322. //返程
  323. tempHTML=tempHTML.replace('[返程出发地]',listback.start_station);
  324. tempHTML=tempHTML.replace('返程出发地站点',listback.start_res_name);
  325. tempHTML=tempHTML.replace('[返程目的地]',listback.end_station);
  326. tempHTML=tempHTML.replace('返程目的地站点',listback.end_res_name);
  327. tempHTML=tempHTML.replace('[yyyy-mm-dd][mm:ss]',listback.run_time);
  328. tempHTML=tempHTML.replace('[座位等级]x[数量]',listback.count);
  329. tempHTML=tempHTML.replace('[订单总额]',parseInt(listgo.order_price)+parseInt(listback.order_price)+'元');
  330. tempHTML=tempHTML.replace('[true]',orderId);
  331. tempHTML=tempHTML.replace('[0]',ifback);
  332. $('#refund_ticket_back').html(tempHTML);
  333. }
  334. //展示成功退单信息
  335. function showRefundOrderSuccess(back,data){
  336. if (back == 0) {
  337. //去程成功退票填充
  338. center_show($('.refund_ticket_go_success'));
  339. refundOrderGoSuccess(data);
  340. } else{
  341. //往返成功退票填充
  342. center_show($('.refund_ticket_back_success'));
  343. refundOrderBackSuccess(data);
  344. }
  345. }
  346. //去程成功退票填充
  347. function refundOrderGoSuccess(data){
  348. var tempHTML = gosuccessHTML;
  349. var list = data.list;
  350. tempHTML=tempHTML.replace('[去程出发地]',list.start_station);
  351. tempHTML=tempHTML.replace('去程出发地站点',list.start_res_name);
  352. tempHTML=tempHTML.replace('[去程目的地]',list.end_station);
  353. tempHTML=tempHTML.replace('去程目的地站点',list.end_res_name);
  354. tempHTML=tempHTML.replace('[yyyy-mm-dd][mm:ss]',list.run_time);
  355. tempHTML=tempHTML.replace('[座位等级]x[数量]',list.count);
  356. tempHTML=tempHTML.replace('[订单总额]',list.order_price);
  357. $('#refund_ticket_go_success').html(tempHTML);
  358. // location.replace(location.href);
  359. $('#order_pay_style'+data.order_id).html('已取消');
  360. $('#use'+data.order_id).html('-');
  361. if (data.back_order_id!=null) {
  362. $('#order_pay_style'+data.back_order_id).html('已取消');
  363. $('#use'+data.back_order_id).html('-');
  364. }
  365. }
  366. //往返成功退票填充
  367. function refundOrderBackSuccess(data){
  368. var tempHTML = backsuccessHTML;
  369. var listgo = data.list.to;
  370. var listback = data.list.back;
  371. //去程
  372. tempHTML=tempHTML.replace('[去程出发地]',listgo.start_station);
  373. tempHTML=tempHTML.replace('去程出发地站点',listgo.start_res_name);
  374. tempHTML=tempHTML.replace('[去程目的地]',listgo.end_station);
  375. tempHTML=tempHTML.replace('去程目的地站点',listgo.end_res_name);
  376. tempHTML=tempHTML.replace('[yyyy-mm-dd][mm:ss]',listgo.run_time);
  377. tempHTML=tempHTML.replace('[座位等级]x[数量]',listgo.count);
  378. //返程
  379. tempHTML=tempHTML.replace('[返程出发地]',listback.start_station);
  380. tempHTML=tempHTML.replace('返程出发地站点',listback.start_res_name);
  381. tempHTML=tempHTML.replace('[返程目的地]',listback.end_station);
  382. tempHTML=tempHTML.replace('返程目的地站点',listback.end_res_name);
  383. tempHTML=tempHTML.replace('[yyyy-mm-dd][mm:ss]',listback.run_time);
  384. tempHTML=tempHTML.replace('[座位等级]x[数量]',listback.count);
  385. tempHTML=tempHTML.replace('[订单总额]',parseInt(listgo.order_price)+parseInt(listback.order_price)+'元');
  386. $('#refund_ticket_back_success').html(tempHTML);
  387. // location.replace(location.href);
  388. $('#order_pay_style'+data.order_id).html('已取消');
  389. $('#use'+data.order_id).html('-');
  390. if (data.back_order_id!=null) {
  391. $('#order_pay_style'+data.back_order_id).html('已取消');
  392. $('#use'+data.back_order_id).html('-');
  393. }
  394. }
  395. //居中显示
  396. var tempDiv = null;
  397. function center_show(show_div) {
  398. tempDiv = show_div;
  399. //显示蒙板
  400. show_div.css('display', 'block');
  401. show_div.css('z-index', 10);
  402. show_div.css('background-color', 'white');
  403. show_div.css('position', 'fixed');
  404. var w = show_div.css('width');
  405. var h = show_div.css('height');
  406. w = w.substr(0, w.length - 2);
  407. h = h.substr(0, h.length - 2);
  408. var s_left = (window.innerWidth - w) / 2 + 'px';
  409. var s_top = (window.innerHeight - h) / 2 + 'px';
  410. show_div.css('left', s_left);
  411. show_div.css('top', s_top);
  412. $('.mask').css('display', 'block');
  413. }
  414. //点击蒙板
  415. function hide_all() {
  416. $('.mask').css('display', 'none');
  417. tempDiv.css('display', 'none');
  418. }
  419. //点击已经有的按钮
  420. function click_show_div(objName, self_obj) {
  421. var obj = $(objName);
  422. if (obj.css('display') == 'none') {
  423. center_show(obj);
  424. } else {
  425. obj.css('display', 'none');
  426. }
  427. }
  428. //点击了第二级
  429. function click_two_show_div(father_name, self_name,self_id) {
  430. var back = $('#'+self_id).attr('back');
  431. var father = $(father_name);
  432. var self = $(self_name);
  433. father.css('display', 'none');
  434. //if代表是去程退单的确认
  435. // if (father_name=='.refund_ticket_go') {
  436. // var father = $(father_name);
  437. // var self = $(self_name);
  438. // father.css('display', 'none');
  439. //
  440. // } else{
  441. //
  442. // }
  443. $.ajax({
  444. url:'./zz-fx/control.php', //请求地址
  445. type: "post", //请求方式
  446. data:{
  447. type:"distribut_DropOrder",
  448. order_id:self_id,
  449. ifback:back,
  450. iffirst:0
  451. },
  452. async:false,
  453. dataType: "json",
  454. success: function (data) {
  455. if(data.code == 0){
  456. console.log(data);
  457. //展示成功退单信息
  458. showRefundOrderSuccess(data.ifback,data);
  459. }else{
  460. window.wxc.xcConfirm(data.massge, window.wxc.xcConfirm.typeEnum.info);
  461. }
  462. },
  463. fail: function (date) {
  464. window.wxc.xcConfirm("退单失败!", window.wxc.xcConfirm.typeEnum.info);
  465. }
  466. });
  467. }
  468. //点击了弹层关闭
  469. function click_cancel(father_name, self_name) {
  470. if (father_name) {
  471. var father = $(father_name);
  472. center_show(father);
  473. } else {
  474. $('.mask').css('display', 'none');
  475. }
  476. $(self_name).css('display', 'none');
  477. }
  478. //获取参数
  479. function getPar(par) {
  480. //获取当前URL
  481. var local_url = document.location.href;
  482. local_url = decodeURI(local_url);
  483. //获取要取得的get参数位置
  484. var get = local_url.indexOf(par + "=");
  485. if (get == -1) {
  486. return false;
  487. }
  488. //截取字符串
  489. var get_par = local_url.slice(par.length + get + 1);
  490. //判断截取后的字符串是否还有其他get参数
  491. var nextPar = get_par.indexOf("&");
  492. if (nextPar != -1) {
  493. get_par = get_par.slice(0, nextPar);
  494. }
  495. return get_par;
  496. }
  497. //获取时间
  498. function getDateTime(nTypeFlag) {
  499. var tNowTime = new Date();
  500. var myYear = ';' + tNowTime.getFullYear() + ';';
  501. var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';';
  502. var myDay = ';' + tNowTime.getDate() + ';';
  503. var myHour = ';' + tNowTime.getHours() + ';';
  504. var myMinu = ';' + tNowTime.getMinutes() + ';';
  505. var mySecond = ';' + tNowTime.getSeconds() + ';';
  506. if(myMonth.length < 4) myMonth = '0' + myMonth;
  507. if(myDay.length < 4) myDay = '0' + myDay;
  508. if(myHour.length < 4) myHour = '0' + myHour;
  509. if(myMinu.length < 4) myMinu = '0' + myMinu;
  510. if(mySecond.length < 4) mySecond = '0' + mySecond;
  511. var cNewTimeStr;
  512. switch(nTypeFlag + 1 - 1) {
  513. case 0:
  514. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  515. break;
  516. case 1:
  517. cNewTimeStr = myYear + myMonth + myDay;
  518. break;
  519. case 2:
  520. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  521. break;
  522. case 3:
  523. cNewTimeStr = myHour + myMinu + mySecond;
  524. break;
  525. case 4:
  526. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  527. break;
  528. case 5:
  529. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  530. break;
  531. case 6:
  532. cNewTimeStr = myYear;
  533. break;
  534. case 7:
  535. cNewTimeStr = myYear + '-' + myMonth;
  536. break;
  537. case 8: //得到上一个月的今天
  538. var date = getDateTime(0);
  539. var arr = date.split('-');
  540. var year = arr[0]; //获取当前日期的年份
  541. var month = arr[1]; //获取当前日期的月份
  542. var day = arr[2]; //获取当前日期的日
  543. var days = new Date(year, month, 0);
  544. days = days.getDate(); //获取当前日期中月的天数
  545. var year2 = year;
  546. var month2 = parseInt(month) - 1;
  547. if(month2 == 0) {
  548. year2 = parseInt(year2) - 1;
  549. month2 = 12;
  550. }
  551. var day2 = day;
  552. var days2 = new Date(year2, month2, 0);
  553. days2 = days2.getDate();
  554. if(day2 > days2) {
  555. day2 = days2;
  556. }
  557. if(month2 < 10) {
  558. month2 = '0' + month2;
  559. }
  560. cNewTimeStr = year2 + '-' + month2 + '-' + day2;
  561. break;
  562. case 9: //得到下一个月的今天
  563. var date = getDateTime(0);
  564. var arr = date.split('-');
  565. var year = arr[0]; //获取当前日期的年份
  566. var month = arr[1]; //获取当前日期的月份
  567. var day = arr[2]; //获取当前日期的日
  568. var days = new Date(year, month, 0);
  569. days = days.getDate(); //获取当前日期中的月的天数
  570. var year2 = year;
  571. var month2 = parseInt(month) + 1;
  572. if(month2 == 13) {
  573. year2 = parseInt(year2) + 1;
  574. month2 = 1;
  575. }
  576. var day2 = day;
  577. var days2 = new Date(year2, month2, 0);
  578. days2 = days2.getDate();
  579. if(day2 > days2) {
  580. day2 = days2;
  581. }
  582. if(month2 < 10) {
  583. month2 = '0' + month2;
  584. }
  585. var t2 = year2 + '-' + month2 + '-' + day2;
  586. return t2;
  587. break;
  588. default:
  589. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  590. break;
  591. }
  592. cNewTimeStr = cNewTimeStr.replace(/;/g, "");
  593. return cNewTimeStr;
  594. }
  595. //
  596. function before(str) {
  597. var dateStr = str;
  598. if (dateStr) {
  599. var now = ConvertDateFromString(dateStr);
  600. now.setDate(now.getDate() -1);
  601. var year = ";" + now.getFullYear() + ";";
  602. var month = ";" + now.getMonth() + ";";
  603. var day = ";" + now.getDate() + ";";
  604. if (year.length < 4) {
  605. year = "0" + year;
  606. }
  607. if (month.length < 4) {
  608. month = "0" + month;
  609. }
  610. if (day.length < 4) {
  611. day = "0" + day;
  612. }
  613. var datestr = year + "-" + month + "-" + day;
  614. datestr = datestr.replace(/;/g, "");
  615. }
  616. return datestr;
  617. }
  618. function after(str) {
  619. var dateStr = str;
  620. if (dateStr) {
  621. var now = ConvertDateFromString(dateStr);
  622. now.setDate(now.getDate() - 0 + 1);
  623. var year = ";" + now.getFullYear() + ";";
  624. var month = ";" + now.getMonth() + ";";
  625. var day = ";" + now.getDate() + ";";
  626. if (year.length < 4) {
  627. year = "0" + year;
  628. }
  629. if (month.length < 4) {
  630. month = "0" + month;
  631. }
  632. if (day.length < 4) {
  633. day = "0" + day;
  634. }
  635. var datestr = year + "-" + month + "-" + day;
  636. datestr = datestr.replace(/;/g, "");
  637. }
  638. return datestr;
  639. }
  640. function ConvertDateFromString(dateString) {
  641. if (dateString) {
  642. var sdate = dateString.split('-');
  643. var date = new Date(sdate[0], sdate[1], sdate[2]);
  644. return date;
  645. }
  646. }