|
- 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 year = getMonthAndDayByDate(list_order.run_date,'year');
- var month = getMonthAndDayByDate(list_order.run_date,'month');
- var day = getMonthAndDayByDate(list_order.run_date,'day');
- var str = year+ '/' +month +'/'+day;
- var week = getWeekDay(str);
- var cur_date_m_d=getDateTime(0);
- var total_pirce = parseInt(Math.ceil(list_order.price));
- var geton_time = "";
- var getoff_time = "";
- $(document).ready(function(){
- goHTML = $('#go').html();
- reloadDate();
- get_bus_inform();
- });
-
- function reloadDate(data){
- var tempHTML = goHTML;
- tempHTML=tempHTML.replace('[时间]',list_order.start_time);
- tempHTML=tempHTML.replace('[9月24日]',month+'月'+day+'日');
- tempHTML=tempHTML.replace('[今天]',list_order.run_date==getDateTime(0)?'今天':week);
- tempHTML=tempHTML.replace('[南京]',list_order.start_area);
- tempHTML=tempHTML.replace('[南通]',list_order.end_area);
- tempHTML=tempHTML.replace('[59]',Math.ceil(list_order.price));
-
- $('#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(){
- 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 get_bus_inform(){
- var geton_name = getStorage("geton_name");
- var geton_point = getStorage("geton_point");
- var getoff_name = getStorage("getoff_name");
- var getoff_point = getStorage("getoff_point");
- var get_people_num = getStorage("people_num");
- var get_people_name = getStorage("people_name");
- var get_people_phone = getStorage("people_phone");
- var people_amount = $(".aticket").text();
- var times = list_order.run_date+" "+list_order.start_time;
- if(get_people_num==null){
- $(".aticket").text("1");
- $("#total").text(total_pirce);
- }else{
-
- $(".aticket").text(get_people_num);
- $("#total").text(parseInt(get_people_num)*parseInt(Math.ceil(list_order.price)));
-
- }
- if(get_people_name==null){
- return;
-
- }else{
-
- $("#people_name").val(get_people_name);
-
- }
- if(get_people_phone==null){
- return;
-
- }else{
-
- $("#people_phone").val(get_people_phone);
-
- }
- if(geton_name==null){
- $("#get_on").text("选择上车地点");
- $("#get_on").css("color","#999");
- }else{
- $("#get_on").text(geton_name);
- $("#get_on").css("color","#333");
-
- }
-
- if(getoff_name==null){
- $("#get_off").text("选择下车地点");
- $("#get_off").css("color","#999");
- }else{
- $("#get_off").text(getoff_name);
- $("#get_off").css("color","#333");
- }
- //判断上下车时间
- if(geton_point!=null&&getoff_point!=null){
- // console.log("num:"+people_amount
- // +"&&&startx_y:"+geton_point
- // +"&&&endx_y:"+getoff_point
- // +"&&&prod_id:"+list_order.prod_id
- // +"&&&run_id:"+list_order.run_id
- // +"&&&run_date:"+times
- // );
- $.ajax({
- url:base_api+"application/api/get_time_by_location.php", //请求地址
- data:{
- num:people_amount,
- startx_y:geton_point,
- endx_y:getoff_point,
- prod_id:list_order.prod_id,
- run_id:list_order.run_id,
- run_date:times
- },
- type: "post",
- dataType: "json",
- success: function (data) {
- console.log(data);
- if(data.code == 0){
- geton_time = data.result[0];
- getoff_time = data.result[1];
- $("#on_time").text(data.str_time[0]);
- $("#off_time").text(data.str_time[1]);
- }else{
- alert(data.info);
- return false;
- }
-
- }
- });
- }
- }
-
- $("#submit").click(function(){
- var geton_name = getStorage("geton_name");
- var geton_point = getStorage("geton_point");
- var getoff_name = getStorage("getoff_name");
- var getoff_point = getStorage("getoff_point");
- var get_people_num = getStorage("people_num");
- var get_people_name = getStorage("people_name");
- var get_people_phone = getStorage("people_phone");
- 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'+list_order.ticket_id+'p'+people_amount+'|r'+list_order.run_id+'}';
- var customer_info = '{,'+people_sub_name+',1,'+people_sub_phone+',150,,,0,,}';
- if(geton_time==null||geton_time==""){
- alert("所选地点不在规划范围内");
- return false;
- }
- if(geton_name==null){
- alert("请选择上车地");
- return false;
- }
- if(getoff_name==null){
- 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();
- $.ajax({
- url:base_api+"application/custom_made/control.php", //请求地址
- data:{
- type:"order_submit",
- prod_list:prod_list,
- customer_info:customer_info,
- startx_y:geton_point,
- start_name:geton_name,
- endx_y:getoff_point,
- end_name:getoff_name,
- start_time:geton_time,
- end_time:getoff_time,
- line_id:list_order.prod_id
- },
- type: "post",
- dataType: "json",
- success: function (data) {
- $("#loadingToast").hide();
- console.log(data);
- if(data.code == "0"){
- clearStorage("getoff_name");
- clearStorage("getoff_point");
- clearStorage("geton_name");
- clearStorage("geton_point");
- window.location.href= data.info;
- }else if(data.code == "101"){
- clearStorage("getoff_name");
- clearStorage("getoff_point");
- clearStorage("geton_name");
- clearStorage("geton_point");
- window.location.href="order_success.html";
-
- }else{
- clearStorage("getoff_name");
- clearStorage("getoff_point");
- clearStorage("geton_name");
- clearStorage("geton_point");
- alert(data.info);
- }
-
- }
- });
- });
|