| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- import constant from '../../utils/constant';
- const app = getApp();
- var isClick = true;
- var isStart = true;
- Page({
- data: {
- IsSelect: false,
- ImagePath: app.globalData.uploadImageUrl,
- },
- onLoad: function (options) {
- var that = this;
- that.setData({
- BookID: options.id,
- Containnerheight: main.getWindowHeight(),
- Name1: options.name1,
- });
- isClick = true;
- main.getHanzi(function () {
- main.getEnglish(function () {
- that.init();
- isStart=false;
- });
- });
- },
- onUnload:function(){
- isStart = true;
- },
- onShow:function(){
- if (!isStart)
- this.init();
- },
- init: function () {
- var that = this;
- var name = that.data.Name1;
- if (name.indexOf(" ") > 0)
- name = name.substr(name.indexOf(" ") + 1);
-
- wx.setNavigationBarTitle({
- title: name
- });
-
- var arr = [];
- var listType="hanzi",fieldName="单词",fieldName2="说含义";
- if (that.data.BookID > 164){
- arr = wx.getStorageSync("CEWEngList");
- listType="english";
- }
- else if (that.data.BookID > 160){
- arr = wx.getStorageSync("BEWEngList");
- listType="english";
- }
- else if (that.data.BookID > 150){
- arr = wx.getStorageSync("MiddleSchoolTestWords");
- listType="english";
- }
- else if (that.data.BookID > 140){
- arr = wx.getStorageSync("EEWEngList");
- listType="english";
- }
- else if (that.data.BookID > 130){
- arr = wx.getStorageSync("CambridgeEngList");
- listType="english";
- if (that.data.BookID==135)
- fieldName="词组";
- }
- else if (that.data.BookID > 120){
- arr = wx.getStorageSync("NewConceptEngList");
- listType="english";
- }
- else if (that.data.BookID > 110){
- arr = wx.getStorageSync("EnglishAll");
- listType="english";
- }
- else if (that.data.BookID > 100){
- arr = wx.getStorageSync("PhoneticEngList");
- fieldName="音标";
- fieldName2="";
- listType="english";
- }
- else if (that.data.BookID >= 43 && that.data.BookID <= 44){
- arr = constant.arrPinyinList;
- fieldName="拼音";
- fieldName2="";
- listType="音";
- }
- else{
- arr = wx.getStorageSync("HanziAll");
- fieldName="汉字";
- fieldName2="";
- if (that.data.BookID == 73){
- fieldName="含义";
- listType="Wenyanwen";
- }
- else if (that.data.BookID == 86){
- fieldName="句子";
- listType="Guwen";
- }
- else if (that.data.BookID >= 45 && that.data.BookID <= 60){
- fieldName="词语";
- }
- }
-
- that.setData({
- ListType: listType,
- FieldName:fieldName,
- FieldName2:fieldName2,
- });
-
- if (that.data.BookID < 43 ||that.data.BookID > 44){
- arr = JSON.parse(arr);
- }
- var id = that.data.BookID;
-
- var testReportList = wx.getStorageSync("UserTestReport");
-
- for (var i = 0; i < arr.length; i++) {
- if (arr[i].ID == id) {
- var list = arr[i].Units;
- for (var j = 0; j < list.length; j++) {
- var str = "";
- for (var k = 0; k < list[j].Words.length; k++) {
- if (k < 27 && k < list[j].Words.length - 1){
- if (that.data.BookID==73)
- str += list[j].Words[k] + " ";
- else
- str += list[j].Words[k] + "、";
- }
- else if (k == list[j].Words.length - 1)
- str += list[j].Words[k];
- else {
- str += list[j].Words[k] + "…";
- break;
- }
- }
- list[j].WordList = str;
- list[j].TestTypeReadFinished = true;
- list[j].TestTypeWriteFinished = true;
- for (var k = 0; k < testReportList.length; k++) {
- if (testReportList[k].Name[0] == that.data.Name1 &&
- testReportList[k].Name[1] == list[j].Name) {
- var testRightCount = 0;
- if (testReportList[k].TestRightStr){
- testRightCount = testReportList[k].TestRightStr.length;
- if (id==73 && testReportList[k].TestRightStr.length>0){
- testRightCount=testReportList[k].TestRightStr.toString().split(",").length;
- }
- }
- var testWrongCount = 0;
- if (testReportList[k].TestWrongStr){
- testWrongCount = testReportList[k].TestWrongStr.length;
- if (id==73 && testReportList[k].TestWrongStr.length>0){
- var arrTemp=testReportList[k].TestWrongStr.toString().split(",");
- testWrongCount=arrTemp.length;
- }
- }
- var testSkipCount = 0;
- if (testReportList[k].TestSkipStr){
- testSkipCount = testReportList[k].TestSkipStr.length;
- if (id==73 && testReportList[k].TestSkipStr.length>0){
- testSkipCount=testReportList[k].TestSkipStr.toString().split(",").length;
- }
- }
- if (testReportList[k].TestType == "read") {
- if (testReportList[k].IsFinished == 1)
- list[j].TestTypeRead = 1;
- if ((testRightCount + testWrongCount + testSkipCount) < testReportList[k].TestTotal) {
- list[j].TestTypeReadFinished = false;
- }
- list[j].ReadReportID = testReportList[k].ID;
- }
- if (testReportList[k].TestType == "write") {
- if (testReportList[k].IsFinished == 1)
- list[j].TestTypeWrite = 1;
- if ((testRightCount + testWrongCount + testSkipCount) < testReportList[k].TestTotal) {
- list[j].TestTypeWriteFinished = false;
- }
- list[j].WriteReportID = testReportList[k].ID;
- }
- }
- }
- }
- //console.log("List:"+list.length);
- that.setData({
- List: list,
- UnitsID: id,
- });
- }
- }
- },
- onShowFrame: function (e) {
- var selectItem;
- var id = e.currentTarget.dataset.id;
- for (var i = 0; i < this.data.List.length; i++) {
- if (id == this.data.List[i].ID) {
- selectItem = this.data.List[i];
- }
- }
- this.setData({
- IsSelect: true,
- SelectItem: selectItem,
- });
- },
- onClose: function () {
- this.setData({
- IsSelect: false,
- });
- },
- goto: function (e) {
- var url = e.currentTarget.dataset.url;
- wx.navigateTo({
- url: url,
- });
- this.onClose();
- },
- gotoTestReportInfo: function (e) {
- var that = this;
- if (isClick) {
- isClick = false;
- setTimeout(function () {
- isClick = true;
- }, 2000);
- var id = e.currentTarget.dataset.id;
- var userid = app.globalData.userInfo.UserID;
- if (id) {
- var reporttype = e.currentTarget.dataset.type;
- if (reporttype=="restart"){
- var testReportList = wx.getStorageSync("UserTestReport");
- for(var i=0;i<testReportList.length;i++){
- if (id==testReportList[i].ID){
- testReportList[i].TestRightStr="";
- testReportList[i].TestWrongStr="";
- testReportList[i].TestSkipStr="";
- testReportList[i].TestExistStr="";
- break;
- }
- }
- wx.setStorageSync("UserTestReport", testReportList);
- }
- main.GetTestReportInfo(id, function (data) {
- data.BookID=that.data.BookID;
- wx.setStorageSync("TestTask2", data);
- that.onClose();
- var url="./item?type=" + reporttype+"&bookid="+that.data.BookID;
- var testtype=e.currentTarget.dataset.testtype;
- if (testtype)
- url+="&testtype="+testtype;
- wx.navigateTo({
- url: url,
- });
- });
- } else {
- that.onClose();
- var url = e.currentTarget.dataset.url+"&bookid="+that.data.BookID;
- wx.navigateTo({
- url: url,
- });
- }
- }
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|