Procházet zdrojové kódy

完善 & bug修复

master
nelson před 3 roky
rodič
revize
c3141f7c72
  1. 10
      controllers/UserController.go
  2. 8
      views/T.header.tpl
  3. 14
      views/T.nav.tpl
  4. 8
      views/blogs.html
  5. 1
      views/index.html
  6. 85
      views/uinfo.html

10
controllers/UserController.go

@ -123,19 +123,9 @@ func (this *UserController) Edit() {
this.ServeJSON()
return
}
birthday := this.GetString("birthday")
if birthday != "" {
birthday += " 00:00:00"
if localTime, errt := time.ParseInLocation("2006-01-02 15:04:05", birthday, time.Local); errt == nil {
user.Birthday = localTime
}
}
user.NickName = this.GetString("nickName")
user.Email = this.GetString("email")
user.Mobile = this.GetString("mobile")
user.QQ = this.GetString("qqnum")
user.Sex, _ = this.GetInt("catory")
user.DescInfo = this.GetString("mdesc")
if _, err := userService.EditUser(user); err != nil {
this.Data["json"] = models.ReurnError(500, "")
} else {

8
views/T.header.tpl

@ -10,12 +10,12 @@
{{end}}
<link type="text/css" rel="styleSheet" href="/static/css/common.css"/>
<script type="text/javascript" src="/static/js/vue.min.js"></script>
<link rel="stylesheet" href="/static/layui/css/layui.css">
<script type="text/javascript" src="/static/layui/layui.js"></script>
<!-- 引入样式 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.3/theme-chalk/index.min.css">
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.3/index.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.4.0/jquery.min.js"></script>
<link rel="stylesheet" href="/static/layui/css/layui.css">
<script type="text/javascript" src="/static/layui/layui.js"></script>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5305532197406602" crossorigin="anonymous"></script>
{{end}}

14
views/T.nav.tpl

@ -21,7 +21,7 @@
{{if .IsLogin }}
<li class="layui-nav-item">
<a href=""><img src="{{.HeadImg}}" class="layui-nav-img"></a>
<dl class="layui-nav-child">
<dl class="layui-nav-child layui-anim layui-anim-upbit">
<dd><a href="/me/info">个人中心</a></dd>
<dd><a href="/note">我的笔记</a></dd>
<dd><a href="/logout">退出登录</a></dd>
@ -36,11 +36,11 @@
</nav>
</div>
<script>
//注意:导航 依赖 element 模块,否则无法进行功能性操作
layui.use('element', function(){
var element = layui.element;
//…
});
$(function () {
//注意:导航 依赖 element 模块,否则无法进行功能性操作
layui.use('element', function(){
var element = layui.element;
});
})
</script>
{{end}}

8
views/blogs.html

@ -9,8 +9,7 @@
<div class="home-hearder">
<div style="flex: 1">
<span>
<el-select v-model="cateId" placeholder="请选择文章分类" @change="catChange">
<el-option value="-1">选择分类</el-option>
<el-select v-model="cateId" placeholder="请选择文章分类" @change="catChange" clearable>
<el-option v-for="item in cats" :key="item.Id" :label="item.Title" :value="item.Id"/>
</el-select>
</span>
@ -95,11 +94,14 @@
el: ".root-container",
delimiters: ['${', '}'],
data: {
cateId: -1,
cateId: '',
cats: []
},
created () {
this.cateId = {{.Cat}}
if(this.cateId == -1){
this.cateId = ''
}
this.cats = {{.Cats}}
},
methods: {

1
views/index.html

@ -53,7 +53,6 @@
delimiters: ['${', '}'],
el: '#vue-app',
data: {
msg: "vue test"
}
})
</script>

85
views/uinfo.html

@ -63,28 +63,35 @@
<hr style="height:1px;border:none;border-top:1px solid #EEE;margin: 10px 0 5px 0;"/>
<div>
<div style="display: flex">
<p style="flex: 1">昵称 :{{.User.NickName}}</p>
<p><a href="javascript:void(0)" style="text-decoration: none" id="editBtn">修改资料</a></p>
<p style="flex: 1">昵称 :${form.nickName}</p>
<p><a href="javascript:void(0)" style="text-decoration: none" @click="dialogFormVisible = true">修改资料</a></p>
</div>
<p>邮箱 :{{.User.Email}}</p>
<p>手机 :{{.User.Mobile}}</p>
<p>简介 :{{.User.DescInfo}}</p>
<p>邮箱 :${form.email}</p>
<p>手机 :${form.mobile}</p>
</div>
</div>
</div>
</div>
</div>
<!-- <el-dialog title="编辑个人信息" :visible.sync="dialogFormVisible">-->
<!-- <el-form :model="form">-->
<!-- <el-form-item label="活动名称" :label-width="150px">-->
<!-- <el-input v-model="form.nickName"></el-input>-->
<!-- </el-form-item>-->
<!-- </el-form>-->
<!-- <div slot="footer" class="dialog-footer">-->
<!-- <el-button @click="dialogFormVisible = false">取 消</el-button>-->
<!-- <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>-->
<!-- </div>-->
<!-- </el-dialog>-->
<el-dialog title="编辑个人信息" :visible.sync="dialogFormVisible" width="500px">
<div>
<el-form :model="form" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="昵称" prop="nickName">
<el-input v-model="form.nickName"></el-input>
</el-form-item>
<el-form-item label="邮箱" prop="email">
<el-input v-model="form.email"></el-input>
</el-form-item>
<el-form-item label="手机号" prop="mobile">
<el-input v-model="form.mobile"></el-input>
</el-form-item>
</el-form>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">取 消</el-button>
<el-button type="primary" @click="saveHandler">确 定</el-button>
</div>
</el-dialog>
</div>
</body>
<script>
@ -98,15 +105,45 @@
nickName: '',
email: '',
mobile: ''
},
rules: {
nickName: [
{required: true, message: '请输入昵称', trigger: 'blur'},
{min: 3, max: 50, message: '长度在 3 到 50 个字符', trigger: 'blur'}
],
email: [
{required: true, message: '请输入邮箱', trigger: 'blur'},
],
mobile: [
{required: true, message: '请输入手机号码', trigger: 'blur'},
]
}
},
created() {
console.log({{.User}})
this.imageUrl = {{.HeadImg}}
this.form.nickName = {{.User.NickName}}
this.form.email = {{.User.Email}}
this.form.mobile = {{.User.Mobile}}
},
methods: {
editBtn(){
saveHandler(){
const _this = this
this.$refs['ruleForm'].validate((valid) => {
if (valid) {
$.post('/api/user/edit', _this.form,
function (data) {
if (data.Status == 0) {
_this.$message.success('修改成功')
_this.dialogFormVisible = false
} else if (data.Status == 401) {
window.location.href = "/login"
} else {
_this.$message.error('服务器异常')
}
}, 'json')
}
})
},
handleAvatarSuccess(res, file){
if(res.Status === 0){
@ -124,17 +161,5 @@
function refresh() {
window.location.href = window.location.href
}
$(function () {
$("#editBtn").click(function () {
layer.open({
type: 2,
title: '修改个人资料',
shadeClose: true,
shade: 0.5,
area: ['450px', '415px'],
content: '/iframe/user.html' //iframe的url
});
})
})
</script>
</html>
Načítá se…
Zrušit
Uložit