提交 e4729cb0 编写于 作者: yma16's avatar yma16

perf:聊天室获取名称

上级 4bdf506b
...@@ -32,7 +32,6 @@ module.exports = { ...@@ -32,7 +32,6 @@ module.exports = {
"/third-login/": { "/third-login/": {
target: "https://yongma16.xyz/third-login/", //后端接口地址 target: "https://yongma16.xyz/third-login/", //后端接口地址
ws: true, //接受websocket请求
changeOrigin: true, //是否允许跨越 changeOrigin: true, //是否允许跨越
chunkOrigins: true, chunkOrigins: true,
pathRewrite: { pathRewrite: {
......
...@@ -80,18 +80,23 @@ ...@@ -80,18 +80,23 @@
<!-- >&nbsp;&nbsp;在线聊天室</i--> <!-- >&nbsp;&nbsp;在线聊天室</i-->
<!-- >--> <!-- >-->
<div style="float: right; overflow: hidden;display: flex;justify-items: center;align-items:center;word-spacing: 16px;"> <div style="float: right; overflow: hidden;display: flex;justify-items: center;align-items:center;word-spacing: 16px;">
<el-avatar
v-if="currentUserImg"
:src="currentUserImg"
></el-avatar>
<span style="cursor: pointer;padding-right: 50px" v-if="currentUserName"> <span style="cursor: pointer;padding-right: 50px" v-if="currentUserName">
<el-popover <el-popover
trigger="click"> trigger="click">
<div style="display: flex;align-items: center;justify-items: center;justify-content: space-between;font-family: Arial">
<span @click="loginOut" style="cursor: pointer; height: 16px">注销</span> <span @click="loginOut" style="cursor: pointer; height: 16px">注销</span>
</div>
<template slot="reference"> <template slot="reference">
<div style="display: flex;align-items: center;justify-items: center;justify-content: space-between;font-family: Arial">
<el-avatar
v-if="currentUserImg"
@click="loginOut"
:src="currentUserImg"
></el-avatar>
<i style="font-weight: 300" v-if="currentUserImg">{{currentUserName}}</i> <i style="font-weight: 300" v-if="currentUserImg">{{currentUserName}}</i>
<i class="el-icon-user" style="font-weight: 300" v-else>{{currentUserName}}</i> <i class="el-icon-user" style="font-weight: 300" v-else>{{currentUserName}}</i>
</div>
</template> </template>
</el-popover> </el-popover>
......
...@@ -193,14 +193,14 @@ export default { ...@@ -193,14 +193,14 @@ export default {
position: relative; position: relative;
width: 100%; width: 100%;
height: auto; height: auto;
box-sizing: border-box;
background: rgba(187, 168, 164, 0.8); background: rgba(187, 168, 164, 0.8);
} }
.contentClass { .contentClass {
position: relative; position: relative;
width: 100%; width: 100%;
margin: 10px; overflow: auto;
padding: 5px;
} }
.postComment { .postComment {
......
...@@ -293,6 +293,7 @@ export default { ...@@ -293,6 +293,7 @@ export default {
} }
}, },
submitForm (formName) { submitForm (formName) {
localStorage.removeItem('thirdUserInfo')
const that = this // this指向 const that = this // this指向
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
...@@ -337,6 +338,12 @@ export default { ...@@ -337,6 +338,12 @@ export default {
async registerThirdLogin () { async registerThirdLogin () {
const that = this const that = this
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
const loading = that.$loading({
lock: true,
text: '登录中...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
try { try {
const res = await that.$axios const res = await that.$axios
.post(that.baseUrl + 'user/register/', { .post(that.baseUrl + 'user/register/', {
...@@ -357,10 +364,19 @@ export default { ...@@ -357,10 +364,19 @@ export default {
'yma16siteUserInfo', 'yma16siteUserInfo',
JSON.stringify(userInfo) JSON.stringify(userInfo)
) )
localStorage.setItem(
'thirdUserInfo',
JSON.stringify({
qOpenid: that.thirdLoginConfig.qOpenid,
nickName: that.thirdLoginConfig.nickName
})
)
that.$router.push({ path: '/' }) that.$router.push({ path: '/' })
loading.close()
resolve(userInfo) resolve(userInfo)
} catch (e) { } catch (e) {
console.log('注册三方账号失败') console.log('注册三方账号失败')
loading.close()
reject(e) reject(e)
} }
}) })
......
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
</template> </template>
<script> <script>
import store from '@/store'
export default { export default {
name: 'Onlinewebsocket', name: 'Onlinewebsocket',
data () { data () {
...@@ -158,8 +158,19 @@ export default { ...@@ -158,8 +158,19 @@ export default {
mounted () { mounted () {
// 判断是否登录 // 判断是否登录
this.judeIsLogin() this.judeIsLogin()
this.initUserName()
}, },
methods: { methods: {
initUserName () {
const thirdUserInfo = JSON.parse(localStorage.getItem('thirdUserInfo'))
const currentUsername = store.state.user.userInfo && store.state.user.userInfo.thirdUserInfo
? store.state.user.userInfo.thirdUserInfo.nickname : store.state.user.userInfo.name ? store.state.user.userInfo.name : ''
this.user = currentUsername
if (thirdUserInfo && thirdUserInfo.nickName) {
this.user = thirdUserInfo.nickName
}
this.registerUsername()
},
judeIsLogin () { judeIsLogin () {
try { try {
console.log( console.log(
...@@ -407,6 +418,7 @@ export default { ...@@ -407,6 +418,7 @@ export default {
let selectNameDom = document.getElementById('selectNameId') let selectNameDom = document.getElementById('selectNameId')
console.log(selectNameDom) console.log(selectNameDom)
selectNameDom.style.display = 'block' selectNameDom.style.display = 'block'
this.initRoom()
// 触发减一 // 触发减一
} }
}, },
......
...@@ -60,6 +60,7 @@ const importElementComponents = (Vue) => { ...@@ -60,6 +60,7 @@ const importElementComponents = (Vue) => {
Vue.use(Popover) Vue.use(Popover)
Vue.prototype.$message = Message Vue.prototype.$message = Message
Vue.prototype.$notify = Notification Vue.prototype.$notify = Notification
Vue.prototype.$loading = Loading.service
} }
export default importElementComponents export default importElementComponents
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册