|
- // 总计
- var tr_finalStr='';
- //html_str
- var tr_oneHTML='';
- var select_room_HTML_str='';
- var http_data_length=0;
- //分销商还是自营
- var fen_xiao_type='';
-
- //得到产品名称
- var base_url="./st-xm/Api/ht_get_place_order_info.php"
- //var base_url="http://127.0.0.1/%E8%9C%98%E8%9B%9B2.0%E8%83%BD%E5%86%99PHP/st-xm/Api/ht_get_place_order_info.php"
- //var base_url_my_add_order="http://192.168.6.108:8082/st-xm/Api/hotel_submit_order.php";
- var base_url_my_add_order="./st-xm/Api/hotel_submit_order.php";
- //var base_url_my_add_order="./st-xm/Api/txt_form.php";
-
- //页面加载的时候调用
- window.onload=function(){
- tr_oneHTML=$('#tr_one').prop('outerHTML');
- tr_oneHTML=tr_oneHTML.replace('none','table-row');
- tr_finalStr=$('#tr_final').html();
- tr_finalStr=tr_finalStr.replace('none','table-row');
- select_room_HTML_str=$('#select_room').html();
- //入住时间初始值
- $('#id-date-picker-1').val(getDateTime(0));
- var prod_id=getPar('prod_id');
- if (!prod_id) {
- alert('缺少参数');
- return;
- }
- $("input[name='prod_id']").val(prod_id);
- //调用 函数
- var url=base_url+"?method=getProdName&prod_id="+prod_id;
- get_http_data_by_url(url);
- }
-
- // 请求方法,传入URL
- function get_http_data_by_url(myURL){
- var tnowtime = getDateTime(4);
- if (myURL.indexOf('?')>=0) {
- myURL+='&tt='+tnowtime;
- }else{
- myURL+='?tt='+tnowtime;
- }
- $.getJSON(myURL,function(res_data){
- if(res_data['code']!="0"){
- alert(res_data['info']);
- return;
- }
- $('#hotel_room').html(res_data['prod_name']);
- $('#prod_name').val(res_data['prod_name']);
- });
- }
- //选择是自营还是分销
- function sel_type(value){
- var list_base_url="./st-xm/Api/ht_get_order_list.php";
- if (value=="177") {
- fen_xiao_type="177";
- $('#fen').css('display','table');
- // $('#distributors').removeAttr('readonly');
- $('#order_no').removeAttr('readonly');
- var url=list_base_url+"?method=getChannelList&channel_type="+value;
- var tnowtime=getDateTime(4);
- if (url.indexOf('?') >= 0) {
- url += '&tt=' + tnowtime;
- } else {
- url += '?tt=' + tnowtime;
- }
- $.getJSON(url,function(res_data){
- if(res_data['code']!="0"){alert(res_data['info']);return;}
- var distributors=$('#distributors');
- var list=res_data['channelList'];
- var HTML='';
- for (var i=0,m=list.length;i<m;i++) {
- var tempHTML='<option value="'+list[i]['org_id']+'">'+list[i]['org_name']+'</option>'
- HTML+=tempHTML;
- }
- distributors.html(HTML);
- });
-
- }else if(value=="176"){
- fen_xiao_type="177";
- $('#fen').css('display','table');
- // $('#distributors').removeAttr('readonly');
- $('#order_no').removeAttr('readonly');
- var url=list_base_url+"?method=getChannelList&channel_type="+value;
- var tnowtime=getDateTime(4);
- if (url.indexOf('?') >= 0) {
- url += '&tt=' + tnowtime;
- } else {
- url += '?tt=' + tnowtime;
- }
- $.getJSON(url,function(res_data){
- if(res_data['code']!="0"){alert(res_data['info']);return;}
- var distributors=$('#distributors');
- var list=res_data['channelList'];
- var HTML='';
- for (var i=0,m=list.length;i<m;i++) {
- var tempHTML='<option value="'+list[i]['org_id']+'">'+list[i]['org_name']+'</option>'
- HTML+=tempHTML;
- }
- distributors.html(HTML);
- });
- }
- else{
- fen_xiao_type=value;
- $('#fen').css('display','none');
- $('#order_no').attr('readonly','true');
- $('#order_no').val('');
- }
- }
- //选择入住时间
- function sel_time_hour(innerHTML){
- }
- //选择日期
- function date_choose_picker(type){
- //开始日期
- var start_date = $('#id-date-picker-1').val();
- if (start_date.trim().length <= 0) {
- return;
- }
- //结束日期
- var end_date = $('#id-date-picker-2').val();
- if (end_date.trim().length < 0) {
- return;
- }
- // 判断日期是否合理
- var date1 = new Date(start_date.replace(/\-/g, '/'));
- var date2 = new Date(end_date.replace(/\-/g, '/'));
- if (date1>date2) {
- alert('结束日期必须大于开始日期!!!');
- $('#all_days').html('共 0 晚');
- $('#hotelList').html('');
- if(type==1){
- $('#id-date-picker-1').val('');
- }else{
- $('#id-date-picker-2').val('');
- }
- return;
- }
- // var date1=new Date(start_date.replace(/-/,'/'));
- // var date2=new Date(end_date.replace(/-/,'/'));
- // var date3=date2-date1;
- // //计算出相差天数
- // var days=Math.floor(date3/(24*3600*1000));
- // $('#all_days').html('共 '+days+' 晚');
-
- var prod_id=getPar('prod_id');
- if(!prod_id){alert('缺少参数');return;};
- var tnowtime = getDateTime(4);
- var url=base_url+"?method=getPlaceOrderInfo&prod_id="+prod_id+"&check_in_date="+start_date+"&check_out_date="+end_date+"&tt="+tnowtime;
- $.getJSON(url,function(res_data){
- var arr_rooms=new Array();
- var hotelListOBJ=$('#hotelList');
- var arr_placeOrder=res_data['place_order_info'];
- //先保存数据的长度
- http_data_length=arr_placeOrder.length;
- $('#all_days').html('共 '+arr_placeOrder.length+' 晚');
- $("input[name='maxcount']").val(arr_placeOrder.length);
- var newHTML=''
- for (var i=0;i<arr_placeOrder.length;i++) {
- var tempDict=arr_placeOrder[i];
- var tempHTML=tr_oneHTML;
- //关于一些事件和参数的替换
- tempHTML=tempHTML.replace('tr_one','tr_one_'+i);
- tempHTML=tempHTML.replace('check_in_date','check_in_date_'+i);
- tempHTML=tempHTML.replace('run_id','run_id_'+i);
- tempHTML=tempHTML.replace('select_room','select_room_'+i);
- tempHTML=tempHTML.replace('room_count','room_count_'+i);
-
- tempHTML=tempHTML.replace('[base]',i);
- tempHTML=tempHTML.replace('[mid]',i);
- tempHTML=tempHTML.replace('[order]',i);
-
- tempHTML=tempHTML.replace('[cai_blur]',i);
- tempHTML=tempHTML.replace('[jie_blur]',i);
- tempHTML=tempHTML.replace('[zero_blur]',i);
- tempHTML=tempHTML.replace('[index]',i);
- tempHTML=tempHTML.replace('[cai1]',i);
- tempHTML=tempHTML.replace('[jie1]',i);
- tempHTML=tempHTML.replace('[zero1]',i);
- tempHTML=tempHTML.replace('[cai2]',i);
- tempHTML=tempHTML.replace('[jie2]',i);
- tempHTML=tempHTML.replace('[lirun]',i);
-
- //关于一些事件和参数的替换
-
- tempHTML=tempHTML.replace('[入住日期]',tempDict['run_date']);
- tempHTML=tempHTML.replace('checkIn:Value',tempDict['run_date']);
- tempHTML=tempHTML.replace('[run_id:Value]',tempDict['run_id']);
- tempHTML=tempHTML.replace('[库存]',tempDict['total_count']);
-
- arr_rooms.push(tempDict['total_count']);
-
- tempHTML=tempHTML.replace('[采购价]',parseInt(tempDict['base_price']));
- tempHTML=tempHTML.replace('[结算价]',parseInt(tempDict['mid_price']));
- tempHTML=tempHTML.replace('[零售价]',parseInt(tempDict['order_price']));
-
-
- newHTML+=tempHTML;
- }
- for (var i=0;i<arr_placeOrder.length;i++) {
- var tempDict=arr_placeOrder[i];
- update_show(i,1,tempDict['base_price'],tempDict['mid_price'])
- }
-
- hotelListOBJ.html(newHTML);
- //加载之后第一次计算
- var all_order=0;
- var all_cai=0;
- var all_jie=0;
- var all_profits=0;//利润
- for (var i=0;i<arr_placeOrder.length;i++) {
- var tempDict=arr_placeOrder[i];
- update_show(i,1,tempDict['base_price'],tempDict['mid_price']);
- all_order+=parseInt(tempDict['order_price']);
- all_cai+=parseInt(tempDict['base_price']);
- all_jie+=parseInt(tempDict['mid_price']);
- all_profits+=all_jie-all_cai;
- }
- //计算完了再加载 总计的HTML
- var all_HTML=$('#hotelList').html();
-
- var tempHTML=tr_finalStr;
- tempHTML=tempHTML.replace('[总零售价]',all_order);
- tempHTML=tempHTML.replace('[采购价金额]',all_cai);
- tempHTML=tempHTML.replace('[结算价金额]',all_jie);
- tempHTML=tempHTML.replace('[销售利润]',all_profits);
- all_HTML+=tempHTML;
- $('#hotelList').html(all_HTML);
- for (var i=0;i<arr_rooms.length;i++) {
- var count=arr_rooms[i];
- var sel_room_all_HTML='';
- for (var j=0;j<count;j++) {
- var tempHT=select_room_HTML_str;
- tempHT=tempHT.replace('[value:i]',j+1);
- tempHT=tempHT.replace('[html:i]',j+1);
- sel_room_all_HTML+=tempHT;
- }
- $('#select_room_'+i).html(sel_room_all_HTML);
- }
-
- });
- }
- //选择房间数
- function select_room(index,count){
- //拿到采购价和结算价
- var cai_price=$('#cai_price_'+index).val();
- var jie_price=$('#jie_price_'+index).val();
- //计算
- update_show(index,count,cai_price,jie_price);
- //总计
- all_total_show()
- }
- //采购价value发生改变
- function cai_change(index,value){
- //拿到房间数
- var rooms=$('#select_room_'+index).find("option:selected").val();
- //拿到结算价
- var jie_price=$('#jie_price_'+index).val();
- //计算
- update_show(index,rooms,value,jie_price);
- //总计
- all_total_show();
- }
- //结算价value发生改变
- function jie_change(index,value){
- if (value.trim().length<=0) {
- value=0;
- }
- //拿到房间数
- var rooms=$('#select_room_'+index).find("option:selected").val();
- //拿到采购价
- var cai_price=$('#cai_price_'+index).val();
- //计算
- update_show(index,rooms,cai_price,value);
- //总计
- all_total_show();
- }
-
-
- //零售价value发生改变
- function zero_change(index,value){
- if (value.trim().length<=0) {
- value=0;
- }
- //拿到房间数
- var rooms=$('#select_room_'+index).find("option:selected").val();
- //拿到采购价
- var cai_price=$('#cai_price_'+index).val();
- //计算
- //update_show(index,rooms,cai_price,value);
- //总计
- all_total_show();
- }
-
- //计算和显示
- function update_show(index,room_count,cai_price,jie_price){
- //计算
- var all_cai=cai_price*room_count;
- var all_jie=jie_price*room_count;
- //改变页面
- //利润
- var profits=all_jie-all_cai;
- //改变页面的效果
- $('#cai_price_balance_'+index).html(all_cai.toFixed(1));
- $('#jie_price_balance_'+index).html(all_jie.toFixed(1));
- $('#profits_'+index).html(profits.toFixed(1));
- }
- //总计
- function all_total_show(){
- var all_cai=0;
- var all_jie=0;
- var all_profits=0;//利润
- var all_order=0;//零售价
- for (var i=0;i<http_data_length;i++) {
- var ling=($('#zero_price_'+i).val())*($('#select_room_'+i).val());
- var cai=$('#cai_price_balance_'+i).html();
- var jie=$('#jie_price_balance_'+i).html();
- var profits=$('#profits_'+i).html();
- all_order+=parseInt(ling);
- all_cai+=parseInt(cai);
- all_jie+=parseInt(jie);
- all_profits=all_jie-all_cai;
- }
- var profits=all_jie-all_cai;
- $('#all_order').html(all_order.toFixed(1));
- $('#all_cai').html(all_cai.toFixed(1));
- $('#all_jie').html(all_jie.toFixed(1));
- $('#all_lirun').html(all_profits.toFixed(1));
- }
- // 点击提交按钮
- $(document).ready(function(){
- $('#btn_submit').click(function(){
- //type:预订信息
- if(fen_xiao_type=="177"){
- //分销商
- var distributorsStr=$('#distributors').val();
- if(distributorsStr.trim().length<=0){alert('请填写分销商名称 / 手机 / 登录名!!!');return;}
- //订单编号
- var order_no=$('#order_no').val();
- if(order_no.trim().length<=0){alert('请填写订单编号!!!');return;}
- }else if(fen_xiao_type.trim()==""){alert('请选择订单来源!!!');return;}
- else{}
- //入住日期的两个
- var start_date=$('#id-date-picker-1').val();
- var end_date=$('#id-date-picker-2').val();
- if(start_date.trim().length<=0){alert('请选择开始日期!!!');return;}
- if(end_date.trim().length<=0){alert('请选择结束日期!!!');return;}
-
- //type:客人信息
- //客人姓名
- var guest_name=$('#guest_name').val();
- var guest_phone=$('#guest_phone').val();
- if(guest_name.trim().length<=0){alert('请填写客人姓名!!!');return;}
- if(guest_phone.trim().length<=0){alert('请填写联系电话!!!');return;}
- if(!checkMobile(guest_phone)){alert('客人手机号输入不合法!!!');return;}
- //备注
- var order_remark=$('#order_remark').val();
-
- //判断结束日期不能小于开始日期
- var date1=new Date(start_date.replace(/\-/g,'/'));
- var date2=new Date(end_date.replace(/\-/g,'/'));
- if(date1>date2){alert('结束日期必须大于开始日期!!!');return;}
-
- //判断是否有房--判断是否有金额-目前低保障
- var isRoom=$('#all_cai').html();
- if(isRoom=="0" || isRoom<=0){alert('相关产品没有库存!!!');return;}
-
-
- document.myform.action=base_url_my_add_order;
- document.myform.submit();
- // var listURL = "hotelOrderList.html";
- // // 跳转前将URL编码
- // listURL = encodeURI(listURL);
- // window.location.href = listURL;
- });
- });
- //$(document).ready(function(){
- // $('#btn_shutdown').click(function(){
- // alert('点击了关闭');
- // });
- //});
-
-
-
-
-
- function getPar(par) {
- //获取当前URL
- var local_url = document.location.href;
- local_url = decodeURI(local_url);
- //获取要取得的get参数位置
- var get = local_url.indexOf(par + "=");
- if (get == -1) {
- return false;
- }
- //截取字符串
- var get_par = local_url.slice(par.length + get + 1);
- //判断截取后的字符串是否还有其他get参数
- var nextPar = get_par.indexOf("&");
- if (nextPar != -1) {
- get_par = get_par.slice(0, nextPar);
- }
- return get_par;
- }
- function checkMobile(str) {
- var re = /^1\d{10}$/;
- if (re.test(str)) {
- return true;
- } else {
- return false;
- }
- }
- function getDateTime(nTypeFlag) {
- var tNowTime = new Date();
- var myYear = ';' + tNowTime.getFullYear() + ';';
- var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';';
- var myDay = ';' + tNowTime.getDate() + ';';
- var myHour = ';' + tNowTime.getHours() + ';';
- var myMinu = ';' + tNowTime.getMinutes() + ';';
- var mySecond = ';' + tNowTime.getSeconds() + ';';
-
- if (myMonth.length < 4) myMonth = '0' + myMonth;
- if (myDay.length < 4) myDay = '0' + myDay;
- if (myHour.length < 4) myHour = '0' + myHour;
- if (myMinu.length < 4) myMinu = '0' + myMinu;
- if (mySecond.length < 4) mySecond = '0' + mySecond;
-
- var cNewTimeStr;
- //alert(tNowTime);
- switch (nTypeFlag + 1 - 1) {
- case 0:
- cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
- break;
- case 1:
- cNewTimeStr = myYear + myMonth + myDay;
- break;
- case 2:
- cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
- break;
- case 3:
- cNewTimeStr = myHour + myMinu + mySecond;
- break;
- case 4:
- cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
- break;
- case 5:
- cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
- break;
- case 6:
- cNewTimeStr = myYear;
- break;
- case 7:
- cNewTimeStr = myYear + '-' + myMonth;
- break;
- default:
- cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
- break;
- }
- cNewTimeStr = cNewTimeStr.replace(/;/g, "");
- return cNewTimeStr;
- }
-
- /*
-
- if (myreq.readyState==4) {
- var newstr=myreq.responseText;
- var httpData = JSON.parse(newstr);
- var hotelListOBJ=$('#hotelList');
- var arr_placeOrder=httpData['placeOrder'];
- //先保存数据的长度
- http_data_length=arr_placeOrder.length;
- var tr_oneHTML=$('#tr_one').prop('outerHTML');
- var newHTML=''
- for (var i=0;i<arr_placeOrder.length;i++) {
- var tempDict=arr_placeOrder[i];
- var tempHTML=tr_oneHTML;
- //关于一些事件和参数的替换
- tempHTML=tempHTML.replace('tr_one','tr_one_'+i);
- tempHTML=tempHTML.replace('select_room','select_room_'+i);
- tempHTML=tempHTML.replace('[cai_blur]',i);
- tempHTML=tempHTML.replace('[jie_blur]',i);
- tempHTML=tempHTML.replace('[zero_blur]',i);
- tempHTML=tempHTML.replace('[index]',i);
- tempHTML=tempHTML.replace('[cai1]',i);
- tempHTML=tempHTML.replace('[jie1]',i);
- tempHTML=tempHTML.replace('[zero1]',i);
- tempHTML=tempHTML.replace('[cai2]',i);
- tempHTML=tempHTML.replace('[jie2]',i);
- tempHTML=tempHTML.replace('[lirun]',i);
-
- //关于一些事件和参数的替换
-
- tempHTML=tempHTML.replace('[入住日期]',tempDict['start_date']);
- tempHTML=tempHTML.replace('[库存]',tempDict['inventory']);
- tempHTML=tempHTML.replace('[采购价]',tempDict['cai_price_balance']);
- tempHTML=tempHTML.replace('[结算价]',tempDict['jie_price_balance']);
- tempHTML=tempHTML.replace('[零售价]',tempDict['zero_sale_price']);
-
-
- newHTML+=tempHTML;
- }
- for (var i=0;i<arr_placeOrder.length;i++) {
- var tempDict=arr_placeOrder[i];
- update_show(i,1,tempDict['cai_price_balance'],tempDict['jie_price_balance'])
- }
- tr_finalStr=$('#tr_final').prop('outerHTML');
- hotelListOBJ.html(newHTML);
- //加载之后第一次计算
- var all_cai=0;
- var all_jie=0;
- var all_profits=0;//利润
- for (var i=0;i<arr_placeOrder.length;i++) {
- var tempDict=arr_placeOrder[i];
- update_show(i,1,tempDict['cai_price_balance'],tempDict['jie_price_balance']);
- all_cai+=parseInt(tempDict['cai_price_balance']);
- all_jie+=parseInt(tempDict['jie_price_balance']);
- all_profits+=all_jie-all_cai;
- }
- //计算完了再加载 总计的HTML
- var all_HTML=$('#hotelList').html();
-
- var tempHTML=tr_finalStr;
- tempHTML=tempHTML.replace('[采购价金额]',all_cai);
- tempHTML=tempHTML.replace('[结算价金额]',all_jie);
- tempHTML=tempHTML.replace('[销售利润]',all_profits);
- all_HTML+=tempHTML;
- $('#hotelList').html(all_HTML);
- }
-
-
-
- * */
|