Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 899242b

Browse files
committed
[CHG]修复对讲多次后,token不刷新问题
1 parent 0c568df commit 899242b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

ezuikit-talk.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,25 @@
169169
// })
170170
// }
171171
EZUITalk.prototype.startTalk = function(){
172-
window.startTalk();
172+
var _this = this;
173+
var apiSuccess = function(data) {
174+
if (data.code == 200) {
175+
var apiResult = data.data;
176+
if (apiResult) {
177+
// 临时将https转换为websocket
178+
_this.opt.stream = apiResult.stream;
179+
window.startTalk();
180+
}
181+
}
182+
}
183+
var apiError = function() {
184+
layer.msg("获取对讲token失败")
185+
}
186+
request(_this.opt.apiDomain, 'POST', {
187+
accessToken: _this.opt.accessToken,
188+
deviceSerial: _this.opt.deviceSerial,
189+
channelNo: _this.opt.channelNo
190+
}, '', apiSuccess, apiError);
173191
}
174192
EZUITalk.prototype.stopTalk = function(){
175193
window.stopTalk();

0 commit comments

Comments
 (0)