|
- /**
- * Created by luocj on 2016/12/8.
- */
- // var order_id = getPar('order_id');
- // var order_id = getPar('org_id');
- //order_id=" + order_id + "&order_status=" + order_status + "&org_id=" + org_id + "&hotel_id=" + hotel_id + "&org_name=" + getPar('org_name') + "&room_type=" + room_type1
- var order_id = getPar('order_id');
- var order_status = getPar('order_status');
- var org_id = getPar('org_id');
- var hotel_id = getPar('hotel_id');
- var org_name = getPar('org_name');
- var room_type1 = getPar('room_type');
- var main_tr = $('.main_tr').prop('outerHTML');
- var memo_tr = $('.memo_tr').prop('outerHTML');
- var tr1 = $('.second_style').prop('outerHTML');
- window.onload = function () {
- getOrderDetail();
- getUpStatus();
- downBookingRecord();
- toOrderLog()
- };
-
- //获取订单详情
- function getOrderDetail() {
- if (order_id) {
- $.ajax({
- url: base_api,
- type: 'post',
- dataType: 'json',
- data: {
- order_id: order_id,
- type: 'order_HotelOrderDetail'
- },
- success: function (res_data) {
- ZZLog(res_data);
- if (res_data['order_id']) {
- setMainInfo(res_data);
- } else {
- return;
- }
- },
- error: function (e) {
- ZZLog(e);
- }
- })
- }
- }
- function setMainInfo(data) {
- $('#order_id').text('订单号:' + data['order_id']);
- $('#order_status').text(data['order_status_name']);
- if (data['order_confirm_code'] != null) {
- $('#make_sure_num').text('酒店确认号:' + data['order_confirm_code']);
- }
- $('#hotel_name').text(data['hotel_name']);
- $('#product_name').text(data['room_name']);
- $('#org_name_down').text(data['org_name']);
- $('#org_name').text('订单渠道:' + data['org_name']);
- $('#start_date').text(data['start_date']);
- $('#end_date').text(data['end_date']);
- $('#org_num').text(data['org_num']);
- $('#customer_name').text(data['customer_name']);
- $('#phone').text(data['customer_mobile']);
- //替换主表
- var sumHTML = '';
- for (var i = 0, m = data['one_day'].length; i < m; i++) {
- var dict = data['one_day'][i];
- var HTML = main_tr;
- HTML = HTML.replace('[入住日期]', dict['start_date']);
- HTML = HTML.replace('[数量]', dict['count']);
- HTML = HTML.replace('[结算价]', parseFloat(dict['order_price'] / dict['count']).toFixed(2));
- HTML = HTML.replace('[佣金]', parseFloat(dict['commission']).toFixed(2));
- HTML = HTML.replace('[结算价总额]', parseFloat(dict['order_price']).toFixed(2));
- HTML = HTML.replace('[销售利润]', parseFloat(dict['profit_value']).toFixed(2));
- sumHTML += HTML;
- }
- $('#sum_price').text(data['all_price']);
- $('#sum_profit').text(data['all_profit']);
- $('#make_order_list').html(sumHTML);
- $('#main_table').show();
- //替换备注
- if (data['memo'].length>0){
- var sumDownHTML = '';
- for (var j = 0, n = data['memo'].length; j < n; j++) {
- var dict1 = data['memo'][j];
- var HTML1 = memo_tr;
- if (dict1['memo_type'] == 0) {
- HTML1 = HTML1.replace('[备注类型]', '公共备注');
- } else {
- HTML1 = HTML1.replace('[备注类型]', '内部备注');
- }
- HTML1 = HTML1.replace('[备注内容]', dict1['memo_info']);
- if (dict1['user_name'] != '') {
- HTML1 = HTML1.replace('[备注人]', dict1['user_name']);
- } else {
- HTML1 = HTML1.replace('[备注人]', '');
- }
- HTML1 = HTML1.replace('[备注时间]', getLocalTime(dict1['time']));
- sumDownHTML += HTML1;
- }
- $('#memo_body').html(sumDownHTML);
- $('.note').show();
- }
- var days = data.one_day.length;
-
- $('#datediff').html('共 ' + days + ' 晚');
- }
- //获取上方状态栏
- function getUpStatus() {
- if (order_id) {
- $.ajax({
- url: base_api,
- type: 'post',
- dataType: 'json',
- data: {
- order_id: order_id,
- type: 'order_ModifyHTOrder',
- op: 'order_status'
- },
- success: function (res_data) {
- ZZLog(res_data);
- if (res_data['order_status'].length>0){
- for (var i = 0, m = res_data['order_status'].length;i<m; i++) {
- var dict = res_data['order_status'][i];
- var temp_date = dict['create_time'].split(" ");
- var date = temp_date[0];
- var time = temp_date[1];
- if (dict['order_status_name'] == "待支付") {
- $('li[data-target="#step1"]').addClass('active');
- $('li[data-target="#step2"]').addClass('active');
- $('#create_date').text(date);
- $('#create_time').text(time);
- $('#pay_date').text(date);
- $('#pay_time').text(time);
- } else if (dict['order_status_name'] == "待发单") {
- $('li[data-target="#step1"]').addClass('active');
- $('li[data-target="#step2"]').addClass('active');
- $('#create_date').text(date);
- $('#create_time').text(time);
- $('#pay_date').text(date);
- $('#pay_time').text(time);
- } else if (dict['order_status_name'] == "待确认") {
- $('li[data-target="#step3"]').addClass('active');
- $('#send_date').text(date);
- $('#send_time').text(time);
- } else if (dict['order_status_name'] == "已安排") {
- $('li[data-target="#step4"]').addClass('active');
- $('#arr_date').text(date);
- $('#arr_time').text(time);
- } else if (dict['order_status_name'] == "已完成") {
- $('li[data-target="#step5"]').addClass('active');
- $('#finish_date').text(date);
- $('#finish_time').text(time);
- } else {
- }
- }
- }
- },
- error: function (e) {
- ZZLog(e);
- }
- })
- }
- }
- //点击下载附件
- function downBookingRecord() {
- $('#down_record').on('click', function () {
- window.location.href = "/zz-jd/st-ht/HTcontrol.php?type=order_ModifyHTOrder&op=export&order_id=" + order_id;
- })
- }
- //隐藏弹窗
- function hideDiv() {
- $('.main_style').hide();
- }
- function toOrderLog() {
- $('#log').on('click', function () {
- window.location.href = "./hotel_detail_log.html?order_id=" + order_id + "&order_status=" + order_status + "&org_id=" + org_id + "&hotel_id=" + hotel_id + "&org_name=" + getPar('org_name') + "&room_type=" + room_type1;
- })
- }
- //时间戳转换函数
- function getLocalTime(nS) {
- return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/, ' ');
- }
- //短信
- function getMessage() {
- //var url = base_api +"?type=hotel_HotelOrderList&op=getmessage&order_id="+order_id;
- var param = {
- type: 'order_HotelOrderList',
- op: 'getmessage',
- order_id: order_id
- };
- ZZLog(param);
- $.ajax({
- url: base_api,
- type: "post",
- dataType: "json",
- data: param,
- success: function (res_data) {
- ZZLog(res_data);
- var HTML = tr1;
- var sumHTML = '';
- $('#send_message').text('短信通知:' + res_data['count']['count(order_id)'] + '条')
- for (var i = 0; i < res_data['message'].length; i++) {
- HTML = tr1;
- var dict = res_data['message'][i]['send_message'];
- HTML = HTML.replace('[短信内容]', dict);
- HTML = HTML.replace('[内容]', dict);
- sumHTML += HTML;
- }
- $('.second_style').html(sumHTML);
- $('.resend_message').on('click', function () {
- var messsage_info = $(this).attr('data-MSinfo');
- var phone = $('#phone').val();
- var param = {
- message: messsage_info,
- mobile: phone,
- op: 'messageAgain',
- type: 'order_HotelOrderList'
- };
- ZZLog(param);
- $.ajax({
- url: base_api,
- type: 'post',
- dataType: 'json',
- data: param,
- success: function (res_data) {
- ZZLog(res_data);
- alert('短信已发送');
- },
- error: function (e) {
- ZZLog(e)
- }
- })
- })
- },
- error: function (e) {
- ZZLog('Ajax_error');
- ZZLog(e);
- }
- })
- }
- function showMessage() {
- $('#send_message').on('click', function () {
- $('.main_style').show();
- })
- }
|