| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- 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<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)
- count++;
- }
- }
- that.setData({
- List:that.data.List,
- Count:count,
- });
- },
- setMenu:function(e){
- var that=this;
- var index=e.currentTarget.dataset.index;
- that.setData({
- Menu:index,
- });
- },
- setMenu2:function(e){
- var that=this;
- var index=e.currentTarget.dataset.index;
- var list=that.data.MenuList,count=0;
- for(var i=0;i<list.length;i++){
- list[i].IsSelected=0;
- if (index==i)
- list[i].IsSelected=1;
- }
- that.setData({
- MenuList:that.data.MenuList,
- });
- },
- buildCard:function(e){
- var url = e.currentTarget.dataset.url;
- wx.navigateTo({
- url: url,
- });
- },
- 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,
- }
- },
- })
|