Commit 27989a27 by 宋毅

tj

parent 267d85e0
......@@ -183,6 +183,9 @@ class tmqueryCtl extends CtlBase {
}
async getUserIdEncryptStr(pobj, qobj, req) {
try {
if (!req.session.userPinInfo) {
return system.getResult(null, "user is not login...");
}
var tokenInfo = await this.getToken(pobj.actionProcess);
if (tokenInfo.status != 0) {
return tokenInfo;
......@@ -191,7 +194,7 @@ class tmqueryCtl extends CtlBase {
var param = {
actionProcess: pobj.actionProcess,
actionType: "encryptStr",
actionBody: { channelUserId: pobj.channelUserId, opStr: pobj.channelUserId },
actionBody: { channelUserId: req.session.userPinInfo.channelUserId, opStr: req.session.userPinInfo.channelUserId },
isUser: "yes"
};
var reqUrl = this.channelApiUrl + "/action/tmTools/springBoard";
......@@ -202,7 +205,8 @@ class tmqueryCtl extends CtlBase {
if (resultUser.status != 0) {
return system.getResult(null, "encrypt userId is error");
}
return resultUser;
req.session.userPinInfo.encryptChannelUserId = resultUser.data || "";
return system.getResultSuccess({ encryptChannelUserId: resultUser.data || "" });
} catch (error) {
console.log(error.stack, "操作error...................");
return system.getResultFail(-200, "操作error");
......@@ -235,24 +239,9 @@ class tmqueryCtl extends CtlBase {
}
async getUserInfo(pobj, qobj, req) {
try {
this.logClient.info("jd", "getUserInfo----->req参数:" + JSON.stringify(pobj));
if (req.session.userPinInfo) {
this.logClient.info("jd", "req.session.userPinInfo true 参数:" + JSON.stringify(req.session.userPinInfo));
if (!req.session.userPinInfo.encryptChannelUserId) {
pobj.channelUserId = req.session.userPinInfo.channelUserId;
var userIdEncryptStrResult = await this.getUserIdEncryptStr(pobj);
this.logClient.info("jd", "req.session.userPinInfo userIdEncryptStrResult 结果1111111:" + JSON.stringify(userIdEncryptStrResult));
if (userIdEncryptStrResult && userIdEncryptStrResult.status == 0) {
req.session.userPinInfo.encryptChannelUserId = userIdEncryptStrResult.data;
}//重新加密成功
else {
return userIdEncryptStrResult;
}
}
return system.getResultSuccess({ encryptChannelUserId: req.session.userPinInfo.encryptChannelUserId });
return system.getResultSuccess({ encryptChannelUserId: req.session.userPinInfo.encryptChannelUserId || "" });
}
// console.log();
var authUrl = pobj.authUrl;
var authToken = pobj.authToken;
var actionProcess = pobj.actionProcess;
......@@ -266,7 +255,6 @@ class tmqueryCtl extends CtlBase {
return system.getResult(null, "actionProcess不能为空");
}
var result = await this.execClient.execPostJDTK("", authUrl, authToken);
this.logClient.info("jd", "getUserInfo----->execPostJDTK----authUrl--->result:" + JSON.stringify(result));
if (!result || !result.account) {
return system.getResult(null, "处理用户请求失败,msg:" + result.error_description);
}
......@@ -289,18 +277,7 @@ class tmqueryCtl extends CtlBase {
return system.getResult(null, "处理请求失败");
}
req.session.userPinInfo = resultUser.data;
if (!req.session.userPinInfo.encryptChannelUserId) {
pobj.channelUserId = req.session.userPinInfo.channelUserId;
var userIdEncryptStrResult = await this.getUserIdEncryptStr(pobj);
this.logClient.info("jd", "req.session.userPinInfo userIdEncryptStrResult 结果222222:" + JSON.stringify(userIdEncryptStrResult));
if (userIdEncryptStrResult && userIdEncryptStrResult.status == 0) {
req.session.userPinInfo.encryptChannelUserId = userIdEncryptStrResult.data;
}//重新加密成功
else {
return userIdEncryptStrResult;
}
}
return resultUser;
return system.getResultSuccess({ encryptChannelUserId: resultUser.data.encryptChannelUserId || "" });
} catch (error) {
this.logClient.error("jd", "req---->getUserInfo---->error:" + error.stack);
return system.getResultFail(-200, "操作error");
......
......@@ -14,8 +14,7 @@ module.exports = function (app) {
var getUserparams = {
actionProcess: "jd",
authUrl: "https://oauth2.jdcloud.com/userinfo",
authToken: params.token_type + " " + params.access_token,
tmpchannelUserId: params.tmpchannelUserId
authToken: params.token_type + " " + params.access_token
};
var userItemResult = await tmqueryCtl.getUserInfo(getUserparams, req.query, req);
if (userItemResult.status != 0) {
......@@ -23,7 +22,7 @@ module.exports = function (app) {
return;
}
if (!userItemResult.data.encryptChannelUserId || userItemResult.data.encryptChannelUserId == "undefined") {
userItemResult = await tmqueryCtl.getUserInfo(getUserparams, req.query, req);
userItemResult = await tmqueryCtl.getUserIdEncryptStr(getUserparams, req.query, req);
if (userItemResult.status != 0) {
res.redirect("/#/jd/jdtrademark");
return;
......
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