Commit 7581526d authored by Hsinli's avatar Hsinli

add mine

parent 574187ef
Pipeline #5935 passed with stage
in 5 seconds
'use strict';
const Controller = require('egg').Controller;
class MineController extends Controller {
/**
* 获取我的信息
*/
async getMineInfo() {
const { ctx } = this;
let ret = await ctx.service.house.mine.getMineInfo();
ctx.success(ret);
}
}
module.exports = MineController;
...@@ -36,5 +36,9 @@ module.exports = app => { ...@@ -36,5 +36,9 @@ module.exports = app => {
//足迹 //足迹
router.get('/foot_print/list', 'house.footPrint.getFootPrintList');//用户浏览记录列表 router.get('/foot_print/list', 'house.footPrint.getFootPrintList');//用户浏览记录列表
//我的
router.get('/mine', 'house.mine.getMineInfo');//获取用户的头像昵称和关注等信息
}; };
...@@ -116,12 +116,11 @@ class CollectionService extends Service { ...@@ -116,12 +116,11 @@ class CollectionService extends Service {
key: "userId", key: "userId",
value: ctx.userId, value: ctx.userId,
operator: "equal" operator: "equal"
}, {
key: "createdAt",
value: endDate,
operator: "greater"
}, },
// {
// key: "createdAt",
// value: endDate,
// operator: "greater"
// },
], ],
orderConditions: [{ orderConditions: [{
key: 'createdAt', key: 'createdAt',
......
'use strict';
const Service = require('egg').Service;
class MineService extends Service {
/**
* 获取我的信息
*/
async getMineInfo() {
const { ctx, service } = this;
let ret = {
user: {
nickname: '',
avatar: '',
phone: ''
},
classification: {
foot_print: {
count: 0,
neme: '浏览足迹'
},
collection: {
count: 0,
neme: '关注的房产'
},
order: {
count: 0,
neme: '预约记录'
},
}
}
if (!ctx.userId) {
return ret;
}
let appUserInfo = await this.getAppUserInfo();
let footPrintList = await service.house.footPrint.getFootPrintList();
let collectionList = await service.house.collection.getCollectionList();
let orderList = await service.house.order.getOrderList();
let phone = appUserInfo.phone || '';
if (phone.length > 0) {
phone = phone.substing(0, 2) + phone.substing(7, 10);
}
ret.user.nickname = appUserInfo.nickname || '';
ret.user.avatar = appUserInfo.avatar || '';
ret.user.avatar = phone;
ret.classification.foot_print.count = footPrintList.count;
ret.classification.collection.count = collectionList.count;
ret.classification.order.count = orderList.count;
return ret;
}
/**
* 获取用户信息
*/
async getAppUserInfo() {
const { ctx } = this;
let appUserId = ctx.appUserId;
const result = await ctx.helper.send_request(this.config.USER_CENTER_API_URI + '/v1/appusers/' + appUserId, {}, { method: 'GET', dataType: 'json' });
const ret = result.status === 200 ? result.data : {};
if (ret.avatar && ret.avatar.indexOf('http') === -1) {
ret.avatar = this.config.AVATAR_URL + ret.avatar;
}
return ret;
}
}
module.exports = MineService;
...@@ -72,12 +72,11 @@ class OrderService extends Service { ...@@ -72,12 +72,11 @@ class OrderService extends Service {
key: "userId", key: "userId",
value: ctx.userId, value: ctx.userId,
operator: "equal" operator: "equal"
}, {
key: "createdAt",
value: endDate,
operator: "greater"
}, },
// {
// key: "createdAt",
// value: endDate,
// operator: "greater"
// },
], ],
orderConditions: [{ orderConditions: [{
key: 'createdAt', key: 'createdAt',
......
...@@ -81,6 +81,9 @@ module.exports = appInfo => { ...@@ -81,6 +81,9 @@ module.exports = appInfo => {
config.HOUSE_SERVICE_API = 'https://dev-nginx.jianbing.com/house-service'; config.HOUSE_SERVICE_API = 'https://dev-nginx.jianbing.com/house-service';
config.CDN_BASE_URL = 'https://r.51gjj.com/image/'; config.CDN_BASE_URL = 'https://r.51gjj.com/image/';
config.USER_CENTER_API_URI = 'https://dev-nginx.jianbing.com/usercenter-service';
return config; return config;
}; };
...@@ -59,6 +59,9 @@ module.exports = appInfo => { ...@@ -59,6 +59,9 @@ module.exports = appInfo => {
config.HOUSE_SERVICE_API = process.env.HOUSE_SERVICE_API; // 房产 config.HOUSE_SERVICE_API = process.env.HOUSE_SERVICE_API; // 房产
config.USER_CENTER_API_URI = process.env.USER_CENTER_API_URI;
return config; return config;
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment