| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- import common from '../../utils/util';
- import server from '../../utils/main';
- const app = getApp();
- Page({
- data: {
- },
- onLoad: function (options) {
- this.setData({
- Height: common.getSystemHeight(),
- ExampleArray: this.getExampleArray(),
- IsSearchResult: false,
- });
- },
- getExampleArray: function () {
- var result = [];
- var arr = JSON.parse(wx.getStorageSync("HanziAll"));
- for (var i = 0; i < arr.length; i++) {
- var rnd1 = common.random(0, arr[i].Units.length - 1);
- var rnd2 = common.random(0, arr[i].Units[rnd1].Words.length - 1);
- var isfinished = false;
- var arrReview = wx.getStorageSync("ReviewList");
- for (var l = 0; l < arrReview.length; l++) {
- if (arrReview[l].Word == arr[i].Units[rnd1].Words[rnd2].Name) {
- isfinished = true;
- break;
- }
- }
- arr[i].Units[rnd1].Words[rnd2].BookID = arr[i].ID;
- arr[i].Units[rnd1].Words[rnd2].UnitID = arr[i].Units[rnd1].ID;
- arr[i].Units[rnd1].Words[rnd2].WordID = rnd2;
- arr[i].Units[rnd1].Words[rnd2].IsFinished = isfinished;
- result.push(arr[i].Units[rnd1].Words[rnd2]);
- }
- return result;
- },
- researchWord: function (e) {
- var that = this;
- that.setData({
- IsSearchResult: false,
- });
- var result = false;
- var word = e.detail.value;
- if (common.IsChinese(word)) {
- server.getData('SearchHanzi?Word=' + word, function (data) {
- if (data) {
- wx.setStorageSync("CurrentSearchWord", data);
- wx.setStorageSync('SelectedRandom', false);
- wx.setStorageSync('IsAutoPage', false);
- wx.navigateTo({
- url: "./detail?Type=search",
- });
- }
- else{
- that.setData({
- IsSearchResult: true,
- });
- }
- });
- }
- else {
- that.setData({
- IsSearchResult: true,
- });
- }
- },
- goto: function (e) {
- var bookid = e.currentTarget.dataset.bookid;
- var unitid = e.currentTarget.dataset.unitid;
- var wordid = e.currentTarget.dataset.wordid;
- var isfinished = e.currentTarget.dataset.isfinished;
- if (!wordid)
- wordid = 0
-
- wx.setStorageSync('SelectedRandom', false);
- wx.setStorageSync('IsAutoPage', false);
-
- wx.navigateTo({
- url: "./detail?Type=search&bookid=" + bookid + "&unitid=" + unitid + "&wordid=" + wordid + "&isfinished=" + isfinished,
- });
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: 'pages/index/index?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: '../../images/07001.png',
- }
- },
- })
|