正在显示
3 个修改的文件
包含
107 行增加
和
15 行删除
此 diff 太大无法显示。
| @@ -26,7 +26,7 @@ import ArrayBufferUtil from 'libs/ArrayBufferUtil'; | @@ -26,7 +26,7 @@ import ArrayBufferUtil from 'libs/ArrayBufferUtil'; | ||
| 26 | import UTF8 from 'utf-8'; | 26 | import UTF8 from 'utf-8'; |
| 27 | 27 | ||
| 28 | let loger = Loger.getLoger('MessageEntrance'); | 28 | let loger = Loger.getLoger('MessageEntrance'); |
| 29 | -let _sdkInfo = {"version": "v.1.8.22.20170411", "author": "www.3mang.com"}; | 29 | +let _sdkInfo = {"version": "v.1.9.0.20170411", "author": "www.3mang.com"}; |
| 30 | 30 | ||
| 31 | //APE | 31 | //APE |
| 32 | let _sass; | 32 | let _sass; |
| @@ -173,9 +173,10 @@ export default class MessageEntrance extends Emiter { | @@ -173,9 +173,10 @@ export default class MessageEntrance extends Emiter { | ||
| 173 | this.getDocImageFullPath = this._getDocImageFullPath.bind(this); | 173 | this.getDocImageFullPath = this._getDocImageFullPath.bind(this); |
| 174 | //获取文档图片的完整路径 | 174 | //获取文档图片的完整路径 |
| 175 | this.getDocPDFFullPath = this._getDocPDFFullPath.bind(this);//获取文档的完整路径 | 175 | this.getDocPDFFullPath = this._getDocPDFFullPath.bind(this);//获取文档的完整路径 |
| 176 | + this.getDocFullAddress=this._getDocFullAddress.bind(this);//获取文档资源地址 | ||
| 176 | 177 | ||
| 177 | - this.setDebuger = this._setDebuger.bind(this);//debug | ||
| 178 | 178 | ||
| 179 | + this.setDebuger = this._setDebuger.bind(this);//debug | ||
| 179 | this.setMessageDelay=this._setMessageDelay.bind(this);//设置是否延迟消息 | 180 | this.setMessageDelay=this._setMessageDelay.bind(this);//设置是否延迟消息 |
| 180 | } | 181 | } |
| 181 | 182 | ||
| @@ -928,16 +929,25 @@ export default class MessageEntrance extends Emiter { | @@ -928,16 +929,25 @@ export default class MessageEntrance extends Emiter { | ||
| 928 | 929 | ||
| 929 | 930 | ||
| 930 | //DocApe | 931 | //DocApe |
| 932 | + //获取文档的所有资源地址 | ||
| 933 | + _getDocFullAddress(_param) { | ||
| 934 | + if (_doc_ape) { | ||
| 935 | + return _doc_ape.getDocFullAddress(_param); | ||
| 936 | + } else { | ||
| 937 | + loger.error("文档模块还没有创建无法获取"); | ||
| 938 | + return {"code":ApeConsts.RETURN_FAILED, "data": "文档模块还没有创建无法获取"}; | ||
| 939 | + } | ||
| 940 | + } | ||
| 941 | + | ||
| 931 | //获取文档完整路径 | 942 | //获取文档完整路径 |
| 932 | _getDocImageFullPath(_param) { | 943 | _getDocImageFullPath(_param) { |
| 933 | if (_doc_ape) { | 944 | if (_doc_ape) { |
| 934 | return _doc_ape.getDocImageFullPath(_param); | 945 | return _doc_ape.getDocImageFullPath(_param); |
| 935 | } else { | 946 | } else { |
| 936 | - loger.error("文档模块还没有创建,无法获取"); | 947 | + loger.error("文档模块还没有创建无法获取"); |
| 937 | return []; | 948 | return []; |
| 938 | } | 949 | } |
| 939 | } | 950 | } |
| 940 | - | ||
| 941 | _getDocPDFFullPath(_param) { | 951 | _getDocPDFFullPath(_param) { |
| 942 | if (_doc_ape) { | 952 | if (_doc_ape) { |
| 943 | return _doc_ape.getDocPDFFullPath(_param); | 953 | return _doc_ape.getDocPDFFullPath(_param); |
| @@ -32,35 +32,31 @@ class DocApe extends Ape { | @@ -32,35 +32,31 @@ class DocApe extends Ape { | ||
| 32 | ApeConsts.DOCSHARING_SESSION_TAG | 32 | ApeConsts.DOCSHARING_SESSION_TAG |
| 33 | ); | 33 | ); |
| 34 | this.docList = {};//记录文档的数组this.docList[itemIdx]=itemIdx的数据 | 34 | this.docList = {};//记录文档的数组this.docList[itemIdx]=itemIdx的数据 |
| 35 | - //this.activeDocItemIdx =0;//当前激活的文档itemIdx | ||
| 36 | - //this.activeDocCurPage=1;//当前激活的文档的当前页 | ||
| 37 | 35 | ||
| 38 | // Ape Models | 36 | // Ape Models |
| 39 | this.registerKey(this._session_id, this._session_name, this._session_tag, new ArrayBuffer); | 37 | this.registerKey(this._session_id, this._session_name, this._session_tag, new ArrayBuffer); |
| 40 | this.registerObj(pdu.RCPDU_REG_REGISTER_TABLE, ApeConsts.DOCSHARING_OBJ_TABLE_ID, ApeConsts.DOCSHARING_OBJ_TABLE_NAME, ApeConsts.DOCSHARING_OBJ_TABLE_TAG, 0, new ArrayBuffer); | 38 | this.registerObj(pdu.RCPDU_REG_REGISTER_TABLE, ApeConsts.DOCSHARING_OBJ_TABLE_ID, ApeConsts.DOCSHARING_OBJ_TABLE_NAME, ApeConsts.DOCSHARING_OBJ_TABLE_TAG, 0, new ArrayBuffer); |
| 41 | - //this.registerObj(pdu.RCPDU_REG_REGISTER_TABLE, ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5, ApeConsts.DOCSHARING_OBJ_TABLE_NAME_H5, ApeConsts.DOCSHARING_OBJ_TABLE_TAG_H5, 0, new ArrayBuffer); | ||
| 42 | - } | 39 | + } |
| 43 | 40 | ||
| 44 | /////////////发送数据操作////////////////////////////////////////////////////// | 41 | /////////////发送数据操作////////////////////////////////////////////////////// |
| 45 | - | ||
| 46 | //上传文档 | 42 | //上传文档 |
| 47 | documentUpload(paramInfo) { | 43 | documentUpload(paramInfo) { |
| 48 | if (paramInfo == null || EngineUtils.isEmptyObject(paramInfo)) { | 44 | if (paramInfo == null || EngineUtils.isEmptyObject(paramInfo)) { |
| 49 | - loger.log('documentUpload失败,参数错误'); | 45 | + loger.warn('上传文档->失败->参数错误->',paramInfo); |
| 50 | this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | 46 | this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); |
| 51 | return; | 47 | return; |
| 52 | } | 48 | } |
| 53 | //判断文档是否已经存在,每个文档都有唯一的docId,如果已经同步的文档中存在相同的docId就不需要再同步 | 49 | //判断文档是否已经存在,每个文档都有唯一的docId,如果已经同步的文档中存在相同的docId就不需要再同步 |
| 54 | if (this.checkDocId(paramInfo.docId)) { | 50 | if (this.checkDocId(paramInfo.docId)) { |
| 55 | //文档已经存在相同的docId,不需要同步上传 | 51 | //文档已经存在相同的docId,不需要同步上传 |
| 56 | - loger.warn('documentUpload->档的docId无效或已经存在相同的docId,不需要上传'); | 52 | + loger.warn('上传文档->失败->文档档的docId无效或已经存在相同的docId不需要上传'); |
| 57 | return; | 53 | return; |
| 58 | } | 54 | } |
| 59 | 55 | ||
| 60 | itemIdx = EngineUtils.creatSoleNumberFromTimestamp();// | 56 | itemIdx = EngineUtils.creatSoleNumberFromTimestamp();// |
| 61 | let docDataModelPdu = this.packPdu(paramInfo, itemIdx); | 57 | let docDataModelPdu = this.packPdu(paramInfo, itemIdx); |
| 62 | if (docDataModelPdu == null) { | 58 | if (docDataModelPdu == null) { |
| 63 | - loger.log('documentUpload失败,参数错误'); | 59 | + loger.log('上传文档->失败->数据无效'); |
| 64 | this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | 60 | this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); |
| 65 | return; | 61 | return; |
| 66 | } | 62 | } |
| @@ -93,7 +89,7 @@ class DocApe extends Ape { | @@ -93,7 +89,7 @@ class DocApe extends Ape { | ||
| 93 | adapterPdu.type = pdu.RCPDU_REG_ADAPTER; | 89 | adapterPdu.type = pdu.RCPDU_REG_ADAPTER; |
| 94 | adapterPdu.item.push(adapterItemPdu); | 90 | adapterPdu.item.push(adapterItemPdu); |
| 95 | 91 | ||
| 96 | - loger.log("文档upload tableItemPdu.itemIdx=" + tableItemPdu.itemIdx); | 92 | + loger.log("上传文档->发送->itemIdx=" + tableItemPdu.itemIdx); |
| 97 | this.sendUniform(adapterPdu, true); | 93 | this.sendUniform(adapterPdu, true); |
| 98 | } | 94 | } |
| 99 | 95 | ||
| @@ -137,6 +133,92 @@ class DocApe extends Ape { | @@ -137,6 +133,92 @@ class DocApe extends Ape { | ||
| 137 | loger.log("发送更新文档.itemIdx=" + tableItemPdu.itemIdx); | 133 | loger.log("发送更新文档.itemIdx=" + tableItemPdu.itemIdx); |
| 138 | this.sendUniform(adapterPdu, true); | 134 | this.sendUniform(adapterPdu, true); |
| 139 | } | 135 | } |
| 136 | + //获取文档的完整地址和所有图片 | ||
| 137 | + getDocFullAddress(_param){ | ||
| 138 | + if (_param == null || _param.url == null || _param.itemIdx ==null) { | ||
| 139 | + loger.warn('获取文档完整地址->传递的参数不正确->', _param); | ||
| 140 | + return {"code":ApeConsts.RETURN_FAILED, "data": "获取文档时传递的参数不对"}; | ||
| 141 | + } | ||
| 142 | + let fullPath='';//文档路径地址 | ||
| 143 | + let pageNum=1;//总页数 | ||
| 144 | + let docType="";//文档地址的后缀类型 | ||
| 145 | + let fileType="";//文档的原始类型 | ||
| 146 | + let docItem=this.docList[_param.itemIdx]; | ||
| 147 | + if(docItem){ | ||
| 148 | + fullPath=docItem.url||""; | ||
| 149 | + pageNum=docItem.pageNum||1; | ||
| 150 | + fileType=docItem.fileType||"" | ||
| 151 | + }else { | ||
| 152 | + fullPath =_param.url; | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + //获取当前文档的后缀名 | ||
| 156 | + docType=this._getDocType(fullPath); | ||
| 157 | + let substrFullPath=this._getDocPath(fullPath);//获取去掉后缀和文件名的地址,需要获取同目录下其他文件 | ||
| 158 | + let imagesArr=[]; | ||
| 159 | + let htmlPath=""; | ||
| 160 | + let pdfPath=""; | ||
| 161 | + | ||
| 162 | + //根据文件后缀名,生成对应的访问地址 | ||
| 163 | + if(docType=="jpg"||docType=="png"||docType=="swf"||docType=="pdf"||docType=="doc"||docType=="pptx"){ | ||
| 164 | + //页数从1开始 | ||
| 165 | + for (let i = 1; i <=pageNum; i++) { | ||
| 166 | + imagesArr.push(substrFullPath + "/" + i + ".jpg"); | ||
| 167 | + } | ||
| 168 | + } | ||
| 169 | + if(docType=="swf"||docType=="pdf"||docType=="doc"||docType=="pptx"){ | ||
| 170 | + pdfPath=fullPath.replace(/\.swf/g, ".pdf")||""; | ||
| 171 | + } | ||
| 172 | + //动态PPT | ||
| 173 | + if(docType=="html"){ | ||
| 174 | + htmlPath=fullPath; | ||
| 175 | + } | ||
| 176 | + //返回文档第所有地址 | ||
| 177 | + return {'code':ApeConsts.RETURN_SUCCESS, 'data': '','docFullAddress':{ | ||
| 178 | + 'images':imagesArr, | ||
| 179 | + 'pdf':pdfPath, | ||
| 180 | + ' html':htmlPath | ||
| 181 | + }}; | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + _getDocType(_fullPath){ | ||
| 185 | + if(!_fullPath){ | ||
| 186 | + return ""; | ||
| 187 | + } | ||
| 188 | + if(_fullPath.lastIndexOf(".jpg")>=0){ | ||
| 189 | + return "jpg"; | ||
| 190 | + } | ||
| 191 | + if(_fullPath.lastIndexOf(".png")>=0){ | ||
| 192 | + return "png"; | ||
| 193 | + } | ||
| 194 | + if(_fullPath.lastIndexOf(".swf")>=0){ | ||
| 195 | + return "swf"; | ||
| 196 | + } | ||
| 197 | + if(_fullPath.lastIndexOf(".pdf")>=0){ | ||
| 198 | + return "pdf"; | ||
| 199 | + } | ||
| 200 | + if(_fullPath.lastIndexOf(".doc")>=0){ | ||
| 201 | + return "doc"; | ||
| 202 | + } | ||
| 203 | + if(_fullPath.lastIndexOf(".html")>=0){ | ||
| 204 | + return "html"; | ||
| 205 | + } | ||
| 206 | + if(_fullPath.lastIndexOf(".pptx")>=0){ | ||
| 207 | + return "pptx"; | ||
| 208 | + } | ||
| 209 | + return ""; | ||
| 210 | + } | ||
| 211 | + //获取去掉文件名和后缀名的地址 http://www.xxx.xxx/image/aa.jpg -->http://www.xxx.xxx/image/ | ||
| 212 | + _getDocPath(_fullPath){ | ||
| 213 | + if(!_fullPath){ | ||
| 214 | + return ""; | ||
| 215 | + } | ||
| 216 | + var lastIndex = _fullPath.lastIndexOf("/"); | ||
| 217 | + if (lastIndex > 0) { | ||
| 218 | + return _fullPath.substr(0, lastIndex); | ||
| 219 | + } | ||
| 220 | + return _fullPath; | ||
| 221 | + } | ||
| 140 | 222 | ||
| 141 | //获取文档的图片完整地址 | 223 | //获取文档的图片完整地址 |
| 142 | getDocImageFullPath(_param) { | 224 | getDocImageFullPath(_param) { |
| @@ -540,7 +622,7 @@ class DocApe extends Ape { | @@ -540,7 +622,7 @@ class DocApe extends Ape { | ||
| 540 | 622 | ||
| 541 | ///////数据的封包和解包///////////////////////////////////////// | 623 | ///////数据的封包和解包///////////////////////////////////////// |
| 542 | packPdu(_param, _itemIdx) { | 624 | packPdu(_param, _itemIdx) { |
| 543 | - loger.log("文档===>packPdu "); | 625 | + loger.log("文档===>packPdu"); |
| 544 | //验证坐标点集合数组是否合法 | 626 | //验证坐标点集合数组是否合法 |
| 545 | if (_param == null || _itemIdx == null) { | 627 | if (_param == null || _itemIdx == null) { |
| 546 | this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | 628 | this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); |
| @@ -555,7 +637,7 @@ class DocApe extends Ape { | @@ -555,7 +637,7 @@ class DocApe extends Ape { | ||
| 555 | docModelPdu.pageNum = _param.pageNum || 1; | 637 | docModelPdu.pageNum = _param.pageNum || 1; |
| 556 | docModelPdu.fileType = _param.fileType || ""; | 638 | docModelPdu.fileType = _param.fileType || ""; |
| 557 | docModelPdu.creatUserId = _param.creatUserId || "0"; | 639 | docModelPdu.creatUserId = _param.creatUserId || "0"; |
| 558 | - docModelPdu.url = "";//这个地址没用到,数据太长占用资源 暂停使用//"http://101.200.150.192/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg"; | 640 | + docModelPdu.url = _param.url||"";//这个地址没用到,数据太长占用资源 暂停使用//"http://101.200.150.192/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg"; |
| 559 | docModelPdu.relativeUrl = _param.relativeUrl || "";//"/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg"; | 641 | docModelPdu.relativeUrl = _param.relativeUrl || "";//"/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg"; |
| 560 | docModelPdu.curV = _param.curV || 0; | 642 | docModelPdu.curV = _param.curV || 0; |
| 561 | docModelPdu.curH = _param.curH || 0; | 643 | docModelPdu.curH = _param.curH || 0; |
-
请 注册 或 登录 后发表评论