Commit 4f475985 authored by 范雪寒's avatar 范雪寒
parents 1f637066 96bdbb45
export function initAir(_this) { export function initAir(_this) {
window.air = { const realAir = {
uploadUrl: "", uploadUrl: "",
uploadData: null, uploadData: null,
hideAirClassLoading(templateName,loadData) { hideAirClassLoading(templateName,loadData) {
...@@ -23,6 +24,28 @@ export function initAir(_this) { ...@@ -23,6 +24,28 @@ export function initAir(_this) {
testCallBack: null, testCallBack: null,
recordCallBack: null, recordCallBack: null,
onCourseInScreen: null, onCourseInScreen: null,
};
try{
window.air = new Proxy(realAir, {
set: function (target, key, value, receiver) {
let newValue = value;
if (key=="osmoCallback"||key=="osmoHandwritingCallback"||key=="osmoFingerReadCallback") {
newValue = function (res) {
_this.log(`||==成功调用${key}==||参数==${JSON.stringify(res)}`);
value(JSON.stringify(res));
}
}
return Reflect.set(target, key, newValue, receiver);
},
get: function (target, key, receiver) {
return Reflect.get(target, key, receiver);
},
deleteProperty: function(target, key){
return Reflect.deleteProperty(target, key);
}
});
}catch(e){
console.error("浏览器不支持ES6新特性Proxy/Reflect,请使用谷歌浏览器!");
} }
window.courseware = { window.courseware = {
getData(callback) { getData(callback) {
...@@ -86,7 +109,7 @@ export function initAir(_this) { ...@@ -86,7 +109,7 @@ export function initAir(_this) {
} }
// 结束录音 // 结束录音
window.air.recordCallBack = (res) => { window.air.recordCallBack = (res) => {
callback && callback(res); callback && callback(JSON.stringify(res));
window.air.recordCallBack = null; window.air.recordCallBack = null;
}; };
this.callOcMethod("stopRecord", {isBreak: 0, isGradePapers: isgradepapers}); this.callOcMethod("stopRecord", {isBreak: 0, isGradePapers: isgradepapers});
...@@ -104,7 +127,7 @@ export function initAir(_this) { ...@@ -104,7 +127,7 @@ export function initAir(_this) {
} }
// 结束录音 // 结束录音
window.air.testCallBack = (res) => { window.air.testCallBack = (res) => {
callback && callback(res); callback && callback(JSON.stringify(res));
window.air.testCallBack = null; window.air.testCallBack = null;
}; };
this.callOcMethod("stopTest", {}); this.callOcMethod("stopTest", {});
...@@ -112,7 +135,7 @@ export function initAir(_this) { ...@@ -112,7 +135,7 @@ export function initAir(_this) {
openRecognitionCamera(callback) { openRecognitionCamera(callback) {
_this.log(`===成功调用openRecognitionCamera===`); _this.log(`===成功调用openRecognitionCamera===`);
window.air.recognitionCameraCallBack = (res) => { window.air.recognitionCameraCallBack = (res) => {
callback && callback(res); callback && callback(JSON.stringify(res));
window.air.recognitionCameraCallBack = null; window.air.recognitionCameraCallBack = null;
}; };
this.callOcMethod("openRecognitionCamera", {}); this.callOcMethod("openRecognitionCamera", {});
...@@ -121,7 +144,7 @@ export function initAir(_this) { ...@@ -121,7 +144,7 @@ export function initAir(_this) {
_this.log(`===成功调用getEngineInfo===`); _this.log(`===成功调用getEngineInfo===`);
// 调用原生获取机器信息 // 调用原生获取机器信息
window.air.getEngineInfoCallback = (res) => { window.air.getEngineInfoCallback = (res) => {
callback && callback(res); callback && callback(JSON.stringify(res));
window.air.getEngineInfoCallback = null; window.air.getEngineInfoCallback = null;
}; };
this.callOcMethod("getEngineInfo", {}); this.callOcMethod("getEngineInfo", {});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment