@@ -29,7 +29,7 @@ module.exports = function (app) {
29
29
res . json ( { code : 700 , msg :'密码不正确!' } )
30
30
return
31
31
} else {
32
- res . json ( { code : 200 , msg :'密码正确,登录成功' } )
32
+ res . json ( { code : 200 , msg :'密码正确,登录成功' , account : doc . nickName } )
33
33
return
34
34
}
35
35
}
@@ -88,127 +88,39 @@ module.exports = function (app) {
88
88
// 返回注册状态
89
89
// res.send(JSON.stringify({code: 200, data: {account: 'guojcres', pass: 111111}}))
90
90
} )
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
+
91
119
// api index
92
120
app . get ( '/api/goods/index' , function ( req , res ) {
93
121
let temai = [ ] ,
94
122
rexiao = [ ] ,
95
123
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 解决
212
124
// temai
213
125
const getTemai = new Promise ( ( resolve , reject ) => {
214
126
db . goodsModel . find (
0 commit comments