会员中心

main
tamguo 7 years ago
parent 501330a1f6
commit 7c5fbededd

@ -1,16 +1,123 @@
package com.tamguo.web;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import com.tamguo.common.utils.DateUtils;
import com.tamguo.common.utils.Result;
import com.tamguo.common.utils.Status;
import com.tamguo.common.utils.UploaderMessage;
import com.tamguo.config.redis.CacheService;
import com.tamguo.modules.member.service.IMemberService;
import com.tamguo.utils.ShiroUtils;
@Controller
public class AccountController {
@Value("${file.storage.path}")
String fileStoragePath;
@Value("${tamguo.domain.name}")
String tamguoDomainName;
@Autowired
IMemberService iMemberService;
@Autowired
CacheService cacheService;
private static final String AVATOR_NO_FORMAT = "00000";
private static final String AVATOR_PREFIX = "MTX";
@RequestMapping(value = {"account.html"}, method = RequestMethod.GET)
public ModelAndView list(ModelAndView model) {
model.setViewName("account");
model.addObject("member", iMemberService.findByUid(ShiroUtils.getMemberId()));
return model;
}
@RequestMapping(value = {"getCurrentMember"}, method = RequestMethod.GET)
@ResponseBody
public Result getCurrentMember() {
return Result.result(0, iMemberService.findByUid(ShiroUtils.getMemberId()), "success");
}
@RequestMapping(value = "uploadFile", method = RequestMethod.POST)
@ResponseBody
public UploaderMessage uploadFileHandler(@RequestParam("file") MultipartFile file,HttpServletRequest request) throws IOException {
if (!file.isEmpty()) {
InputStream in = null;
OutputStream out = null;
try {
String path = fileStoragePath + DateUtils.format(new Date(), "yyyyMMdd");
File dir = new File(path);
if (!dir.exists())
dir.mkdirs();
String avatorName = this.getAvatorNo() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
in = file.getInputStream();
out = new FileOutputStream(path + "/" + avatorName);
byte[] b = new byte[1024];
int len = 0;
while ((len = in.read(b)) > 0) {
out.write(b, 0, len);
}
out.close();
in.close();
UploaderMessage msg = new UploaderMessage();
msg.setStatus(Status.SUCCESS);
msg.setStatusMsg("File upload success");
msg.setFilePath("files/" + DateUtils.format(new Date(), "yyyyMMdd") + "/" + avatorName);
msg.setFileDomain(tamguoDomainName);
return msg;
} catch (Exception e) {
UploaderMessage msg = new UploaderMessage();
msg.setStatus(Status.ERROR);
msg.setError("File upload file");
return msg;
} finally {
if (out != null) {
out.close();
out = null;
}
if (in != null) {
in.close();
in = null;
}
}
} else {
UploaderMessage msg = new UploaderMessage();
msg.setStatus(Status.ERROR);
msg.setError("File is empty");
return msg;
}
}
private String getAvatorNo() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
String format = sdf.format(new Date());
DecimalFormat df = new DecimalFormat(AVATOR_NO_FORMAT);
String key = AVATOR_PREFIX + format;
Long incr = cacheService.incr(key);
String avatorNo = AVATOR_PREFIX + df.format(incr);
return avatorNo;
}
}

@ -14,14 +14,14 @@ spring.datasource.maxPoolPreparedStatementPerConnectionSize=20
spring.datasource.maxWait=60000
spring.datasource.minEvictableIdleTimeMillis=300000
spring.datasource.minIdle=5
spring.datasource.password=tanguo520pig
spring.datasource.password=123456
spring.datasource.poolPreparedStatements=true
spring.datasource.testOnBorrow=false
spring.datasource.testOnReturn=false
spring.datasource.testWhileIdle=true
spring.datasource.timeBetweenEvictionRunsMillis=60000
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/tamguo?useUnicode=true&characterEncoding=UTF-8&useSSL=false
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/tamguo_20181110?useUnicode=true&characterEncoding=UTF-8&useSSL=false
spring.datasource.username=root
spring.datasource.validationQuery=SELECT 1 FROM DUAL

@ -1,23 +1,137 @@
@charset "utf-8";
body { font-family: "Microsoft Yahei"; color: #333;background:#f5f5f6}
em, i { font-style: normal; }
.start{color: red}
.hide-text{ overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
.well{height: 10px;background: #f5f5f6;width: 340px;position: relative;left: -10px;}
.cnav { height: 98px; width: 100%; background: url(../../images/project-cnavbj.jpg) no-repeat; background-size: cover; }
.cnav_b { position: relative; }
.cnav_left { float: left; width: 162px; height: 54px; margin: 22px 0 0 46px; font-size: 18px; color: #fff; line-height: 54px; background: url(../../images/test-paper/top-kaos.png) no-repeat; padding-left: 55px; }
.cnav_right { float: left; width:728px; height: 5px; background: url(../../images/project-cnav.png) repeat-x; margin: 47px 0 0 0; }
.cnav_right ul { position: absolute; top: 30px; left: 230px; }
.cnav_right ul li { width: 120px; height: 50px; float: left; font-size: 14px; color: #fff; text-align: center; line-height: 12px; margin-left: 32px; }
.cnav_right ul li span { font-size: 12px; font-weight: bold; width: 27px; height: 27px; color: #29bdb9; display: block; margin: 5px auto 5px auto; text-align: center; line-height: 27px; background: url(../../images/project-candidate.png) no-repeat -26px 0; }
.cnavX { background: url(../../images/project-candidate.png) no-repeat -61px -39px; width: 17px; height: 17px; position: absolute; top: 12px; left: 1082px; cursor: pointer; }
.cnav_right ul li .Cnav_t { background: url(../../images/project-candidate.png) no-repeat -54px 0; width: 37px; height: 37px; line-height: 37px; margin: 0 auto; }
.contentBox{margin-top: 20px;font-size: 14px;overflow: hidden;}
.contentBox {
margin-top: 20px;
font-size: 14px;
overflow: hidden;
}
.infoCnt-box {
padding: 0px;
}
.cnt-box {
background: #FFFFFF;
padding: 10px;
}
.public {
width: 1098px;
margin: 0px auto;
}
.info-cnt {
padding-top: 0px;
padding-bottom: 0px;
}
.contentBox .navLeft {
float: left;
display: inline-block;
width: 16.4%;
background: rgb(41,186,185);
}
.contentBox .navLeft dl dt {
height: 40px;
line-height: 40px;
background: rgb(37,172,169);
padding-left: 10px;
font-size: 14px;
color: white;
cursor: pointer;
}
.icon-w {
float: right;
position: relative;
top: 50%;
transform: translateY(-50%);
margin-right: 10px;
}
.fa {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.fa-minus:before {
content: "\f068";
}
.contentBox .navLeft dl dd {
text-align: center;
color: white;
height: 40px;
line-height: 40px;
cursor: pointer;
}
.navLeft dl dd i {
width: 17px;
height: 14px;
display: inline-block;
background: url(../../images/member/account/icon-erro.png) no-repeat;
margin: 0px 4px;
position: relative;
top: 1px;
margin-left: 0px;
}
.contentBox .navLeft dl dd {
text-align: center;
color: white;
height: 40px;
line-height: 40px;
cursor: pointer;
}
.contentBox .newsRight {
float: left;
display: inline-block;
width: 83%;
background: white;
min-height: 279px;
}
.info-rBox {
padding-left: 76px;
}
.info-rBox {
padding-bottom: 40px!important;
}
.info-rBox {
padding-left: 80px;
position: relative;
}
.user_list {
padding: 0px;
}
.user_list {
padding: 20px 0px;
vertical-align: top;
width: 550px;
}
.info-table {
width: 100%;
margin-top: 28px;
font-size: 14px;
}
.info-table tr td {
padding-bottom: 20px;
}
.info-label {
position: relative;
}
.info-label span {
position: absolute;
left: -15px;
top: 0px;
color: #ff5a00;
}
* {
box-sizing: border-box;
}
.cvcadd-text {
height: 40px;
border: 1px solid #d4d7db;
font-size: 14px;
padding: 0px 12px;
width: 311px;
}
.acphoto {
display: inline-block;
position: relative;
/*padding: 0 2em;*/
/* padding: 0 2em; */
border: none;
border-radius: 80px;
height: 80px;
@ -30,11 +144,16 @@ em, i { font-style: normal; }
cursor: pointer;
float: left;
}
.up_photo{
.mybtn {
float: left;
margin-left: 10px;
padding-top: 10px;
}
.up_photo {
display: inline-block;
position: relative;
padding: 0 2em;
/*border: none;*/
/* border: none; */
border: 1px solid #29bdb9;
border-radius: 0px;
background: #29bdb9;
@ -45,62 +164,35 @@ em, i { font-style: normal; }
cursor: pointer;
margin-top: 15px;
}
.mybtn{
float: left;
margin-left: 10px;
padding-top: 10px;
}
.contentBox{margin-top: 20px;font-size: 14px;overflow: hidden;}
.contentBox .navLeft{float: left;display: inline-block;width: 16.4%;background:rgb(41,186,185);}
.contentBox .navLeft dl{}
.contentBox .navLeft dl dt{height: 40px;line-height: 40px;background:rgb(37,172,169);padding-left: 10px;font-size: 14px;color:white;cursor: pointer; }
.icon-w{float: right;position: relative;top: 50%;transform: translateY(-50%);margin-right: 10px;}
.icon-f{margin-right: 10px;}
.contentBox .navLeft dl dd{text-align: center;;color: white;height: 40px;line-height: 40px;cursor: pointer; }
.contentBox .navLeft dl dd a{color: white}
.contentBox .newsRight{float: left;display: inline-block;width:83%;background:white;min-height: 279px;}
.user_list{padding: 0px;}
.info-cnt{padding-top:0px;background: #f5f5f6; }
.photoBox{display: none;}
.navLeft dl dd i {width: 17px;height: 14px;display: inline-block;background: url(../../images/icon-erro.png) no-repeat;margin: 0px 4px;position: relative;top: 1px;margin-left: 0px;
}
.icon-h {
font-size: 14px;
.up_photo {
display: inline-block;
position: relative;
margin-right: 10px;
padding: 0 2em;
/* border: none; */
border: 1px solid #29bdb9;
border-radius: 0px;
background: #29bdb9;
color: #fff;
font-size: 14px;
line-height: 28px;
text-decoration: none;
cursor: pointer;
margin-top: 15px;
}
.acm-container{/*position: relative;top: -20px;*/padding-bottom: 200px;}
.info-cnt {
padding-top:0px;
padding-bottom:0px;
}
.footer{margin-top: 0px!important;}
.headlogotable{float: right;}
.info-rBox{padding-bottom: 40px!important;}
.navLeft .list a dd:hover{background:#52cdc8}
.contentBox .navLeft dl dt:hover{background:#52cdc8 }
.head .logo {
padding-top: 0px;
float: left;
display: -webkit-box;
line-height: 59px;
a.btn_ok {
display: inline-block;
position: relative;
padding: 0 2em;
border: none;
border-radius: 0px;
background: #29bdb9;
color: #fff;
font-size: 14px;
line-height: 28px;
text-decoration: none;
cursor: pointer;
}
.head .logo a{
max-width: 120px;
height: 55px;
line-height: 55px;
text-align: center;
display: block;
}
.head .logo img{
float: none;
max-width: 100%;
max-height: 100%
}
.head .logo p {
float: none;
line-height: 59px;
padding-left: 12px;
}
.weixinPng:hover img:nth-child(2){display: block}
.head .nav li:hover {
border-bottom: 2px solid #29bdb9;
font-weight: bold;
}

@ -0,0 +1,68 @@
var vm = new Vue({
el:'#app',
data() {
return {
loading:false,
courses:[],
member:{
name:null
},
rules: {
username: [
{ required: true, message: '请输入用户名', trigger: 'blur' }
],
nickName: [
{ required: true, message: '请输入用户名', trigger: 'blur' }
]
}
};
},
methods: {
handleAvatarSuccess(res, file) {
vm.member.avatar = res.filePath;
vm.member.imageUrl = res.fileDomain + res.filePath;
},
beforeAvatarUpload(file) {
const isJPG = file.type === 'image/jpeg';
const isLt2M = file.size / 1024 / 1024 < 2;
if (!isJPG) {
this.$message.error('上传头像图片只能是 JPG 格式!');
}
if (!isLt2M) {
this.$message.error('上传头像图片大小不能超过 2MB!');
}
return isJPG && isLt2M;
},
onSubmit:function(){
loading = true;
this.$refs['member'].validate((valid) => {
if (valid) {
axios({method: 'post',url: mainHttp + 'account/update.html',data: vm.member}).then(function(response){
if(response.data.code == 0){
vm.loading = false;
vm.$message({message: "修改成功",duration:500,type: 'success',onClose:function(){
window.location.reload();
}});
}else{
vm.loading = false;
vm.$message.error(response.data.message);
vm.$refs['member'].validate();
}
});
} else {
console.log('error submit!!');
return false;
}
});
},
getMember:function(){
axios.get(mainHttp + 'getCurrentMember').then(function(response){
vm.member = response.data.result;
console.log(vm.member.avatar);
vm.member.imageUrl = mainHttp + vm.member.avatar;
});
}
}
});
vm.getMember();

@ -4,6 +4,7 @@
<meta charset="UTF-8">
<title>个人信息 - 探果网</title>
<link rel="stylesheet" th:href="${domainName + 'static/css/reset.css' }" />
<link rel="stylesheet" th:href="${domainName + 'static/css/member/account.css' }" />
<link rel="stylesheet" th:href="${domainName + 'static/css/member/booklist.css' }" />
<link rel="stylesheet" th:href="${domainName + 'static/css/member/memberMain.css'}" />
<link rel="stylesheet" th:href="${domainName + 'static/css/amazeui/css/amazeui.css'}">
@ -79,8 +80,55 @@
</div>
</div>
<div id="container" class="plist test_public prof_t ng-scope">
<div class="acm-container">
<div class="cnt-box public infoCnt-box contentBox ">
<div class="info-cnt">
<div class="navLeft">
<dl>
<dt class="down">
<img th:src="${domainName + 'static/images/member/index/person.png'}" style="width: 14px;
margin-right: 6px;margin-top: -5px;"> 个人信息 <i class="fa fa-minus icon-w"></i>
</dt>
<div class="list" style="display: block;">
<a th:href="${domainName + 'account.html'}"><dd class="activeDd"><i></i>基本信息</dd></a>
<!-- <dd>绑定账号</dd> -->
<a th:href="${domainName + 'account.html'}"><dd><i></i>修改密码</dd></a>
</div>
</dl>
</div>
<div class="info-right newsRight" id="app">
<div class="info-rBox" style="padding-bottom: 20px;">
<div class=" user_list clearfix">
<el-form ref="member" :rules="rules" :model="member" label-width="80px">
<el-form-item label="用户头像">
<el-upload
class="avatar-uploader"
action="uploadFile"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload">
<img v-if="member.avatar" :src="member.imageUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
</el-form-item>
<el-form-item label="用户名" prop="username">
<el-input v-model="member.username" th:value="${member.username}" :disabled="true"></el-input>
</el-form-item>
<el-form-item label="昵称" prop="nickName">
<el-input v-model="member.nickName" th:value="${member.nickName}"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">立即修改</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
<div class="clear"></div>
</div>
</div>
<!--content end-->
</div>
<!-- 尾部-->
<div th:replace="include/footer :: footer"></div>
@ -94,4 +142,5 @@
var mainHttp = [[${domainName}]];
var bookDomainName = [[${bookDomainName}]];
</script>
<script type="text/javascript" th:src="${domainName + 'static/js/member/account.js'}"></script>
</html>
Loading…
Cancel
Save