| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- const app = getApp();
- Page({
- data: {
- List: [],
- IsSelectGrade: false,
- TestSelectGrade: 0,
- },
- onLoad: function (options) {
- var that = this;
- that.setData({
- Containnerheight: main.getWindowHeight(),
- });
- main.getHanzi(function (arr) {
- if (!arr) {
- wx.removeStorageSync("HanziUpdateTime");
- wx.removeStorageSync("HanziAll");
- main.getHanzi(function (arr) {});
- }
- });
- },
- onShow: function () {
- this.getTestReportList();
- },
- showSelectGrade: function () {
- var that = this;
- that.setData({
- IsSelectGrade: true,
- });
- },
- closeSelectGrade: function () {
- var that = this;
- that.setData({
- IsSelectGrade: false,
- });
- },
- goto: function (e) {
- var url = e.currentTarget.dataset.url;
- wx.navigateTo({
- url: url,
- });
- },
- getTestReportList: function () {
- var that = this;
- that.setData({
- GradeArr: [{
- Name: "一年级",
- Name2: "语文一年级",
- Select: "Select",
- List: [{
- ID: 1,
- Type: "Shizi",
- Name: "语文识字",
- Name2: "上学期",
- Finish: 0,
- Total: 12,
- Image: "../images/examine_subject_a001.png"
- }, {
- ID: 2,
- Type: "Shizi",
- Name: "语文识字",
- Name2: "下学期",
- Finish: 0,
- Total: 14,
- Image: "../images/examine_subject_a002.png"
- }, ]
- },
- {
- Name: "二年级",
- Name2: "语文二年级",
- Select: "",
- List: [{
- ID: 3,
- Type: "Shizi",
- Name: "语文识字",
- Name2: "上学期",
- Finish: 0,
- Total: 16,
- Image: "../images/examine_subject_a003.png"
- }, {
- ID: 4,
- Type: "Shizi",
- Name: "语文识字",
- Name2: "下学期",
- Finish: 0,
- Total: 16,
- Image: "../images/examine_subject_a004.png"
- }, ]
- },
- {
- Name: "三年级",
- Name2: "语文三年级",
- Select: "",
- List: [{
- ID: 5,
- Type: "Shizi",
- Name: "语文识字",
- Name2: "上学期",
- Finish: 0,
- Total: 16,
- Image: "../images/examine_subject_a005.png"
- }, {
- ID: 6,
- Type: "Shizi",
- Name: "语文识字",
- Name2: "下学期",
- Finish: 0,
- Total: 16,
- Image: "../images/examine_subject_a006.png"
- }, ]
- },
- {
- Name: "四年级",
- Name2: "语文四年级",
- Select: "",
- List: [{
- ID: 7,
- Type: "Shizi",
- Name: "语文识字",
- Name2: "上学期",
- Finish: 0,
- Total: 16,
- Image: "../images/examine_subject_a007.png"
- }, ]
- },
- {
- Name: "五年级",
- Name2: "语文五年级",
- Select: "",
- List: [{
- ID: 9,
- Type: "Shizi",
- Name: "语文识字",
- Name2: "上学期",
- Finish: 0,
- Total: 16,
- Image: "../images/examine_subject_a009.png"
- }, ]
- },
- {
- Name: "六年级",
- Name2: "语文六年级",
- Select: "",
- List: [
- {
- ID: 11,
- Type: "Shizi",
- Name: "语文识字",
- Name2: "上学期",
- Finish: 0,
- Total: 16,
- Image: "../images/examine_subject_a011.png"
- },
- ]
- },
- // {
- // Name: "英语常用词",
- // Name2: "英语常用词",
- // Select: "",
- // List: [
- // {
- // ID: 13,
- // Type: "Word",
- // Name: "常用词1",
- // Name2: "词汇1~220",
- // Finish: 0,
- // Total: 22,
- // Image: "../images/examine_subject_b001.png"
- // },
- // {
- // ID: 14,
- // Type: "Word",
- // Name: "常用词2",
- // Name2: "词汇221~500",
- // Finish: 0,
- // Total: 28,
- // Image: "../images/examine_subject_b002.png"
- // },
- // {
- // ID: 15,
- // Type: "Word",
- // Name: "常用词3",
- // Name2: "词汇500~1000",
- // Finish: 0,
- // Total: 25,
- // Image: "../images/examine_subject_b003.png"
- // },
- // ]
- // },
- ],
- })
- var userid = app.globalData.userInfo.UserID;
- main.getData('GetTestReportList?UserID=' + userid, function (data) {
- if (data) {
- var dataTemp = [];
- for (var i = 0; i < data.length; i++) {
- for (var j = 0; j < dataTemp.length; j++) {
- if (dataTemp[j].Name[0] == data[i].Name[0] &&
- dataTemp[j].Name[1] == data[i].Name[1] &&
- dataTemp[j].TestType == data[i].TestType &&
- data[i].IsFinished == 1
- ) {
- dataTemp.splice(j, 1);
- break;
- }
- }
- dataTemp.push(data[i]);
- }
- for (var i = 0; i < dataTemp.length; i++) {
- var name = dataTemp[i].Name[0].split(" ");
- for (var j = 0; j < that.data.GradeArr.length; j++) {
- var item = that.data.GradeArr[j];
- if (name[0] == item.Name) {
- for (var k = 0; k < item.List.length; k++) {
- if (name[1] == item.List[k].Name && name[2] == item.List[k].Name2) {
- if (dataTemp[i].IsFinished == 1)
- item.List[k].Finish++;
- }
- }
- }
- }
- }
- for (var j = 0; j < that.data.GradeArr.length; j++) {
- var item = that.data.GradeArr[j];
- for (var k = 0; k < item.List.length; k++) {
- item.List[k].Finished = Math.round(100 * item.List[k].Finish / item.List[k].Total);
- }
- }
- that.setData({
- TestReport: data,
- GradeArr: that.data.GradeArr,
- });
- wx.setStorageSync("UserTestReport", data);
- common.getStorageValue(that, "TestSelectGrade", 0, function () {
- that.onSelectGrade({
- currentTarget: {
- dataset: {
- value: that.data.TestSelectGrade
- }
- }
- });
- });
- }
- });
- },
- onSelectGrade: function (e) {
- var index = e.currentTarget.dataset.value;
- for (var i = 0; i < this.data.GradeArr.length; i++)
- this.data.GradeArr[i].Select = "";
- this.data.GradeArr[index].Select = "Select";
- this.setData({
- TestSelectGrade: index,
- GradeArr: this.data.GradeArr,
- });
- this.closeSelectGrade();
- wx.setStorageSync("TestSelectGrade", index);
- },
- gotoTestReportInfo: function (e) {
- var id = e.currentTarget.dataset.id;
- var userid = app.globalData.userInfo.UserID;
- //todo
- // main.getData('GetTestReportInfo?UserID=' + userid+'&ID='+id, function (data) {
- // if (data) {
- // wx.setStorageSync("TestTask", data);
- // wx.navigateTo({
- // url: "./report?type=edit",
- // });
- // }
- // });
- main.GetTestReportInfo(id,function(data){
- wx.setStorageSync("TestTask", data);
- wx.navigateTo({
- url: "./report?type=edit",
- });
- });
- },
- onUnload: function () {
- wx.removeStorageSync("UserTestReport");
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|