|
@@ -134,10 +134,36 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async urlchange(ctx) {
|
|
|
- // 设置用户微信登录项目,跳转到对应wap页面
|
|
|
- co
|
|
|
- ctx.redirect(ctx.query.url);
|
|
|
+ // 设置用户微信登录项目,跳转到对应wap页面
|
|
|
+ async url2wap(ctx) {
|
|
|
+ try {
|
|
|
+ if (!ctx.query.project || !ctx.query.url) {
|
|
|
+ throw '参数有误';
|
|
|
+ }
|
|
|
+ const code = ctx.query.project;
|
|
|
+ // 查找项目数据
|
|
|
+ const projectData = await ctx.service.project.getProjectByCode(code.toString().trim());
|
|
|
+ if (projectData === null) {
|
|
|
+ throw '不存在项目数据';
|
|
|
+ }
|
|
|
+ const pa = await ctx.service.projectAccount.getDataByCondition({ code, wx_openid: ctx.session.wechatToken.openid });
|
|
|
+ if (!pa) {
|
|
|
+ throw '该微信号未绑定此项目';
|
|
|
+ }
|
|
|
+ if (pa.enable !== 1) {
|
|
|
+ throw '该账号已被停用,请联系销售人员';
|
|
|
+ }
|
|
|
+ // 设置项目和用户session记录
|
|
|
+ const result = await ctx.service.projectAccount.accountLogin({ project: projectData, accountData: pa }, 3);
|
|
|
+ if (!result) {
|
|
|
+ throw '登录出错';
|
|
|
+ }
|
|
|
+ ctx.redirect(ctx.query.url);
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ ctx.body = error;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
async oauthTxt(ctx) {
|