ソースを参照

feat: 更新weapp控制器,优化错误信息返回,增强用户登录体验

lanjianrong 3 週間 前
コミット
fee11c7966

+ 1 - 1
app/controller/weapp_controller.js

@@ -86,7 +86,7 @@ module.exports = app => {
                 ctx.body = { code: 0, msg: '', data: { access_token: token } };
             } catch (error) {
                 this.log(error);
-                ctx.body = { code: -1, msg: '登录已过期,请重新登录', data: null };
+                ctx.body = { code: -1, msg: error.toString(), data: null };
             }
         }
 

+ 10 - 4
app/controller/weapp_tender_controller.js

@@ -19,7 +19,13 @@ module.exports = app => {
                 const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
                 if (userPermission !== null && userPermission.tender !== undefined && userPermission.tender.indexOf('1') !== -1) {
                     const subProject = await this.ctx.service.subProject.getDataById(projectId);
-                    const tenderList = await this.ctx.service.tender.getList('manage', userPermission, ctx.session.sessionUser.is_admin, '', subProject);
+                    const tenderList = await this.ctx.service.tender.getList('', userPermission, ctx.session.sessionUser.is_admin, '', subProject);
+                    for (const tender of tenderList) {
+                        // 查询当前审批期以及状态
+                        const stage = await this.ctx.service.stage.getLastestStage(tender.id, true);
+                        tender.stage_order = stage && stage.order ? stage.order : null;
+                        tender.stage_status = stage && stage.status ? stage.status : null;
+                    }
                     const categoryData = await this.ctx.service.category.getAllCategory(subProject);
                     const renderData = {
                         categoryData,
@@ -155,8 +161,8 @@ module.exports = app => {
                 advance.auditors = await this.service.advanceAudit.getAuditors(advance.id, advance.times);
                 advance.curAuditor = await this.service.advanceAudit.getCurAuditor(advance.id, advance.times);
                 // 根据状态判断是否需要更新审批人列表
-                if ((advance.status === status.uncheck || advance.status === status.checkNo) && this.tender.info.shenpi.advance !== shenpiConst.sp_status.sqspr) {
-                    const shenpi_status = this.tender.info.shenpi.advance;
+                if ((advance.status === status.uncheck || advance.status === status.checkNo) && ctx.tender.info.shenpi.advance !== shenpiConst.sp_status.sqspr) {
+                    const shenpi_status = this.ctx.tender.info.shenpi.advance;
                     // 进一步比较审批流是否与审批流程设置的相同,不同则替换为固定审批流或固定的终审
                     const auditList = await this.service.advanceAudit.getAllDataByCondition({ where: { vid: advance.id, times: advance.times }, orders: [['order', 'asc']] });
                     const auditIdList = _.map(auditList, 'audit_id');
@@ -174,7 +180,7 @@ module.exports = app => {
                             await this.service.advanceAudit.updateLastAudit(advance, auditList, shenpiInfo.audit_id);
                         } else if (!shenpiInfo) {
                             // 不存在终审人的状态下这里恢复为授权审批人
-                            this.tender.info.shenpi.advance = shenpiConst.sp_status.sqspr;
+                            this.ctx.tender.info.shenpi.advance = shenpiConst.sp_status.sqspr;
                         }
                     }
                 }

+ 2 - 0
app/service/weapp.js

@@ -175,6 +175,8 @@ module.exports = app => {
             // 2. 校验 Redis 中是否存在(防止篡改/过期/被踢)
             const redisKey = `user:${openid}:refresh_token`;
             const redisRefreshToken = await app.redis.get(redisKey);
+            console.log(`Redis refresh token for ${openid}:`, redisRefreshToken);
+
             if (!redisRefreshToken || redisRefreshToken !== refreshToken) {
                 throw 'refresh_token 无效或已过期';
             }