Skip to content

Commit ed211f3

Browse files
committed
center.vue
1 parent f3fa370 commit ed211f3

File tree

4 files changed

+133
-117
lines changed

4 files changed

+133
-117
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<template>
2+
<div class="c-center">
3+
<ul>
4+
<li class="group-li">
5+
<a href="javascript:;" class="group-a">
6+
<img class="pic" src="http://img01.rastargame.com/p_upload/2017/0605/1496634201481713.png"/>
7+
<span class="name">colleague</span>
8+
</a>
9+
</li>
10+
<li class="group-li">
11+
<a href="javascript:;" class="group-a">
12+
<img class="pic" src="http://img01.rastargame.com/p_upload/2017/0605/1496634201481713.png"/>
13+
<span class="name">classmate</span>
14+
</a>
15+
</li>
16+
</ul>
17+
</div>
18+
</template>
19+
20+
<script>
21+
import './../../public/css/base.scss'
22+
// import Vue from 'vue'
23+
// import VueRouter from 'vue-router'
24+
// Vue.use(VueRouter)
25+
// const router = new VueRouter()
26+
export default {
27+
data () {
28+
return {
29+
showLogin: true,
30+
time: null // Date.parse(new Date())
31+
}
32+
},
33+
created () {
34+
// window.localStorage.setItem(name, JSON.stringify(obj))
35+
// JSON.parse(window.localStorage.getItem(name))
36+
},
37+
methods: {
38+
changeShow () {
39+
this.showLogin = !this.showLogin
40+
console.log(this.showLogin)
41+
},
42+
getAccountGroup () {
43+
let chatState = this.$store.getters.getChatState
44+
this.$http({
45+
url: '/api/user/getAccountGroup',
46+
method: 'GET',
47+
params: {
48+
account: chatState.account
49+
}
50+
})
51+
.then((res) => {
52+
let data = res.data
53+
console.log(data)
54+
if (data.code === 200) {
55+
// 更新我加入的群
56+
57+
} else {
58+
// 提示获取失败
59+
}
60+
})
61+
}
62+
}
63+
}
64+
</script>
65+
66+
<style lang="scss" scope>
67+
.c-center{
68+
position: relative;
69+
box-sizing: border-box;
70+
max-width:600px;
71+
height: 100%;
72+
overflow: auto;
73+
margin: 0 auto;
74+
border: 1px solid #E6E6E6;
75+
}
76+
.group-li{
77+
.group-a{
78+
display: block;
79+
padding: 5px 10px;
80+
overflow: hidden;
81+
background: #dbeef7;
82+
border-bottom: 1px solid #d8d8d8;
83+
.pic{
84+
float: left;
85+
width: 50px;
86+
height: 50px;
87+
margin-right: 8px;
88+
border-radius: 50px;
89+
}
90+
.name{
91+
display: inline-block;
92+
height: 50px;
93+
line-height: 50px;
94+
font-size: 18px;
95+
}
96+
}
97+
}
98+
</style>

client/src/components/page/login.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
let data = res.data
7373
console.log(data)
7474
if (data.code === 200) {
75+
// 更新登录的状态vuex
76+
this.$store.dispatch('updateChatState', {account: parseInt(this.loginAccount), nickName: data.account})
7577
// 登录成功,跳转路由
7678
console.log(data.msg)
7779
this.waringText = ''
@@ -110,6 +112,8 @@
110112
let data = res.data
111113
console.log(data)
112114
if (data.code === 200) {
115+
// 更新登录的状态vuex
116+
this.$store.dispatch('updateChatState', {account: parseInt(this.registerAccount), nickName: this.registerNickName})
113117
// 注册成功,跳转路由
114118
console.log(data.msg)
115119
this.waringText = ''

client/src/router/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Vue from 'vue'
22
import Router from 'vue-router'
33
import Hello from '@/components/Hello'
44
import Login from '@/components/page/login'
5+
import Center from '@/components/page/center'
56
import ChatGroup from '@/components/page/chatGroup'
67

78
Vue.use(Router)
@@ -11,6 +12,7 @@ export default new Router({
1112
// {path: '/', name: 'Hello', component: Hello},
1213
{path: '/', redirect: '/login', name: 'Hello', component: Hello},
1314
{path: '/login', name: 'Login', component: Login},
15+
{path: '/center', name: 'Center', component: Center},
1416
{path: '/chatGroup', name: 'ChatGroup', component: ChatGroup}
1517
]
1618
})

server/api.js

Lines changed: 29 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = function (app) {
2929
res.json({code: 700, msg:'密码不正确!'})
3030
return
3131
} else {
32-
res.json({code: 200, msg:'密码正确,登录成功'})
32+
res.json({code: 200, msg:'密码正确,登录成功', account: doc.nickName})
3333
return
3434
}
3535
}
@@ -88,127 +88,39 @@ module.exports = function (app) {
8888
// 返回注册状态
8989
// res.send(JSON.stringify({code: 200, data: {account: 'guojcres', pass: 111111}}))
9090
})
91+
//
92+
app.get('/api/user/getAccountGroup', function (req, res) {
93+
// 对发来的注册数据进行验证
94+
let account = req.query.account
95+
if (!account) {
96+
res.json({code: 600, msg:'account 不能为空!'})
97+
return
98+
}
99+
let accountGroups = {}
100+
// 查询数据库,账号所在群组
101+
db.relationModel.find(
102+
{groupNumber: account},
103+
{groupAccount:1, groupNickName:1, _id:0},
104+
function(err, doc){
105+
if (err) {
106+
console.log('temai find error!')
107+
reject('reject temai')
108+
} else {
109+
if (!doc) {
110+
accountGroups = [];
111+
} else {
112+
accountGroups = doc;
113+
}
114+
resolve(accountGroups)
115+
}
116+
})
117+
})
118+
91119
// api index
92120
app.get('/api/goods/index', function (req, res) {
93121
let temai = [],
94122
rexiao = [],
95123
jingpin = [];
96-
// // 1.temai
97-
// db.goodsModel.find(
98-
// {brand_status: "temai"},
99-
// {brand_id:1, brand_name:1, brand_price:1, brand_pic:1, _id:0},
100-
// {limit: 3},
101-
// function(err, doc){
102-
// if (err) {
103-
// console.log('temai find error!');
104-
// } else {
105-
// if (!doc) {
106-
// temai = [];
107-
// } else {
108-
// temai = doc;
109-
// }
110-
// }
111-
// })
112-
// // 2.rexiao
113-
// db.goodsModel.find(
114-
// {brand_status: "rexiao"},
115-
// {brand_id:1, brand_name:1, brand_desc:1, brand_pic:1, _id:0},
116-
// {limit: 3},
117-
// function(err, doc){
118-
// if (err) {
119-
// console.log('rexiao find error!');
120-
// } else {
121-
// if (!doc) {
122-
// rexiao = [];
123-
// } else {
124-
// rexiao = doc;
125-
// }
126-
// }
127-
// })
128-
// // 3.jingpin
129-
// db.goodsModel.find(
130-
// {brand_status: "jingpin"},
131-
// {brand_id:1, brand_name:1, brand_price:1, brand_pic:1, _id:0},
132-
// {limit: 4},
133-
// function(err, doc){
134-
// if (err) {
135-
// console.log('jingpin find error!');
136-
// } else {
137-
// if (!doc) {
138-
// jingpin = [];
139-
// } else {
140-
// jingpin = doc;
141-
// // res
142-
// res.json({code: 200, msg:'', data: {"temai": temai, "rexiao": rexiao, "jingpin": jingpin}})
143-
// return
144-
// }
145-
// }
146-
// })
147-
148-
// 异步操作,未解决
149-
// 1.temai
150-
// db.goodsModel.find(
151-
// {brand_status: "temai"},
152-
// {brand_id:1, brand_name:1, brand_price:1, brand_pic:1, _id:0},
153-
// {limit: 3},
154-
// function(err, doc){
155-
// if (err) {
156-
// console.log('temai find error!');
157-
// } else {
158-
// if (!doc) {
159-
// temai = [];
160-
// } else {
161-
// temai = doc;
162-
// }
163-
// }
164-
// })
165-
// .then( () => {
166-
// // 2.rexiao
167-
// db.goodsModel.find(
168-
// {brand_status: "rexiao"},
169-
// {brand_id:1, brand_name:1, brand_desc:1, brand_pic:1, _id:0},
170-
// {limit: 3},
171-
// function(err, doc){
172-
// if (err) {
173-
// console.log('rexiao find error!');
174-
// } else {
175-
// if (!doc) {
176-
// rexiao = [];
177-
// } else {
178-
// rexiao = doc;
179-
// }
180-
// }
181-
// })
182-
// .then( () => {
183-
// // 3.jingpin
184-
// db.goodsModel.find(
185-
// {brand_status: "jingpin"},
186-
// {brand_id:1, brand_name:1, brand_price:1, brand_pic:1, _id:0},
187-
// {limit: 4},
188-
// function(err, doc){
189-
// if (err) {
190-
// console.log('jingpin find error!');
191-
// } else {
192-
// if (!doc) {
193-
// jingpin = [];
194-
// } else {
195-
// jingpin = doc;
196-
// }
197-
// }
198-
// })
199-
// .then( () => {
200-
// // res
201-
// res.json({code: 200, msg:'', data: {"temai": temai, "rexiao": rexiao, "jingpin": jingpin}})
202-
// return
203-
// })
204-
// })
205-
// })
206-
// .catch( (err) => {
207-
// res.json({code: 200, msg:'', data: {"temai": temai, "rexiao": rexiao, "jingpin": jingpin}})
208-
// return
209-
// })
210-
211-
// promise 解决
212124
// temai
213125
const getTemai = new Promise((resolve,reject) => {
214126
db.goodsModel.find(

0 commit comments

Comments
 (0)