| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- const app = getApp();
- Page({
- data: {
- WordList:[],
- TestTypeNumber:1,
- FolderID:0,
- MenuList:[{Name:"不分配(默认)",IsSelected:1},{Name:"分配到新卡单",IsSelected:0},{Name:"选择卡单",IsSelected:0,HasArrow:1}],
- },
- onLoad: function (options) {
- var that = this;
- that.setData({
- Containnerheight: main.getWindowHeight(),
- ImagePath: app.globalData.uploadImageUrl,
- List:[
- {Name:"答错的",List:[],BColor:"#F26D5F",IsShow:1},
- {Name:"不会的",List:[],BColor:"#787878",IsShow:1},
- {Name:"答对的",List:[],BColor:"#51BE3D",IsShow:1},
- ]
- });
- if (options.ID){
- that.getReportID(options.ID,function(data){
- app.globalData.TestTask=data;
- that.init();
- });
- }
- else{
- that.init();
- }
- },
- init: function () {
- var that = this;
- var TestTask = app.globalData.TestTask;
- var date=common.formatDateCHS(common.formatTime(new Date()),1);
- if (TestTask.ID)
- date=TestTask.TestTime;
- that.setData({
- LibraryName1:TestTask.LibraryName1,
- LibraryName2:TestTask.LibraryName2,
- BookID:TestTask.BookID,
- BookName:TestTask.BookName,
- UnitID:TestTask.UnitID,
- UnitName:TestTask.UnitName,
- TestType:TestTask.TestType,
- TestTypeName:TestTask.TestTypeName,
- ReportType:TestTask.ReportType,
- TestTime:date,
- });
- if (!TestTask)
- TestTask={};
- var TestTypeNumber=1;
- if (TestTask.TestType=="read")
- TestTypeNumber=2;
-
- var list = TestTask.List;
- if (list) {
- if (!TestTask.ID && TestTask.ReportType!="build"){
- that.data.WordList=[];
- for (var i = 0; i < list.length; i++) {
- var item={};
-
- item.Word=list[i].Word;
- if (list[i].Result == -1) {
- item.IsSelected=1;
- that.data.List[0].List.push(item);
- that.data.WordList.push(item.Word);
- } else if (list[i].Result == 0) {
- item.IsSelected=1;
- that.data.List[1].List.push(item);
- that.data.WordList.push(item.Word);
- } else if (list[i].Result == 1) {
- item.IsSelected=0;
- that.data.List[2].List.push(item);
- }
- }
- that.setData({
- WordList: that.data.WordList,
- });
- }
- else if (TestTask.ReportType=="build"){
- for(var i=0;i<that.data.List.length;i++){
- that.data.List[i].List=list[i];
- if (i==0 || i==2)
- that.data.List[i].IsShow=0;
- else
- that.data.List[i].Name="知识点";
- }
- that.setData({
- WordList:list[1],
- });
- }
- else
- that.data.List=list;
- that.setData({
- List:that.data.List,
- TestTypeNumber:TestTypeNumber,
- });
- if (TestTask.ReportType == "new")
- that.saveInfo();
- }
- },
- getReportID:function(id,callback){
- var that=this;
- main.getData('GetMiaoguoTestReportByID?ID='+id+'&UserID='+app.globalData.userInfo.UserID, function (data) {
- for(var i=0;i<that.data.List.length;i++){
- var arr=[];
- for(var j=0;j<data.List[i].length;j++){
- var obj={};
- obj.IsSelected=0;
- obj.Word=data.List[i][j];
- arr.push(obj);
- }
- that.data.List[i].List=arr;
- }
- data.List=that.data.List;
- callback(data);
- });
- },
- saveInfo:function(){
- var that=this;
- var userid=app.globalData.userInfo.UserID;
- var param1={};
- param1.BookID=that.data.BookID;
- param1.UnitID=that.data.UnitID;
- param1.UnitName=that.data.UnitName;
- param1.TestTypeName=that.data.TestTypeName;
- if (that.data.ReportType=="build"){
- if (that.data.TestType=="read")
- param1.IsBuildRead=1;
- else
- param1.IsBuildWrite=1;
- }
- else{
- if (that.data.TestType=="read")
- param1.IsTestRead=1;
- else
- param1.IsTestWrite=1;
- var arrAll=[];
- for(var i=0;i<that.data.List.length;i++){
- var arr=[];
- for(var j=0;j<that.data.List[i].List.length;j++){
- arr.push(that.data.List[i].List[j].Word);
- }
- arrAll.push(arr);
- }
- param1.JSONData=JSON.stringify(arrAll);
- }
- //debugger;
-
- main.postData('InsertTestReport2?UserID=' + userid, param1, function (data) {});
- },
- selectItem:function(e){
- var that=this;
- var index=e.currentTarget.dataset.index;
- var index2=e.currentTarget.dataset.index2;
- var list=that.data.List;
- that.data.WordList=[];
- for(var i=0;i<list.length;i++){
- if (index==i){
- for(var j=0;j<list[i].List.length;j++){
- if (index2==j){
- list[i].List[j].IsSelected=!list[i].List[j].IsSelected?1:0;
- }
- else if (index2=="all"){
- list[i].List[j].IsSelected=1;
- }
- else if (index2=="none"){
- list[i].List[j].IsSelected=0;
- }
- }
- }
- for(var j=0;j<list[i].List.length;j++){
- if (list[i].List[j].IsSelected==1)
- that.data.WordList.push(list[i].List[j]);
- }
- }
- that.setData({
- List:that.data.List,
- WordList:that.data.WordList,
- });
- },
- setMenu:function(e){
- var that=this;
- var index=e.currentTarget.dataset.index;
- if (index==1 && that.data.WordList.length==0){
- wx.showToast({
- title: '请选择题卡',
- });
- }
- else{
- that.setData({
- Menu:index,
- });
- }
- },
- setMenu2:function(e){
- var that=this;
- var index=e.currentTarget.dataset.index;
- var list=that.data.MenuList;
- for(var i=0;i<list.length;i++){
- list[i].IsSelected=0;
- if (index==i)
- list[i].IsSelected=1;
- }
- if (index==0){
- list[2].Name="选择卡单";
- that.data.FolderID=0;
- }
- else if (index==1){
- list[2].Name="选择卡单";
- that.data.FolderID=-1;//-1表示要生成一个新卡单
- }
- that.setData({
- MenuList:that.data.MenuList,
- FolderID:that.data.FolderID,
- });
- if (index==2){
- that.getFolder();
- }
- },
- getFolder:function(){
- var that=this;
- main.getData('GetUserFolderList?UserID='+app.globalData.userInfo.UserID, function (data) {
- that.setData({
- FolderList:data,
- Menu:2,
- });
- });
- },
- selectFolder:function(e){
- var that=this;
- var index=e.currentTarget.dataset.index;
- var list=that.data.MenuList;
- if (index==-1){
- list[0].IsSelected=1;
- list[2].IsSelected=0;
- list[2].Name="选择卡单";
- that.setData({
- FolderID:0,
- });
- }
- else{
- list[2].IsSelected=1;
- list[2].Name=that.data.FolderList[index].Name;
- that.setData({
- FolderID:that.data.FolderList[index].ID,
- });
- }
- that.setData({
- MenuList:that.data.MenuList,
- Menu:1,
- });
- },
- buildCard:function(e){
- var that=this;
- that.setData({
- Menu:0,
- });
- var param={};
- param.BookID=app.globalData.TestTask.BookID;
- param.UnitName=app.globalData.TestTask.UnitName;
- param.UnitID=app.globalData.TestTask.UnitID;
- param.TestType=app.globalData.TestTask.TestType;
- if(that.data.ReportType=="build"){
- param.WordList=[];
- for(var i=0;i<that.data.WordList.length;i++)
- param.WordList.push(that.data.WordList[i].Word);
- }
- else
- param.WordList=that.data.WordList;
- param.FolderID=that.data.FolderID;
- main.postData('BuildMiaoguoTestCard?UserID=' + app.globalData.userInfo.UserID, param, function (data) {
-
- });
- wx.navigateTo({
- url: "./build?Count="+that.data.WordList.length,
- });
- if(that.data.ReportType=="build")
- that.saveInfo();
- },
- closePanel:function(){
- wx.navigateBack({
- delta: 1,
- });
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|