report.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. Count:0,
  7. TestTypeNumber:1,
  8. MenuList:[{Name:"不分配(默认)",IsSelected:0},{Name:"分配到新卡单",IsSelected:1},{Name:"选择卡单",IsSelected:0,HasArrow:1}],
  9. List:[
  10. {Name:"答错的",List:[],BColor:"#F26D5F"},
  11. {Name:"不会的",List:[],BColor:"#787878"},
  12. {Name:"答对的",List:[],BColor:"#51BE3D"}
  13. ]
  14. },
  15. onLoad: function (options) {
  16. var that = this;
  17. var testtask=app.globalData.TestTask;
  18. that.setData({
  19. ReportType: options.type,
  20. LibraryName:testtask.LibraryName,
  21. BookName:testtask.BookName,
  22. UnitName:testtask.UnitName,
  23. TestTypeName:testtask.TestTypeName,
  24. TestTime:common.formatDateCHS(common.formatTime(new Date()),1),
  25. Containnerheight: main.getWindowHeight(),
  26. ImagePath: app.globalData.uploadImageUrl,
  27. });
  28. that.init();
  29. },
  30. init: function () {
  31. var that = this;
  32. var TestTask = app.globalData.TestTask;
  33. if (!TestTask)
  34. TestTask={};
  35. var TestTypeNumber=1;
  36. if (TestTask.TestType=="read")
  37. TestTypeNumber=2;
  38. var list = TestTask.List;
  39. //debugger;
  40. if (list) {
  41. for (var i = 0; i < list.length; i++) {
  42. var item={};
  43. item.IsSelected=0;
  44. item.Word=list[i].Word;
  45. if (list[i].Result == -1) {
  46. that.data.List[0].List.push(item);
  47. } else if (list[i].Result == 0) {
  48. that.data.List[1].List.push(item);
  49. } else if (list[i].Result == 1) {
  50. that.data.List[2].List.push(item);
  51. }
  52. }
  53. that.setData({
  54. List:that.data.List,
  55. TestTypeNumber:TestTypeNumber,
  56. });
  57. if (that.data.ReportType == "new")
  58. that.saveInfo(TestTask);
  59. }
  60. },
  61. saveInfo:function(e){
  62. var that=this;
  63. var userid=app.globalData.userInfo.UserID;
  64. var param1={};
  65. param1.Category=e.Category;
  66. param1.LibraryName=that.data.LibraryName;
  67. param1.BookName=that.data.BookName;
  68. param1.UnitName=that.data.UnitName;
  69. param1.TestTypeName=that.data.TestTypeName;
  70. if (e.TestType=="read")
  71. param1.IsTestRead=1;
  72. else
  73. param1.IsTestWrite=1;
  74. //debugger;
  75. param1.JSONData=JSON.stringify(that.data.List);
  76. main.postData('InsertTestReport2?UserID=' + userid, param1, function (data) {
  77. if (data){
  78. }
  79. });
  80. },
  81. selectItem:function(e){
  82. var that=this;
  83. var index=e.currentTarget.dataset.index;
  84. var index2=e.currentTarget.dataset.index2;
  85. var list=that.data.List,count=0;
  86. for(var i=0;i<list.length;i++){
  87. if (index==i){
  88. for(var j=0;j<list[i].List.length;j++){
  89. if (index2==j){
  90. list[i].List[j].IsSelected=!list[i].List[j].IsSelected?1:0;
  91. }
  92. else if (index2=="all"){
  93. list[i].List[j].IsSelected=1;
  94. }
  95. else if (index2=="none"){
  96. list[i].List[j].IsSelected=0;
  97. }
  98. }
  99. }
  100. for(var j=0;j<list[i].List.length;j++){
  101. if (list[i].List[j].IsSelected==1)
  102. count++;
  103. }
  104. }
  105. that.setData({
  106. List:that.data.List,
  107. Count:count,
  108. });
  109. },
  110. setMenu:function(e){
  111. var that=this;
  112. var index=e.currentTarget.dataset.index;
  113. that.setData({
  114. Menu:index,
  115. });
  116. },
  117. setMenu2:function(e){
  118. var that=this;
  119. var index=e.currentTarget.dataset.index;
  120. var list=that.data.MenuList,count=0;
  121. for(var i=0;i<list.length;i++){
  122. list[i].IsSelected=0;
  123. if (index==i)
  124. list[i].IsSelected=1;
  125. }
  126. that.setData({
  127. MenuList:that.data.MenuList,
  128. });
  129. },
  130. buildCard:function(e){
  131. var url = e.currentTarget.dataset.url;
  132. wx.navigateTo({
  133. url: url,
  134. });
  135. },
  136. closePanel:function(){
  137. wx.navigateBack({
  138. delta: 1,
  139. });
  140. },
  141. onShareAppMessage: function () {
  142. return {
  143. title: app.globalData.ShareTitle,
  144. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  145. imageUrl: app.globalData.ShareImage,
  146. }
  147. },
  148. })