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# 操作数据库
    dataview findrows
    C++:gethostname,gethostbyname获取IP地址和计算机名
    MQTT
    STM32操作外部SRAM
    JAVA中最常用的快捷键总结
    Zstack中End Device设备失去父节点时的重新入网处理方法(转)
    VC++ 重叠窗口
    (转载)PLC内部电路常见的几种形式
    VS2005 DoModal函数
  • 原文地址:https://www.cnblogs.com/92xcd/p/9450782.html
Copyright © 2011-2022 走看看