|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- var list_order = getStorJson("list_order");
- var get_bus = "";
- var people_num = $(".aticket").text();
- var people_name = $("#people_name").val();
- var people_phone = $("#people_phone").val();
- var goHTML = '';
- var total_pirce = parseInt(Math.ceil(list_order.price));
- var geton_time = "";
- var getoff_time = "";
-
- var line_name = '';
- var str_id = getStorage('list_id');
- var run_id = getStorage('run_id');
- var ticket_id = '';
- var line_id = '';
-
- var start_station_ary = '';
- var end_station_ary = '';
- var wei_infoHTML = '';
-
- $(document).ready(function(){
- wei_infoHTML = $('#wei_info').html();
- goHTML = $('#go').html();
- reloadDate();
- });
-
- function reloadDate(){
-
- //zsq
- var data = {line_id:str_id,run_id:run_id};
- ZZLog(data);
- $.ajax({
- url:"http://wx.zhizhuchuxing.com/ZZDZ2/application/custom_made/order/get_station_info.php", //请求地址
- data:data,
- type: "post",
- dataType: "json",
- success: function (data) {
- console.log(data);
- if(data.code == 0){
- line_name = data.line_name;
- showInfo(data);
- }else{
- alert(data.info);
- }
-
- }
- });
-
-
- //zsq end
-
-
-
- // $("#geton_bus").click(function(){
- // people_num = $(".aticket").text();
- // people_name = $("#people_name").val();
- // people_phone = $("#people_phone").val();
- // setStorage("people_num",people_num);
- // setStorage("people_name",people_name);
- // setStorage("people_phone",people_phone);
- // get_bus = "0";
- // setStorage("get_bus",get_bus);
- // window.location.href="select_add.html";
- // });
- // $("#getoff_bus").click(function(){
- // people_num = $(".aticket").text();
- // people_name = $("#people_name").val();
- // people_phone = $("#people_phone").val();
- // setStorage("people_num",people_num);
- // setStorage("people_name",people_name);
- // setStorage("people_phone",people_phone);
- // get_bus = "1";
- // setStorage("get_bus",get_bus);
- // window.location.href="select_add.html";
- // });
-
- }
-
- function showInfo(data){
- var tempHTML = goHTML;
- tempHTML=tempHTML.replace('[时间]',data.time);
- tempHTML=tempHTML.replace('[线路]',data.line_name);
- var year = getMonthAndDayByDate(data.date,'year');
- var month = getMonthAndDayByDate(data.date,'month');
- var day = getMonthAndDayByDate(data.date,'day');
- var str = year+ '/' +month +'/'+day;
- var week = getWeekDay(str);
- var cur_date_m_d=getDateTime(0);
- start_station_ary = data.data_start;
- end_station_ary = data.data_end;
- tempHTML=tempHTML.replace('[9月24日]',month+'月'+day+'日');
- tempHTML=tempHTML.replace('[今天]',data.date==getDateTime(0)?'今天':week);
- tempHTML=tempHTML.replace('[南京]',data.start_area);
- tempHTML=tempHTML.replace('[南通]',data.end_area);
- tempHTML=tempHTML.replace('[59]',data.price);
-
- ticket_id = data.tic_id;
- run_id = data.run_id;
- line_id = data.line_id;
-
- $('#go').html(tempHTML);
- //加
- $(".add").on("click",function(){
- var num =parseInt($(this).siblings("span").text());
-
- if(num>=6){
- $(".add").removeClass("bor_right");
- $(".add").addClass("bor_right_c");
- var people_number = $(".aticket").text();
- total_pirce = parseInt(people_number)*parseInt(Math.ceil(list_order.price));
- $("#total").text(total_pirce);
- }else{
- var num = $(this).siblings("span").text();
- $(this).siblings("span").text(++num);
- $(".cut").removeClass("bor_left_c");
- $(".cut").addClass("bor_left");
- var people_number = $(".aticket").text();
- total_pirce = parseInt(people_number)*parseInt(Math.ceil(list_order.price));
- $("#total").text(total_pirce);
- }
-
- });
- //减
- $(".cut").on("click",function(){
- var num = parseInt($(this).siblings("span").text());
- if(num==2){
- $(".cut").removeClass("bor_left");
- $(".cut").addClass("bor_left_c");
- var people_number = $(".aticket").text();
- total_pirce = parseInt(people_number)*parseInt(Math.ceil(list_order.price));
- $("#total").text(total_pirce);
- }
- if(num==1){
- var people_number = $(".aticket").text();
- total_pirce = parseInt(people_number)*parseInt(Math.ceil(list_order.price));
- $("#total").text(total_pirce);
- }else{
- $(this).siblings("span").text(--num);
- $(".add").removeClass("bor_right_c");
- $(".add").addClass("bor_right");
- var people_number = $(".aticket").text();
- total_pirce = parseInt(people_number)*parseInt(Math.ceil(list_order.price));
- $("#total").text(total_pirce);
- }
-
- })
-
- //选择站点的下侧弹层
- $("#geton_bus").click(function(){
- upDiv(start_station_ary,'get_on','on_time');
- $("#mask").css("display","block");
- $('#actionSheet_wrap').show();
- $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
- $('#sel_info').html('选择上车站点');
- })
- $("#getoff_bus").click(function(){
- upDiv(end_station_ary,'get_off','off_time');
- $("#mask").css("display","block");
- $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
- $('#sel_info').html('选择下车站点');
- })
-
- $('#mask').click(function(){
- $("#mask").css("display","none");
- $("#weui_actionsheet").removeClass("weui_actionsheet_toggle");
- })
- $('#actionsheet_cancel').click(function(){
- $("#mask").css("display","none");
- $("#weui_actionsheet").removeClass("weui_actionsheet_toggle");
- })
-
- }
-
-
- function upDiv(data,sel_station,sel_time){
- var html = '';
- for (var i = 0 ; i < data.length; i ++) {
- var tempHTML = wei_infoHTML;
- tempHTML = tempHTML.replace('[站点名称]',data[i].name+'('+data[i].time+')');
- tempHTML = tempHTML.replace('[id]',data[i].id);
- tempHTML = tempHTML.replace('[name]',data[i].name);
- tempHTML = tempHTML.replace('[time]',data[i].time);
- html += tempHTML;
- }
- $('#wei_info').html(html);
- $(".weui_actionsheet_cell").click(function(){
- $('#'+sel_station).text($(this).attr('name'));
- $('#'+sel_station).css('color','#666666');
- $('#'+sel_station).attr('idstr',$(this).attr('id'));
- $('#'+sel_time).text($(this).attr('time'));
- $('#mask').click();
- });
- // var name = $(this).attr()
- // $('#'+sel_station).html(this.attr('name'));
- // $('#'+sel_time).html(this.attr('time'));
-
-
- }
-
-
-
- $("#submit").click(function(){
- var start_id = $('#get_on').attr('idstr');
- var end_id = $('#get_off').attr('idstr');
- var start_time = $('#on_time').text();
- var end_time = $('#off_time').text();
-
- var people_amount = $(".aticket").text();
- var people_sub_name = $("#people_name").val();
- var people_sub_phone = $("#people_phone").val();
- var phoneRe =/^1[3|4|5|7|8]\d{9}$/;
- var prod_list = '{m'+ticket_id+'p'+people_amount+'|r'+run_id+'}';
- var customer_info = '{,'+people_sub_name+',1,'+people_sub_phone+',150,,,0,,}';
-
- if (!start_id) {
- alert('请选择上车站点');
- return false;
- }
- if (!end_id) {
- alert('请选择下车站点');
- return false;
- }
-
- if(people_sub_name==""){
- alert("请输入姓名");
- return false;
- }
- if(people_sub_phone==""){
- alert("请输入手机号");
- return false;
- }
- if(!phoneRe.test(people_sub_phone)){
- alert("请输入正确的手机号");
- return false;
- }
- $("#loadingToast").show();
- var data = {
- type:"order_submit",
- prod_list:prod_list,
- customer_info:customer_info,
- start_time:start_time,
- end_time:end_time,
- line_id:line_id,
- start_id:start_id,
- end_id:end_id
- };
- ZZLog(data);
- $.ajax({
- url:base_api+"application/custom_made/control.php", //请求地址
- data:data,
- type: "post",
- dataType: "json",
- success: function (data) {
- $("#loadingToast").hide();
- console.log(data);
- if(data.code == "0"){
- window.location.href= data.info;
- }else if(data.code == "101"){
- window.location.href="order_success.html";
- }else{
- alert(data.info);
- }
-
- }
- });
- });
|