fission-page.html 6.0 KB

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