正在显示
5 个修改的文件
包含
22 行增加
和
6 行删除
| @@ -104,7 +104,8 @@ userController.prototype.login = async(ctx, next) =>{ | @@ -104,7 +104,8 @@ userController.prototype.login = async(ctx, next) =>{ | ||
| 104 | userMobile:userData.userMobile, | 104 | userMobile:userData.userMobile, |
| 105 | userEmail:userData.userEmail, | 105 | userEmail:userData.userEmail, |
| 106 | token:userData.token, | 106 | token:userData.token, |
| 107 | - createTime:userData.createTime | 107 | + createTime:userData.createTime, |
| 108 | + userPhoto:userData.userPhoto | ||
| 108 | } | 109 | } |
| 109 | if(!userData.code){ | 110 | if(!userData.code){ |
| 110 | return userBack; | 111 | return userBack; |
| @@ -47,12 +47,13 @@ router.post('/upLoadDoc',uploaddemo, async (ctx, next) => { | @@ -47,12 +47,13 @@ router.post('/upLoadDoc',uploaddemo, async (ctx, next) => { | ||
| 47 | } | 47 | } |
| 48 | ctx.response.status= 200; | 48 | ctx.response.status= 200; |
| 49 | ctx.body = { | 49 | ctx.body = { |
| 50 | - fileUrl:'http://localhost:10000/'+ctx.req.file.originalname | 50 | + code:200, |
| 51 | + fileUrl:path+ctx.req.file.originalname | ||
| 51 | } | 52 | } |
| 52 | } catch (error) { | 53 | } catch (error) { |
| 53 | console.log(error) | 54 | console.log(error) |
| 54 | ctx.response.status= 400; | 55 | ctx.response.status= 400; |
| 55 | - ctx.body = {msg:error} | 56 | + ctx.body = {code:400,msg:error} |
| 56 | } | 57 | } |
| 57 | 58 | ||
| 58 | }) | 59 | }) |
| @@ -5,6 +5,8 @@ var sequelize = require('../config'); | @@ -5,6 +5,8 @@ var sequelize = require('../config'); | ||
| 5 | var tokenUtil = require('../util/tokenUtil'); | 5 | var tokenUtil = require('../util/tokenUtil'); |
| 6 | var co = require('co'); | 6 | var co = require('co'); |
| 7 | const emailUtil = require('../util/emailUtil') | 7 | const emailUtil = require('../util/emailUtil') |
| 8 | +const attachmentModel =require( '../model/attachmentModel') | ||
| 9 | + | ||
| 8 | 10 | ||
| 9 | 11 | ||
| 10 | function userService(){ | 12 | function userService(){ |
| @@ -45,12 +47,19 @@ userService.prototype.login = async(loginName,pw,userEmail) => { | @@ -45,12 +47,19 @@ userService.prototype.login = async(loginName,pw,userEmail) => { | ||
| 45 | {loginName:loginName} | 47 | {loginName:loginName} |
| 46 | ]; | 48 | ]; |
| 47 | let User = await userModel.find({where:{$or:queryData}}) | 49 | let User = await userModel.find({where:{$or:queryData}}) |
| 50 | + let attachment = await attachmentModel.findOne({where:{businessId:User.id}}) | ||
| 48 | if(!User){ | 51 | if(!User){ |
| 49 | return {code:300,msg:'用户不存在'} | 52 | return {code:300,msg:'用户不存在'} |
| 50 | }else if(User.password != saitMd5.md5(pw)){ | 53 | }else if(User.password != saitMd5.md5(pw)){ |
| 51 | return {code:300,msg:'密码不正确'} | 54 | return {code:300,msg:'密码不正确'} |
| 52 | } | 55 | } |
| 53 | let token = await tokenUtil.getSession(User); | 56 | let token = await tokenUtil.getSession(User); |
| 57 | + if(attachment){ | ||
| 58 | + token.userPhoto = attachment.path | ||
| 59 | + }else{ | ||
| 60 | + token.userPhoto = null | ||
| 61 | + } | ||
| 62 | + console.dir(token) | ||
| 54 | return token | 63 | return token |
| 55 | }catch (err){ | 64 | }catch (err){ |
| 56 | console.log(err) | 65 | console.log(err) |
| @@ -15,7 +15,6 @@ module.exports = new JwtSession() ; | @@ -15,7 +15,6 @@ module.exports = new JwtSession() ; | ||
| 15 | * @param cb | 15 | * @param cb |
| 16 | */ | 16 | */ |
| 17 | JwtSession.prototype.getSession = (users) =>{ | 17 | JwtSession.prototype.getSession = (users) =>{ |
| 18 | - console.log(users) | ||
| 19 | var expiresIn = 60 * 60 * 1000; | 18 | var expiresIn = 60 * 60 * 1000; |
| 20 | var payload = {}; | 19 | var payload = {}; |
| 21 | payload.id = users.id; | 20 | payload.id = users.id; |
| @@ -7,9 +7,8 @@ | @@ -7,9 +7,8 @@ | ||
| 7 | <script src="http://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script> | 7 | <script src="http://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script> |
| 8 | </head> | 8 | </head> |
| 9 | <body> | 9 | <body> |
| 10 | - <form action="/upload/upLoadDoc?businessId=0aJeQOYgLAo5yB1mE14Rvzb69V7mpZKD&category=1" method="post" enctype="multipart/form-data"> | 10 | + <form action="/upload/upLoadDoc?businessId=0aJeQOYgLAo5yB1mE14Rvzb69V7mpZKD&category=1" method="post" enctype="multipart/form-data" target="http://baidu.com"> |
| 11 | <input type="file" name="file"/> | 11 | <input type="file" name="file"/> |
| 12 | - <input type="text" value="1212" name="class" > | ||
| 13 | <input type="submit" value="ok"/> | 12 | <input type="submit" value="ok"/> |
| 14 | </form> | 13 | </form> |
| 15 | <button onclick="window.open('/record')"> asdas </button> | 14 | <button onclick="window.open('/record')"> asdas </button> |
| @@ -17,6 +16,13 @@ | @@ -17,6 +16,13 @@ | ||
| 17 | 16 | ||
| 18 | </body> | 17 | </body> |
| 19 | <script> | 18 | <script> |
| 19 | + function saveReport() { | ||
| 20 | +// jquery 表单提交 | ||
| 21 | +$("#showDataForm").ajaxSubmit(function(message) { | ||
| 22 | + console.log(message) | ||
| 23 | +}); | ||
| 20 | 24 | ||
| 25 | +return false; // 必须返回false,否则表单会自己再做一次提交操作,并且页面跳转 | ||
| 26 | +} | ||
| 21 | </script> | 27 | </script> |
| 22 | </html> | 28 | </html> |
-
请 注册 或 登录 后发表评论