Commit f6c1cea1 by 蒋勇

d

parent e55a97ca
......@@ -167,6 +167,64 @@ class AccessAuthAPI extends APIBase {
await this.cacheManager["OpenCodeCache"].cache(opencode, ruser, 120);
return system.getResultSuccess({ auth_url: authUrl, opencode: opencode });
}
//根据openid查询是否与用户绑定
async checkWxBind(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, "用户未绑定微信");
}
return system.getResult(ruser);
}
//wxbind
async wxBind(pobj, qobj, req) {
var appkey = req.app.appkey;
if (!pobj.mobile) {
return system.getResult(null, "电话号码不能未空.");
}
if (!pobj.vcode) {
return system.getResult(null, "验证码不能未空.");
}
if (!pobj.openid) {
return system.getResult(null, "openid不能未空.");
}
var cacheCode = await this.cacheManager["VCodeCache"].cache(appkey + "_" + pobj.mobile, null);
if (pobj.vcode != cacheCode.vcode) {
return system.getResult(system.verifyVCodeFail, "验证码校验不成功,请重新获取验证码验证.");
}
var param = {
app_id: req.app.id,
mobile: pobj.mobile,
openid:pobj.openid
}
var ruser = await this.userSve.wxBind(param);
if (!ruser) {
param = {
app_id: req.app.id,
userName: pobj.mobile,
nickName:pobj.mobile,
mobile: pobj.mobile,
password: pobj.mobile,
wxopenid:pobj.openid
}
ruser = await this.userSve.register(param);
}
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 });
}
//根据openid登录
async loginByMobileWithReg(pobj, qobj, req) {
if (!pobj.mobile) {
return system.getResult(null, "电话不能为空");
......
......@@ -34,6 +34,7 @@ module.exports = (db, DataTypes) => {
type:DataTypes.BOOLEAN,
defaultValue: false
},
wxopenid:DataTypes.STRING,
app_id:DataTypes.INTEGER,
account_id:DataTypes.INTEGER,
isEnabled:{
......
......@@ -309,6 +309,10 @@ class UserService extends ServiceBase {
}
return user;
}
async checkWxBind(u){
var user = await this.dao.model.findOne({where: {wxopenid: u.openid, app_id: u.app_id}});
return user;
}
async getUserByUserNamePwd(u) {
//勇于从别的应用中,点击页面连接,跳转到平台应用中进行管理
if(!u.isNavto){
......
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