welfare-two-channel.html 3.4 KB

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