|
-
-
- //当前时间
- var tmonth = new Date();
-
- var year = tmonth.getFullYear();
-
- var month = tmonth.getMonth();
-
- var dom = $('.month');
- //中间变量 记录
- var tttmonth = '';
-
- var tyear = '';
-
- var newData=null;
-
- var select_length = "";
- //获取产品id
-
- //var pro_id=getPar(pro_id);
-
- //测试产品id
- var pro_id=getPar("pro_id");
-
- //可选开始日期 xxxx-xx-xx
- var select_start_time = "";
- //可选结束日期 xxxx-xx-xx
- var select_end_time = "";
- //可选开始日期数组 xxxx-xx-xx
- var select_start_time_arr = "";
- //可选结束日期数组 xxxx-xx-xx
- var select_end_time_arr = "";
- //可选日
- var select_start_day ="";
- //可选月
- var select_start_month ="";
- //可选年
- var select_start_year ="";
- //可选日
- var select_end_day ="";
- //可选月
- var select_end_month ="";
- //可选年
- var select_end_year ="";
- //价格数据
- var select_data;
- //选择的价格
- var select_price;
- //选择的日期
- var select_go_date;
-
- //价格
- var one_price = 0;
-
-
-
-
- window.onload = function(){
- //获取产品价格
- get_product_price();
- !dom.hasClass("amonth")&&dom.addClass("amonth");
- //当前日期
- var date1 = new Date(year,month);
- //当前月份
- var tomonth = new Date().getMonth();
- //后台开始月份
- var select_tomonth = select_start_month-1;
-
- var today = new Date().getDate();
- var dayhtml = [];
- var week = ["日","一","二","三","四","五","六"];
-
-
-
- for (var t=1;t<=3;t++){
- dayhtml.push('<div style="clear:both">');
-
- var date = date1;
- month = date.getMonth()+t-1;
-
- if (month>=11) {
- tyear = year+1;
- tttmonth = month-12 ;
-
- // month = 0;
- }else{
- tyear =year;
- tttmonth = month;
- }
- if(tttmonth==-1){
- tttmonth=11;
- tyear = year;
- }
- dayhtml.push('<div class="month_title"><span class="current_month">'+(tttmonth+1)+'月'+'</span><span class="current_year">'+tyear+'</span></div>')
-
- // dayhtml.push();
- // $.each(week,function(i,v){
- // dayhtml.push('<div class="aweek" style="float:left">'+week[i]+'</div>')
- // });
-
- var str = '';
-
- $.each(week,function(i,v){
- str += '<div class="aweek ub-f1 text_middle ui_p_t15 ui_p_b15">'+week[i]+'</div>';
- });
- dayhtml.push('<div class="ub" style="margin-left:0.2rem;margin-right:0.2rem;">'+str+'</div>')
-
- var nextdate = new Date(year,month)
- var firstweek = nextdate.getDay();
- // var firstweek = month.getDay();
- // var first = month.getDay();
-
- var allday = new Date(parseInt(year),(parseInt(month)+1),0).getDate();
-
- var daystr = '<div style="margin-left:0.2rem;margin-right:0.2rem;">';
-
- for(var i = 0;i<firstweek;i++){
- daystr+='<div class="aday"></div>'
- };
- var data_cur_str=''; //日期str
- var data_cur=''; //日期-
- // 得到去程日期
- var go_run_date=getPar('go_date');
- // var date1 = new Date(go_run_date.replace(/\-/g, '/'));
- // // 判断日期是否合理
- // var date1 = new Date(start_date.replace(/\-/g, '/'));
- // var date2 = new Date(end_date.replace(/\-/g, '/'));
- // if (date1>date2 || end_date=="") {
- // $('#id-date-picker-2').val(start_date);
- // }
- if (month==select_tomonth){
- for(i=1;i<=allday;i++){
- var t_m=(tttmonth+1);
- var t_m_str=t_m;
- var t_d_str=i;
- if(t_m<=9){
- t_m_str="0"+t_m;
- }
- if(i<=9){
- t_d_str="0"+i;
- }
- data_cur_str=t_m_str+"月"+t_d_str+'日';
- data_cur=tyear+"-"+(Array(2).join(0)+(tttmonth+1)).slice(-2)+"-"+(Array(2).join(0)+i).slice(-2);
-
- // if(data[data_cur]){
- // you
- // }else{
- //
- // }
-
-
- var run_day=go_run_date.substring(8);
- if(i<parseInt(run_day)){
- daystr+='<div style="font-size:0.14rem" class="aday disday">'+i+'</div>';
- }else{
- if(i<select_start_day){
- if(i==today){
- daystr+='<div style="font-size:0.14rem" data-cur-str="'+data_cur_str+'" data-cur="'+data_cur+'" class="aday disday today">今天</div>';
- }else{
- daystr+='<div style="font-size:0.14rem" class="aday disday">'+i+'</div>';
- }
-
- }else{
- if(i==today){
- daystr+='<div style="font-size:0.14rem" data-cur-str="'+data_cur_str+'" data-cur="'+data_cur+'" class="aday canday today"><div style="font-size:0.14rem">今天</div><div style="font-size:0.09rem;padding-right:0.04rem;top: -0.02rem;">¥123</div></div>';
- }else{
- daystr+='<div data-cur-str="'+data_cur_str+'" data-cur="'+data_cur+'"class="aday canday"><div style="font-size:0.14rem">'+i+'</div><div style="font-size:0.09rem;padding-right:0.04rem;top: -0.02rem;"></div></div>';
- }
-
- }
- }
-
- }
- }else if(month<select_tomonth){
- for(i=1;i<=allday;i++){
- daystr+='<div style="font-size:0.14rem" class="aday disday">'+i+'</div>'
- }
- }else{
- for(i=1;i<=allday;i++){
- var t_m=(tttmonth+1);
- var t_m_str=t_m;
- var t_d_str=i;
- if(t_m<=9){
- t_m_str="0"+t_m;
- }
- if(i<=9){
- t_d_str="0"+i;
- }
- data_cur_str=t_m_str+"月"+t_d_str+'日';
- data_cur=tyear+"-"+(Array(2).join(0)+(tttmonth+1)).slice(-2)+"-"+(Array(2).join(0)+i).slice(-2);
- daystr+='<div data-cur-str="'+data_cur_str+'" data-cur="'+data_cur+'"class="aday canday"><div style="font-size:0.14rem">'+i+'</div><div style="font-size:0.09rem;padding-right:0.04rem;top: -0.02rem;"></div></div>'
- }
- }
-
- daystr += "</div>";
-
- dayhtml.push(daystr);
- dayhtml.push('</div>');
- }
- dom.html(dayhtml.join(""))
-
-
- //选中去程的日期
- $(".canday").each(function(index,domE){
- if($(this).attr('data-cur')==getPar('go_date')){
- $(this).removeClass('select_day');
- $(this).removeClass('select_go_day');
- $(this).addClass('select_go_day');
- };
- if(index<select_length){
- var date_time = $(this).attr("data-cur");
- $(this).attr("one_price",parseInt(Math.ceil(select_data[index].price)));
- if((new Date(date_time).getDay() == 6)||(new Date(date_time).getDay() == 0)){
- $(this).children().eq(1).text("¥"+parseInt(Math.ceil(select_data[index].price)));
- $(this).children().eq(1).css("color","#519d9e");
- }else{
- $(this).children().eq(1).text("¥"+parseInt(Math.ceil(select_data[index].price)));
- $(this).children().eq(1).css("color","#519d9e");
- }
-
- }else{
- $(this).removeClass("canday");
- $(this).addClass("disday");
- $(this).children().eq(0).css("color","rgb(207,207,207)");
- }
-
-
- })
-
- $(".canday").on("click",function(){
- $(".canday").removeClass('select_day');
- $(this).addClass('select_day');
- select_go_date = $(this).attr("data-cur");
- one_price = $(this).attr("one_price");
- var people_number = $(".aticket").text();
- total_pirce = parseInt(people_number)*parseInt(Math.ceil(one_price));
- $("#total").text(total_pirce);
-
-
- })
- $("#loading_html").show();
-
- }
-
-
- //加
- $(".add").on("click",function(){
- var num =parseInt($(this).siblings("span").text());
-
- if(num>=20){
- $(".add").removeClass("bor_right");
- $(".add").addClass("bor_right_c");
- var people_number = $(".aticket").text();
- total_pirce = parseInt(people_number)*parseInt(Math.ceil(one_price));
- $("#total").text(total_pirce);
- $("#people_number").text("共"+people_number+"人");
- }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(one_price));
- $("#total").text(total_pirce);
- $("#people_number").text("共"+people_number+"人");
- }
-
- });
- //减
- $(".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(one_price));
- $("#total").text(total_pirce);
- $("#people_number").text("共"+people_number+"人");
- }
- if(num==1){
- var people_number = $(".aticket").text();
- total_pirce = parseInt(people_number)*parseInt(Math.ceil(one_price));
- $("#total").text(total_pirce);
- $("#people_number").text("共"+people_number+"人");
- }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(one_price));
- $("#total").text(total_pirce);
- $("#people_number").text("共"+people_number+"人");
- }
-
- })
-
- function get_product_price(){
- $.ajax({
- url:base_api + "around/getDate", //请求地址
- data:{pro_id:pro_id},
- async:false,
- type: "post", //请求方式
- dataType: "json",
- success: function (data) {
- console.log(data);
- if(data.flag == true){
- select_data = data.data;
- var num = data.data.length-1;
- select_length = data.data.length;
- select_start_time = data.data[0].date;
- select_start_time_arr=select_start_time.split("-");
- select_end_time = data.data[num].date;
- select_end_time_arr=select_end_time.split("-");
- //可选日
- select_start_day = select_start_time_arr[2];
- //可选月
- select_start_month = select_start_time_arr[1];
- //可选年
- select_start_year = select_start_time_arr[0];
- //可选日
- select_end_day = select_end_time_arr[2];
- //可选月
- select_end_month = select_end_time_arr[1];
- //可选年
- select_end_year = select_end_time_arr[0];
- }else{
- alert(data.msg);
- }
-
- }
- });
- }
-
- function go_to_pay(){
- var peo_no = $("#people_no").text();
- if (select_go_date) {
- window.location.href="trave_around_fill_order.html?peo_no="+peo_no+"&go_date="+select_go_date+"&pro_id="+pro_id;
- }else{
- alert('请选择正确的日期!');
- return;
- }
-
-
- }
|