//Author:zhangsq //Date:2016-11-17 //Description:填写订单 //全局参数 往返程run_id var run_id = getPar('run_id'); var start_area_id = getPar('start_area_id'); var end_area_id = getPar('end_area_id'); //是否返程 var if_back = '0'; //0去程 1返程 //去程--- 出发站点 目的站点数组 var go_start_res_ary = ''; var go_end_res_ary = ''; //返程--- 触犯站点 目的站点数组 var back_start_res_ary = ''; var back_end_res_ary = ''; //去程的优惠价格 var go_discount_price = ''; //返程的优惠价格 var back_discount_price = ''; //去程的ticket_id var go_ticket_id = ''; var stock = ''; //返程的ticket_id var back_ticket_id = ''; //站点下弹框 var resHTML = ''; // 选中的上下车站点 var selected_res_name = ''; var selected_res_id = ''; var selected_sel_id = ''; //去程的run_date; var go_run_date = ''; var back_run_date = ''; window.onload = function() { //站点html 下弹框 resHTML = $('#wei_info').html(); var if_go = getPar('if_go'); if(if_go == 'go') { $('#backinfo').hide(); if_back = '0'; //加载去程的信息 reloadGoInfo(); } else { if_back = '1'; //加载返程的信息 reloadBackInfo(); } } //页面开始加载去程的信息 function reloadGoInfo() { var go_data = getStorJson('CacheStationInfo_Go'); if(go_data) { //替换去程信息 replaceGoInfo(go_data); var data_str = setJsonHtml(go_data); $('#goinfo').attr('data_str', data_str); var sel_station = getStorJson('CacheInfo_custmer'); if(sel_station) { //加载之前站点的选中信息 // reloadHistoryStation(sel_station); $('#custmer').val(sel_station.custmer); $('#tel').val(sel_station.tel); $('.aticket').text(sel_station.count); } } else { //重新加载 var urlstr = base_api + 'order/order/getRunDetail'; var run_id = $('#goinfo').attr('run_id'); if(!run_id) { run_id = getPar('run_id'); } var data = { start_area_id: start_area_id, end_area_id: end_area_id, run_id: run_id } ZZLog(data); $.ajax({ url: urlstr, data: data, async: false, type: 'post', dataType: 'json', success: function(data) { ZZLog(data); if(data.flag) { //替换去程数据 var dataHTML = setJsonHtml(data.data); $('#goinfo').attr('data_str', dataHTML); replaceGoInfo(data.data); } }, error: function(error) { ZZLog(error); } }); } } //替换去程的数据 function replaceGoInfo(data) { console.log(data); //替换时间信息 $('#gotime').html(data.select_start_res.res_time); go_run_date = data.run_date; var year = getMonthAndDayByDate(go_run_date, 'year'); var month = getMonthAndDayByDate(go_run_date, 'month'); if(month < 10) { month = month.substring(1, month.length); } var day = getMonthAndDayByDate(go_run_date, 'day'); var showday = month + '月' + day + '日'; $('#go_day').html(showday); //判断是否是今天 if(go_run_date == getDateTime(0)) { $('#go_week').html('今天'); } else { var str = year + '/' + month + '/' + day; var week = getWeekDay(str); $('#go_week').html(week); } //run_id $('#goinfo').attr('run_id', data.run_id); $('#goinfo').attr('go_run_date', data.run_date); //替换选中站点信息 var sel_start_info = data.select_start_res; var sel_end_info = data.select_end_res; //===站点信息 $('#start_res_go').attr('startres_goid', sel_start_info.res_id); $('#start_res_go').html(sel_start_info.res_name + '(' + sel_start_info.res_time + ')'); $('#end_res_go').attr('endres_goid', sel_end_info.res_id); $('#end_res_go').html(sel_end_info.res_name + '(' + sel_end_info.res_time + ')'); //===poi信息 $('#stare_area_id').html(data.start_area_name); $('#stare_area_id').attr('startarea_goid', data.start_area_id); $('#end_area_id').html(data.end_area_name); $('#end_area_id').attr('endarea_goid', data.end_area_id); //去程站点数据 go_start_res_ary = data.start_res_arr; go_end_res_ary = data.end_res_arr; //替换票种 日程信息 var ticket_info = data.ticket_info; $('#go_price').html(ticket_info.price); go_discount_price = ticket_info.discount_price; go_ticket_id = ticket_info.ticket_id; $('#distance_back').html('全程' + ticket_info.total_distance + '公里'); $('#usetime_back').html('约' + ticket_info.total_time + '到达'); if(go_discount_price > 0) { $('#discount').html('选择往返有优惠'); } else { $('#discount').html(''); } // $('#discount').html('选择往返有优惠'); $('#goinfo').attr('discount_price', ticket_info.discount_price); $('#select_back').html('添加返程'); $('#select_back').css('color', '#3d434f'); $('#tupian').attr('src', 'images/ic_addback@2x.png'); //库存 stock = ticket_info.stock > 20 ? 20 : ticket_info.stock; stock = stock > 0 ? stock : 0; // stock = "10"; countTotal(); $("#loading_html").show(); } //去程上车站点的选择 function goStartAreaDidClicked() { $("#mask").css("display", "block"); $('#res_div').css("display", "block"); sel_res_div = 'startres_goid'; upDiv(go_start_res_ary, 'start_res_go', 'go'); $("#weui_actionsheet").addClass("weui_actionsheet_toggle"); } //切换去程的出发地站点信息 function changeGoStartResInfo(id, time, name) { var start_res_id = $('#start_res_go').attr('startres_goid'); var urlstr = base_api + 'order/order/getRunDetailByStart'; var run_id = $('#goinfo').attr('run_id'); $('#gotime').html(time); var data = { start_res_id: start_res_id, end_area_id: end_area_id, run_id: run_id } $.ajax({ url: urlstr, data: data, async: false, type: 'post', dataType: 'json', success: function(data) { ZZLog(data); if(data.flag) { //选择去程的出发站点,修改详情数据 showDetailInfoByChangeStartRes(data.data); //替换 html json 数据 var data_str = $('#goinfo').attr('data_str'); data_str = getJsonHtml(data_str); data_str.ticket_info = data.data.ticket_info; data_str.end_res_arr = data.data.end_res_arr; data_str.select_end_res = data.data.select_end_res; data_str.select_start_res.res_id = id; data_str.select_start_res.res_time = time; data_str.select_start_res.res_name = name; var data_str = setJsonHtml(data_str); $('#goinfo').attr('data_str', data_str); } }, error: function(error) { ZZLog(error); } }); } //选择去程的出发站点,修改详情数据 function showDetailInfoByChangeStartRes(data) { //替换选中站点信息 var sel_end_info = data.select_end_res; //===站点信息 $('#end_res_go').attr('endres_goid', sel_end_info.res_id); $('#end_res_go').html(sel_end_info.res_name + '(' + sel_end_info.res_time + ')'); //去程站点数据 go_end_res_ary = data.end_res_arr; //替换票种 日程信息 var ticket_info = data.ticket_info; $('#go_price').html(ticket_info.price); go_discount_price = ticket_info.discount_price; go_ticket_id = ticket_info.ticket_id; $('#distance_back').html('全程' + ticket_info.total_distance + '公里'); $('#usetime_back').html('约' + ticket_info.total_time + '到达'); if(go_discount_price > 0) { $('#discount').html('选择往返有优惠'); } else { $('#discount').html(''); } // $('#discount').html('选择往返有优惠'); $('#goinfo').attr('discount_price', go_discount_price); //库存 stock = ticket_info.stock > stock ? stock : ticket_info.stock; stock = stock > 0 ? stock : 0; countTotal(); } //去程下车站点的选择 function goEndAreaDidClicked() { $("#mask").css("display", "block"); $('#res_div').css("display", "block"); sel_res_div = 'endres_goid'; upDiv(go_end_res_ary, 'end_res_go', 'go'); $("#weui_actionsheet").addClass("weui_actionsheet_toggle"); } //切换去程的目的地站点信息 function changeGoEndResInfo(id, time, name) { var start_res_id = $('#start_res_go').attr('startres_goid'); var end_res_id = $('#end_res_go').attr('endres_goid'); var urlstr = base_api + 'order/order/getRunDetailByEnd'; var run_id = $('#goinfo').attr('run_id'); var data = { start_res_id: start_res_id, end_res_id: end_res_id, run_id: run_id } $.ajax({ url: urlstr, data: data, async: false, type: 'post', dataType: 'json', success: function(data) { ZZLog(data); if(data.flag) { //选择去程的目的站点,修改详情数据 showDetailInfoByChangeEndRes(data.data); //替换 html json 数据 var data_str = $('#goinfo').attr('data_str'); data_str = getJsonHtml(data_str); data_str.ticket_info = data.data.ticket_info; data_str.select_end_res.res_id = id; data_str.select_end_res.res_name = name; data_str.select_end_res.res_time = time; var data_str = setJsonHtml(data_str); $('#goinfo').attr('data_str', data_str); } }, error: function(error) { ZZLog(error); } }); } //选择去程的目的站点,修改详情数据 function showDetailInfoByChangeEndRes(data) { //替换票种 日程信息 var ticket_info = data.ticket_info; $('#go_price').html(ticket_info.price); go_discount_price = ticket_info.discount_price; go_ticket_id = ticket_info.ticket_id; $('#distance_back').html('全程' + ticket_info.total_distance + '公里'); $('#usetime_back').html('约' + ticket_info.total_time + '到达'); // $('#discount').html('选择往返有优惠'); $('#goinfo').attr('discount_price', go_discount_price); if(go_discount_price > 0) { $('#discount').html('选择往返有优惠'); } else { $('#discount').html(''); } //库存 stock = ticket_info.stock > stock ? stock : ticket_info.stock; stock = stock > 0 ? stock : 0; countTotal(); } //添加返程 function selectBackInfo() { if(if_back == '0') { //缓存联系人信息 cacheTheCustomerInfo(); //缓存站点信息 cacheTheStationInfo(); if_back = '1'; $('#select_back').html('取消返程'); $('#select_back').css('color', '#999999'); $('#tupian').attr('src', 'images/ic_sub.png'); var start_area_id = $('#stare_area_id').attr('startarea_goid'); var end_area_id = $('#end_area_id').attr('endarea_goid'); var go_run_date = $('#goinfo').attr('go_run_date'); window.location.href = './calendar.html?start_area_id=' + end_area_id + '&end_area_id=' + start_area_id + '&from=fill_order&if_go=go' + '&go_run_date=' + go_run_date; } else { cacheTheCustomerInfo(); clearStorage('CacheStationInfo_Back'); if_back = '0'; $('#backinfo').hide(); $('#select_back').html('添加返程'); $('#tupian').attr('src', 'images/ic_addback@2x.png'); var go_discount_price = $('#goinfo').attr('discount_price'); // go_discount_price = 5; if(go_discount_price > 0) { $('#discount').html('选择往返有优惠'); } else { $('#discount').html(''); } // $('#discount').html('选择往返有优惠'); $('#select_back').css('color', '#3d434f'); countTotal(); } } //加载返程的信息 function reloadBackInfo() { var sel_station = getStorJson('CacheInfo_custmer'); if(sel_station) { //加载之前站点的选中信息 // reloadHistoryStation(sel_station); $('#custmer').val(sel_station.custmer); $('#tel').val(sel_station.tel); $('.aticket').text(sel_station.count); } var back_data = getStorage('CacheStationInfo_Back'); if(back_data) { //替换去程信息 replaceBackInfo(back_data); var data_str = setJsonHtml('back_data'); $('#backinfo').attr('data_str', data_str); } else { var urlstr = base_api + 'order/order/getRunDetail'; var data = { start_area_id: start_area_id, end_area_id: end_area_id, run_id: run_id } $.ajax({ url: urlstr, data: data, async: false, type: 'post', dataType: 'json', success: function(data) { if(data.flag) { ZZLog(data); var dataHTML = setJsonHtml(data.data); $('#backinfo').attr('data_str', dataHTML); //替换返程数据 replaceBackInfo(data.data); } }, error: function(error) { ZZLog(error); } }); } } //替换返程数据 function replaceBackInfo(data) { //展示去程的数据 var go_info = getStorJson('CacheStationInfo_Go'); var data_str = setJsonHtml(go_info); $('#goinfo').attr('data_str', data_str); replaceGoInfo(go_info); console.log(go_info); $('#backinfo').removeClass('ui_hide'); // 替换时间信息 // $('#backtime').html(data.run_time); $('#backtime').html(data.select_start_res.res_time); back_run_date = data.run_date; var year = getMonthAndDayByDate(back_run_date, 'year'); var month = getMonthAndDayByDate(back_run_date, 'month'); // if (month < 10) { // month = month.substring(1,month.length-1); // } var day = getMonthAndDayByDate(back_run_date, 'day'); var showday = month + '月' + day + '日'; $('#back_day').html(showday); //判断是否是今天 if(back_run_date == getDateTime(0)) { $('#back_week').html('今天'); } else { var str = year + '/' + month + '/' + day; var week = getWeekDay(str); $('#back_week').html(week); } //run_id_back $('#backinfo').attr('run_id', data.run_id); //替换选中站点信息 var sel_start_info = data.select_start_res; var sel_end_info = data.select_end_res; //===站点信息 $('#start_res_back').attr('startres_backid', sel_start_info.res_id); $('#start_res_back').html(sel_start_info.res_name + '(' + sel_start_info.res_time + ')'); $('#end_res_back').attr('endres_backid', sel_end_info.res_id); $('#end_res_back').html(sel_end_info.res_name + '(' + sel_end_info.res_time + ')'); //===poi信息 $('#back_stare_area_id').html(data.start_area_name); $('#back_stare_area_id').attr('startarea_backid', data.start_area_id); $('#back_end_area_id').html(data.end_area_name); $('#back_end_area_id').attr('endarea_backid', data.end_area_id); //返程站点数据 back_start_res_ary = data.start_res_arr; back_end_res_ary = data.end_res_arr; //替换票种 日程信息 var ticket_info = data.ticket_info; // $('#back_price').html(parseInt(ticket_info.price)-parseInt(ticket_info.discount_price)-parseInt(go_discount_price)); $('#back_price').html(parseInt(ticket_info.price)); back_discount_price = ticket_info.discount_price; back_ticket_id = ticket_info.ticket_id; // $('#distance_back').html('全程'+ticket_info.total_distance+'公里'); // $('#usetime_back').html(ticket_info.total_time+'到达'); var new_price = (parseInt(go_discount_price) + parseInt(back_discount_price)); if(new_price > 0) { $('#discount').html('已优惠' + new_price + '元/人'); } else { $('#discount').html(''); } // $('#discount').html('已优惠'+(parseInt(go_discount_price)+parseInt(back_discount_price))+'元/人'); $('#select_back').html('取消返程'); $('#select_back').css('color', '#3d434f'); $('#tupian').attr('src', 'images/ic_sub.png'); $('#backinfo').attr('discount_price', back_discount_price); //库存 stock = ticket_info.stock > stock ? stock : ticket_info.stock; stock = stock > 0 ? stock : 0; countTotal(); } //返程上车站点的选择 function goStartAreaDidClickedBack() { $("#mask").css("display", "block"); $('#res_div').css("display", "block"); sel_res_div = 'startres_backid'; upDiv(back_start_res_ary, 'start_res_back', 'back'); $("#weui_actionsheet").addClass("weui_actionsheet_toggle"); } //切换返程的出发地站点信息 function changeBackStartResInfo(id, time, name) { var start_res_id = $('#start_res_back').attr('startres_backid'); var urlstr = base_api + 'order/order/getRunDetailByStart'; var data = { start_res_id: start_res_id, end_area_id: end_area_id, run_id: run_id } $.ajax({ url: urlstr, data: data, async: false, type: 'post', dataType: 'json', success: function(data) { ZZLog(data); if(data.flag) { //选择返程的出发站点,修改详情数据 showDetailInfoByChangeStartResBack(data.data); //替换 html json 数据 var data_str = $('#backinfo').attr('data_str'); data_str = getJsonHtml(data_str); data_str.ticket_info = data.data.ticket_info; data_str.end_res_arr = data.data.end_res_arr; data_str.select_end_res = data.data.select_end_res; data_str.select_start_res.res_id = id; data_str.select_start_res.res_time = time; data_str.select_start_res.res_name = name; var data_str = setJsonHtml(data_str); $('#backinfo').attr('data_str', data_str); } }, error: function(error) { ZZLog(error); } }); } //选择返程的出发站点,修改详情数据 function showDetailInfoByChangeStartResBack(data) { //替换选中站点信息 var sel_end_info = data.select_end_res; //===站点信息 $('#end_res_back').attr('endres_backid', sel_end_info.res_id); $('#end_res_back').html(sel_end_info.res_name + '(' + sel_end_info.res_time + ')'); //去程站点数据 back_end_res_ary = data.end_res_arr; //替换票种 日程信息 var ticket_info = data.ticket_info; // $('#back_price').html(parseInt(ticket_info.price)-parseInt(ticket_info.discount_price)-parseInt(go_discount_price)); $('#back_price').html(parseInt(ticket_info.price)); back_discount_price = ticket_info.discount_price; back_ticket_id = ticket_info.ticket_id; // $('#distance_back').html('全程'+ticket_info.total_distance+'公里'); // $('#usetime_back').html(ticket_info.total_time+'到达'); // $('#discount').html('选择往返有优惠'); var new_price = (parseInt(go_discount_price) + parseInt(back_discount_price)); if(new_price > 0) { $('#discount').html('已优惠' + new_price + '元/人'); } else { $('#discount').html(''); } // $('#discount').html('已优惠'+(parseInt(go_discount_price)+parseInt(back_discount_price))+'元/人'); $('#backinfo').attr('discount_price', back_discount_price); //库存 stock = ticket_info.stock > stock ? stock : ticket_info.stock; stock = stock > 0 ? stock : 0; countTotal(); } //返程下车站点的选择 function goEndAreaDidClickedBack() { $("#mask").css("display", "block"); $('#res_div').css("display", "block"); sel_res_div = 'endres_backid'; upDiv(back_end_res_ary, 'end_res_back', 'back'); $("#weui_actionsheet").addClass("weui_actionsheet_toggle"); } //切换返程的目的地站点信息 function changeBackEndResInfo(id, time, name) { var start_res_id = $('#start_res_back').attr('startres_backid'); var end_res_id = $('#end_res_back').attr('endres_backid'); var urlstr = base_api + 'order/order/getRunDetailByEnd'; var data = { start_res_id: start_res_id, end_res_id: end_res_id, run_id: run_id } $.ajax({ url: urlstr, data: data, async: false, type: 'post', dataType: 'json', success: function(data) { ZZLog(data); if(data.flag) { //选择去程的目的站点,修改详情数据 showDetailInfoByChangeEndResBack(data.data); //替换 html json 数据 var data_str = $('#backinfo').attr('data_str'); data_str = getJsonHtml(data_str); data_str.ticket_info = data.data.ticket_info; data_str.select_end_res.res_id = id; data_str.select_end_res.res_name = name; data_str.select_end_res.res_time = time; var data_str = setJsonHtml(data_str); $('#backinfo').attr('data_str', data_str); } }, error: function(error) { ZZLog(error); } }); } //选择返程的目的站点,修改详情数据 function showDetailInfoByChangeEndResBack(data) { //替换票种 日程信息 var ticket_info = data.ticket_info; // $('#back_price').html(parseInt(ticket_info.price)-parseInt(ticket_info.discount_price)-parseInt(go_discount_price)); $('#back_price').html(parseInt(ticket_info.price)); back_discount_price = ticket_info.discount_price; back_ticket_id = ticket_info.ticket_id; // $('#distance_back').html('全程'+ticket_info.total_distance+'公里'); // $('#usetime_back').html(ticket_info.total_time+'到达'); // $('#discount').html('选择往返有优惠'); var new_price = (parseInt(go_discount_price) + parseInt(back_discount_price)); if(new_price > 0) { $('#discount').html('已优惠' + new_price + '元/人'); } else { $('#discount').html(''); } // $('#discount').html('已优惠'+(parseInt(go_discount_price)+parseInt(back_discount_price))+'元/人'); $('#backinfo').attr('discount_price', back_discount_price); //库存 stock = ticket_info.stock > stock ? stock : ticket_info.stock; stock = stock > 0 ? stock : 0; countTotal(); } //缓存联系人信息 function cacheTheCustomerInfo() { var custmer = $('#custmer').val(); var tel = $('#tel').val(); var count = $('.aticket').text(); var info_data = { custmer: custmer, tel: tel, count: count }; setStorJson('CacheInfo_custmer', info_data); } //缓存站点信息 function cacheTheStationInfo() { if(if_back == '0') { //去程 var data_str = $('#goinfo').attr('data_str'); data_str = getJsonHtml(data_str); setStorJson('CacheStationInfo_Go', data_str); } else { //去程 var data_str = $('#goinfo').attr('data_str'); data_str = getJsonHtml(data_str); setStorJson('CacheStationInfo_Go', data_str); //返程 var data_str_back = $('#backinfo').attr('data_str'); data_str_back = getJsonHtml(data_str_back); setStorJson('CacheStationInfo_Back', data_str_back); } } //提交订单 function payBtnDidClicked() { delay(makorder,300); function makorder() { var custmer = $('#custmer').val(); var tel = $('#tel').val(); var phoneRe = /^1[3|4|5|7|8]\d{9}$/; var custmer_count = $('.aticket').text(); if(custmer == '' || tel == '') { alert('请填写联系人信息!') return; } else if(!phoneRe.test(tel)) { alert('请输入正确的手机号!') return; } else if(custmer_count == '0') { alert('请填写正确的票种数量!'); return; } var customer_info = '{' + custmer + ',' + tel + ',' + " " + '}'; var new_str = ''; if(if_back == '0') { var go_run_id = $('#goinfo').attr('run_id'); var go_discount = $('#goinfo').attr('discount_price'); var go_price = parseInt($('#go_price').html()); new_str = '{1' + ',' + go_run_id + ',' + go_ticket_id + ',' + go_price + ',' + custmer_count + '}'; } else { var go_run_id = $('#goinfo').attr('run_id'); var go_discount = $('#goinfo').attr('discount_price'); var go_price = parseInt($('#go_price').html()) - parseInt(go_discount); new_str = '{1' + ',' + go_run_id + ',' + go_ticket_id + ',' + go_price + ',' + custmer_count + '}'; var back_run_id = $('#backinfo').attr('run_id'); var back_discount = $('#backinfo').attr('discount_price'); var back_price = parseInt($('#back_price').html()) - parseInt(back_discount); new_str += '{2' + ',' + back_run_id + ',' + back_ticket_id + ',' + back_price + ',' + custmer_count + '}'; } var data = { customer_info: customer_info, ticket_info: new_str }; ZZLog(data); $("#loadingToast").show(); $("#payBtn").removeAttr('onClick'); $.ajax({ url: base_api + 'order/order/submitOrder', data: data, async: false, type: 'post', dataType: 'json', success: function(data) { if(data.flag) { clearStorage('disney_tranship'); $("#loadingToast").hide(); $("#payBtn").attr('onClick', 'payBtnDidClicked();'); window.location.href = data.url; } else { $("#loadingToast").hide(); $("#payBtn").attr('onClick', 'payBtnDidClicked();'); if (data.code != '10001') { alert(data.msg); } else{ return; } } }, error: function(error) { ZZLog(error); } }); } } //上弹框的内容封装 function upDiv(data, select_id, goBack) { var sel = $('#' + select_id).attr(sel_res_div); var html = ''; for(var i = 0; i < data.length; i++) { var tempHTML = resHTML; tempHTML = tempHTML.replace('示例菜单', data[i].res_name); tempHTML = tempHTML.replace('[res_id]', data[i].res_id); tempHTML = tempHTML.replace('[showtime]', data[i].res_time); if(sel == data[i].res_id) { tempHTML = tempHTML.replace('images/a3/ic_select_nor.png', 'images/a3/ic_select_sel.png'); } else { tempHTML = tempHTML.replace('images/a3/ic_select_nor.png', 'images/a3/ic_select_nor.png'); } html += tempHTML; } $('#wei_info').html(html); $('#actionsheet_cancel').click(function() { $('#mask').click(); }) $('.weui_actionsheet_cell').parent().click(function() { console.log($(this).children().eq(0).attr('id')); selected_res_name = $(this).children().eq(0).text(); selected_res_id = $(this).children().eq(0).attr('id'); selected_sel_id = select_id; var seltime = $(this).children().eq(0).attr('showtime'); $('#' + select_id).html($(this).children().eq(0).text() + '(' + seltime + ')'); $('#' + select_id).attr(sel_res_div, $(this).children().eq(0).attr('id')); $('#mask').click(); var id = $(this).children().eq(0).attr('id'); var name = $(this).children().eq(0).text(); var time = seltime; switch(select_id) { case 'start_res_go': //切换去程的出发地站点信息 changeGoStartResInfo(id, time, name); break; case 'end_res_go': //切换去程的目的地站点信息 changeGoEndResInfo(id, time, name); break; case 'start_res_back': //切换去程的出发地站点信息 changeBackStartResInfo(id, time, name); break; case 'end_res_back': //切换去程的目的地站点信息 changeBackEndResInfo(id, time, name); break; default: break; } }) } //点击了蒙板 $('#mask').click(function() { $("#mask").css("display", "none"); $("#weui_actionsheet").removeClass("weui_actionsheet_toggle"); // $('#res_div').hide(); }) //加 $(".add").on("click", function() { var current = $('.aticket').text(); var now_count = parseInt(current) + 1; if(now_count >= stock) { $('.aticket').text(stock); if(now_count > stock) { alert('没有更多的库存!') } $('.add').addClass('bor_right_c'); $('.add').removeClass('bor_right'); $('.cut').addClass('bor_left'); $('.cut').removeClass('bor_left_c'); } else { $('.aticket').text(now_count); $('.add').removeClass('bor_right_c'); $('.add').addClass('bor_right'); $('.cut').addClass('bor_left'); $('.cut').removeClass('bor_left_c'); } countTotal(); }); //减 $(".cut").on("click", function() { var current = $('.aticket').text(); var now_count = parseInt(current) - 1; if(now_count > 1 && now_count <= stock) { $('.aticket').text(now_count); $('.cut').addClass('bor_left'); $('.cut').removeClass('bor_left_c'); $('.add').removeClass('bor_right_c'); $('.add').addClass('bor_right'); } else { // alert('请选择正确的数量!'); $('.aticket').text('1'); $('.cut').removeClass('bor_left'); $('.cut').addClass('bor_left_c'); $('.add').removeClass('bor_right_c'); $('.add').addClass('bor_right'); } countTotal(); }) //计算价格信息 function countTotal() { var count = $('.aticket').text(); // $('#total_people').html('共'+count+'人'); var price = ''; var count_price = ''; if(if_back == '0') { price = parseInt($('#go_price').html()); // count_price = parseInt($('#goinfo').attr('discount_price')); // if (count_price > 0) { // $('#total_people').html('共'+count+'人'+'  '+'优惠'+count_price*count+'元'); // } else{ $('#total_people').html('共' + count + '人'); // } } else { price = parseInt($('#go_price').html()) + parseInt($('#back_price').html()); count_price = parseInt($('#goinfo').attr('discount_price')) + parseInt($('#backinfo').attr('discount_price')); if(count_price > 0) { $('#total_people').html('共' + count + '人' + '  ' + '优惠' + count_price * count + '元'); } else { $('#total_people').html('共' + count + '人'); } } $('#count_price').html(count * price); } var delay = (function() { var timer = 0; return function(callback, time) { clearTimeout(timer); timer = setTimeout(callback, time); }; })()