try_order.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
  7. <meta name="apple-mobile-web-app-capable" content="yes">
  8. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  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/style.css" />
  12. <style>
  13. .head {height: 60px;}
  14. #head {line-height: 60px;}
  15. .icon-songhuo{font-size: 15px;padding-left: 22px;}
  16. .icon-songhuo:before{font-size: 18px;color: #24cae9;position: absolute;left: 0;width: 20px;height: 18px;}
  17. .try_price{color: #f1436c;}
  18. .mui-table-view .mui-media .mui-media-body{height: 41px;line-height: 41px;color: #333;}
  19. .mui-table-view .mui-media .mui-media-body>span{color: #f1436c;}
  20. .my-table-view-try{border-top: .6em solid #f0f0f0;border-bottom: .6em solid #f0f0f0;padding: 10px 0;}
  21. .mui-table-view-cell:after,.mui-table-view:before,.mui-table-view:after,.mui-input-group .mui-input-row:after,.mui-input-group:before,.mui-input-group:after{display: none;}
  22. .mui-table-view-cell>a:not(.mui-btn){margin: -15px -15px;}
  23. .mui-table-view-cell>a .mui-pull-right{color: #999;font-size: 14px;}
  24. #btn_pay{color: #fff;padding: 10px 0;font-size: 18px;background: #24cae9;}
  25. .mui-content-padded{margin: 10px 13px;}
  26. .tips{padding: 20px 10px;background: #24cae9;text-align: center;color: #fff;}
  27. .icon-yanse,.icon-youhui,.icon-fuxuankuang,.icon-jiage,.icon-songhuo{font-size: 15px;padding-left: 22px;}
  28. .icon-yanse:before,.icon-fuxuankuang:before,.icon-youhui:before,.icon-jiage:before,.icon-songhuo:before{font-size: 18px;color: #24cae9;position: absolute;left: 0;width: 20px;height: 18px;}
  29. .point-time {content: "";position: absolute;width: 12px;height: 12px;top: 3px;left: 22px;background: #ccc;margin-left: -4px;border-radius: 50%;}
  30. .point-blue{color: #ccc;}
  31. .my-active .point-time {background-color:#01c0b5;}
  32. .my-active .point-blue{color:#fff;position: relative;background: #01c0b5;padding: 3px 10px;border-radius:25px;}
  33. .my-active .point-blue:before {position: absolute;content: "\00a0";width: 0px;height: 0px;border-width: 3px 6px 3px 0;border-style: solid;border-color: transparent #01c0b5 transparent transparent;top: 6px;left:-5px;}
  34. .mui-btn-block.mui-active,.btn-pull-code.mui-active{background-color: #c8c8c8 !important;}
  35. .content {width: 100%;margin:0 auto;}
  36. .content article {position: relative;}
  37. .content article section {padding: 0 0 20px 0;position: relative;}
  38. .content article section:before {content: "";width: 1px;top: 17px;bottom:0;left: 23px;background: #ccc;position: absolute;}
  39. .content article section:last-child:before {bottom:0;}
  40. .content article section time {display: block;}
  41. .content article section time > span {display: block;margin-left: 45px;color:#ccc;font-size: 12px;}
  42. .content article section aside {color: #3a3a38;margin-left:45px;margin-right: 5px;}
  43. .content article section aside p{margin-bottom: 0;font-size:13px;}
  44. .content article section aside .things{color:#222;margin-top: 5px;}
  45. .content article section:last-child:before {display: none;}
  46. .content article .my-active time > span{color: #333;}
  47. .ul-addres{padding-left: 24px;color: #333;font-size:12px;}
  48. </style>
  49. <script>
  50. // 屏蔽分享
  51. window.hiddenAllWechatMenu = true;
  52. </script>
  53. </head>
  54. <body style="background: #fff;">
  55. <div class="loading-bg">
  56. <div class="mui-loading">
  57. <div class="mui-spinner">
  58. </div>
  59. &nbsp;&nbsp;加载中...
  60. </div>
  61. </div>
  62. <div class="mui-content" style="background: #fff;">
  63. <div class="tips more">
  64. <h3>试用订单详情</h3>
  65. </div>
  66. <ul class="mui-table-view">
  67. <li class="mui-table-view-cell">
  68. 试用订单号<span class="mui-pull-right" id="postNum"></span>
  69. </li>
  70. <li class="mui-table-view-cell">
  71. 试用商品<span class="mui-pull-right" id="proName"></span>
  72. </li>
  73. <li class="mui-table-view-cell">
  74. 商品价格<span class="mui-pull-right ft-12">试用期内体验价<span class="try_price">0元</span>,<!-- <s class="mui-h6" id="cost_price"></s> -->&nbsp;&nbsp;<span class="try_price" id="try_price"></span></span>
  75. </li>
  76. <li style="padding: 10px 0 0 10px;">
  77. <span class="iconfont icon-youhui">支付优惠</span>
  78. </li>
  79. <li class="mui-table-view-cell" style="display:none">
  80. <span>试用价格:<span class="try_price">0元</span></span><br/>
  81. <img width="100%" src="images/cp-zeng.jpg" />
  82. <br/><span class="try_price">产品试用未购买,不给予开发票</span>
  83. </li>
  84. </ul>
  85. <ul class="mui-table-view my-table-view-try">
  86. <li class="mui-table-view-cell">
  87. <a>
  88. <span class="iconfont icon-songhuo">送货信息</span>
  89. <ul class="ul-addres">
  90. <!-- <li>收 货 人:林林</li>
  91. <li>手 机 号:15999999999</li>
  92. <li>详细地址:广东省深圳市福田区莲花街道特区报业大厦12B</li> -->
  93. </ul>
  94. </a>
  95. </li>
  96. </ul>
  97. <ul class="mui-table-view" id="ul-status">
  98. <li class="mui-table-view-cell">
  99. 订单状态
  100. </li>
  101. <li style="padding: 0;">
  102. <div class="content">
  103. <article>
  104. <section id="statu1">
  105. <span class="point-time"></span>
  106. <time>
  107. <span><span class="point-blue">待派送</span></span>
  108. </time>
  109. </section>
  110. <section id="statu2">
  111. <span class="point-time"></span>
  112. <time>
  113. <span><span class="point-blue">派送中</span><span id="sendName"></span></span>
  114. </time>
  115. </section>
  116. <section id="statu3">
  117. <span class="point-time"></span>
  118. <time>
  119. <span><span class="point-blue">待支付</span></span>
  120. </time>
  121. </section>
  122. <section id="statu4">
  123. <span class="point-time"></span>
  124. <time>
  125. <span><span class="point-blue">试用暂停</span></span>
  126. </time>
  127. </section>
  128. <section id="statu5">
  129. <span class="point-time"></span>
  130. <time>
  131. <span><span class="point-blue">支付完成</span></span>
  132. </time>
  133. </section>
  134. </article>
  135. </div>
  136. </li>
  137. <li class="mui-table-view-cell">
  138. 试用时间:剩余<span class="try_price" id="time_out"></span>
  139. </li>
  140. </ul>
  141. <div class="mui-content-padded">
  142. <button type="button" data-loading-icon="mui-spinner mui-spinner-custom" data-loading-text="正在请求数据,请稍后" class="mui-btn mui-btn-block mui-btn-outlined mui-active" id="btn_pay" disabled="disabled">立即支付</button>
  143. </div>
  144. </div>
  145. <script type="text/javascript" src="js/mui.min.js"></script>
  146. <script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
  147. <script type="text/javascript" src="js/main.js"></script>
  148. <script type="text/javascript" src="js/page/wechat-utils-1.0.js"></script>
  149. <script type="text/javascript">
  150. var postNum='';
  151. var isPay = true; // 是否在请求支付,false表示正在请求,true可以请求
  152. var istry=true;
  153. mui.ready(function(){
  154. $.ajax({
  155. type: 'post',
  156. url: base_path+'/probation/getProbationOrderDetail',
  157. data: {"orderId":getParam("orderId")},
  158. dataType: 'json',
  159. timeout: 15000,
  160. xhrFields: {
  161. withCredentials: true
  162. },
  163. crossDomain: true,
  164. success: function(dt) {
  165. if (dt.isRedirect) {
  166. location.href = dt.redirectURL;
  167. } else {
  168. //console.log(dt);
  169. if(dt.status) {
  170. postNum=dt.data.probationOrderid;
  171. $("#postNum").text(dt.data.probationOrderid);
  172. $("#try_price").text("试用价¥"+accDiv(dt.data.probationYetAmount, 100));
  173. //$("#cost_price").text("原价¥"+accDiv(dt.data.probationAmount, 100));
  174. if (dt.data.probationPostNum != "" && dt.data.probationPostFirm != "") {
  175. $(".ul-addres").html('<li>收 件 人:'+dt.data.probationReceiveName+'</li><li>手 机 号:'+dt.data.probationReceiveTel+'</li><li>详细地址:'+dt.data.probationAddressInfo+'</li><li>快递单号:' + dt.data.probationPostNum + '</li><li>快递公司:上门送货</li>');
  176. } else {
  177. $(".ul-addres").html('<li>收 件 人:'+dt.data.probationReceiveName+'</li><li>手 机 号:'+dt.data.probationReceiveTel+'</li><li>详细地址:'+dt.data.probationAddressInfo+'</li>');
  178. }
  179. if(dt.data.probationSendName!=""){
  180. $("#sendName").html('(派送员:'+dt.data.probationSendName+' 手机:<a href="tel:'+dt.data.probationSendTel+'">'+dt.data.probationSendTel+'</a>)');
  181. }
  182. var proColor='';
  183. switch (dt.data.probationColorType){
  184. case 1:
  185. proColor="品蓝";
  186. break;
  187. case 2:
  188. proColor="品黑";
  189. break;
  190. case 3:
  191. proColor="苹果绿";
  192. break;
  193. case 4:
  194. proColor="西瓜红";
  195. break;
  196. default:
  197. break;
  198. }
  199. $("#proName").html(dt.data.probationProductName+'('+proColor+')');
  200. //console.log(new Date().getTime())
  201. $(".content #statu"+dt.data.probationStatus).addClass("my-active");
  202. if(dt.data.probationStatus==3){
  203. addTimer('time_out', dt.data.probationRemainingTime/ 1000);
  204. $("#btn_pay").removeAttr("disabled").removeClass("mui-active");
  205. mui('body').on('tap', '#btn_pay', function() {
  206. var th=this;
  207. //console.log("立即支付");
  208. mui(this).button('loading');
  209. if(isPay){
  210. isPay = false; //锁定请求
  211. $.ajax({
  212. type: 'post',
  213. url: base_path+'/probation/pay',
  214. data: {"orderId":postNum},
  215. dataType: 'json',
  216. timeout: 15000,
  217. success: function(dt) {
  218. if (dt.isRedirect) {
  219. location.href = dt.redirectURL;
  220. } else {
  221. //console.log(dt);
  222. if(dt.status) {
  223. var obj = JSON.parse("{" + dt.data.info + "}");
  224. WeixinJSBridge.invoke('getBrandWCPayRequest', obj, function(res) {
  225. if(res.err_msg == 'get_brand_wcpay_request:ok') {
  226. $.ajax({
  227. type: 'post',
  228. url: base_path+'/probation/check_probation_pay_success',
  229. data: {"orderId":postNum},
  230. dataType: 'json',
  231. timeout: 15000,
  232. xhrFields: {
  233. withCredentials: true
  234. },
  235. crossDomain: true,
  236. success: function(data) {
  237. //console.log(data);
  238. if(data.status) {
  239. if(data.data==5){
  240. mui.alert("支付成功", '', function() {
  241. mui.openWindow({url: base_path+'/probation/try_order?orderId='+postNum});
  242. });
  243. }else{
  244. mui.alert(data.message, '', function() {
  245. mui(th).button('reset');
  246. });
  247. }
  248. } else {
  249. mui(th).button('reset');
  250. mui.alert(data.message);
  251. }
  252. },
  253. error: function(xhr, type, errorThrown) {
  254. //异常处理;
  255. console.log(xhr);
  256. mui(th).button('reset');
  257. mui.alert("请检查网络或刷新页面重试!");
  258. }
  259. });
  260. } else {
  261. isPay = true;
  262. mui(th).button('reset');
  263. mui.alert("对不起,支付失败!请稍后重试!");
  264. }
  265. });
  266. } else {
  267. mui(th).button('reset');
  268. mui.alert(dt.message);
  269. }
  270. }
  271. },
  272. error: function(xhr, type, errorThrown) {
  273. //异常处理;
  274. console.log(xhr);
  275. mui(th).button('reset');
  276. mui.alert("请检查网络或刷新页面重试!");
  277. }
  278. });
  279. }else{
  280. mui.alert("正在请求支付中~~请稍后!");
  281. return;
  282. }
  283. });
  284. }else if(dt.data.probationStatus==1){
  285. $("#time_out").parent().hide();
  286. $("#btn_pay").removeAttr("disabled").removeClass("mui-active").text("取消订单");
  287. mui('body').on('tap', '#btn_pay', function() {
  288. var th=this;
  289. //console.log("取消订单");
  290. var btnArray = ['否', '是'];
  291. mui.confirm('确认取消试用订单?', '温馨提示', btnArray, function(e) {
  292. if (e.index == 1) {
  293. mui(th).button('loading');
  294. if(istry){
  295. istry = false; //锁定请求
  296. $.ajax({
  297. type: 'post',
  298. url: base_path+'/probation/userCancelOrder',
  299. data: {"orderId":postNum},
  300. dataType: 'json',
  301. timeout: 15000,
  302. xhrFields: {
  303. withCredentials: true
  304. },
  305. crossDomain: true,
  306. success: function(dt) {
  307. if (dt.isRedirect) {
  308. location.href = dt.redirectURL;
  309. } else {
  310. //console.log(dt);
  311. if(dt.resultCode=="200") {
  312. location.reload(true);
  313. } else {
  314. mui(th).button('reset');
  315. mui.alert(dt.returnMsg.returnMsg);
  316. }
  317. }
  318. },
  319. error: function(xhr, type, errorThrown) {
  320. //异常处理;
  321. console.log(xhr);
  322. mui(th).button('reset');
  323. mui.alert("请检查网络或刷新页面重试!");
  324. }
  325. });
  326. }else{
  327. mui.alert("正在请求取消订单中~~请稍后!");
  328. return;
  329. }
  330. } else {
  331. mui(th).button('reset');
  332. }
  333. });
  334. });
  335. }else if(dt.data.probationStatus==0){
  336. $("#time_out").parent().hide();
  337. $("#ul-status").hide();
  338. $("#btn_pay").text("订单已取消");
  339. }else{
  340. $("#time_out").parent().hide();
  341. }
  342. } else {
  343. mui.alert(dt.message);
  344. }
  345. }
  346. },
  347. error: function(xhr, type, errorThrown) {
  348. //异常处理;
  349. console.log(xhr);
  350. mui.alert("请检查网络或刷新页面重试!");
  351. }
  352. });
  353. //console.log("页面加载完毕")
  354. document.querySelector('.loading-bg').style.display='none';
  355. });
  356. var addTimer = function() {
  357. var list = [],
  358. interval;
  359. return function(id, time) {
  360. if(!interval)
  361. interval = setInterval(go, 1000);
  362. list.push({
  363. ele: document.getElementById(id),
  364. time: time
  365. });
  366. }
  367. function go() {
  368. for(var i = 0; i < list.length; i++) {
  369. list[i].ele.innerHTML = getTimerString(list[i].time ? list[i].time -= 1 : 0);
  370. if(!list[i].time)
  371. list.splice(i--, 1);
  372. }
  373. }
  374. function getTimerString(time) {
  375. d = Math.floor(time / 86400),
  376. h = Math.floor((time % 86400) / 3600),
  377. m = Math.floor(((time % 86400) % 3600) / 60),
  378. s = Math.floor(((time % 86400) % 3600) % 60);
  379. if(time > 0)
  380. return d + "天" + h + "时" + m + "分" + s+"秒";
  381. else return "试用已结束";
  382. }
  383. }();
  384. </script>
  385. </body>
  386. </html>