zoukankan      html  css  js  c++  java
  • 公众号

    var wx_login = {//微信登录

    base_url: 'http://xxx.com',
    init:function(){
      var code = public_fun.getUrlParms('code');//获取地址栏参数判断是否已经授权
      code ? this.login(code) : this.getAuthorization();
      console.log(code)
    },
    getAuthorization: function() { //获取授权

      var current_url =window.location.href;
      var dir_url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxxxx&redirect_uri='+current_url+'&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect'
      location.href = dir_url;

    },
    login: function(code) { //登录
      var code = code;
      Vue.http({
        method: 'POST',
        url: this.base_url + '/auth/wxlogin.do',
        params: {
          code: code
        },
      headers: {
        "X-Requested-With": "XMLHttpRequest"
      },
      emulateJSON: true
      }).then(function(res) {
        console.log(res)
        var res = JSON.parse(res.bodyText),
        _url = sessionStorage.getItem('entry');
        location.href = _url;
        //登录成功,跳往已存储网页,每个页面都能过期,所以在后台返回过期状态码下存储网页
          Vue.$toast(res.msg);
        }).catch(function(error) {
          console.log(error);
        });
      }
    }

  • 相关阅读:
    C++重载运算符
    C++中的友元函数和友元类
    C++中的static关键字
    C++的new运算符和delete运算符
    git常用命令
    php+mysql+apache报错
    Nodejs 异步式 I/O 与事件式编程
    开始用Node.js编程
    Nodejs 模块
    Mac OS X上安装Node.js
  • 原文地址:https://www.cnblogs.com/92xcd/p/9450782.html
Copyright © 2011-2022 走看看