| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
- <link rel="stylesheet" href="css/weui.min.css"/>
- <link rel="stylesheet" href="css/weuix.min.css"/>
- <link rel="stylesheet" href="css/style.css?vision=1.11">
- <script src="js/md5.js"></script>
- <script src="js/vue.min.js"></script>
- <script src="js/zepto.min.js"></script>
- <script src="js/zepto.weui.min.js"></script>
- <script src="js/php.js"></script>
- <script src="js/axios.min.js"></script>
- <script src="js/weChatSdk.js"></script>
- </head>
- <body>
- <div id="myApp" class="bg-box">
- <img alt="" class="headImg-box" :src=headSrc>
- <div class="content-box">
- <img alt="" :src=contentSrc />
- </div>
- <div class="num-box">已有 <span style="color: #A4404E">{{num}}</span> 人领取成功</div>
- <!--<img class="get-btn-box" src="image/get-free.gif" alt="" onclick="isfollowqr('http://open.weixin.qq.com/qr/code?username=hszuqiu')" />-->
- <img class="get-btn-box" src="image/get-free.gif" alt="" @click="goWeChat" />
- </div>
- </body>
- <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js" type="text/javascript"></script>
- <script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.2.1/weui.min.js"></script>
- <script>
- const apiUrl = 'http://fission.xazhima.com/api/api.php';
- new Vue({
- el:'#myApp',
- data:{
- num:52255,
- headSrc:'image/headImg.png',
- contentSrc:"image/content-bg.png",
- weChatCode:'',
- isFollow:'0'
- },
- methods:{
- goWeChat(){
- if(this.isFollow === '0'){
- location.href = 'http://mp.weixin.qq.com/mp/getmasssendmsg?__biz=MzUzOTcwMjM0OQ==#wechat_webview_type=1&wechat_redirect'
- }
- else {
- console.log('show share modal');
- wx.onMenuShareAppMessage()
- }
- },
- subStrUrlCode: function () {
- let weChatCodeUrl = location.search; //获取url中"?"符后的字符串
- let theRequest = {};
- if (weChatCodeUrl.indexOf("?") !== -1) {
- let str = weChatCodeUrl.substr(1);
- let strS = str.split("&");
- for(let i = 0; i < strS.length; i ++) {
- theRequest[strS[i].split("=")[0]]=(strS[i].split("=")[1]);
- }
- }
- console.log(theRequest);
- return theRequest.code;
- },
- judgeLogin(){
- axios({
- method: 'post', //请求方式 有常用的有get post等
- url: apiUrl, //请求地址
- data: {
- method: 'login',
- timestamp: 11111111,
- sign:md5('login'+'11111111')
- }, //代表传过去的参数对象,
- transformRequest: [function(data) {
- let ret = '';
- for (let it in data) {
- ret += encodeURIComponent(it) + '=' +
- encodeURIComponent(data[it]) + '&'
- }
- return ret
- }], //将传参修改为formData格式 注释则为JSON格式
- }).then(function(rs) {
- if(rs.data.code === 200) {
- window.location.href = rs.data.msg;
- }else {
- }
- }).catch(function(e) {
- console.log(e);
- });
- },
- setWxConfig(param){
- wx.config({
- debug: false,
- appId: param.appId,
- timestamp: param.timestamp ,
- nonceStr : param.nonceStr,
- signature: param.signature,
- jsApiList: [
- 'imagePreview', 'chooseImage', 'uploadImage'
- ]
- });
- },
- sendCodeRequest(){
- let that = this;
- that.weChatCode = that.subStrUrlCode();
- axios({
- method: 'post', //请求方式 有常用的有get post等
- url: apiUrl, //请求地址
- data: {
- method: 'wxinfo',
- timestamp: 11111111,
- code:that.weChatCode,
- jsUrl:'http://www.baidu.com',//(location.href.split('#')[0]),
- sign:md5('wxinfo'+'11111111')
- }, //代表传过去的参数对象,
- transformRequest: [function(data) {
- let ret = '';
- for (let it in data) {
- ret += encodeURIComponent(it) + '=' +
- encodeURIComponent(data[it]) + '&'
- }
- return ret
- }], //将传参修改为formData格式 注释则为JSON格式
- }).then(function(rs) {
- if(rs.data.code === 200) {
- that.setWxConfig(rs.data.msg.js_sign);
- that.headSrc = rs.data.msg.headimgurl;
- that.isFollow = rs.data.msg.subscribe;
- }
- }).catch(function(e) {
- console.log(e);
- });
- }
- },
- mounted(){
- this.subStrUrlCode() ? this.sendCodeRequest() : this.judgeLogin()
- }
- })
- </script>
- </html>
|