welfare-receive-coupon.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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/main.css" />
  12. <script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
  13. <script type="text/javascript">
  14. // 屏蔽分享
  15. window.hiddenAllWechatMenu = true;
  16. </script>
  17. </head>
  18. <body>
  19. <!--<div class="mui-content">
  20. <img src="images/coupon_hunderd.jpg" style="margin: 5%;width: 90%;"/>
  21. <div style="text-align: center; margin-bottom: 20px;">
  22. <button type="button" class="my-btn-receive fulishe" style="width: 168px;height: 38px;padding: 0px;">立即领取</button>
  23. </div>
  24. </div>-->
  25. <!-- 加载ing begin-->
  26. <div class="loading covers">
  27. <div class="loading-bj"></div>
  28. <p>正在加载...</p>
  29. </div>
  30. <!-- 加载ing end -->
  31. <script type="text/javascript" src="js/mui.min.js"></script>
  32. <script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
  33. <script type="text/javascript" src="js/main.js"></script>
  34. <script type="text/javascript">
  35. window.addEventListener('pageshow', function(e) {
  36. // 通过persisted属性判断是否存在 BF Cache
  37. if(e.persisted) {
  38. location.reload();
  39. }
  40. });
  41. var notReceive=null; //先判断是否领取过
  42. var couponId = getParam("couponId");//从URL带过来的优惠券id
  43. var isFirst = getParam("isFirst");//1
  44. mui.ready(function(){
  45. if(isFirst != 1 ){
  46. location.href = "welfare-receive-coupon.html?couponId="+ couponId +"&isFirst="+ 1 +"&dates=" + new Date().getTime(); // 前往首页
  47. }
  48. var newDate = new Date();
  49. var limitedDate = new Date(2018, 6, 9, 0, 0, 0, 0);
  50. if(newDate > limitedDate){
  51. mui.alert("活动已过期!", function() {
  52. WeixinJSBridge.call('closeWindow');
  53. wx.closeWindow();
  54. return false;
  55. });
  56. return false;
  57. }
  58. console.log("页面加载完毕");
  59. $(".loading").hide().css("opacity", "0");//隐藏(正在加载...)
  60. receiceCoupon();
  61. });
  62. //领取新人现金券
  63. function receiceCoupon(){
  64. $.ajax(base_path + '/wechat/coupon/re_coupon?dates=' + new Date().getTime(), {
  65. data: {
  66. couponId : couponId //优惠券类型id
  67. },
  68. dataType: 'json',
  69. xhrFields: {
  70. withCredentials: true
  71. },
  72. crossDomain: true,
  73. type: 'get',
  74. timeout: 15000,
  75. success: function(dt) {
  76. if(dt.isRedirect) {//先判断isRedirect,然后跳转redirectURL
  77. location.href = dt.redirectURL;
  78. } else {
  79. if(dt.status) {//判断接口返回状态status
  80. mui.alert("领取成功!", function() {
  81. location.href = "index.html?dates=" + new Date().getTime(); // 前往首页
  82. });
  83. return false;
  84. } else {
  85. if(dt.resultCode == "500" || dt.resultCode == "502" || dt.resultCode == "503"){
  86. mui.alert(dt.message, function() {
  87. //刷新
  88. WeixinJSBridge.call('closeWindow');
  89. wx.closeWindow();
  90. });
  91. return false;
  92. }else{
  93. var myjson = JSON.stringify(dt);
  94. mui.alert("领取失败!" + myjson);
  95. return false;
  96. }
  97. }
  98. }
  99. },
  100. error: function(xhr, type, errorThrown) {
  101. console.log(xhr);
  102. mui.alert("领取优惠券失败!网络错误");
  103. }
  104. });
  105. }
  106. </script>
  107. </body>
  108. </html>