| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- const app = getApp();
- var hasStart = {};
- Page({
- data: {
- ImagePath: app.globalData.uploadImageUrl,
- IsPoemRead: 0,
- ShowKaiti: 0,
- ShowSoundMark: 1,
- CSS: {},
- IsHelp: false,
- IsShowHelp: false,
- HelpArr: ["help_board_tips_zhidingduanluo", "help_board_tips_tiaozhuanchaxun"],
- },
- onLoad: function (options) {
- var that = this;
- that.setData({
- Containnerheight: main.getWindowHeight(),
- });
- this.getList();
- hasStart = {};
- },
- onShow: function () {
- var that = this;
- if (wx.getStorageSync("IsHelpAddInfomation") == 1) {
- that.setData({
- IsShowHelp: true,
- });
- main.ShowHelp(that, "#helpTianKong0", "down", "选择拼音作为问题,点一下","Left");
- }
- else{
- that.setData({
- IsShowHelp:false,
- });
- }
- },
- getList: function () {
- if (app.globalData.SearchItem) {
- this.getListFinished(app.globalData.SearchItem);
- }
- },
- getListFinished: function (data) {
- var that = this;
- if (data.CHN) {
- if (data.CHN.PeomContent)
- data.TypeName = "S";
- else if (data.CHN.HanZi.length == 1)
- data.TypeName = "Z";
- else
- data.TypeName = "C";
- } else if (data.ENG) {
- data.TypeName = "D";
- }
- if (data.CHN && data.CHN.KaitiArr) {
- if (data.CHN.KaitiArr.length == 1) {
- data.CHN.KaitiWidth = "";
- } else {
- data.CHN.KaitiWidth = "panelItemSmall";
- }
- if (data.CHN.BiShunArr2.length == 1) {
- data.CHN.BiShunWidth = "";
- } else {
- data.CHN.BiShunWidth = "panelItemSmall";
- }
- }
- if (data.ENG && data.ENG.Paraphrase && common.checkIsArray(data.ENG.Paraphrase)) {
- for (var i = 0; i < data.ENG.Paraphrase.length; i++) {
- var item = data.ENG.Paraphrase[i];
- item.PartOfSpeech = common.ReplaceAllString(item.PartOfSpeech, "释义", "");
- }
- }
- if (data.ENG && data.ENG.ExamplesSentences) {
- for (var i = 0; i < data.ENG.ExamplesSentences.length; i++) {
- var item = data.ENG.ExamplesSentences[i];
- var obj = [{
- ContentType: 0,
- Content: ""
- }, {
- ContentType: 1,
- Content: item[0]
- }, {
- ContentType: 2,
- Content: ""
- }, {
- ContentType: 3,
- Content: ""
- }];
- var obj2 = main.changeStringToView(obj);
- var str = obj2.Field[1][0].Content;
- item.push(str);
- item[1] = common.ReplaceAllString(item[1], "<b>", "");
- item[1] = common.ReplaceAllString(item[1], "</b>", "");
- }
- }
- that.setData({
- Result: data,
- })
- },
- getInputData: function (e) {
- var that = this;
- //console.log("time1:"+new Date().getTime());
- var type = e.currentTarget.dataset.type;
- var css = e.currentTarget.dataset.css;
- var tag = e.currentTarget.dataset.tag;
- var content = e.currentTarget.dataset.content;
- var soundmark = e.currentTarget.dataset.soundmark;
- //console.log(content);
- //console.log("time2:" + new Date().getTime());
- if (!this.data.CSS[css] || this.data.CSS[css].Number == "") {
- if (!this.data.CSS[css])
- this.data.CSS[css] = {};
- this.data.CSS[css].Css1 = "Select1";
- this.data.CSS[css].Css2 = "Select2";
- this.data.CSS[css].Content = content;
- this.data.CSS[css].Type = type;
- this.data.CSS[css].Tag = tag;
- if (tag == "发音")
- this.data.CSS[css].SoundMark = soundmark;
- if (tag == "默写" || tag == "拼音") {
- var soundmark = e.currentTarget.dataset.soundmark;
- if (soundmark)
- this.data.CSS[css].SoundMark = e.currentTarget.dataset.soundmark;
- }
- this.data.CSS[css].Number = "1";
- if (app.globalData.TempFieldNumber > 0 && !hasStart[css]) {
- this.data.CSS[css].Number = app.globalData.TempFieldNumber;
- hasStart[css] = true;
- }
- } else if (this.data.CSS[css].Number == "3") {
- this.data.CSS[css].Css1 = "";
- this.data.CSS[css].Css2 = "";
- this.data.CSS[css].Number = "";
- this.data.CSS[css].Content = "";
- this.data.CSS[css].Type = "";
- this.data.CSS[css].Tag = "";
- } else {
- this.data.CSS[css].Number = Number(this.data.CSS[css].Number) + 1;
- }
- //console.log("time3:" + new Date().getTime());
- this.setData({
- CSS: this.data.CSS,
- });
- //console.log("time4:" + new Date().getTime());
- if (wx.getStorageSync("IsHelpAddInfomation") == 1) {
- that.setData({
- IsShowHelp: true,
- });
- if (this.data.CSS[css].Number == 0)
- main.ShowHelp(that, "#HelpHanZi", "down", "选择文字作为答案,\n点两下,注意是点两下","Left");
- else if (this.data.CSS[css].Number == 1)
- main.ShowHelp(that, "#HelpHanZi", "down", "选择文字作为答案,\n点两下,注意是点两下\n让左侧数字成为2","Left");
- else if (this.data.CSS[css].Number == 2)
- main.ShowHelp(that, "#btnAdd", "down", "请点“添加”按钮","Left");
- }
- },
- addData: function () {
- if (JSON.stringify(this.data.CSS) != "{}") {
- for (var item in this.data.CSS) {
- if (this.data.CSS[item].Number == "") {
- delete this.data.CSS[item];
- }
- }
- app.globalData.TempFieldNumber = 0;
- var id = app.globalData.TempMiaoguoCardID;
- var list = app.globalData.CardList;
- for (var i = 0; i < list.length; i++) {
- if (id == list[i].MiaoguoCardID) {
- for (var key in this.data.CSS) {
- var item = this.data.CSS[key];
- if (item.Tag) {
- var strArrTag = list[i].Content[0].Content + ",";
- if (list[i].Content[0].Content.constructor == Array)
- strArrTag = list[i].Content[0].Content.join(",") + ",";
- else
- list[i].Content[0].Content = list[i].Content[0].Content.split(",");
- var tags = item.Tag.split(",");
- for (var j = 0; j < tags.length; j++) {
- if (tags[i]) {
- if (strArrTag.indexOf(tags[i] + ",") < 0)
- list[i].Content[0].Content.push(tags[i]);
- }
- }
- }
- var str = "";
- if (item.Type == "image") {
- item.Content = main.encryptUrl(item.Content);
- str = "[图]" + item.Content + "[/图]";
- } else if (item.Type == "sound") {
- str = "[读]" + item.Content + "[/读]";
- if (item.Tag == "发音") {
- var strTemp = item.Content.substr(0, 1);
- if (this.data.ShowSoundMark == "1")
- str = "[读 src='" + item.SoundMark + "']" + item.Content + "[/读]";
- else
- str = "[读 src='" + item.SoundMark + "']" + strTemp + "式[/读]";
- } else if (item.Tag == "拼音" || item.Tag == "默写") {
- if (item.SoundMark) {
- if (this.data.Result.CHN.HanZi) {
- var sound = this.data.Result.CHN.HanZi;
- sound = main.GetSoundError(sound);
- str = "[读 src='" + sound + "']" + item.Content + "[/读]";
- } else
- str = "[读 src='" + item.SoundMark + "']" + item.Content + "[/读]";
- } else {
- var sound = this.data.Result.CHN.HanZi + "(" + main.getPinyinNormal(item.Content) + ")";
- sound = main.GetSoundError(sound);
- str = "[读 src='" + sound + "']" + item.Content + "[/读]";
- }
- }
- } else {
- if (item.Tag == "诗词" || item.Tag == "译文") {
- if (common.checkIsArray(item.Content) &&
- common.checkIsArray(item.Content[0])) {
- for (var j = 0; j < item.Content.length; j++) {
- if (common.checkIsArray(item.Content[j])) {
- item.Content[j] = item.Content[j].join("");
- }
- }
- if (common.checkIsArray(item.Content))
- str = item.Content.join("\n");
- else
- str = item.Content;
- } else {
- if (common.checkIsArray(item.Content))
- str = item.Content.join("");
- else
- str = item.Content;
- }
- if (item.Tag == "诗词" && this.data.IsPoemRead == 1) {
- var arr = str.split("\n");
- var arr2 = [];
- for (var j = 0; j < arr.length; j++) {
- arr2.push("[读]" + arr[j] + "[/读]");
- }
- str = arr2.join("\n");
- }
- } else
- str = item.Content;
- }
- if (this.data.Result && this.data.Result.CHN && this.data.Result.CHN.PinYin && this.data.Result.CHN.PinYin.length == 1) {
- if (item.Tag == "释义") {
- str = str.substr(str.indexOf("[/读]") + 4);
- }
- }
- if (list[i].Content[item.Number].Content) {
- if (item.Tag == "组词" || item.Tag == "近义词" || item.Tag == "反义词") {
- str = "\n" + str;
- } else {
- str = "\n\n" + str;
- }
- }
- list[i].Content[item.Number].Content += str;
- if (list[i].Content[item.Number].Content.indexOf("\n\n") == 0)
- list[i].Content[item.Number].Content = list[i].Content[item.Number].Content.substr(2);
- if (item.Tag == "诗词") {
- if (list[i].Content[item.Number].Content.indexOf("\n") > 0 && list[i].Content[item.Number].Content.indexOf("[") != 0) {
- list[i].Content[item.Number].Content = "\n\n" + list[i].Content[item.Number].Content;
- }
- }
- }
- break;
- }
- }
- app.globalData.CardList = list;
- wx.navigateBack({
- delta: app.globalData.TempSearchBackNumber,
- });
- } else {
- wx.showToast({
- title: '请选择内容',
- })
- }
- },
- changeBishun: function (e) {
- var id = e.currentTarget.dataset.id;
- if (id === "0") {
- for (var i = 0; i < 6; i++) {
- delete this.data.CSS["CHN_BiShunArr2_" + i];
- }
- } else if (id === "1") {
- for (var i = 0; i < 6; i++) {
- delete this.data.CSS["CHN_KaitiArr_" + i];
- }
- }
- this.setData({
- ShowKaiti: id,
- CSS: this.data.CSS,
- });
- },
- changeSoundMark: function (e) {
- var id = e.currentTarget.dataset.id;
- this.setData({
- ShowSoundMark: id,
- });
- },
- changeRead: function (e) {
- var id = e.currentTarget.dataset.id;
- var count = Object.getOwnPropertyNames(this.data.CSS).length;
- for (var i = 0; i < count; i++) {
- delete this.data.CSS["CHN_PeomContent_" + i];
- }
- delete this.data.CSS["CHN_PeomContent"];
- this.setData({
- IsPoemRead: id,
- CSS: this.data.CSS,
- });
- },
- changeInfomation: function (e) {
- var word = e.currentTarget.dataset.word;
- if (word.indexOf(";") > 0) {
- word = word.substr(0, word.indexOf(";"));
- }
- var url = 'GetMiaoguoAISearch2?UserID=' + app.globalData.userInfo.UserID;
- url += "&Word=" + word;
- if (!e.currentTarget.dataset.ischn)
- url += "&SearchType=zici";
- wx.showLoading();
- main.getData(url, function (data) {
- wx.hideLoading();
- if (data && (data.CHN || data.ENG)) {
- var obj = {};
- var len = 26;
- obj.Value = data;
- if (data.CHN) {
- obj.Key = data.CHN.HanZi;
- obj.Content = data.CHN.PinYin[0].explain;
- if (obj.Key.length == 1)
- obj.TypeName = "Z";
- else
- obj.TypeName = "C";
- obj.Url = "&UserID=" + app.globalData.userInfo.UserID + "&Word=" + obj.Key;
- } else if (data.ENG) {
- obj.Key = data.ENG.Word;
- obj.TypeName = "D";
- if (data.ENG.Soundmark)
- obj.Remark = data.ENG.Soundmark.Eng;
- if (data.ENG.Paraphrase && data.ENG.Paraphrase[0] && data.ENG.Paraphrase[0].ParaphraseList)
- obj.Content = data.ENG.Paraphrase[0].ParaphraseList;
- obj.Url = "&UserID=" + app.globalData.userInfo.UserID + "&Word=" + obj.Key;
- }
- if (data.CHN && data.CHN.PinYin && data.CHN.PinYin.length > 0) {
- obj.Remark = data.CHN.PinYin[0].pinyin;
- }
- if (obj.Content && obj.Content.length > len)
- obj.Content = obj.Content.substr(0, len) + "...";
- main.updateSearchList(obj);
- if (app.globalData.TempSearchBackNumber == 0)
- app.globalData.TempSearchBackNumber = 1;
- else if (app.globalData.TempSearchBackNumber >= 1)
- app.globalData.TempSearchBackNumber = 2;
- wx.redirectTo({
- url: './addInfomationDetail',
- });
- } else {
- wx.showToast({
- title: '无资料',
- image: "../images/universalpic_exclamation_white_120x120.png",
- });
- }
- });
- },
- showHelp0: function () {
- var that = this;
- that.setData({
- IsHelp: true,
- });
- },
- closeHelp0: function () {
- this.setData({
- IsHelp: false,
- });
- },
- closeHelp: function () {
- this.setData({
- IsShowHelp: false,
- });
- wx.setStorageSync('IsHelpAddInfomation', 0);
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|