fission-page.html 6.0 KB

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