Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
陈轩
8 years ago
Commit
dcfcb8804c1a69ce683fe0bac3365504eab6a2a0
1 parent
1be13752
移动serverAPI里的im 文件
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
136 additions
and
1 deletions
apps/service/controllers/chat.js
apps/service/models/im-api.js
apps/service/controllers/chat.js
View file @
dcfcb88
'use strict'
;
const
orderModel
=
require
(
'../../home/models/order'
);
const
crypto
=
global
.
yoho
.
crypto
;
const
imApi
=
require
(
'../
../serverAPI/im
'
);
const
imApi
=
require
(
'../
models/im-api
'
);
const
userApi
=
require
(
'../../passport/models/auth-helper'
);
const
imModel
=
require
(
'../models/im'
);
const
helpers
=
global
.
yoho
.
helpers
;
...
...
apps/service/models/im-api.js
0 → 100644
View file @
dcfcb88
'use strict'
;
const
_
=
require
(
'lodash'
);
const
crypto
=
global
.
yoho
.
crypto
;
const
config
=
global
.
yoho
.
config
;
const
ImService
=
new
global
.
yoho
.
ApiBase
(
config
.
domains
.
imCs
,
{
name
:
'im'
,
cache
:
global
.
yoho
.
cache
,
useCache
:
false
});
const
encryptedUid
=
uid
=>
crypto
.
encryption
(
null
,
uid
+
''
);
/**
* 新建留言信息
* path: {host}/leavemessage/saveLeavemessage
*
* @param {int} uid 用户id
* @param {int} conversationId 会话id
* @param {str} content 留言内容
*/
exports
.
saveMessage
=
(
uid
,
conversationId
,
content
)
=>
{
let
params
=
{
uid
,
conversationId
,
content
,
encryptedUid
:
encryptedUid
(
uid
)
};
return
ImService
.
post
(
'/api/leavemessage/saveLeavemessage'
,
params
);
};
/**
* 查询用户聊天记录
* @param {int} uid 用户uid
* @param [int] pageSize 每次加载的聊天记录
* @param [int] startTime
* @param [int] endTime
*/
exports
.
fetchImHistory
=
(
uid
,
endTime
,
pageSize
,
startTime
)
=>
{
pageSize
=
pageSize
||
10
;
let
params
=
{
uid
,
pageSize
,
encryptedUid
:
encryptedUid
(
uid
)
};
_
.
forEach
({
startTime
,
endTime
},
(
val
,
key
)
=>
{
val
&&
(
params
[
key
]
=
val
);
});
return
ImService
.
get
(
'/api/conversationMessage/pageList'
,
params
)
.
then
(
result
=>
{
return
result
;
},
()
=>
{
return
{
code
:
500
,
data
:
{
records
:
[],
totalCount
:
0
}
};
});
};
/**
* 获取用户订单, 默认最近10笔
* @param {int} uid 用户uid
* @param {init} createTimeBegin 开始时间
*/
exports
.
fetchOrderList
=
(
uid
,
createTimeBegin
)
=>
{
let
params
=
{
uid
,
encryptedUid
:
encryptedUid
(
uid
),
imgSize
:
'90x120'
,
};
_
.
forEach
({
createTimeBegin
},
(
key
,
val
)
=>
{
val
&&
(
params
[
key
]
=
val
);
});
return
ImService
.
get
(
'/api/order/queryLastTenOrder'
,
params
);
};
/**
*
新建评价信息
### url
```
{host}/evalute/saveEvalute
```
### 请求参数说明
| 名称 | 类型 | 是否必须 | 描述 |
| -------------- | ------ | ---- | --------------- |
| conversationId | long | Y | 会话id |
| uid | int | Y | 用户ID |
|encryptedUid | String |Y |加密的用户标识 |
| promoter | int | Y | 评价发起者 1 用户 2 客服 |
| stars | int | Y | 评分星级 |
| reasonIds | string | N | 固定原因Id用冒号隔开 |
| reasonMsgs | string | N | 固定原因用分号隔开 |
| reasonMsg | string | N | 其他原因 |
*/
exports
.
saveEvalute
=
(
uid
,
conversationId
,
promoter
,
stars
,
reasonMsg
)
=>
{
let
params
=
{
conversationId
,
uid
,
encryptedUid
:
encryptedUid
(
uid
),
promoter
,
stars
,
reasonMsg
};
return
ImService
.
post
(
'/api/evalute/saveEvalute'
,
params
);
};
/**
* 获取全球购的订单
*/
exports
.
queryGlobalOrder
=
uid
=>
{
let
params
=
{
uId
:
uid
};
return
ImService
.
get
(
'/api/order/queryGlobalOrder'
,
params
);
};
...
...
Please
register
or
login
to post a comment