2.润工作相关API
- 目录
- 文件引用
- 2.1 页面跳转
- 2.2 用户信息
- 2.3 获取润工作应用信息【iOS】【Android】
- 2.4 通用移动平台网络请求API【iOS】【Android】
- 2.5 通用分享API【iOS】【Android】
- 2.6 下载文档相关API
- 2.7 IM
- 2.8 选取器
- 2.9 保存电话到系统通讯录 【iOS】【Android】
- 2.10 审批中心待办处理完成后发送通知【iOS】【Android】
文件引用:
-
在入口文件中的head中引入js文件
run.work.jssdk.bundle.min.js
-
注:在引入js文件后需要调用
crhReady()
方法进行初始化
2.1 页面跳转
2.1.1 退出轻应用返回原生应用【iOS】【Android】
crh.closeWebApp()
JSBridgeHook:crh_common_go_back
退出轻应用返回原生应用
示例代码:
crh.closeWebApp();
2.1.2 跳转至润工作首页【iOS】【Android】
crh.gotoMangoHome()
JSBridgeHook:crh_common_go_home
切到润工作首页
示例代码:
crh.gotoMangoHome();
2.1.3 跳转至意见反馈页面【iOS】【Android】
crh.openFeedbackPage()
JSBridgeHook:crh_common_go_2_feedback
打开意见反馈页面
示例代码:
crh.openFeedbackPage();
2.1.4 跳转至通讯录页面【iOS】【Android】
crh.gotoAddressbook()
JSBridgeHook:crh_common_go_addressbook
跳转到润工作通讯录页面
示例代码:
crh.gotoAddressbook();
2.1.5 打开外部原生应用【iOS】【Android】
crh.openNativeApp(OBJECT)
JSBridgeHook:crh_common_open_native_app
打开外部原生应用
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
action_url | String | 是 | 区分平台 调起应用协议 |
download_url | String | 是 | 区分平台 下载地址 |
success | Function | 否 | 接口调用成功的回调函数 |
fail | Function | 否 | 接口调用失败的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
示例代码:
crh.openNativeApp({
param:{
action_url:"weixin://",
download_url:"https://appstore.applel.com?xxx"
}
});
2.2 用户信息
2.2.1 获取当前用户信息【iOS】【Android】
crh.getCurrentUserInfo(OBJECT)
JSBridgeHook:crh_common_get_current_user_info
获取当前用户信息
OBJECT参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
success | Function | 是 | 接口调用成功的回调函数 |
fail | Function | 否 | 接口调用失败的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
success返回参数说明:
参数 | 类型 | 说明 |
---|---|---|
userId | String | 用户ID |
userToken | String | 用户Token |
hrInfo | Object | HR数据 |
hrInfo参数说明:
参数 | 类型 | 说明 |
---|---|---|
userId | String | 用户ID |
userToken | String | 用户Token |
hrInfo | Object | HR数据 |
示例代码:
crh.getCurrentUserInfo({
success: function(res){
console.log(res.userId);
}
})
2.2.2 获取IM用户基本信息(组织架构)【iOS】【Android】
crh.getIMUserInfo(OBJECT)
JSBridgeHook:crh_common_get_im_user_info
获取IM用户基本信息,现在IM去的就是组织架构的信息。
OBJECT参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
userId | String | 是 | 需要查询的用户ID |
success | Function | 是 | 接口调用成功的回调函数 |
fail | Function | 否 | 接口调用失败的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
success返回参数说明:
参数 | 类型 | 说明 |
---|---|---|
userId | String | 用户ID |
userInfo | OBJECT | 组织架构返回的信息 |
示例代码:
crh.getIMUserInfo({
param:{
userId:"cyd"
},
success: function(res){
console.log(res.userId);
console.log(res.userInfo);
}
})
2.3 获取润工作应用信息【iOS】【Android】
crh.getAppInfo(OBJECT)
JSBridgeHook:crh_common_get_app_info
润工作应用信息
OBJECT参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
success | Function | 是 | 接口调用成功的回调函数 |
fail | Function | 否 | 接口调用失败的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
success返回参数说明:
参数 | 类型 | 说明 |
---|---|---|
appCode | String | App代号 002601 |
environment | String | 运行后台环境 0:SIT/1:UAT/2:RELEASE |
示例代码:
crh.getAppInfo({
success: function(res){
console.log(res.appCode);
console.log(res.environment);
}
})
2.4 通用移动平台网络请求API【iOS】【Android】
crh.postRequestToEMAP(OBJECT)
JSBridgeHook:crh_common_post_emap_request
通用移动平台网络请求
OBJECT参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
apicode | String | 是 | 需要调用的接口代号 |
apitoken | String | 是 | 需要调用的接口Token |
reqdata | String | 是 | 请求的业务报文,一般是jsonBase64后的字符串 |
success | Function | 是 | 接口调用成功的回调函数 |
fail | Function | 否 | 接口调用失败的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
success返回参数说明: 取决于业务方数据结构
示例代码:
crh.postRequestToEMAP({
param:{
apicode:"M0029000020",
apitoken:"24666195faafe4228c2888d38b121b81",
reqdata:"eyJhcHBUeXBlIjoiMSIsImFwcFZlcnNpb24iOiIwLjAuMTgyIiwicGFja2FnZU5hbWUiOiJjbi5jb20uY3JjLm1hbmdvU0lUIn0="
},
success: function(res){
console.log(res);
}
})
2.5 通用分享API【iOS】【Android】
crh.shareContent(OBJECT)
JSBridgeHook:crh_common_share_content
通用分享
OBJECT参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
shareType | INT | 是 | 分享范围 1:支持应用内分享、 2:支持应用外分享、 3:支持应用内外分享 |
title | String | 是 | 分享标题 |
link | String | 是 | 分享的目标链接 |
imageUrl | String | 是 | 分享的图片URL |
desc | String | 是 | 分享的内容摘要 |
示例代码:
crh.shareContent({
param:{
shareType:3,
title:"打造有情怀的 iTerm2 终端",
link:"http://www.jianshu.com/p/83c38271b09c",
imageUrl:"http://www.jianshu.com/p/c47c24ab1e76",
desc:"iTerm2 是 MAC 下最好的终端工具。可以简单的认为,iTerm2 是配置完毕开箱即用的 tmux。"
}
})
2.6 下载文档相关API
2.6.1 通用GET请求下载并打开附件【iOS】【Android】
crh.openFileWithGETMethod(OBJECT)
JSBridgeHook:crh_common_open_file_get
通用GET请求下载并打开附件
OBJECT参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
fileunid | String | 是 | 附件唯一标识,用于缓存 |
file_name | String | 是 | 文件名称,需要包含文件后缀名 |
download_url | String | 是 | 下载路径 |
model_name | String | 是 | 模块名 |
file_encrypt_type | String | 是 | 文件加密方式 "0":没有加密、"1":移动平台OA加密方式 |
示例代码:
crh.openFileWithGETMethod({
param:{
fileunid:"394827589748972",
file_name:"20140428164949-1920123854.jpg",
download_url:"http://pic.baike.soso.com/p/20140428/20140428164949-1920123854.jpg",
model_name:"unknow",
file_encrypt_type:"0"
}
})
2.6.2 通过移动平台附件服务器下载附件【iOS】【Android】
crh.openOAFileFromEMAP(OBJECT)
JSBridgeHook:crh_common_open_oa_file_post
通用GET请求下载并打开附件
OBJECT参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
fileunid | String | 是 | 附件唯一标识,用于缓存(fileId+fileunid[原始]+md5) |
file_name | String | 是 | 文件名称,需要包含文件后缀名 |
download_url | String | 否 | 下载路径,已固定为移动平台下载路径无需指定 |
model_name | String | 是 | 模块名 |
file_encrypt_type | String | 是 | 文件加密方式 "0":没有加密、"1":移动平台OA加密方式 |
oa_sys_code | String | 是 | 附件 所属 OA 业务系统代号 |
oa_file_param | Object | 是 | 附件 下载 所需参数 |
oa_file_param参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
dbname | String | 是 | 相关数据库名称 |
servername | String | 是 | 相关服务名称 |
fileid | String | 是 | 文件ID |
md5 | String | 是 | 文件MD5值 |
atturl | String | 是 | 业务系统文件目标地址 |
示例代码:
crh.openOAFileFromEMAP({
param:{
fileunid:"131363725979613595NW262E9CFE41406702482580FF002E14CC60E402D2DBD796CD140C3DF8D4657A71",
file_name:"5ed9b8fe55744108a37f1001a94f5dc6.jpg",
download_url:"",
model_name:"H5OA",
file_encrypt_type:"1",
oa_sys_code:"F001",
oa_file_param:{
dbname:"hrzb/excutecommitmemo.nsf",
servername:"CN=OAHRZB/O=crcapital",
fileid:"131363725979613595NW",
md5:"60E402D2DBD796CD140C3DF8D4657A71",
atturl:"http://oa1uat.crcapital.com.hk/hrzb/excutecommitmemo.nsf/(vwIndiDocs)/262E9CFE41406702482580FF002E14CC/$file/131363725979613595NW.jpg"
}
}
})
2.6.3 下载进度与状态回调【iOS】【Android】
crh.onFileDownloadProgressStatusChange(CALLBACK)
JSBridgeHook:crh_common_update_file_download_progress
下载进度与状态回调
CALLBACK返回参数:
参数 | 类型 | 说明 |
---|---|---|
fileunid | String | 需要更新文件的唯一ID |
progress | INT | 下载进度 |
progress 有效值:
值 | 说明 |
---|---|
-1 | 下载出错 |
0 - 99 | 正在下载 |
> 99 | 下载完成 |
示例代码:
crh.onFileDownloadProgressStatusChange(function(res) {
console.log(res.fileunid)
console.log(res.progress)
})
2.7 IM
2.7.1 打开IM用户详情页面【iOS】【Android】
crh.openIMUserInfoPage(OBJECT)
JSBridgeHook:crh_im_view_user_detail
打开IM用户详情页面
OBJECT参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
userId | String | 是 | 用户ID |
success | Function | 否 | 接口调用成功的回调 |
fail | Function | 否 | 接口调用失败的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
示例代码:
crh.openIMUserInfoPage({
param:{
userId:"cyd"
}
});
2.7.2 给目标用户发送添加好友邀请 【Android】
crh.sendAddFirendInvite(OBJECT)
JSBridgeHook:crh_im_add_friend
给目标用户发送添加好友邀请
OBJECT参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
userId | String | 是 | 用户ID |
success | Function | 否 | 接口调用成功的回调 |
fail | Function | 否 | 接口调用失败的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
示例代码:
crh.sendAddFirendInvite({
param:{
userId:"cyd"
}
});
2.7.3 打开IM聊天界面 【Android】
crh.chatWithUser(OBJECT)
JSBridgeHook:crh_im_chat_with_user
打开IM聊天界面
OBJECT参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
userId | String | 是 | 用户ID |
success | Function | 否 | 接口调用成功的回调 |
fail | Function | 否 | 接口调用失败的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
示例代码:
crh.chatWithUser({
param:{
userId:"cyd"
}
});
2.8 选取器
2.8.1 通用日期/时间选取器【iOS】【Android】
crh.showDatePicker(OBJECT)
JSBridgeHook:crh_oa_common_show_date_picker
选取日期 时间 控件
OBJECT参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
type | String | 是 | 选取器类型 date 、time |
defaultValue | String | 否 | 打开选取器后默认值 |
minDate | String | 否 | 日期模式:最小日期 |
maxDate | String | 否 | 日期模式:最大日期 |
minuteInterval | String | 否 | 时间模式:分钟间隔数 |
success | Function | 是 | 接口调用成功的回调函数 |
fail | Function | 否 | 接口调用失败的回调函数 |
fail | Function | 否 | 取消时的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
success返回参数说明:
参数 | 类型 | 说明 |
---|---|---|
result | String | 日期和时间结果 |
示例代码:
//日期
crh.showDatePicker({
param:{
type:"date",
defaultValue:"2017-05-01",
minDate:"2017-01-01",
maxDate:"2017-12-31"
},
success:function(res){
console.log(res);
}
});
//时间
crh.showDatePicker({
param:{
type:"time",
defaultValue:"12:00:00",
minuteInterval:"15"
},
success:function(res){
console.log(res);
}
});
日期格式:2017-02-28 不要使用 2017/02/28
时间格式:23:56:00
2.9 保存电话到系统通讯录 【iOS】【Android】
crh.savePhoneToSystemAddressBook(OBJECT)
JSBridgeHook:crh_common_save_to_system_addressbook
保存电话到系统通讯录
OBJECT参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
name | String | 是 | 姓名 |
StringArray | 否 | 邮箱地址数组 | |
mainPhone | StringArray | 否 | 标签为主要 的电话号码数组 |
officePhone | StringArray | 否 | 标签为工作 的电话号码数组 |
mobilePhone | StringArray | 否 | 标签为手机 的电话号码数组 |
success | Function | 是 | 接口调用成功的回调函数 |
fail | Function | 否 | 接口调用失败的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
示例代码:
crh.savePhoneToSystemAddressBook({
param:{
name:"老干妈",
mainPhone:["139xxxxoooo","158ooooxxxxx"]
},
success: function(res){
console.log(res);
}
})
2.10 审批中心待办处理完成后发送通知【iOS】【Android】
crh.postApprovalOADocumentSuccessNotification(OBJECT)
JSBridgeHook:crh_oa_common_send_submit_success_notification
OA待办处理完成后发送通知
OBJECT参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
type | String | 是 | 操作类型 unread 、submit 、bohui 等 |
todoId | String | 是 | 待办ID |
businessunid | String | 是 | 主文档ID |
businessType | String | 是 | 所属业务模块类型 |
time | String | 是 | 待办时间戳 |
示例代码:
crh.postApprovalOADocumentSuccessNotification({
param:{
type:"bohui",
todoId:"xoxkoeikasjfokkf",
businessType:"8001",
businessunid:"xoofkefjksfjkdfsdf",
time:"IjIwMTctMDQtMjkgMDk6MTI6MzEi"
}
});