You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

824 lines
28 KiB

  1. //json/jsonHotelWaitConfirm.html
  2. var tr_finalStr = '';
  3. //订单备注-tr_str
  4. var cur_order_id = 0;
  5. var pay_end_time = '';
  6. var ht_tr_com_one_str = ''; //订单备注tr的str
  7. var ht_tr_mes_one_str = ''; //短信通知tr的str
  8. var ht_select_room_HTML_st = ''; //库存后面房间数
  9. var tr_modify = '';
  10. var http_data_length = 0;
  11. //详情
  12. var base_url = "./st-xm/Api/ht_get_order_detail.php";
  13. var base_url_modify = "./st-xm/Api/ht_get_order_modify.php";
  14. //库存-下订单前的info
  15. //var base_url_place="./st-xm/Api/ht_get_place_order_info.php";
  16. var base_url_place = "./st-xm/Api/ht_get_place_order_info.php";
  17. //my--moyan
  18. //var my_base_url_ok = "http://192.168.6.108:8082/st-xm/Api/hotel_order_status.php";
  19. var my_base_url_ok = "./st-xm/Api/hotel_order_status.php";
  20. var my_base_url_cancel = "./st-xm/Api/hotel_order_cancel_changeback.php";
  21. var base_url_my_add_order = "./st-xm/Api/hotel_submit_order.php";
  22. //订单主表里面的订单根据order_id得到的
  23. var detail_date_arr = null;
  24. //头部左侧
  25. var order_detail = null;
  26. //页面加载的时候调用
  27. window.onload = function() {
  28. ht_tr_com_one_str = $('#ht_tr_com_one').prop('outerHTML');
  29. ht_tr_com_one_str = ht_tr_com_one_str.replace('none', 'table-row');
  30. ht_tr_mes_one_str = $('#ht_tr_mes_one').prop('outerHTML');
  31. ht_tr_mes_one_str = ht_tr_mes_one_str.replace('none', 'table-row');
  32. tr_modify = $('#tr_modify_one').prop('outerHTML');
  33. tr_modify = tr_modify.replace('none', 'table-row');
  34. // ht_select_room_HTML_st=$('#select_room').prop('outerHTML');
  35. ht_select_room_HTML_st = $('#select_room').html();
  36. tr_finalStr = $('#tr_modify_final').prop('outerHTML');
  37. tr_finalStr = tr_finalStr.replace('none', 'table-row');
  38. var order_id = getPar('order_id');
  39. if (!order_id) {
  40. alert('缺少参数');
  41. return;
  42. }
  43. $('#order_id').val(getPar('order_id'));
  44. //调用 函数
  45. var url_modify = base_url_modify + "?method=getOrderChannel&order_id=" + order_id;
  46. $.getJSON(url_modify, function(res_data) {
  47. console.log('-----------');
  48. console.log(res_data);
  49. if (res_data['order_channel'].length > 0) {
  50. var dict = res_data['order_channel'][0];
  51. //判断是否是自营
  52. // if (dict['org_type_id'] == "176" || dict['org_type'] == "自营") {
  53. // $('#order_channel').html("自营");
  54. // $('#outside_order_id').css('display', 'none');
  55. // $('#order_from').val(dict['org_type_id']);
  56. // $('#distributors').val('0');
  57. // } else {
  58. var str = dict['org_type'] + '  |  ' + dict['org_name'] + '     渠道订单号:';
  59. $('#order_channel').html(str);
  60. var num = dict['outside_order_id'];
  61. $('#outside_order_id').val(num);
  62. $('#outside_order_id').css('display', '');
  63. $('#order_from').val(dict['org_type_id']);
  64. $('#distributors').val(dict['org_id']);
  65. // }
  66. $('#myform').css('display', 'block');
  67. }
  68. });
  69. var url = base_url + '?method=getOrderDetail&order_id=' + order_id;
  70. get_http_data_by_url(url);
  71. }
  72. // 请求方法,传入URL
  73. function get_http_data_by_url(myURL) {
  74. $.getJSON(myURL, function(httpData) {
  75. if (httpData['code'] != "0") {
  76. alert(httpData['info']);
  77. return;
  78. }
  79. if (httpData['order_detail'].length <= 0) {
  80. alert('没有符合条件的数据');
  81. return;
  82. }
  83. console.log('订单详情');
  84. console.log(httpData);
  85. //头部左侧
  86. order_detail = httpData['order_detail'][0];
  87. var top_left_HTML = $('#chartLeftSpan').html();
  88. //将订单号保存在一个临时变量里
  89. cur_order_id = getPar('order_id');
  90. top_left_HTML = top_left_HTML.replace('[订单号]', getPar('order_id'));
  91. var st = order_detail['order_status_str'];
  92. top_left_HTML = top_left_HTML.replace('[是否入住]', st);
  93. top_left_HTML = top_left_HTML.replace('[分销商(上海驴妈妈)]', order_detail['org_name']);
  94. top_left_HTML = top_left_HTML.replace('[酒店]', '酒店');
  95. $('#chartLeftSpan').html(top_left_HTML);
  96. //头部右侧
  97. var or_st = httpData['order_status'];
  98. var new_or_st = new Array();
  99. for (var i = 0; i < or_st.length; i++) {
  100. var temp = or_st[i];
  101. new_or_st[temp['order_status_id']] = temp;
  102. }
  103. if (new_or_st['145']) { //待支付
  104. var arr_date_time = new_or_st['145']['status_date'].split(' ');
  105. $('#one_date').html(arr_date_time[0]);
  106. $('#one_time').html(arr_date_time[1]);
  107. pay_end_time = order_detail['pay_end_time'];
  108. if (!new_or_st['198']) {
  109. ShowCountDown();
  110. timer = setInterval('ShowCountDown()', 1000);
  111. }
  112. //变成支付,,添加支付剩余时间
  113. }
  114. if (new_or_st['198']) { //待确认
  115. var arr_date_time = new_or_st['198']['status_date'].split(' ');
  116. $('#two_date').html(arr_date_time[0]);
  117. $('#two_time').html(arr_date_time[1]);
  118. $('#two_cir').css('border', '3px solid greenyellow');
  119. $('#two_cir').css('border-radius', '15px;');
  120. $('#pay_time').html('');
  121. $('#downBtn1').html('确认');
  122. $('#downBtn3').css('width', '100px');
  123. $('#downBtn3').html('退改申请');
  124. }
  125. if (new_or_st['200']) { //待安排
  126. var arr_date_time = new_or_st['200']['status_date'].split(' ');
  127. $('#three_date').html(arr_date_time[0]);
  128. $('#three_time').html(arr_date_time[1]);
  129. $('#three_cir').css('border', '3px solid greenyellow');
  130. $('#three_cir').css('border-radius', '15px;');
  131. $('#downBtn1').css('width', '125px');
  132. $('#downBtn1').html('录入确认号');
  133. $('#downBtn2').css('display', 'none');
  134. $('#downBtn2').html('');
  135. $('#downBtn3').css('width', '100px');
  136. $('#downBtn3').html('退改申请');
  137. }
  138. if (new_or_st['199']) { //待通知
  139. var arr_date_time = new_or_st['199']['status_date'].split(' ');
  140. $('#four_date').html(arr_date_time[0]);
  141. $('#four_time').html(arr_date_time[1]);
  142. $('#four_cir').css('border', '3px solid greenyellow');
  143. $('#four_cir').css('border-radius', '15px;');
  144. $('#downBtn1').css('width', '150px');
  145. $('#downBtn1').html('人工确认通知');
  146. }
  147. if (new_or_st['218']) { //已安排
  148. var arr_date_time = new_or_st['218']['status_date'].split(' ');
  149. $('#five_date').html(arr_date_time[0]);
  150. $('#five_time').html(arr_date_time[1]);
  151. $('#five_cir').css('border', '3px solid greenyellow');
  152. $('#five_cir').css('border-radius', '15px;');
  153. $('#downBtn1').css('display', 'none');
  154. $('#downBtn1').html('');
  155. $('#downBtn3').css('width', '100px');
  156. $('#downBtn3').html('退改申请');
  157. }
  158. if (new_or_st['201']) { //退改中
  159. $('#pay_time').html('');
  160. // $('#pay_time').css('display','none');
  161. $('#six_cir').css('border', '3px solid darkgray');
  162. $('#downBtn1').css('display', 'none');
  163. $('#downBtn1').html('');
  164. $('#downBtn2').css('display', 'none');
  165. $('#downBtn2').html('');
  166. $('#downBtn3').css('width', '100px');
  167. $('#downBtn3').html('退单确认');
  168. }
  169. if (new_or_st['147']) { //已完成
  170. if (!new_or_st['201']) {
  171. $('#pay_time').html('<img width="10px" height="10px" src="../img/timer.jpg"/>入住日期:' + order_detail['check_in_date']);
  172. $('#downBtn3').css('width', '100px');
  173. $('#downBtn3').html('退改申请');
  174. $('#six_cir').css('border', '3px solid greenyellow');
  175. $('#six_cir').css('border-radius', '15px;');
  176. }
  177. }
  178. if (new_or_st['238']) { //已退单
  179. $('#downBtn1').css('display', 'none');
  180. $('#downBtn1').html('');
  181. $('#downBtn2').css('display', 'none');
  182. $('#downBtn2').html('');
  183. $('#downBtn3').css('display', 'none');
  184. $('#downBtn3').html('');
  185. }
  186. if (new_or_st['148']) { //已取消
  187. $('#downBtn1').css('display', 'none');
  188. $('#downBtn2').css('display', 'none');
  189. $('#downBtn3').css('display', 'none');
  190. $('#downBtn1').html('');
  191. $('#downBtn2').html('');
  192. $('#downBtn3').html('');
  193. $('#pay_time').html('');
  194. clearInterval(timer);
  195. }
  196. // 订单备注短信通知
  197. $('#span_order_remark').html('订单备忘:' + order_detail['com_count'] + '条');
  198. $('#span_info_noti').html('短信通知:' + order_detail['mes_count'] + '条');
  199. // 1.预订信息
  200. $('#hotel_room').html(order_detail['prod_name']);
  201. $('#form_prod_id').val(order_detail['prod_id']);
  202. $('#form_prod_name').val(order_detail['prod_name'])
  203. //开始和结束日期
  204. $('#id-date-picker-1').val(order_detail['start_date']);
  205. $('#id-date-picker-2').val(order_detail['end_date']);
  206. //共几晚 最晚到店
  207. $('#all_days').html('共 ' + order_detail['all_day'] + ' 晚');
  208. $('#arrive_latest_time').val(order_detail['latest_time']);
  209. // 表格
  210. detail_date_arr = httpData['detail_date_arr'];
  211. date_choose_picker(1);
  212. // 2.客人信息
  213. $('#customer_name').val(order_detail['customer_name']);
  214. $('#customer_mobile').val(order_detail['customer_mobile']);
  215. //显示整个页面
  216. $('.hotelWaitConfirm').css('display', 'block');
  217. //订单备注
  218. get_order_comment(base_url + '?method=getOrderRemark&order_id=' + cur_order_id);
  219. //短信通知
  220. get_order_send_message(base_url + '?method=getOrderSendMessage&order_id=' + cur_order_id);
  221. });
  222. }
  223. //请求订单备注
  224. function get_order_comment(com_url) {
  225. $.getJSON(com_url, function(res_data) {
  226. var ht_comment_list = $('#ht_comment_list');
  227. var order_remark_arr = res_data['order_remark_arr'];
  228. if (order_remark_arr == undefined) {
  229. return;
  230. }
  231. var comHTML = '';
  232. for (var i = 0; i < order_remark_arr.length; i++) {
  233. var dict = order_remark_arr[i];
  234. var HTML = ht_tr_com_one_str;
  235. HTML = HTML.replace('[类型]', dict['comment_type_str']);
  236. HTML = HTML.replace('[内容]', dict['comment_txt']);
  237. HTML = HTML.replace('[添加人]', dict['user_name']);
  238. HTML = HTML.replace('[添加时间]', dict['create_time']);
  239. comHTML += HTML;
  240. }
  241. ht_comment_list.html(comHTML);
  242. });
  243. }
  244. //请求订单-短信通知
  245. function get_order_send_message(mes_url) {
  246. $.getJSON(mes_url, function(res_data) {
  247. var ht_send_message_list = $('#ht_send_message_list');
  248. var order_send_message_arr = res_data['order_send_message_arr'];
  249. if (order_send_message_arr == undefined) {
  250. return;
  251. }
  252. var mesHTML = '';
  253. for (var i = 0; i < order_send_message_arr.length; i++) {
  254. var dict = order_send_message_arr[i];
  255. var HTML = ht_tr_mes_one_str;
  256. HTML = HTML.replace('[内容]', dict['send_mobile'] + ":" + dict['message']);
  257. HTML = HTML.replace('[操作人]', dict['user_name']);
  258. HTML = HTML.replace('[发送时间]', dict['send_time']);
  259. mesHTML += HTML;
  260. }
  261. ht_send_message_list.html(mesHTML);
  262. });
  263. }
  264. //判断日期是否合法
  265. function date_choose_picker(type) {
  266. var start_date = $('#id-date-picker-1').val();
  267. var end_date = $('#id-date-picker-2').val();
  268. // 判断日期是否合理
  269. var date1 = new Date(start_date.replace(/\-/g, '/'));
  270. var date2 = new Date(end_date.replace(/\-/g, '/'));
  271. if (date1 > date2) {
  272. alert('开始日期不能小于结束日期!!!');
  273. $('#all_days').html('共 0 晚');
  274. $('#hotelList').html('');
  275. if (type == 1) {
  276. $('#id-date-picker-1').val('');
  277. } else {
  278. $('#id-date-picker-2').val('');
  279. }
  280. return;
  281. }
  282. if (detail_date_arr.length > 0) {
  283. var cur_order_prod_id = detail_date_arr[0]['prod_id'];
  284. //去查询库存
  285. var tnowtime = getDateTime(4);
  286. var url = base_url_place + "?method=getPlaceOrderInfo&prod_id=" + cur_order_prod_id + "&check_in_date=" + start_date + "&check_out_date=" + end_date + "&tt=" + tnowtime;
  287. console.log('ku chun ' + url);
  288. $.getJSON(url, function(res_data) {
  289. if (res_data['code'] != "0") {
  290. alert(res_data['info']);
  291. return;
  292. }
  293. var arr_rooms = new Array();
  294. console.log('订单中的');
  295. console.log(detail_date_arr); //订单中的
  296. console.log('库存');
  297. console.log(res_data); //库存
  298. $('#maxcount').val(detail_date_arr.length);
  299. //库存的
  300. var res_order_info = res_data['place_order_info'];
  301. var bookingHTML = '';
  302. $('#all_days').html('共 '+res_order_info.length+' 晚');
  303. if (res_order_info.length > 0) {
  304. $('#maxcount').val(res_order_info.length);
  305. //先保存数据的长度
  306. http_data_length = res_order_info.length;
  307. var v_b_p=0;//采购价
  308. var v_m_p=0;//结算价
  309. var v_p_p=0;//利润
  310. var v_o_p=0;//零售价
  311. for (var i = 0; i < res_order_info.length; i++) {
  312. var tempHTML = tr_modify;
  313. var dict_res = res_order_info[i];
  314. tempHTML = tempHTML.replace('[base]', i);
  315. tempHTML = tempHTML.replace('[mid]', i);
  316. tempHTML = tempHTML.replace('[order]', i);
  317. tempHTML = tempHTML.replace('check_in_date', 'check_in_date_' + i);
  318. tempHTML = tempHTML.replace('run_id', 'run_id_' + i);
  319. tempHTML = tempHTML.replace('select_room', 'select_room_' + i);
  320. tempHTML = tempHTML.replace('room_count', 'room_count_' + i);
  321. tempHTML = tempHTML.replace('[cai_blur]', i);
  322. tempHTML = tempHTML.replace('[jie_blur]', i);
  323. tempHTML = tempHTML.replace('[zero_blur]', i);
  324. tempHTML = tempHTML.replace('[index]', i);
  325. tempHTML = tempHTML.replace('[cai1]', i);
  326. tempHTML = tempHTML.replace('[jie1]', i);
  327. tempHTML = tempHTML.replace('[zero1]', i);
  328. tempHTML = tempHTML.replace('[cai2]', i);
  329. tempHTML = tempHTML.replace('[jie2]', i);
  330. tempHTML = tempHTML.replace('[lirun]', i);
  331. tempHTML = tempHTML.replace('[库存]', dict_res['total_count']);
  332. //arr_rooms.push(dict_res['total_count']);
  333. var dict_order='';
  334. for(var item in detail_date_arr){
  335. if((dict_res['run_date']== detail_date_arr[item]['check_in_date']) && (dict_res['prod_id'] == detail_date_arr[item]['prod_id'])){
  336. dict_order = detail_date_arr[item];
  337. }
  338. }
  339. if(dict_order==''){
  340. tempHTML = tempHTML.replace('[入住日期]', dict_res['run_date']);
  341. tempHTML = tempHTML.replace('checkIn:Value', dict_res['run_date']);
  342. tempHTML = tempHTML.replace('[run_id:Value]', dict_res['run_id']);
  343. tempHTML = tempHTML.replace('[采购价]', dict_res['base_price']);
  344. tempHTML = tempHTML.replace('[结算价]', dict_res['mid_price']);
  345. tempHTML = tempHTML.replace('[零售价]', dict_res['order_price']);
  346. tempHTML = tempHTML.replace('[采购价金额]', dict_res['base_price']);
  347. tempHTML = tempHTML.replace('[结算价金额]', dict_res['mid_price']);
  348. tempHTML = tempHTML.replace('[销售利润]', dict_res['mid_price'] - dict_res['base_price']);
  349. v_b_p=v_b_p+ parseFloat(dict_res['base_price']);//采购价
  350. v_m_p=v_m_p+parseFloat(dict_res['mid_price']);//结算价
  351. v_p_p=v_p_p+parseFloat(dict_res['mid_price'] - dict_res['base_price']);//利润
  352. v_o_p=v_o_p+parseFloat(dict_res['order_price']);
  353. arr_rooms.push(dict_res['total_count']);
  354. }else{
  355. tempHTML = tempHTML.replace('[入住日期]', dict_order['check_in_date']);
  356. tempHTML = tempHTML.replace('checkIn:Value', dict_order['check_in_date']);
  357. tempHTML = tempHTML.replace('[run_id:Value]', dict_res['run_id']);
  358. tempHTML = tempHTML.replace('[采购价]', dict_order['base_price']);
  359. tempHTML = tempHTML.replace('[结算价]', dict_order['mid_price']);
  360. tempHTML = tempHTML.replace('[零售价]', dict_order['order_price']);
  361. tempHTML = tempHTML.replace('[采购价金额]', dict_order['base_balance']);
  362. tempHTML = tempHTML.replace('[结算价金额]', dict_order['mid_balance']);
  363. tempHTML = tempHTML.replace('[销售利润]', dict_order['profits']);
  364. v_b_p=v_b_p+parseFloat(dict_order['base_balance']);
  365. v_m_p=v_m_p+parseFloat(dict_order['mid_balance']);//结算价
  366. v_p_p=v_p_p+parseFloat(dict_order['profits']);//利润
  367. v_o_p=v_o_p+parseFloat(dict_order['order_balance']);
  368. arr_rooms.push(parseInt(dict_res['total_count'])+parseInt(dict_order['count']));
  369. }
  370. bookingHTML += tempHTML;
  371. }
  372. //总计
  373. tr_finalStr = tr_finalStr.replace('[总零售价]', order_detail['all_order_balance']);
  374. tr_finalStr = tr_finalStr.replace('[采购价金额]',order_detail['all_base_balance']);
  375. tr_finalStr = tr_finalStr.replace('[结算价金额]', order_detail['all_mid_balance']);
  376. tr_finalStr = tr_finalStr.replace('[销售利润]', order_detail['all_profits']);
  377. bookingHTML += tr_finalStr
  378. $('#ht_modify_or_list').html(bookingHTML);
  379. $('#order').html(v_o_p);
  380. $('#base').html(v_b_p);
  381. $('#mid').html(v_m_p);
  382. $('#profit').html(v_p_p);
  383. for (var i = 0; i < arr_rooms.length; i++) {
  384. var count = arr_rooms[i];
  385. var sel_room_all_HTML = '';
  386. for (var j = 0; j < count; j++) {
  387. var tempHT = ht_select_room_HTML_st;
  388. tempHT = tempHT.replace('[value:i]', j + 1);
  389. tempHT = tempHT.replace('[html:i]', j + 1);
  390. sel_room_all_HTML += tempHT;
  391. }
  392. $('#select_room_' + i).html(sel_room_all_HTML);
  393. }
  394. //让房间数默认选中下单时的个数
  395. for (var i = 0; i < res_order_info.length; i++) {
  396. var dict_res = res_order_info[i];
  397. var dict_order='';
  398. for(var item in detail_date_arr){
  399. if((dict_res['run_date']== detail_date_arr[item]['check_in_date']) && (dict_res['prod_id'] == detail_date_arr[item]['prod_id'])){
  400. dict_order = detail_date_arr[item];
  401. }
  402. }
  403. if(dict_order!=''){
  404. $('#select_room_' + i).val(dict_order['count']);
  405. }
  406. }
  407. }
  408. });
  409. }
  410. }
  411. //计时
  412. var timer = null;
  413. function ShowCountDown() {
  414. // pay_end_time
  415. var dt1 = getDateTime(0) + " " + getDateTime(2);
  416. var dt2 = pay_end_time;
  417. var date1 = new Date(dt1.replace(/\-/g, '/'));
  418. var date2 = new Date(dt2.replace(/\-/g, '/'));
  419. var date3 = date2 - date1;
  420. //计算出相差天数
  421. var days = Math.floor(date3 / (24 * 3600 * 1000))
  422. //计算出小时数
  423. var leave1 = date3 % (24 * 3600 * 1000) //计算天数后剩余的毫秒数
  424. var hours = Math.floor(leave1 / (3600 * 1000))
  425. //计算相差分钟数
  426. var leave2 = leave1 % (3600 * 1000) //计算小时数后剩余的毫秒数
  427. var minutes = Math.floor(leave2 / (60 * 1000))
  428. //计算相差秒数
  429. var leave3 = leave2 % (60 * 1000) //计算分钟数后剩余的毫秒数
  430. var seconds = Math.round(leave3 / 1000);
  431. var str = days + "日" + hours + "时" + minutes + "分" + seconds + "秒";
  432. if (hours < 10) {
  433. str = str.replace('日', '日0');
  434. // str = days + "日0" + hours + "时" + minutes + "分" + seconds + "秒";
  435. }
  436. if (minutes < 10) {
  437. str = str.replace('时', '时0')
  438. // str = days + "日" + hours + "时0" + minutes + "分" + seconds + "秒";
  439. }
  440. if (seconds < 10) {
  441. str = str.replace('分', '分0');
  442. // str = days + "日" + hours + "时" + minutes + "分0" + seconds + "秒";
  443. }
  444. if(date2==date1){
  445. location.replace(location.href);
  446. }else if(date2<date1){
  447. str="0日00时00分00秒";
  448. str = '<img width="10px" height="10px" src="../img/timer.jpg"/>剩余时间:' + str;
  449. $('#pay_time').html(str);
  450. }else{
  451. str = '<img width="10px" height="10px" src="../img/timer.jpg"/>剩余时间:' + str;
  452. $('#pay_time').html(str);
  453. }
  454. }
  455. //点击了三个固定的
  456. function click_show_div(objName, self_obj) {
  457. var obj = $(objName);
  458. if (obj.css('display') == 'none') {
  459. center_show(obj);
  460. } else {
  461. obj.css('display', 'none');
  462. }
  463. }
  464. //点击了第二级
  465. function click_two_show_div(father_name, self_name) {
  466. var father = $(father_name);
  467. var self = $(self_name);
  468. father.css('display', 'none');
  469. center_show(self);
  470. }
  471. //选择房间数
  472. function select_room(index, count) {
  473. //拿到采购价和结算价
  474. var cai_price = $('#cai_price_' + index).val();
  475. var jie_price = $('#jie_price_' + index).val();
  476. //计算
  477. update_show(index, count, cai_price, jie_price);
  478. //总计
  479. all_total_show()
  480. }
  481. //采购价value发生改变
  482. function cai_change(index, value) {
  483. //拿到房间数
  484. var rooms = $('#select_room_' + index).find("option:selected").val();
  485. //拿到结算价
  486. var jie_price = $('#jie_price_' + index).val();
  487. //计算
  488. update_show(index, rooms, value, jie_price);
  489. //总计
  490. all_total_show();
  491. }
  492. //结算价value发生改变
  493. function jie_change(index, value) {
  494. if (value.trim().length <= 0) {
  495. value = 0;
  496. }
  497. //拿到房间数
  498. var rooms = $('#select_room_' + index).find("option:selected").val();
  499. //拿到采购价
  500. var cai_price = $('#cai_price_' + index).val();
  501. //计算
  502. update_show(index, rooms, cai_price, value);
  503. //总计
  504. all_total_show();
  505. }
  506. //零售价value发生改变
  507. function zero_change(index, value) {
  508. if (value.trim().length <= 0) {
  509. value = 0;
  510. }
  511. //拿到房间数
  512. var rooms = $('#select_room_' + index).find("option:selected").val();
  513. //拿到采购价
  514. var cai_price = $('#cai_price_' + index).val();
  515. //计算
  516. //update_show(index, rooms, cai_price, value);
  517. //总计
  518. all_total_show();
  519. }
  520. //计算和显示
  521. function update_show(index, room_count, cai_price, jie_price) {
  522. //计算
  523. var all_cai = cai_price * room_count;
  524. var all_jie = jie_price * room_count;
  525. //改变页面
  526. //利润
  527. var profits = all_jie - all_cai;
  528. //改变页面的效果
  529. $('#cai_price_balance_' + index).html(all_cai);
  530. $('#jie_price_balance_' + index).html(all_jie);
  531. $('#profits_' + index).html(profits);
  532. }
  533. //总计
  534. function all_total_show() {
  535. var all_cai = 0;
  536. var all_jie = 0;
  537. var all_profits = 0; //利润
  538. var all_order=0;//零售价
  539. for (var i = 0; i < http_data_length; i++) {
  540. var ling=($('#zero_price_'+i).val())*($('#select_room_'+i).val());
  541. var cai = $('#cai_price_balance_' + i).html();
  542. var jie = $('#jie_price_balance_' + i).html();
  543. var profits = $('#profits_' + i).html();
  544. all_order+=parseInt(ling);
  545. all_cai += parseInt(cai);
  546. all_jie += parseInt(jie);
  547. all_profits = all_jie - all_cai;
  548. }
  549. var all_HTML = $('#tr_modify_final').html();
  550. var tempHTML = tr_finalStr;
  551. var profits = all_jie - all_cai;
  552. tempHTML = tempHTML.replace('[总零售价]', all_order);
  553. tempHTML = tempHTML.replace('[采购价金额]', all_cai);
  554. tempHTML = tempHTML.replace('[结算价金额]', all_jie);
  555. tempHTML = tempHTML.replace('[销售利润]', all_profits);
  556. all_HTML += tempHTML;
  557. $('#tr_modify_final').html(all_HTML);
  558. $('#order').html(all_order);
  559. $('#base').html(all_cai);
  560. $('#mid').html(all_jie);
  561. $('#profit').html(all_profits);
  562. }
  563. //订单备注的——提交
  564. $(document).ready(function() {
  565. $('#btn_comment_submit').click(function() {
  566. hide_all();
  567. var type = $('#add_com_sel').find("option:selected").val();
  568. var text = $('#or_remark_txt').val();
  569. if (type == "") {
  570. alert('请选择类型!!!');
  571. return;
  572. }
  573. if (text.trim().length <= 0) {
  574. alert('请输入备注信息!!!');
  575. return;
  576. }
  577. var ok_num_url = my_base_url_ok + "?method=addcomment&order_id=" + cur_order_id + "&comment_type=" + type + "&comment_text=" + text;
  578. $('#or_remark_txt').val();
  579. $.getJSON(ok_num_url, function(res_data) {
  580. if (res_data['code'] != "0") {
  581. alert(res_data['info']);
  582. return;
  583. }
  584. location.replace(location.href);
  585. });
  586. });
  587. });
  588. //短信通知——提交
  589. $(document).ready(function() {
  590. $('#btn_message_submit').click(function() {
  591. hide_all();
  592. $('#or_send_mes_txt').html('');
  593. // var mes_url="http://127.0.0.1/%E8%9C%98%E8%9B%9B2.0%E8%83%BD%E5%86%99PHP/st-xm/Api/ht_get_order_detail.php?method=getOrderSendMessage&order_id="+cur_order_id;
  594. get_order_send_message(mes_url + '?method=getOrderSendMessage&order_id=' + cur_order_id);
  595. });
  596. });
  597. //点击了关闭
  598. function click_cancel(father_name, self_name) {
  599. if (father_name) {
  600. var father = $(father_name);
  601. center_show(father);
  602. } else {
  603. $('.mask').css('display', 'none');
  604. }
  605. $(self_name).css('display', 'none');
  606. }
  607. //居中显示
  608. var tempDiv = null;
  609. function center_show(show_div) {
  610. tempDiv = show_div;
  611. //显示蒙板
  612. show_div.css('display', 'block');
  613. show_div.css('z-index', 10);
  614. show_div.css('background-color', 'white');
  615. show_div.css('position', 'fixed');
  616. var w = show_div.css('width');
  617. var h = show_div.css('height');
  618. w = w.substr(0, w.length - 2);
  619. h = h.substr(0, h.length - 2);
  620. // var s_left=(window.screen.availWidth-w)/2 +"px";
  621. // var s_top=(window.screen.availHeight-h)/2 +'px';
  622. var s_left = (window.innerWidth - w) / 2 + 'px';
  623. var s_top = (window.innerHeight - h) / 2 + 'px';
  624. show_div.css('left', s_left);
  625. show_div.css('top', s_top);
  626. $('.mask').css('display', 'block');
  627. }
  628. //点击蒙板
  629. function hide_all() {
  630. $('.mask').css('display', 'none');
  631. tempDiv.css('display', 'none');
  632. }
  633. //order_pay选择改变
  634. function select_pay_way(value) {
  635. if (value == '0') {
  636. $('#pay1').css('display', 'block');
  637. $('#pay2').css('display', 'none');
  638. } else {
  639. $('#pay1').css('display', 'none');
  640. $('#pay2').css('display', 'block');
  641. }
  642. }
  643. //保存修改
  644. $(document).ready(function() {
  645. $('#btn_modify_save').click(function() {
  646. document.myform.action = base_url_my_add_order;
  647. document.myform.submit();
  648. });
  649. });
  650. //取消
  651. $(document).ready(function() {
  652. $('#btn_cancel').click(function() {
  653. history.back();
  654. });
  655. });
  656. function getPar(par) {
  657. //获取当前URL
  658. var local_url = document.location.href;
  659. local_url = decodeURI(local_url);
  660. //获取要取得的get参数位置
  661. var get = local_url.indexOf(par + "=");
  662. if (get == -1) {
  663. return false;
  664. }
  665. //截取字符串
  666. var get_par = local_url.slice(par.length + get + 1);
  667. //判断截取后的字符串是否还有其他get参数
  668. var nextPar = get_par.indexOf("&");
  669. if (nextPar != -1) {
  670. get_par = get_par.slice(0, nextPar);
  671. }
  672. return get_par;
  673. }
  674. function checkMobile(str) {
  675. var re = /^1\d{10}$/;
  676. if (re.test(str)) {
  677. return true;
  678. } else {
  679. return false;
  680. }
  681. }
  682. function getDateTime(nTypeFlag) {
  683. var tNowTime = new Date();
  684. var myYear = ';' + tNowTime.getFullYear() + ';';
  685. var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';';
  686. var myDay = ';' + tNowTime.getDate() + ';';
  687. var myHour = ';' + tNowTime.getHours() + ';';
  688. var myMinu = ';' + tNowTime.getMinutes() + ';';
  689. var mySecond = ';' + tNowTime.getSeconds() + ';';
  690. if (myMonth.length < 4) myMonth = '0' + myMonth;
  691. if (myDay.length < 4) myDay = '0' + myDay;
  692. if (myHour.length < 4) myHour = '0' + myHour;
  693. if (myMinu.length < 4) myMinu = '0' + myMinu;
  694. if (mySecond.length < 4) mySecond = '0' + mySecond;
  695. var cNewTimeStr;
  696. //alert(tNowTime);
  697. switch (nTypeFlag + 1 - 1) {
  698. case 0:
  699. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  700. break;
  701. case 1:
  702. cNewTimeStr = myYear + myMonth + myDay;
  703. break;
  704. case 2:
  705. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  706. break;
  707. case 3:
  708. cNewTimeStr = myHour + myMinu + mySecond;
  709. break;
  710. case 4:
  711. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  712. break;
  713. case 5:
  714. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  715. break;
  716. case 6:
  717. cNewTimeStr = myYear;
  718. break;
  719. case 7:
  720. cNewTimeStr = myYear + '-' + myMonth;
  721. break;
  722. default:
  723. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  724. break;
  725. }
  726. cNewTimeStr = cNewTimeStr.replace(/;/g, "");
  727. return cNewTimeStr;
  728. }
  729. /*
  730. // // 3.结算信息
  731. // //分销商
  732. // var arr_fen_shop=httpData['fen_shop'];
  733. // var tr_fen=$('#tr_fen_one').prop('outerHTML');
  734. // var fenHTML='';
  735. // for (var i=0;i<arr_fen_shop.length;i++) {
  736. // var tempDict=arr_fen_shop[i];
  737. // var tempHTML=tr_fen;
  738. // tempHTML=tempHTML.replace('[名称]',tempDict['shop_name']);
  739. // tempHTML=tempHTML.replace('[分销商订单号]',tempDict['order_no']);
  740. // tempHTML=tempHTML.replace('[交易类型]',tempDict['sale_type']);
  741. // tempHTML=tempHTML.replace('[项目]',tempDict['project']);
  742. // tempHTML=tempHTML.replace('[金额]',tempDict['balance']);
  743. // tempHTML=tempHTML.replace('[交易方式]',tempDict['sale_way']);
  744. // tempHTML=tempHTML.replace('[生成时间]',tempDict['create_date']);
  745. // tempHTML=tempHTML.replace('[支付时间]',tempDict['pay_date']);
  746. // fenHTML+=tempHTML;
  747. // }
  748. // $('#fen_shopList').html(fenHTML);
  749. // //供应商
  750. // var arr_give_shop=httpData['give_shop'];
  751. // var tr_give=$('#tr_give').prop('outerHTML');
  752. // var giveHTML='';
  753. // for (var i=0;i<arr_give_shop.length;i++) {
  754. // var tempDict=arr_give_shop[i];
  755. // var tempHTML=tr_give;
  756. // tempHTML=tempHTML.replace('[名称]',tempDict['shop_name']);
  757. // tempHTML=tempHTML.replace('[分销商订单号]',tempDict['order_no']);
  758. // tempHTML=tempHTML.replace('[交易类型]',tempDict['sale_type']);
  759. // tempHTML=tempHTML.replace('[项目]',tempDict['project']);
  760. // tempHTML=tempHTML.replace('[金额]',tempDict['balance']);
  761. // tempHTML=tempHTML.replace('[交易方式]',tempDict['sale_way']);
  762. // tempHTML=tempHTML.replace('[生成时间]',tempDict['create_date']);
  763. // tempHTML=tempHTML.replace('[支付时间]',tempDict['pay_date']);
  764. // giveHTML+=tempHTML;
  765. // }
  766. // $('#give_shopList').html(giveHTML);
  767. */