文档
测试

微信登录

POST
https://runtong.hd2c.com/login?wx_code=微信授权代码

接口描述

微信登录

请求参数

参数名
类型
描述
必填
term
string
登录终端, wx:微信
必填

响应参数

参数名
类型
描述
必填
status
string
状态,success: 成功, faild:失败
必填
session_id
string
会话ID
必填
user_id
int
会员ID
必填
user_name
string
用户名
必填
nick_name
string
昵称
必填
user_mobile
string
手机号
必填
user_email
string
邮箱
必填
user_avatar
string
会员头像
必填
user_sex
string
性别, women:女, man:男, unknow:未知
必填
new
int
新注册会员, 1:是, 0:不是
必填
error
array
错误信息,字符串数组
必填

说明 / 示例

<pre><code> Login: function () { // 登录 wx.login({ success: res => { if (res.code) { var that = this; this.globalData.code = res.code; wx.request({ url: this.globalData.domain + '/login?json=1&wx_code=' + res.code + (that.globalData.fromuid ? '&from_uid=' + that.globalData.fromuid : ''),//请求地址 header: {//请求头 "Content-Type": "applciation/json" }, method: "GET",//get为默认方法/POST success: function (res) { if (res.data.status == 'success') { var session = { id: res.data.session_id, user_id: res.data.user_id }; that.globalData.session = session; if(res.data.user_id) { that.globalData.user = {}; that.globalData.user.user_id = res.data.user_id; that.globalData.user.nick_name = res.data.nick_name; that.globalData.user.user_mobile = res.data.user_mobile; that.globalData.user.user_avatar = res.data.user_avatar; that.globalData.user.user_ctime = res.data.user_ctime; that.globalData.user.user_sex = res.data.user_sex; } wx.getSetting({ success: function (res) { if (res.authSetting['scope.userInfo']) { // 已经授权,可以直接调用 getUserInfo 获取头像昵称 wx.getUserInfo({ success: function (res) { that.globalData.userInfo = res.userInfo; that.updateFan(); //that.getCity(); if (that.callback) { that.callback(); } } }); } else { //that.getCity(); if (that.callback) { that.callback(); } } } }); } else{ console.log(res); } }, fail: function (err) { },//请求失败 complete: function () { }//请求完成后执行的函数 }) } } }); }`