Model.prototype.openFile = function(fileUrl){
if(this.wx){
warning.onAlert();
}else {
// var open = cordova.plugins.disusered.open;
function success() {
console.log('Success');
alert("Success");
}
function error(code) {
alert(code);
if (code === 1) {
console.log('No file handler found');
alert("No file handler found");
} else {
console.log('Undefined error');
alert("Undefined error");
}
}
cordova.plugins.disusered.open(fileUrl, success, error);
}
}
Model.prototype.button2Click = function(event){
this.openFile('http://192.168.8.34/Rec/courseFile/1000100000/201762009311812312/20170508.doc');
};
Model.prototype.button1Click = function(event){
this.openFile('http://192.168.8.34/Rec/courseFile/1000100000/201612070302136078/201612070302136078.ppt');
};
Model.prototype.button3Click = function(event){
this.openFile('http://192.168.8.34/Rec/courseFile/1000100000/201612070239318852/201612070239318852.pptx');
};
Model.prototype.button4Click = function(event){
this.openFile('http://192.168.8.34/Rec/courseFile/1000100000/201762009311812312/2017620095952.docx');
};
Model.prototype.button6Click = function(event){
this.openFile('http://192.168.8.34/Rec/20170504-225935/HD/resource/videos/1_1.mp4');
};
Model.prototype.button5Click = function(event){
this.openFile('http://imgsrc.baidu.com/imgad/pic/item/caef76094b36acaf0accebde76d98d1001e99ce7.jpg');
};
Model.prototype.button7Click = function(event){
this.openFile('http://192.168.8.34/hls/1493174178997_01_H.m3u8');
};
Model.prototype.button10Click = function(event){
this.openFile('http://192.168.8.34/Rec/courseFile/1000100000/201612070239318852/201612070239318852.swf');
};
Model.prototype.button11Click = function(event){
this.openFile('http://192.168.8.34/Rec/courseFile/1000100000/201612070239318852/201612070239318852.pdf');
};
Model.prototype.button12Click = function(event){
this.openFile('rtmp://192.168.8.34/live/1493174178997_01_H');
};
Model.prototype.button8Click = function(event){
this.openFile('http://192.168.8.34/Rec/courseFile/1000100000/201762009311812312/2017620095357.xls');
};
Model.prototype.button9Click = function(event){
this.openFile('http://192.168.8.34/Rec/excel/import_registration_user.xlsx');
};
使用此方法进行文件打开,在安卓系统中没有任何问题,在苹果系统中就出现APP闪退现象。我的IOS版本是10.3.2。