|

楼主 |
发表于 2017-2-21 10:52:44
|
显示全部楼层
这是那个js代码你看一下
define(function(require) {
var $ = require("jquery");
var justep = require("$UI/system/lib/justep");
var correct = '';
var GoNext = false;
var Model = function() {
this.callParent();
};
Model.prototype.titleDataCustomRefresh = function(event) {
var me = this;
// var data = this.comp("titleData");
$.support.cors = true;
$.ajax({
"async" : "true",
"url" : "http://192.168.1.119/OnlineSer.asmx/GetRemoteInterface",
"type" : "post",
"dataType" : "json",
"data" : {
"sInterface" : "GetExamsQuestion",
// // 序列化参数JSON字符串
"sProcName" : "KS_GetExamsQuestion",
// //"INparams" : options.INparams
"sParam" : "0|1|1|3|0|10"
},
"complete" : function(xhr) {
if (xhr.readyState == 4 && xhr.status == 200) {
//alert(xhr.responseText);
var loadDatas = JSON.parse(xhr.responseText);
loadDatas = loadDatas.Table;
me.comp("titleData").loadData(loadDatas);
// var ss = xhr.responseText;
// console.log(ss.Table);
// alert(me.comp("titleData").count());
me.comp("titleData").first();
} else {
alert("fail");
}
}
});
};
Model.prototype.showdata = function() {
var data = this.comp("titleData");
var rows = data.getCurrentRow(true);
correct = rows.val("FAnswer");
var FOne = rows.val("FOne");
var FTwo = rows.val("FTwo");
var FThree = rows.val("FThree");
var FFour = rows.val("FFour");
var D_array = new Array();
if (FOne != undefined && FOne != "") {
D_array[0] = {
"choose" : FOne,
"ID" : A
};
}
if (FTwo != undefined && FTwo != "") {
D_array[1] = {
"choose" : FTwo,
"ID" : B
};
}
if (FThree != undefined && FThree != "") {
D_array[2] = {
"choose" : FThree,
"ID" : C
};
}
if (FFour != undefined && FFour != "") {
D_array[3] = {
"choose" : FFour,
"ID" : D
};
}
var mainData = this.comp("chooseData");
mainData.clear();
mainData.newData({
defaultValues : D_array
});
};
Model.prototype.titleDataAfterRefresh = function(event) {
this.showdata();
};
Model.prototype.checkquestion = function() {
var item = this.comp("checkboxGroup").val();
item = item.replace(" ", "|");
if (item == correct) {
GoNext = true;
this.getElementByXid("error").innerHTML = "回答正确!";
this.comp("titleData").next();
} else {
GoNext = false;
var tem = correct;
tem = tem.replace("|", ",");
tem = tem.replace("1", "A");
tem = tem.replace("2", "B");
tem = tem.replace("3", "C");
tem = tem.replace("4", "D");
this.getElementByXid("error").innerHTML = "回答错误! " + "正确答案为:" + tem;
}
};
Model.prototype.preBtnClick = function(event) {
console.log(this.checkquestion());
var data = this.comp("titleData");
data.pre();
};
Model.prototype.nextBtnClick = function(event) {
var data = this.comp("titleData");
this.checkquestion();
};
Model.prototype.modelParamsReceive = function(event) {
var dataUrl = this.params.dataUrl;
var mainData = this.comp("titleData");
mainData.clear();
var url = require.toUrl(dataUrl);
$.getJSON(url, function(data) {
mainData.newData({
defaultValues : data
})
});
};
Model.prototype.titleDataIndexChanged = function(event) {
this.showdata();
this.showCount();
this.getElementByXid("error").innerHTML = "";
};
return Model;
});
|
|