|
定义的接口代码:
调用代码:
define(function(require){
var $ = require("jquery");
var justep = require("$UI/system/lib/justep");
require("cordova!your_carrier_plugin_location");
var Model = function(){
this.callParent();
};
Model.prototype.modelLoad = function(event){
document.addEventListener("deviceready",onDeviceReady,false);
function onDeviceReady(){
}
};
Model.prototype.button1Click = function(event){
navigator.carrier.getCarrierName(onSuccess, onFailure);
function onSuccess(){
var resStr = "Result: " + result;
}
function onFailure(){
console.log("onFailure: " + JSON.stringify(err));
alert("Failure: " + err);
}
};
Model.prototype.button2Click = function(event){
navigator.carrier.getCountryCode(onSuccess, onFailure);
function onSuccess(){
var resStr = "Result: " + result;
}
function onFailure(){
console.log("onFailure: " + JSON.stringify(err));
alert("Failure: " + err);
}
};
return Model;
});
运行结果:
|
|