fission-page.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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">
  25. 已有 <span style="color: #A4404E">{{num}}</span> 人领取成功
  26. </div>
  27. <!--<img class="get-btn-box" src="image/get-free.gif" alt="" onclick="isfollowqr('http://open.weixin.qq.com/qr/code?username=hszuqiu')" />-->
  28. <img class="get-btn-box" src="image/get-free.gif" alt="" @click="goWeChat" />
  29. </div>
  30. </body>
  31. <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js" type="text/javascript"></script>
  32. <script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.2.1/weui.min.js"></script>
  33. <script>
  34. const apiUrl = 'http://fission.xazhima.com/api/api.php';
  35. new Vue({
  36. el:'#myApp',
  37. data:{
  38. num:52255,
  39. headSrc:'image/headImg.png',
  40. contentSrc:"image/content-bg.png",
  41. weChatCode:'',
  42. isFollow:'0',
  43. openId:'',
  44. },
  45. methods:{
  46. goWeChat(){
  47. if(this.isFollow === '0'){
  48. location.href = 'http://mp.weixin.qq.com/mp/getmasssendmsg?__biz=MzUzOTcwMjM0OQ==#wechat_webview_type=1&wechat_redirect'
  49. }
  50. else {
  51. console.log('show share modal');
  52. wx.onMenuShareAppMessage()
  53. }
  54. },
  55. subStrUrlCode: function () {
  56. let weChatCodeUrl = location.search; //获取url中"?"符后的字符串
  57. let theRequest = {};
  58. if (weChatCodeUrl.indexOf("?") !== -1) {
  59. let str = weChatCodeUrl.substr(1);
  60. let strS = str.split("&");
  61. for(let i = 0; i < strS.length; i ++) {
  62. theRequest[strS[i].split("=")[0]]=(strS[i].split("=")[1]);
  63. }
  64. }
  65. console.log(theRequest);
  66. return theRequest.code;
  67. },
  68. judgeLogin(){
  69. axios({
  70. method: 'post', //请求方式 有常用的有get post等
  71. url: apiUrl, //请求地址
  72. data: {
  73. method: 'login',
  74. timestamp: 11111111,
  75. sign:md5('login'+'11111111')
  76. }, //代表传过去的参数对象,
  77. transformRequest: [function(data) {
  78. let ret = '';
  79. for (let it in data) {
  80. ret += encodeURIComponent(it) + '=' +
  81. encodeURIComponent(data[it]) + '&'
  82. }
  83. return ret
  84. }], //将传参修改为formData格式 注释则为JSON格式
  85. }).then(function(rs) {
  86. if(rs.data.code === 200) {
  87. window.location.href = rs.data.msg;
  88. console.log(rs.data)
  89. }else {
  90. }
  91. }).catch(function(e) {
  92. console.log(e);
  93. });
  94. },
  95. setWxConfig(param){
  96. wx.config({
  97. debug: false,
  98. appId: param.appId,
  99. timestamp: param.timestamp ,
  100. nonceStr : param.nonceStr,
  101. signature: param.signature,
  102. jsApiList: [
  103. 'imagePreview', 'chooseImage', 'uploadImage'
  104. ]
  105. });
  106. },
  107. sendCodeRequest(){
  108. let that = this;
  109. that.weChatCode = that.subStrUrlCode();
  110. axios({
  111. method: 'post', //请求方式 有常用的有get post等
  112. url: apiUrl, //请求地址
  113. data: {
  114. method: 'wxinfo',
  115. timestamp: 11111111,
  116. code:that.weChatCode,
  117. jsUrl:(location.href.split('#')[0]),
  118. sign:md5('wxinfo'+'11111111')
  119. }, //代表传过去的参数对象,
  120. transformRequest: [function(data) {
  121. let ret = '';
  122. for (let it in data) {
  123. ret += encodeURIComponent(it) + '=' +
  124. encodeURIComponent(data[it]) + '&'
  125. }
  126. return ret
  127. }], //将传参修改为formData格式 注释则为JSON格式
  128. }).then(function(rs) {
  129. if(rs.data.code === 200) {
  130. that.setWxConfig(rs.data.msg.js_sign);
  131. that.headSrc = rs.data.msg.headimgurl;
  132. that.isFollow = rs.data.msg.subscribe;
  133. that.openId = rs.data.msg.openid;
  134. }
  135. }).catch(function(e) {
  136. console.log(e);
  137. });
  138. }
  139. },
  140. mounted(){
  141. this.subStrUrlCode() ? this.sendCodeRequest() : this.judgeLogin()
  142. }
  143. })
  144. </script>
  145. </html>