order-details.html 19 KB

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