Commit debaddca by 蒋勇

d

parent f6c1cea1
......@@ -184,7 +184,25 @@ class AccessAuthAPI extends APIBase {
}
return system.getResult(ruser);
}
//根据openid登录
async loginByOpenId(p,q,req){
var openid=p.openid;
if (!openid) {
return system.getResult(null, "openid不能为空");
}
var param = {
app_id: req.app.id,
openid: openid,
}
var ruser = await this.userSve.checkWxBind(param);
if(!ruser){
return system.getResult(null, "用户未绑定微信");
}
var opencode = super.getUUID();
var authUrl = req.app.authUrl + "?opencode=" + opencode;
await this.cacheManager["OpenCodeCache"].cache(opencode, ruser, 120);
return system.getResultSuccess({ auth_url: authUrl, opencode: opencode });
}
//wxbind
async wxBind(pobj, qobj, req) {
var appkey = req.app.appkey;
......@@ -561,6 +579,60 @@ class AccessAuthAPI extends APIBase {
rtnType: "json object{status:-1,data:2030),验证码错误,成功:{status:0,...}"
},
{
methodDesc: "按照微信openid检查是否绑定,访问地址:http://......../api/auth/accessAuth/checkWxBind,访问token需要放置到后续API方法调用的请求头中",
methodName: "checkWxBind",
paramdescs: [
{
paramDesc: "微信openid",
paramName: "openid",
paramType: "string",
defaultValue: "",
}
],
rtnTypeDesc: "返回绑定后的用户",
rtnType: "成功:{status:0,data:{}),未绑定:{status:-1}"
},
{
methodDesc: "按照手机号、验证码,微信ID,绑定账号,访问地址:http://......../api/auth/accessAuth/wxBind,访问token需要放置到后续API方法调用的请求头中",
methodName: "wxBind",
paramdescs: [
{
paramDesc: "手机号",
paramName: "mobile",
paramType: "string",
defaultValue: "",
},
{
paramDesc: "验证码",
paramName: "vcode",
paramType: "string",
defaultValue: "",
},
{
paramDesc: "微信openid",
paramName: "openid",
paramType: "string",
defaultValue: "",
}
],
rtnTypeDesc: "返回绑定后的获取用户的code",
rtnType: "成功:{status:0,data:{auth_url: xxxxx/auth?opencode=xxxxx,opencode:yyyy})"
},
{
methodDesc: "按照微信ID进行登录,访问地址:http://......../api/auth/accessAuth/loginByOpenId,访问token需要放置到后续API方法调用的请求头中",
methodName: "loginByOpenId",
paramdescs: [
{
paramDesc: "微信openid",
paramName: "openid",
paramType: "string",
defaultValue: "",
}
],
rtnTypeDesc: "返回绑定后的获取用户的code",
rtnType: "成功:{status:0,data:{auth_url: xxxxx/auth?opencode=xxxxx,opencode:yyyy})"
},
{
methodDesc: "按照手机号、验证码修改密码,访问地址:http://......../api/auth/accessAuth/modiPasswordByUserName,访问token需要放置到后续API方法调用的请求头中",
methodName: "modiPasswordByUserName",
paramdescs: [
......
......@@ -341,6 +341,20 @@ class UserService extends ServiceBase {
}
return user;
}
async wxBind(u) {
var self=this;
return this.db.transaction(async function (t) {
var user = await self.dao.model.findOne({where: { mobile: u.mobile,app_id: u.app_id }});
if(!user){
return null;
}else{
user.wxopenid=u.openid;
await user.save();
return user;
}
});
}
async getUserByUserMobile(u) {
//勇于从别的应用中,点击页面连接,跳转到平台应用中进行管理
var user = await this.dao.model.findOne({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment