order-details.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
  6. <meta name="apple-mobile-web-app-capable" content="yes">
  7. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  8. <title>订单详情</title>
  9. <link rel="stylesheet" type="text/css" href="css/mui.min.css" />
  10. <link rel="stylesheet" type="text/css" href="css/iconfont.css" />
  11. <link rel="stylesheet" type="text/css" href="css/main.css" />
  12. <script type="text/javascript">
  13. // 屏蔽分享
  14. window.hiddenAllWechatMenu = true;
  15. </script>
  16. </head>
  17. <body>
  18. <footer class="mui-bar mui-bar-tab" id="footer-bar-tab">
  19. <a class="mui-tab-item">
  20. <span class="iconfont icon-shouye"></span>
  21. <span class="mui-tab-label">首页</span>
  22. </a>
  23. <a class="mui-tab-item">
  24. <span class="iconfont icon-gouwuche"></span>
  25. <span class="mui-tab-label">购物车</span>
  26. </a>
  27. <a class="mui-tab-item mui-active">
  28. <span class="iconfont icon-dingdan"></span>
  29. <span class="mui-tab-label">订单</span>
  30. </a>
  31. <a class="mui-tab-item ">
  32. <span class="iconfont icon-wode"></span>
  33. <span class="mui-tab-label">我的</span>
  34. </a>
  35. </footer>
  36. <div class="loading-bg">
  37. <div class="mui-loading">
  38. <div class="mui-spinner">
  39. </div>
  40. &nbsp;&nbsp;加载中...
  41. </div>
  42. </div>
  43. <div class="mui-content">
  44. <input type="hidden" id="salesPostFirm" name="salesPostFirm" value=""/>
  45. <input type="hidden" id="salesPostNum" name="salesPostNum" value=""/>
  46. <div style="margin:14px 14px 0 14px;background-color: #f3f3f3;text-align: center;">
  47. <ul class="mui-table-view mui-table-view-striped my-grid-view-no mui-table-view-condensed">
  48. <li class="mui-table-view-cell" style="background-color: #f3f3f3;border-radius: 5px;padding: 11px 8px;">
  49. <div class="mui-table" style="height: 80px;">
  50. <div class="mui-table-cell mui-col-xs-12 table-middle" style="display: none;">
  51. <div style="height: 20px;position: relative;width: 150px; margin: 0 auto;"><span class="iconfont icon-jia" style="position: absolute;left:0%;top: 0;font-size: 20px;"></span></div>
  52. </div>
  53. <div class="mui-table-cell mui-col-xs-1 mui-text-left table-middle">
  54. <p><span class="iconfont icon-dingwei"></span></p>
  55. </div>
  56. <div class="mui-table-cell mui-col-xs-10 mui-text-left table-middle">
  57. <div><span id="addressName"></span> <span class="mui-pull-right" id="salesAddressTel"></span></div>
  58. <p id="addressInfo"></p>
  59. </div>
  60. <div class="mui-table-cell mui-col-xs-1 mui-text-right table-middle">
  61. <!--<p><span class="mui-icon mui-icon-arrowright"></span></p>-->
  62. </div>
  63. </div>
  64. </li>
  65. </ul>
  66. </div>
  67. <div class="clearing-box">
  68. <ul class="mui-table-view mui-table-view-striped my-grid-view-no mui-table-view-condensed shopping-cart-list">
  69. </ul>
  70. <ul class="mui-table-view my-view-no-top">
  71. <li class="mui-table-view-cell cl-red" style="padding: 11px 2px;">
  72. 共<span id="num">0</span>件<span class="mui-pull-right">合计:¥<span id="salesYetAmount">0.00</span></span>
  73. </li>
  74. </ul>
  75. <ul class="my-table-view">
  76. <li>
  77. 订单状态:<span id="statusName"></span>
  78. </li>
  79. <li>
  80. 订单编号:<span id="orderId"></span>
  81. </li>
  82. <li>
  83. 下单时间:<span id="salesCreateDate"></span>
  84. </li>
  85. </ul>
  86. <!--<textarea id="textarea" rows="1" placeholder="如您选择退款,请先输入退款原因!" style="background-color: #f9f9f9;border: 0;margin:0;padding: 15px;font-size: 14px;"></textarea>-->
  87. <div class="mui-content-padded mui-text-center" id="operation">
  88. </div>
  89. </div>
  90. </div>
  91. <script src="js/mui.min.js"></script>
  92. <script src="js/jquery-2.1.1.min.js"></script>
  93. <script src="js/main.js"></script>
  94. <script src="js/wechat-utils-1.0.js"></script>
  95. <script>
  96. var orderId = getParam("orderId");
  97. var status;
  98. var isPay = true; // 是否在请求支付,false表示正在请求,true可以请求
  99. var isEfficacious = true; //商品是否有效,有效则可以支付,无效则不能支付
  100. mui.ready(function() {
  101. // var str="";
  102. // for (i=0;i<3;i++) {
  103. // str+='<div class="mui-table"><div class="mui-table-cell mui-col-xs-4"><img class="mui-media-object wh-100" src="images/chanpin-1.jpg"></div><div class="mui-table-cell table-middle mui-col-xs-8">Aiberle美国智能净饮水一体机<h6>颜色:优雅白<span class="center">数量:2</span></h6><div>¥2999.00</div><h6>(赠品:美国aiberle咖啡杯 数量:3)</h6></div></div>';
  104. // }
  105. // document.querySelector('.shopping-cart-list').innerHTML=str;
  106. var table = document.body.querySelector('.shopping-cart-list');
  107. $.ajax(base_path + '/wechat/cart/getShopOrderByOrderId', {
  108. data: {
  109. orderId: orderId
  110. },
  111. dataType: 'json',
  112. xhrFields: {
  113. withCredentials: true
  114. },
  115. crossDomain: true,
  116. type: 'post',
  117. timeout: 15000,
  118. success: function(dt) {
  119. //服务器返回响应
  120. if(dt.isRedirect) {
  121. location.href = dt.redirectURL;
  122. } else {
  123. if(dt.status) {
  124. console.log(dt)
  125. var order = dt.data;
  126. status = order.salesStatus;
  127. $("#addressInfo").html(order.salesAddressInfo);
  128. $("#addressName").html(order.salesAddressName);
  129. $("#salesAddressTel").html(order.salesAddressTel);
  130. var str = '';
  131. var num = 0,a='';
  132. mui.each(order.orderItemList, function(index) {
  133. num += this.itemNum;
  134. str += '<div class="mui-table"><div class="mui-table-cell mui-col-xs-5"><img class="mui-media-object wh-100" src="'+ this.itemProductPic +'"></div><div class="mui-table-cell table-middle mui-col-xs-7" style="line-height:2.5">'+ this.itemProductName +'<h6>颜色:'+ this.itemProductColor +'<span class="center">数量:'+ this.itemNum +'</span></h6><div>¥'+ accDiv(this.itemProductDiscount,100) +'</div></div></div>';
  135. mui(this.salesUserGiftList).each(function(index) {
  136. var txt_gift = this;
  137. if (index == 0) {
  138. a += '<h6>赠品:' + txt_gift.giftName + '&nbsp;&nbsp;&nbsp;&nbsp;数量:' + txt_gift.userGiftCount + '</h6>';
  139. } else {
  140. a += '<h6>&nbsp;&nbsp;&nbsp;&nbsp;' + txt_gift.giftName + '&nbsp;&nbsp;&nbsp;&nbsp;数量:' + txt_gift.userGiftCount + '</h6>';
  141. }
  142. });
  143. str += a
  144. });
  145. document.querySelector('.shopping-cart-list').innerHTML = str;
  146. document.querySelector('.loading-bg').style.display = 'none';
  147. if(order.salesPostFirm != null && order.salesPostFirm != "" && typeof(order.salesPostFirm) != "undefined"){
  148. $("#salesPostFirm").val(order.salesPostFirm);
  149. }
  150. if(order.salesPostNum != null && order.salesPostNum != "" && typeof(order.salesPostNum) != "undefined"){
  151. $("#salesPostNum").val(order.salesPostNum);
  152. }
  153. var logisticsHtml = '';
  154. if(status == 5 || status == 12 || status == 6 || status == 11) { //状态为取消,待支付,代发货,退货,换货都没有物流信息
  155. if(order.salesPostFirm != null && order.salesPostFirm != "" && typeof(order.salesPostFirm) != "undefined" && order.salesPostNum != null && order.salesPostNum != "" && typeof(order.salesPostNum) != "undefined"){
  156. logisticsHtml = '<button type="button" class="mui-btn my-btn-request logistics" style="margin-right: 20px;">查看物流</button>';
  157. }
  158. }
  159. var payHtml = '<button type="button" class="mui-btn my-btn-request go_pay" style="margin-right: 20px;">立即支付</button>';
  160. var cancelOrderHtml = '<button type="button" class="mui-btn my-btn-request go_cancel" style="margin-right: 20px;">取消订单</button>';
  161. var aftermarketHtml = '<button type="button" class="mui-btn my-btn-request go_aftermarket" style="margin-right: 20px;">我要售后</button>';
  162. var cancelHtml = '<button type="button" class="mui-btn my-btn-request go_cancel" style="margin-right: 20px;">取消申请</button>';
  163. var confirmHtml = '<button type="button" class="mui-btn my-btn-request go_confirm" style="margin-right: 20px;">确认收货</button>';
  164. /*订单状态*/
  165. var statusName = "";
  166. var operationHtml = "";
  167. switch (parseInt(order.salesStatus)){
  168. case 0 :
  169. statusName = "取消订单";
  170. break;
  171. case 1 :
  172. statusName = "待支付";
  173. operationHtml += payHtml + cancelOrderHtml;
  174. break;
  175. case 2 :
  176. statusName = "已支付";
  177. operationHtml += aftermarketHtml;
  178. break;
  179. case 3 :
  180. statusName = "退款申请中";
  181. operationHtml += cancelHtml;
  182. break;
  183. case 4 :
  184. statusName = "已退款";
  185. break;
  186. case 5 :
  187. statusName = "已发货";
  188. operationHtml += aftermarketHtml + logisticsHtml;
  189. break;
  190. case 6 :
  191. statusName = "申请退货中";
  192. operationHtml += cancelHtml + logisticsHtml;
  193. break;
  194. case 7 :
  195. statusName = "退货中";
  196. operationHtml += cancelHtml;
  197. break;
  198. case 8 :
  199. statusName = "订单退货完成";
  200. break;
  201. case 9 :
  202. statusName = "换货中";
  203. break;
  204. case 10 :
  205. statusName = "换货完成";
  206. break;
  207. case 11 :
  208. statusName = "申请换货中";
  209. operationHtml += cancelHtml + logisticsHtml;
  210. break;
  211. case 12 :
  212. statusName = "订单完成";
  213. operationHtml += logisticsHtml
  214. break;
  215. default:
  216. break;
  217. }
  218. $("#statusName").html(statusName);
  219. $("#orderId").html(order.salesOrderid);
  220. $("#salesCreateDate").html(order.salesCreateDate);
  221. $("#salesYetAmount").html(accDiv(order.salesYetAmount,100));
  222. $("#num").html(num);
  223. $("#operation").html(operationHtml);
  224. }
  225. }
  226. },
  227. error: function(xhr, type, errorThrown) {
  228. console.log(xhr);
  229. }
  230. });
  231. });
  232. mui('body').on('tap', '.go_web_shop', function() {
  233. mui.openWindow({
  234. url: 'chanpin_list.html'
  235. });
  236. });
  237. mui('body').on('tap', '.go-clearing', function() {
  238. if($("input[type='checkbox']:checked").length > 0) {
  239. mui.openWindow({
  240. url: 'clearing.html'
  241. });
  242. } else {
  243. mui.alert('您没有选中任何商品', '爱贝源-消息提醒', function() {
  244. console.log("您关闭了警告框");
  245. });
  246. }
  247. });
  248. /*确认收货*/
  249. mui('body').on('tap', '.go_confirm', function() {
  250. confirm_receipt(orderId,status);
  251. });
  252. //确认收货
  253. function confirm_receipt(salesOrderid,status) {
  254. var dataArgs = {
  255. "orderId": salesOrderid,
  256. "status": status
  257. };
  258. $.ajax(base_path+'/wechat/cart/confirm_receipt', {
  259. data: dataArgs,
  260. dataType: 'json',
  261. type: 'POST',
  262. xhrFields: {
  263. withCredentials: true
  264. },
  265. crossDomain: true,
  266. timeout: 15000,
  267. success: function (dt) {
  268. mui.alert(dt.message);
  269. },
  270. error: function(xhr, type, errorThrown) {
  271. }
  272. });
  273. }
  274. /**
  275. * 立即支付
  276. */
  277. mui('body').on('tap', '.go_pay', function() {
  278. goOrderPay(orderId);
  279. });
  280. /**
  281. * 申请售后
  282. */
  283. mui('body').on('tap', '.go_aftermarket', function() {
  284. location.href = "customer-service.html?orderId=" + orderId;
  285. });
  286. /**
  287. * 查询物流
  288. */
  289. mui('body').on('tap', '.logistics', function() {
  290. var salesPostFirm = $("#salesPostFirm").val();
  291. var salesPostNum = $("#salesPostNum").val();
  292. location.href = "logistics-massage.html?salesPostFirm="+salesPostFirm + "&salesPostNum="+salesPostNum;
  293. });
  294. /**
  295. * 取消订单
  296. */
  297. mui('body').on('tap', '.go_cancel', function() {
  298. var newStatus;
  299. if(status == 1){//取消订单
  300. newStatus = 1;
  301. }else if(status == 3){ //申请退款的
  302. newStatus = 3;
  303. }else if(status == 6){ //申请退货的
  304. newStatus = 5;
  305. }else if(status == 7){ //退货中 的
  306. newStatus = 6;
  307. }else if(status == 11){
  308. newStatus = 8;
  309. }
  310. if(status != null){
  311. updateOrderStatus(orderId,newStatus,"");
  312. }
  313. });
  314. /*修改订单状态*/
  315. function updateOrderStatus(orderId, status, remark) {
  316. var msg = "";
  317. if(status == 1){
  318. msg = "是否取消该订单";
  319. }else if(status == 3){
  320. msg = "是否取消申请退款";
  321. }else if(status == 5){
  322. msg = "是否取消申请退货";
  323. }else if(status == 6){
  324. msg = "是否取消申请退货";
  325. }else if(status == 8){
  326. msg = "是否取消申请换货";
  327. }
  328. var btnArray = ['否', '是'];
  329. mui.confirm(msg, "", btnArray, function(e){
  330. if (e.index == 1) {
  331. $.ajax(base_path + '/wechat/cart/updateOrderStatus?dates=' + new Date().getTime(), {
  332. data: {
  333. "status": status, //更改后的状态
  334. "orderId": orderId, //订单id
  335. "remark": remark
  336. },
  337. dataType: 'json',
  338. xhrFields: {
  339. withCredentials: true
  340. },
  341. crossDomain: true,
  342. type: 'get',
  343. timeout: 15000,
  344. success: function(dt) {
  345. if(dt.resultCode == 200) {
  346. //mui.alert("获取订单列表失败!网络错误");
  347. //location.reload();//刷新
  348. }
  349. location.reload();//刷新
  350. },
  351. error: function(xhr, type, errorThrown) {
  352. console.log(xhr);
  353. mui.alert("获取订单列表失败!网络错误");
  354. }
  355. });
  356. }
  357. })
  358. }
  359. function goOrderPay(salesOrderid) {
  360. var dataArgs = {
  361. "orderId": salesOrderid
  362. };
  363. $.ajax(base_path+'/wechat/cart/orderPay', { // 提交订单,准备支付
  364. data: dataArgs,
  365. dataType: 'json',
  366. xhrFields: {
  367. withCredentials: true
  368. },
  369. crossDomain: true,
  370. type: 'POST',
  371. xhrFields: {
  372. withCredentials: true
  373. },
  374. crossDomain: true,
  375. timeout: 15000,
  376. success: function(dt) {
  377. // layer.closeAll();
  378. if(dt.status) {
  379. var str = dt.data.info;
  380. var obj = JSON.parse("{" + str + "}");
  381. WeixinJSBridge.invoke('getBrandWCPayRequest', obj, function(res) {
  382. if(res.err_msg == 'get_brand_wcpay_request:ok') {
  383. var orderIds = {
  384. "orderId": dt.data.orderId
  385. };
  386. // layer.open({
  387. // type: 2,
  388. // shadeClose: false,
  389. // content: "正在请求加载订单信息..."
  390. // }); // 调用加载弹出层
  391. $.ajax(base_path+'/wechat/order/checkOrderPaySuccess', { // 校验订单状态
  392. data: orderIds,
  393. dataType: 'json',
  394. xhrFields: {
  395. withCredentials: true
  396. },
  397. crossDomain: true,
  398. type: 'post',
  399. xhrFields: {
  400. withCredentials: true
  401. },
  402. crossDomain: true,
  403. timeout: 15000,
  404. success: function(dt) {
  405. if(dt.status) { // 支付成功
  406. window.location.href = "pay-win.html?orderId=" + orderIds.orderId + "&dates=" + new Date().getTime();
  407. } else {
  408. mui.toast("支付失败,请稍后重试!");
  409. //setTimeout(checkOrderStatus(orderIds), 1000);
  410. }
  411. },
  412. error: function(xhr, type, errorThrown) {
  413. isPay = true;
  414. // layer.closeAll();
  415. mui.toast("您的网络异常,请刷新重试!");
  416. return;
  417. }
  418. });
  419. } else {
  420. isPay = true;
  421. mui.alert("对不起,支付失败!请稍后重试!" + dt.data.orderId + "支付失败!");
  422. //window.location.href = "order-details.html?orderId=" + dt.data.orderId; // 前往订单详情
  423. }
  424. });
  425. } else {
  426. isPay = true;
  427. mui.toast(dt.message);
  428. }
  429. },
  430. error: function(xhr, type, errorThrown) {
  431. isPay = true;
  432. // layer.closeAll();
  433. mui.toast("您的网络异常,请刷新重试!");
  434. return;
  435. }
  436. });
  437. }
  438. </script>
  439. </body>
  440. </html>