import common from '../../utils/util'; import main from '../../utils/main'; const app = getApp(); Page({ data: { Count:0, TestTypeNumber:1, MenuList:[{Name:"不分配(默认)",IsSelected:0},{Name:"分配到新卡单",IsSelected:1},{Name:"选择卡单",IsSelected:0,HasArrow:1}], List:[ {Name:"答错的",List:[],BColor:"#F26D5F"}, {Name:"不会的",List:[],BColor:"#787878"}, {Name:"答对的",List:[],BColor:"#51BE3D"} ] }, onLoad: function (options) { var that = this; var testtask=app.globalData.TestTask; that.setData({ ReportType: options.type, LibraryName:testtask.LibraryName, BookName:testtask.BookName, UnitName:testtask.UnitName, TestTypeName:testtask.TestTypeName, TestTime:common.formatDateCHS(common.formatTime(new Date()),1), Containnerheight: main.getWindowHeight(), ImagePath: app.globalData.uploadImageUrl, }); that.init(); }, init: function () { var that = this; var TestTask = app.globalData.TestTask; if (!TestTask) TestTask={}; var TestTypeNumber=1; if (TestTask.TestType=="read") TestTypeNumber=2; var list = TestTask.List; //debugger; if (list) { for (var i = 0; i < list.length; i++) { var item={}; item.IsSelected=0; item.Word=list[i].Word; if (list[i].Result == -1) { that.data.List[0].List.push(item); } else if (list[i].Result == 0) { that.data.List[1].List.push(item); } else if (list[i].Result == 1) { that.data.List[2].List.push(item); } } that.setData({ List:that.data.List, TestTypeNumber:TestTypeNumber, }); if (that.data.ReportType == "new") that.saveInfo(TestTask); } }, saveInfo:function(e){ var that=this; var userid=app.globalData.userInfo.UserID; var param1={}; param1.Category=e.Category; param1.LibraryName=that.data.LibraryName; param1.BookName=that.data.BookName; param1.UnitName=that.data.UnitName; param1.TestTypeName=that.data.TestTypeName; if (e.TestType=="read") param1.IsTestRead=1; else param1.IsTestWrite=1; //debugger; param1.JSONData=JSON.stringify(that.data.List); main.postData('InsertTestReport2?UserID=' + userid, param1, function (data) { if (data){ } }); }, selectItem:function(e){ var that=this; var index=e.currentTarget.dataset.index; var index2=e.currentTarget.dataset.index2; var list=that.data.List,count=0; for(var i=0;i