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.
 
 
 
 
 

171 line
5.8 KiB

  1. /**
  2. * Created by web_developer_02 on 2017/11/22
  3. */
  4. String.prototype.format = function() {
  5. if(arguments.length === 0) return this;
  6. var param = arguments[0];
  7. var s = this;
  8. if(typeof(param) === 'object') {
  9. for(var key in param)
  10. s = s.replace(new RegExp("\\{" + key + "\\}", "g"), param[key]);
  11. return s;
  12. } else {
  13. for(var i = 0; i < arguments.length; i++)
  14. s = s.replace(new RegExp("\\{" + i + "\\}", "g"), arguments[i]);
  15. return s;
  16. }
  17. };
  18. window.onload = function(){
  19. ifLogin(function(flag) {
  20. httpLoadInfo();
  21. });
  22. };
  23. function httpLoadInfo(){
  24. var order_id = getPar('order_id');
  25. if(order_id===""){
  26. alert('参数异常,请重试');
  27. return;
  28. }
  29. var res_data = httpSync({
  30. url:'user/fx-user/get-order-info',
  31. data:{
  32. order_id:order_id
  33. }
  34. });
  35. $('body').show();
  36. if(false === res_data['flag']) {
  37. if(codeNotLogin === res_data['code']) {
  38. // alert(infoNotLogin)
  39. var URL = '/web/fx/order_detail.html';
  40. URL = encodeURI(URL);
  41. location.href = res_data['url'] + URL;
  42. } else if(codeNotRegister === res_data['code']) {
  43. location.href = 'register.html';
  44. } else {
  45. alert(res_data['msg']);
  46. }
  47. } else {
  48. //..
  49. var data = res_data['data'];
  50. // 1.订单状态
  51. var order_info = data['order_info'];
  52. var order_id = order_info['order_id'];
  53. // 1 待支付 2:已支付 3:已完成 4:已退款 5:已取消
  54. var status = order_info['order_status'];
  55. if('1' === status){
  56. $('.order_status').find('.status_icon').css('background-image','url(images/order/dai_fu_kuan.png)');
  57. $('.order_status').find('.status_desc').html('待支付');
  58. }else if('2' === status){
  59. $('.order_status').find('.status_icon').css('background-image','url(images/order/dai_fan_yong.png)');
  60. $('.order_status').find('.status_desc').html('已支付');
  61. }else if('3' === status){
  62. $('.order_status').find('.status_icon').css('background-image','url(images/order/yi_fan_yong.png)');
  63. $('.order_status').find('.status_desc').html('已完成');
  64. }else if('4' === status){
  65. $('.order_status').find('.status_icon').css('background-image','url(images/order/yi_tui_kuan.png)');
  66. $('.order_status').find('.status_desc').html('已退款');
  67. }else if('5'===status){
  68. $('.order_status').find('.status_icon').css('background-image','url(images/order/yi_tui_kuan.png)');
  69. $('.order_status').find('.status_desc').html('已取消');
  70. }else{}
  71. $('.order_name').html(order_info['order_name']);
  72. //实付
  73. if(0 === order_info['discount_type']){
  74. var cstr = order_info['total_money']+'元';
  75. $('.shifu_money').html(cstr);
  76. }else if(1 === order_info['discount_type']){
  77. var cstr = '{0} - {1} = {2}元';
  78. var a = Math.floor(order_info['original_price']);
  79. var b = Math.floor(order_info['discount_money']);
  80. var c = Math.floor(order_info['total_money']);
  81. cstr=cstr.format(a,b,c);
  82. $('.shifu_money').html(cstr);
  83. }else{
  84. var cstr = '{0} + {1} = {2}元';
  85. var a = Math.floor(order_info['original_price']);
  86. var b = Math.floor(order_info['discount_money']);
  87. var c = Math.floor(order_info['total_money']);
  88. cstr=cstr.format(a,b,c);
  89. $('.shifu_money').html(cstr);
  90. }
  91. // 佣金
  92. $('.commission').html(order_info['commission']+'元');
  93. // 2. 预订人信息
  94. var contacts_info = data['content'];
  95. $('.contacts_name').html(contacts_info['contacts_name']);
  96. $('.contacts_phone').html(contacts_info['contacts_phone']);
  97. // 3. prod_arr
  98. var prod_arr = data['prod_arr'];
  99. var html = '';
  100. for(var i=0;i<prod_arr.length;i++){
  101. var item = prod_arr[i];
  102. var tempHTML = '<div class="ub center_one_line">\n' +
  103. ' <div class="ub txt_left">'+item['prod_name']+'</div>\n' +
  104. ' <div class="ub txt_right">× '+item['prod_num']+'</div>\n' +
  105. ' </div>';
  106. html+=tempHTML;
  107. }
  108. $('.prod_arr').html(html);
  109. // 4.日志
  110. var order_log = data['order_log'];
  111. var html = '<div class="ub center_one_line">\n' +
  112. ' <div class="ub txt_left">订单编号</div>\n' +
  113. ' <div class="ub txt_right">'+order_id+'</div>\n' +
  114. ' </div>';
  115. for(var i=0;i<order_log.length;i++){
  116. var item = order_log[i];
  117. var tempHTML = '<div class="ub center_one_line">\n' +
  118. ' <div class="ub txt_left">{name}</div>\n' +
  119. ' <div class="ub txt_right">{time}</div>\n' +
  120. ' </div>';
  121. tempHTML=tempHTML.format(item);
  122. html+=tempHTML;
  123. }
  124. $('.order_log').html(html);
  125. }
  126. }
  127. /**
  128. * @param {Object} arg
  129. * @description ajax同步请求
  130. * */
  131. function httpSync(arg){
  132. var param={
  133. type:arg.type || 'post',
  134. url:arg.url || '',
  135. async:false,
  136. dataType:arg.dataType || 'json',
  137. data:arg.data || {}
  138. };
  139. var rep={};
  140. $.ajax({
  141. type: param.type,
  142. url:base_api+param.url,
  143. async: param.async,
  144. dataType: param.dataType,
  145. data:param.data,
  146. success: function(res_data) {
  147. ZZLog(res_data);
  148. rep=res_data;
  149. },
  150. error: function() {
  151. alert(infoApiError);
  152. }
  153. });
  154. return rep;
  155. }