差别
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 | |||
im:web:draft:toolrelated [2019/03/22 12:53] jk 移除 |
— (当前版本) | ||
---|---|---|---|
行 1: | 行 1: | ||
- | ====== 工具类说明 ====== | ||
- | |||
- | ---- | ||
- | |||
- | ===== 文件上传下载判断 ===== | ||
- | |||
- | <code javascript> | ||
- | //是否能上传file | ||
- | WebIM.utils.isCanUploadFile; | ||
- | //是否能下载file | ||
- | WebIM.utils.isCanDownLoadFile ; | ||
- | //是否设置header | ||
- | WebIM.utils. isCanSetRequestHeader; | ||
- | //是否设置mimetype | ||
- | WebIM.utils.hasOverrideMimeType; | ||
- | </code> | ||
- | |||
- | |||
- | ===== 表情解析工具类 ===== | ||
- | |||
- | <code javascript> | ||
- | WebIM.utils.parseEmoji(message); | ||
- | </code> | ||
- | |||
- | ===== 格式化字符串类 ===== | ||
- | |||
- | 目前只能解析字符串''%s'' | ||
- | |||
- | <code javascript> | ||
- | WebIM.utils.sprintf(string[, args...]) | ||
- | </code> | ||
- | |||
- | ===== 文件上传下载工具类 ===== | ||
- | |||
- | <code javascript> | ||
- | var fileInfo = WebIM.utils.getFileUrl(fileInputId); | ||
- | |||
- | |||
- | //上传 | ||
- | var options = { | ||
- | appName: 'chatdemoui', | ||
- | orgName: 'easemob-demo', | ||
- | accessToken: 'YWMtjPPoovCqEeOQs7myPqqaOwAAAUaqNH0a8rRj4PwJLQju6-S47ZO6wYs3Lwo', | ||
- | onFileUploadComplete: function ( data ) { //upload file success }, | ||
- | onFileUploadError: function ( e ) { //upload file error } | ||
- | }; | ||
- | |||
- | WebIM.utils.uploadFile(options); | ||
- | |||
- | |||
- | |||
- | //下载 | ||
- | var options = { | ||
- | responseType: 'blob',//default blob | ||
- | mimeType: 'text/plain; charset=x-user-defined',//default | ||
- | url:'http://s1.easemob.com/weiquan2/a2/chatfiles/0c0f5f3a-e66b-11e3-8863-f1c202c2b3ae', | ||
- | secret: 'NSgGYPCxEeOou00jZasg9e-GqKUZGdph96EFxJ4WxW-qkxV4', | ||
- | accessToken: 'YWMtjPPoovCqEeOQs7myPqqaOwAAAUaqNH0a8rRj4PwJLQju6-S47ZO6wYs3Lwo', | ||
- | onFileDownloadComplete: function ( data ) { //download file success }, | ||
- | onFileDownloadError: function ( e ) { //download file error } | ||
- | }; | ||
- | |||
- | WebIM.utils.download(options); | ||
- | </code> | ||
- | |||
- | |||
- | ===== 发送Ajax请求 ===== | ||
- | |||
- | <code javascript> | ||
- | var options = { | ||
- | dataType: 'text',//default | ||
- | success: function () { //handle request success }, | ||
- | error: function () { //handle request error }, | ||
- | type: 'post',//default 'post' | ||
- | url: 'http://s1.easemob.com/weiquan2/a2/chatfiles/0c0f5f3a-e66b-11e3-8863-f1c202c2b3ae', | ||
- | headers: '',//default {} | ||
- | data: '';//default null | ||
- | }; | ||
- | |||
- | WebIM.utils.ajax(options); | ||
- | </code> | ||
- | |||
- | |||
- | |||
- | ---- | ||
- | <WRAP group> | ||
- | <WRAP half column> | ||
- | 上一页:[[im:web:basics:multiuserconference|多人实时通话]] | ||
- | </WRAP> | ||
- | |||
- | <WRAP half column> | ||
- | 下一页:[[im:web:other:apidoc|Web SDK API Doc]] | ||
- | </WRAP> | ||
- | </WRAP> | ||
- | |||
- | |||