welfare-receive-coupon.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. mui.ready(function(){
  44. var newDate = new Date();
  45. var limitedDate = new Date(2018, 6, 5, 0, 0, 0, 0);
  46. if(newDate > limitedDate){
  47. mui.alert("活动已过期!", function() {
  48. WeixinJSBridge.call('closeWindow');
  49. wx.closeWindow();
  50. return false;
  51. });
  52. return false;
  53. }
  54. console.log("页面加载完毕");
  55. $(".loading").hide().css("opacity", "0");//隐藏(正在加载...)
  56. receiceCoupon();
  57. });
  58. //领取新人现金券
  59. function receiceCoupon(){
  60. $.ajax(base_path + '/wechat/coupon/re_coupon?dates=' + new Date().getTime(), {
  61. data: {
  62. couponId : couponId //优惠券类型id
  63. },// ajax参数 没有则不写
  64. dataType: 'json',
  65. xhrFields: {
  66. withCredentials: true
  67. },
  68. crossDomain: true,
  69. type: 'get',
  70. timeout: 15000,
  71. success: function(dt) {
  72. if(dt.isRedirect) {//先判断isRedirect,然后跳转redirectURL
  73. location.href = dt.redirectURL;
  74. } else {
  75. if(dt.status) {//判断接口返回状态status
  76. mui.alert("领取成功!", function() {
  77. location.href = "index.html?dates=" + new Date().getTime(); // 前往首页
  78. });
  79. return false;
  80. } else {
  81. if(dt.resultCode == "500" || dt.resultCode == "502" || dt.resultCode == "503"){
  82. mui.alert(dt.message, function() {
  83. //刷新
  84. WeixinJSBridge.call('closeWindow');
  85. wx.closeWindow();
  86. });
  87. return false;
  88. }else{
  89. mui.alert("领取失败!");
  90. return false;
  91. }
  92. }
  93. }
  94. },
  95. error: function(xhr, type, errorThrown) {
  96. console.log(xhr);
  97. mui.alert("领取新人现金券失败!网络错误");
  98. }
  99. });
  100. }
  101. </script>
  102. </body>
  103. </html>