|
20 | 20 |
|
21 | 21 | // Pass this if window is not defined yet |
22 | 22 | })(typeof window !== "undefined" ? window : this, function (window, noGlobal) { |
23 | | - // 加载js |
| 23 | + function PrefixCode(code,msg) { |
| 24 | + if(parseInt(code,10) > 0){ |
| 25 | + var PRECODE = 102; |
| 26 | + var retcode = '102' + (code/Math.pow(10,5)).toFixed(5).substr(2); |
| 27 | + } else if (code == -1) { |
| 28 | + retcode = -1; |
| 29 | + }else if (typeof code === 'undefined'){ |
| 30 | + retcode = 0; |
| 31 | + } |
| 32 | + return { |
| 33 | + code : retcode, |
| 34 | + data: msg, |
| 35 | + } |
| 36 | + // function PrefixInteger(num, length) { |
| 37 | + // return (num/Math.pow(10,length)).toFixed(length).substr(2); |
| 38 | + // } |
| 39 | + } |
| 40 | + // 加载js |
24 | 41 | function addJs(filepath, callback) { |
25 | 42 | var oJs = document.createElement("script"); |
26 | 43 | oJs.setAttribute("src", filepath); |
|
48 | 65 | http_request.send(data); |
49 | 66 | }; |
50 | 67 | var EZUITalk = function (params) { |
51 | | - console.log("params",params); |
52 | | - // this.opt = { |
53 | | - // apiDomain: 'https://test12open.ys7.com/api/lapp/live/talk/url' |
54 | | - // } |
| 68 | + this.params = params; |
55 | 69 | this.opt = { |
56 | 70 | apiDomain: 'https://open.ys7.com/api/lapp/live/talk/url', |
57 | 71 | filePath: '', |
|
93 | 107 | // 加载依赖 |
94 | 108 | // this.init(); |
95 | 109 | var adapeterJS = _this.opt.filePath + '/adapeter.js'; |
96 | | - var janusJS = _this.opt.filePath + '/janus.js'; |
| 110 | + var janusJS = _this.opt.filePath + '/rtcgw.js'; |
97 | 111 | var ttsJS = _this.opt.filePath + '/tts.js'; |
98 | 112 | console.log("加载jquery.js"); |
99 | 113 | addJs(adapeterJS,function(){ |
|
103 | 117 | addJs(ttsJS,function(){ |
104 | 118 | console.log("加载tts.js"); |
105 | 119 | // 文件加载完毕; |
106 | | - |
| 120 | + if (typeof params.onMessage === 'function') { |
| 121 | + params.onMessage({ |
| 122 | + code : 10200001, |
| 123 | + data: "插件加载成功" |
| 124 | + }); |
| 125 | + } |
107 | 126 | }) |
108 | 127 | }) |
109 | 128 | }) |
| 129 | + } else { |
| 130 | + if (typeof params.onError === 'function') { |
| 131 | + params.onError(PrefixCode(data.code,data)); |
| 132 | + } |
110 | 133 | } |
111 | 134 |
|
| 135 | + } else { |
| 136 | + if (typeof params.onError === 'function') { |
| 137 | + params.onError(PrefixCode(data.code,data)); |
| 138 | + } |
112 | 139 | } |
113 | 140 | } |
114 | 141 | function apiError(err){ |
115 | | - if(params.handleError){ |
116 | | - params.handleError(err); |
| 142 | + if(params.onError){ |
| 143 | + params.onError(err); |
117 | 144 | } |
118 | | - |
119 | 145 | } |
120 | 146 | request( |
121 | 147 | this.opt.apiDomain, |
|
0 commit comments