Browse Source

我的页面

富文本skins
old
wangqing 5 years ago
parent
commit
ee92673708
  1. 1
      .eslintignore
  2. 1
      .stylelintignore
  3. 2
      src/components/tinymce/index.vue
  4. 19
      src/router/modules/root.js
  5. 12
      src/store/modules/user.js
  6. 2
      src/views/account/login.vue
  7. 13
      src/views/account/member.vue
  8. 50
      src/views/account/validate.vue
  9. 23
      src/views/home/index.vue
  10. 34
      src/views/redirect.vue

1
.eslintignore

@ -7,3 +7,4 @@ src/utils/sign.js
src/views/form/
src/utils/
src/components/
src/assets/

1
.stylelintignore

@ -6,3 +6,4 @@ src/utils/sign.js
src/views/form/
src/utils/
src/components/
src/assets/

2
src/components/tinymce/index.vue

@ -36,6 +36,8 @@ export default {
selector: `#${this.tinymceId}`,
language: 'zh_CN',
menubar: 'false',
skin_url: '/tinymce/skins/ui/tduck',
content_css : '/tinymce/skins/content/tduck' ,
plugins,
toolbar,
height: 300,

19
src/router/modules/root.js

@ -2,13 +2,18 @@ export default [
{
path: '/test',
meta: {requireLogin: false},
component: () => import(/* webpackChunkName: 'root' */ '@/views/test')
component: () => import(/* webpackChunkName: 'root' */ '@/components/tinymce/example/Index')
},
{
path: '/redirect',
path: '/redirect/:type',
meta: {requireLogin: false},
component: () => import(/* webpackChunkName: 'root' */ '@/views/redirect')
},
{
path: '/account/validate',
meta: {requireLogin: true},
component: () => import(/* webpackChunkName: 'root' */ '@/views/account/validate')
},
{
path: '/',
meta: {requireLogin: false},
@ -25,15 +30,10 @@ export default [
component: () => import(/* webpackChunkName: 'root' */ '@/views/account/login.vue')
},
{
path: '/forget/password',
path: 'forget/password',
meta: {requireLogin: false},
component: () => import(/* webpackChunkName: 'root' */ '@/views/account/ForgetPwd')
},
{
path: '/account/validate',
meta: {requireLogin: true},
component: () => import(/* webpackChunkName: 'root' */ '@/views/account/validate')
},
{
path: '/enterprise',
meta: {requireLogin: false},
@ -50,7 +50,8 @@ export default [
component: () => import(/* webpackChunkName: 'root' */ '@/views/official/proposal')
}
]
}, {
},
{
path: '/home',
meta: {requireLogin: true},
component: () => import(/* webpackChunkName: 'root' */ '@/views/home/index.vue'),

12
src/store/modules/user.js

@ -25,6 +25,16 @@ const actions = {
resolve()
})
},
update(context, payload) {
return new Promise(resolve => {
// 模拟登录成功,写入 token 信息
context.commit('setData', {
token: state.token,
userInfo: payload
})
resolve()
})
},
logout(context) {
context.commit('delData')
}
@ -38,6 +48,8 @@ const mutations = {
state.userInfo = JSON.stringify(data.userInfo)
},
delData() {
state.token = null
state.userInfo = null
localStorage.removeItem('token')
localStorage.removeItem('userInfo')
}

2
src/views/account/login.vue

@ -349,7 +349,7 @@ export default {
},
// qq
getQQLoginAuthorizeUrl() {
let reUrl = getCurrentDomain() + '/redirect'
let reUrl = getCurrentDomain() + '/redirect/qqlogin'
this.$api.get('/login/qq/authorize/url', {params: {redirectUri: reUrl}}).then(res => {
this.qqLoginAuthorizeUrl = res.data
})

13
src/views/account/member.vue

@ -342,7 +342,7 @@ export default {
]
},
bindWxDialogVisible: false,
bindWxQrcode: false,
bindWxQrcode: '',
editNameDialogVisible: false,
pwdDialogVisible: false,
phoneDialogVisible: false,
@ -372,6 +372,9 @@ export default {
this.$api.get('/user/current/detail').then(res => {
if (res.data) {
this.userInfo = res.data
this.$store.dispatch('user/update', this.userInfo).then(() => {
})
}
})
},
@ -409,6 +412,7 @@ export default {
this.$api.get('/user/update-email/msg', {params: {email: this.userInfoForm.email}}).then(res => {
if (res.data) {
this.msgSuccess('发送成功,请去您的邮箱查看')
this.emailDialogVisible = false
}
})
}
@ -437,18 +441,19 @@ export default {
if (res.data) {
this.msgSuccess('保存成功')
this.queryUserInfo()
}
})
},
// qq
getQQLoginAuthorizeUrl() {
let reUrl = getCurrentDomain() + '/redirect'
let reUrl = getCurrentDomain() + '/redirect/bindqq'
this.$api.get('/login/qq/authorize/url', {params: {redirectUri: reUrl}}).then(res => {
this.qqLoginAuthorizeUrl = res.data
})
},
redirectUrl(url) {
location.href = url
window.open(url)
},
updateUserPhoneHandle() {
this.$refs['updatePhoneForm'].validateField(['phoneNumber', 'code'], err => {
@ -468,6 +473,7 @@ export default {
let {wxName} = res.data
if (wxName) {
this.msgSuccess('绑定成功')
clearInterval(this.bindWxTimer)
this.userInfo.wxName = wxName
this.bindWxDialogVisible = false
}
@ -476,7 +482,6 @@ export default {
}, 5 * 1000)
},
cropUploadSuccess(res) {
console.log(res)
this.userInfoForm.avatar = res.data
this.updateUserHandle()
}

50
src/views/account/validate.vue

@ -1,8 +1,16 @@
<template>
<div>
<p v-if="bindEmailErr">
绑定邮箱失败可能是超出绑定时间或者是该邮箱已被绑定等请稍后重试
</p>
<div class="account-validate-container">
<div v-if="bindEmailErr" style="display: flex; flex-direction: column; align-items: center;">
<el-alert
title="绑定失败"
type="error"
:closable="false"
:center="true"
description="绑定邮箱失败,可能是超出绑定时间或者是该邮箱已被绑定等,请稍后重试!"
show-icon
/>
<el-button style="width: 50%;" @click="$router.push({path: '/home'})">返回首页</el-button>
</div>
</div>
</template>
@ -23,8 +31,8 @@ export default {
if (type == 'updateEmail') {
let code = this.$route.query.code
let email = this.$route.query.email
this.$api.post('/update/email', {email: email, key: code}).then(res => {
if (res.data) {
this.$api.post('/user/update/email', {email: email, key: code}).then(res => {
if (!res.data) {
this.bindEmailErr = true
}
})
@ -34,3 +42,33 @@ export default {
}
</script>
<style scoped>
.account-validate-container {
width: 100%;
height: 100%;
display: flex;
align-content: center;
justify-content: center;
justify-items: center;
align-items: center;
}
.el-alert--error.is-light {
background-color: transparent;
}
.el-alert {
display: flex;
flex-direction: column;
}
/deep/ .el-alert__content {
margin-top: 20px;
text-align: center;
}
/deep/ .el-alert__title {
font-size: 18px;
line-height: 25px;
}
/deep/ .el-alert__icon.is-big {
font-size: 60px;
width: 60px;
}
</style>

23
src/views/home/index.vue

@ -110,9 +110,6 @@ export default {
},
getUserInfo() {
let user = JSON.parse(this.getStore.getters['user/userInfo'])
if (!user) {
this.logoutHandle()
}
return user
}
},
@ -129,13 +126,21 @@ export default {
this.menuIndex = routerPath
},
logoutHandle() {
this.$store.dispatch('user/logout').then(() => {
router.push({
path: '/login',
query: {
redirect: router.currentRoute.fullPath
}
this.$confirm('您确定要退出登录吗?', '退出确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$store.dispatch('user/logout').then(() => {
router.push({
path: '/login',
query: {
redirect: router.currentRoute.fullPath
}
})
})
}).catch(() => {
})
}
}

34
src/views/redirect.vue

@ -11,11 +11,39 @@ export default {
return {}
},
created() {
//
let type = this.$route.params.type
// eslint-disable-next-line no-debugger
debugger
if (type == 'qqlogin') {
this.qqLoginHandle()
} else if (type == 'bindqq') {
this.bindQqHandle()
}
},
methods: {
bindQqHandle() {
let code = getQueryString('code')
let state = getQueryString('state')
if (code && state) {
let reUrl = getCurrentDomain() + '/redirect/bindqq'
this.$api.post('/user/bind/qq', {authorizeCode: code, redirectUri: reUrl}).then(res => {
if (res.data) {
this.msgSuccess('绑定成功')
window.close()
} else {
this.msgError('绑定失败,该qq已经绑定其他账号')
}
})
}
}
},
qqLoginHandle() {
// qq
let code = getQueryString('code')
let state = getQueryString('state')
if (code && state) {
let reUrl = getCurrentDomain() + '/redirect'
let reUrl = getCurrentDomain() + '/redirect/qqlogin'
this.$api.post('/login/qq', {authorizeCode: code, redirectUri: reUrl}).then(res => {
if (res.data) {
this.msgSuccess('登录成功')
@ -39,8 +67,6 @@ export default {
}
})
}
},
methods: {}
}
}
</script>

Loading…
Cancel
Save