fission-page.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
  7. <link rel="stylesheet" href="css/weui.min.css"/>
  8. <link rel="stylesheet" href="css/weuix.min.css"/>
  9. <link rel="stylesheet" href="css/style.css?vision=1.11">
  10. <script src="js/md5.js"></script>
  11. <script src="js/vue.min.js"></script>
  12. <script src="js/zepto.min.js"></script>
  13. <script src="js/zepto.weui.min.js"></script>
  14. <script src="js/php.js"></script>
  15. <script src="js/axios.min.js"></script>
  16. <script src="js/weChatSdk.js"></script>
  17. </head>
  18. <body>
  19. <div id="myApp" class="bg-box">
  20. <img alt="" class="headImg-box" :src=headSrc>
  21. <div class="content-box">
  22. <img alt="" :src=contentSrc />
  23. </div>
  24. <div class="num-box">已有 <span style="color: #A4404E">{{num}}</span> 人领取成功</div>
  25. <!--<img class="get-btn-box" src="image/get-free.gif" alt="" onclick="isfollowqr('http://open.weixin.qq.com/qr/code?username=hszuqiu')" />-->
  26. <img class="get-btn-box" src="image/get-free.gif" alt="" @click="goWeChat" />
  27. </div>
  28. </body>
  29. <script>
  30. const apiUrl = 'http://fission.xazhima.com/api/api.php';
  31. new Vue({
  32. el:'#myApp',
  33. data:{
  34. num:52255,
  35. headSrc:'image/headImg.png',
  36. contentSrc:"image/content-bg.png",
  37. weChatCode:'',
  38. isFollow:'0'
  39. },
  40. methods:{
  41. goWeChat(){
  42. if(this.isFollow === '0'){
  43. location.href = 'http://mp.weixin.qq.com/mp/getmasssendmsg?__biz=MzUzOTcwMjM0OQ==#wechat_webview_type=1&wechat_redirect'
  44. }
  45. else {
  46. console.log('show share modal');
  47. wx.onMenuShareAppMessage()
  48. }
  49. },
  50. subStrUrlCode: function () {
  51. let weChatCodeUrl = location.search; //获取url中"?"符后的字符串
  52. let theRequest = {};
  53. if (weChatCodeUrl.indexOf("?") !== -1) {
  54. let str = weChatCodeUrl.substr(1);
  55. let strS = str.split("&");
  56. for(let i = 0; i < strS.length; i ++) {
  57. theRequest[strS[i].split("=")[0]]=(strS[i].split("=")[1]);
  58. }
  59. }
  60. console.log(theRequest);
  61. return theRequest.code;
  62. },
  63. judgeLogin(){
  64. axios({
  65. method: 'post', //请求方式 有常用的有get post等
  66. url: apiUrl, //请求地址
  67. data: {
  68. method: 'login',
  69. timestamp: 11111111,
  70. sign:md5('login'+'11111111')
  71. }, //代表传过去的参数对象,
  72. transformRequest: [function(data) {
  73. let ret = '';
  74. for (let it in data) {
  75. ret += encodeURIComponent(it) + '=' +
  76. encodeURIComponent(data[it]) + '&'
  77. }
  78. return ret
  79. }], //将传参修改为formData格式 注释则为JSON格式
  80. }).then(function(rs) {
  81. if(rs.data.code === 200) {
  82. window.location.href = rs.data.msg;
  83. }else {
  84. }
  85. }).catch(function(e) {
  86. console.log(e);
  87. });
  88. },
  89. setWxConfig(param){
  90. wx.config({
  91. debug: false,
  92. appId: param.appId,
  93. timestamp: param.timestamp ,
  94. nonceStr : param.nonceStr,
  95. signature: param.signature,
  96. jsApiList: [
  97. 'imagePreview', 'chooseImage', 'uploadImage'
  98. ]
  99. });
  100. },
  101. sendCodeRequest(){
  102. let that = this;
  103. that.weChatCode = that.subStrUrlCode();
  104. axios({
  105. method: 'post', //请求方式 有常用的有get post等
  106. url: apiUrl, //请求地址
  107. data: {
  108. method: 'wxinfo',
  109. timestamp: 11111111,
  110. code:that.weChatCode,
  111. sign:md5('wxinfo'+'11111111')
  112. }, //代表传过去的参数对象,
  113. transformRequest: [function(data) {
  114. let ret = '';
  115. for (let it in data) {
  116. ret += encodeURIComponent(it) + '=' +
  117. encodeURIComponent(data[it]) + '&'
  118. }
  119. return ret
  120. }], //将传参修改为formData格式 注释则为JSON格式
  121. }).then(function(rs) {
  122. if(rs.data.code === 200) {
  123. that.setWxConfig(rs.data.msg.js_sign);
  124. that.headSrc = rs.data.msg.headimgurl;
  125. that.isFollow = rs.data.msg.subscribe;
  126. }
  127. }).catch(function(e) {
  128. console.log(e);
  129. });
  130. }
  131. },
  132. mounted(){
  133. this.subStrUrlCode() ? this.sendCodeRequest() : this.judgeLogin()
  134. }
  135. })
  136. </script>
  137. </html>