order-details.html 17 KB

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