| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- import constant1 from '../../utils/constant';
- const app = getApp();
- var arrTag = [];
- var tempCursor = undefined,
- btnName = "";
- var arrSoundMark = [];
- var isUnload = true;
- var isEdit = true;
- var isSave = true;
- var interval;
- var timeoutUploadImage = 0;
- var intervalRecorder = 0; //录音计时器
- var recorderManager;
- var tempRecorderFile = "";
- var innerAudioContext;
- var isViolate = false; //是否是违禁词
- var isFirstAdd = true;//是第一个填加
- var isAddFolder = false;//用于新增卡单时用
- var isCancel=false;//是否放弃题卡内容
- Page({
- data: {
- ImagePath: app.globalData.uploadImageUrl,
- HiddenFieldEdit: true,
- FieldContent: "",
- SoundSign: "[读]",
- LineSign: "[线]",
- HighlighterSign: "[光]",
- IsPracticeTime: false,
- IsRecorder: false,
- IsIPhoneX: app.globalData.IsIPhoneX,
- IsAndroid: app.globalData.IsAndroid,
- IsTagShow:false,
- PageTitle:"新建题卡",
- InputHeight:315,
- IsShowMenu:false,
- IsHelp:false,
- HelpArr:["help_board_tips_jiaziliao","help_board_tips_diankaigengduo","help_board_tips_lianxvxinjian","help_board_tips_meihua","help_board_tips_geshi"],
- IsFontsize:false,
- IsCollect:0,
- BtnSaveSelectCss:"",
- },
- onReady: function () {
- recorderManager = wx.getRecorderManager();
- recorderManager.onStart(() => {
- console.log('recorder start')
- });
- recorderManager.onStop((res) => {
- console.log('recorder stop', res);
- tempRecorderFile = res.tempFilePath;
- });
- recorderManager.onError((err) => {});
- },
- //获取导航栏高度
- getBarInfo(e) {
- var h=e.detail.topBarHeight;
- h=h*2;
- var h2=0;
- var h3=0;
- if (app.globalData.IsIPad){
- h2=-68;
- h3=-100;
- }
- this.setData({
- topBarHeight: h,
- topBarHeightIPad: h2,
- topBarHeightIPad2: h3,
- })
- },
- onLoad: function (options) {
- var that = this;
- var fieldNumber = 0;
- if (options.fieldid)
- fieldNumber = options.fieldid;
- var cardtype=options.CardType;
- if (!cardtype)
- cardtype=0;
- else
- cardtype=Number(cardtype);
- var folderid=options.FolderID;
- var foldername="";
- if (!folderid)
- folderid=0;
- else{
- folderid=Number(folderid);
- foldername=options.FolderName;
- }
-
- that.setData({
- Containnerheight: main.getWindowHeight(),
- UpdateType: options.type,
- MiaoguoCardID: options.id,
- FieldNumber: fieldNumber,
- IsShow: app.globalData.userInfo.IsShow,
- CardType:cardtype,
- PracticeCardType: constant1.arrStudyPattern[cardtype]+"题卡",
- FolderID:folderid,
- FolderName:foldername,
- LimitTime:common.formatTime(new Date()),
- PracticeTimeStr:common.formatDateCHS(common.formatTime(new Date())),
- FontSize:48,
- FontSizeName:"标准",
- OpenType:options.opentype,
- });
- var list = app.globalData.CardList;
- for (var i = 0; i < list.length; i++) {
- if (that.data.MiaoguoCardID == list[i].MiaoguoCardID) {
- wx.setStorageSync("TempCardInfo", list[i]);
- break;
- }
- }
- app.globalData.TempFieldNumber = 0;
- app.globalData.TempMiaoguoCardID = that.data.MiaoguoCardID;
- isViolate = false;
- isFirstAdd = true;
- if (app.globalData.IsIPhoneX){
- that.setData({
- InputHeight: 480,
- });
- }
- if (options.type=="add3"){
- that.gotoAddInfomationDetail(options);
- }
- if (options.type.indexOf("add")>=0)
- common.getStorageValue(that, "IsShowAddHelp", 0, function () {});
-
- },
- onShow: function () {
- var that = this;
- if (that.data.UpdateType == "add" || that.data.UpdateType == "add3") {
- that.initAddCard();
- } else {
- var card = {},
- content = "";
-
- var list = app.globalData.CardList;
- for (var i = 0; i < list.length; i++) {
- if (that.data.MiaoguoCardID == list[i].MiaoguoCardID) {
- card = main.changeStringToView(list[i].Content);
- card.MiaoguoCardID = list[i].MiaoguoCardID;
- if (list[i].CardType==0 || list[i].CardType==1 || list[i].CardType==-1)
- card.CardType=list[i].CardType;
- else if (that.data.CardType)
- card.CardType=that.data.CardType;
- else
- card.CardType=0;
-
- card.IsCollect=list[i].IsCollect;
- if (that.data.IsCollect)
- card.IsCollect=that.data.IsCollect;
- else if (!card.IsCollect)
- card.IsCollect=0;
- card.FontSize=list[i].FontSize;
- if (that.data.FontSize)
- card.FontSize=that.data.FontSize;
- else if (!card.FontSize)
- card.FontSize=48;
- card.FolderID=list[i].FolderID;
- if (that.data.FolderID) {
- card.FolderID=that.data.FolderID;
- card.FolderName=that.data.FolderName;
- }
- else if (!card.FolderID){
- card.FolderID=0;
- }
-
- if (list[i].LimitTime)
- card.LimitTime=list[i].LimitTime;
- else if (that.data.LimitTime)
- card.LimitTime=that.data.LimitTime;
-
- if (that.data.FieldNumber && that.data.FieldNumber > 0)
- content = main.encryptUrl(list[i].Content[that.data.FieldNumber].Content);
-
- break;
- }
- }
- var arrTagTemp=[];
- for(var j=0;j<card.Tags.length;j++){
- if (card.Tags[j])
- arrTagTemp.push(card.Tags[j]);
- }
- card.Tags=arrTagTemp;
- var fontSize=constant1.arrFontSize;
- var fontSizeName="";
- for(var j=0;j<fontSize.length;j++){
- if (fontSize[j].Value==card.FontSize){
- fontSizeName=fontSize[j].Name;
- break;
- }
- }
- that.setData({
- MiaoguoCardID: card.MiaoguoCardID,
- LimitTime: common.formatTime(card.LimitTime),
- PracticeCardType: constant1.arrStudyPattern[card.CardType]+"题卡",
- PracticeTimeStr: common.formatDateCHS(common.formatTime(card.LimitTime)),
- Field: card.Field,
- Tags: card.Tags,
- TagsStr: card.Tags.join("、"),
- FieldContent: content,
- CardType:card.CardType,
- IsCollect:card.IsCollect,
- FolderID:card.FolderID,
- FolderName:card.FolderName,
- FontSize:card.FontSize,
- FontSizeName:fontSizeName,
- });
- if (that.data.UpdateType != "add2") {
- that.setData({
- PageTitle: '编辑题卡',
- });
- }
- if (that.data.UpdateType == "edit3") {
- that.gotoAddItem({
- currentTarget: {
- dataset: {
- fieldid: that.data.FieldNumber
- }
- }
- });
- }
- if (that.data.OpenType){
- that.showPanel({currentTarget:{dataset:{type:that.data.OpenType}}});
- }
- }
- if (that.data.IsFolder){
- that.getFolderList();
- }
- that.setBtnSaveCss();
- common.getStorageValue(that, "SymbolMain", app.globalData.SymbolMain, function () {});
- },
- onHide: function () {
- //用于恢复未保存的新题卡
- //console.log("onHide");
- var that = this;
- if (!that.data.HiddenFieldEdit) {
- that.updateField();
- }
- if (!(that.data && that.data.Field && that.data.Field[1].length == 0 &&
- that.data.Field[2].length == 0 &&
- that.data.Field[3].length == 0) && !isCancel) {
- if (!isViolate && (that.data.UpdateType == "add" || that.data.UpdateType == "add2")) {
- var card = {};
- card.MiaoguoCardID = that.data.MiaoguoCardID;
- card.Content = [];
- var param1 = {};
- param1 = that.formatField(that.data.Field);
- for (var i = 0; i < 4; i++) {
- var obj = {};
- obj.ContentType = i;
- if (i == 0)
- obj.Content = that.data.Tags;
- else
- obj.Content = param1["Field" + i];
- card.Content.push(obj);
- }
- wx.setStorageSync("TempCardNoSaved", card);
- }
- }
- isCancel=false;
- },
- onUnload: function () {
- this.onHide();
- var card = wx.getStorageSync("TempCardInfo");
- if (card) {
- var list = app.globalData.CardList;
- for (var i = 0; i < list.length; i++) {
- if (this.data.MiaoguoCardID == list[i].MiaoguoCardID) {
- list[i] = card;
- break;
- }
- }
- app.globalData.CardList = list;
- wx.removeStorageSync("TempCardInfo");
- }
- clearInterval(interval);
- clearTimeout(timeoutUploadImage);
- clearInterval(intervalRecorder);
- if (this.data.IsRecorder)
- this.closeRecorder();
- if (wx.getStorageSync("IsRemindContinuousNew")==1){
- wx.removeStorageSync('IsRemindContinuousNew');
- }
- },
- onClose: function () {
- wx.navigateBack({
- delta: 1,
- });
- isCancel=true;
- wx.removeStorageSync('TempCardNoSaved');
- clearInterval(intervalRecorder);
- },
- gotoAddItem: function (e) {
- var that = this;
- var fieldid = e.currentTarget.dataset.fieldid;
- var content;
- var list = app.globalData.CardList;
- for (var i = 0; i < list.length; i++) {
- if (that.data.MiaoguoCardID == list[i].MiaoguoCardID) {
- content = main.encryptUrl(list[i].Content[fieldid].Content);
- break;
- }
- }
- wx.setStorageSync("TempCardInfoAddItem", content);
- that.setData({
- HiddenFieldEdit: false,
- Focus: true,
- FieldNumber: fieldid,
- FieldContent: content,
- });
-
- that.setData({
- PageTitle: '编辑 段落' + fieldid,
- });
- },
- onSearch: function (e) {
- app.globalData.TempFieldNumber = 0;
- wx.navigateTo({
- url: './addInfomation',
- })
- },
- onPreview: function (e) {
- var that = this;
- if (that.data.Field[1] == "") {
- wx.showToast({
- title: '填写段落1',
- image: "../images/universalpic_exclamation_white_120x120.png",
- });
- } else {
- var list = app.globalData.CardList;
- for (var i = 0; i < list.length; i++) {
- if (list[i].MiaoguoCardID == this.data.MiaoguoCardID){
- list[i].FontSize=this.data.FontSize;
- }
- }
- app.globalData.CardList = list;
- wx.navigateTo({
- url: './preview?type=preview&id=' + this.data.MiaoguoCardID,
- });
- }
- },
- saveCard: function () {
- var that = this;
- if (that.data.Field[1] == "") {
- wx.showToast({
- title: '填写段落1',
- image: "../images/universalpic_exclamation_white_120x120.png",
- });
- } else {
- if (isSave) {
- isSave = false;
- setTimeout(function () {
- isSave = true;
- }, 5000);
- if (that.checkImageCount(that.data.Field)) {
- that.uploadImageAll(that.data.Field, function (success, field) {
- if (success) {
- that.data.Field = field;
- var userid = app.globalData.userInfo.UserID;
- var tags = [];
- for (var i = 0; i < that.data.Tags.length; i++) {
- if (that.data.Tags[i])
- tags.push(that.data.Tags[i]);
- }
- var param1 = {};
- param1 = that.formatField(that.data.Field);
- param1.Tags = tags;
- param1.IsCollect=that.data.IsCollect;
-
- param1.LimitTime = that.data.LimitTime;
- if (!param1.LimitTime)
- param1.LimitTime=common.formatTime(new Date(),"-",true);
- param1.CardType = that.data.CardType;
- if (!param1.CardType)
- param1.CardType=0;
-
- if (that.data.FolderID)
- param1.FolderID = that.data.FolderID;
- if (that.data.FontSize)
- param1.FontSize = that.data.FontSize;
- param1.ID = that.data.MiaoguoCardID;
- that.saveLocalCardList(param1);
- wx.hideLoading();
- wx.showLoading({
- title: '保存中',
- mask: true,
- });
- timeoutUploadImage = setTimeout(function () {
- wx.hideLoading();
- }, 15000);
- main.postData('AddMiaoguoCard?Type=' + that.data.UpdateType + '&UserID=' + userid, param1, function (data) {
- wx.removeStorageSync("TempCardNoSaved");
- if (that.data.UpdateType.indexOf("edit")>=0) {
- var list = app.globalData.CardList;
- for (var i = 0; i < list.length; i++) {
- if (list[i].MiaoguoCardID == that.data.MiaoguoCardID){
- list[i].CardType = that.data.CardType;
- list[i].IsCollect = that.data.IsCollect;
- list[i].FontSize=that.data.FontSize;
- list[i].FolderID=that.data.FolderID;
- list[i].FolderName=that.data.FolderName;
-
- list[i].LimitTime=that.data.LimitTime;
- list[i].LimitTimeStr=common.formatDateCHS(that.data.LimitTime);
- list[i].UpdateTime=common.formatTime(new Date());
- }
- }
- app.globalData.CardList = list;
- app.globalData.IsUpdateStudyPlan = 1;
-
- if (that.data.CardType==1){
- app.globalData.TaskToday.CardNumberUrgent++;
- }
- that.onClose();
- } else {
- wx.hideLoading();
- if (that.data.UpdateType == "add2") {
- var remind=wx.getStorageSync("IsRemindContinuousNew")
- if (!remind){
- wx.showModal({
- title: '提醒',
- showCancel: true,
- cancelText: "不再提醒",
- content: '已进入连续新建状态,此时会保留上一张题卡的练习模式、到期时间、卡单、字号的设置,以方便您创建大量有相同属性的新题卡。另外,还能一键「复查」上一张题卡。',
- confirmText: '知道了',
- success(res) {
- if (res.confirm) {
- wx.setStorageSync("IsRemindContinuousNew",1);
- }
- else{
- wx.setStorageSync("IsRemindContinuousNew",2);
- }
- changePattern(that);
-
- }
- });
- }
- else{
- wx.showToast({
- title: '已保存',
- image: "../images/universalpic_save_white_120x120.png",
- });
- changePattern(that);
- }
- isFirstAdd = false;
- that.initAddCard();
- }
- else{
- wx.showToast({
- title: '已保存',
- image: "../images/universalpic_save_white_120x120.png",
- });
- changePattern(that);
- }
- if (that.data.FolderID>0){
- app.globalData.FolderList=[];
- }
- }
- wx.removeStorageSync("TempCardInfo");
-
- });
- } else {
- wx.showToast({
- title: '图片上传失败1',
- image: "../images/universalpic_exclamation_white_120x120.png",
- mask: true,
- });
- }
- });
- }
- } else {
- wx.showToast({
- title: '点击太频繁',
- image: "../images/universalpic_exclamation_white_120x120.png",
- mask: true,
- });
- }
- }
- function changePattern(obj){
- if (obj.data.CardType==1){
- var cardType=wx.getStorageSync('CardType');
- if (cardType==0 && app.globalData.TaskToday.CardNumberUrgent==1){
- wx.navigateTo({
- url: "../other/menu?Type=0",
- });
- }
- }
- }
- },
- formatField: function (field) {
- var result = {};
- for (var i = 1; i <= 3; i++) {
- result["Field" + i] = "";
- if (field.length>0 && field[i]) {
- for (var key in field[i]) {
- var item = field[i][key];
- var str = "";
- if (item.Type == "image") {
- str = "[图 w='" + item.Width + "' h='" + item.Height + "']" + item.Content + "[/图]";
- } else if (item.Type == "line") {
- for (var j = 0; j < item.Content.length; j++) {
- if (item.Content[j].key == "normal")
- str += item.Content[j].value;
- if (item.Content[j].key == "line") {
- str += "[线]" + item.Content[j].value + "[/线]";
- }
- if (item.Content[j].key == "highlighter") {
- str += "[光]" + item.Content[j].value + "[/光]";
- }
- }
- } else if (item.Type == "sound") {
- if (item.SoundMark)
- str = "[读 src='" + item.SoundMark + "']" + item.Content + "[/读]";
- else
- str = "[读]" + item.Content + "[/读]";
- } else if (item.Type == "recorder") {
- if (item.SoundMark)
- str = "[音 url='" + item.SoundMark + "'][/音]";
- } else if (item.Type == "normal") {
- str = item.Content;
- } else if (item.Type == "return") {
- str = "\n";
- }
- result["Field" + i] += str;
- }
- }
- result["Field" + i] = main.changeViewToString(result["Field" + i]);
- }
- return result;
- },
- checkImageCount: function (arr) {
- var count = 0;
- for (var i = 0; i < arr.length; i++) {
- for (var j = 0; j < arr[i].length; j++) {
- if (arr[i][j].Type == "image" && arr[i][j].Content) {
- count++;
- }
- }
- }
- if (count > 4) {
- wx.showToast({
- title: '只能上传四张图片',
- image: "../images/universalpic_exclamation_white_120x120.png",
- });
- return false;
- } else
- return true;
- },
- uploadImageAll: function (arr, callback) {
- var that = this;
- var b = false;
- var arrSource = [],
- arrResult = [];
- for (var i = 0; i < arr.length; i++) {
- for (var j = 0; j < arr[i].length; j++) {
- if (arr[i][j].Type == "image" && arr[i][j].Content) {
- arrSource.push(arr[i][j].Content);
- if (arr[i][j].ContentServer.indexOf(app.globalData.uploadImageUrl) >= 0 ||
- arr[i][j].ContentServer.indexOf("baidu.com") >= 0 ||
- arr[i][j].ContentServer.indexOf("bcebos.com") >= 0) {
- var result = {};
- result.Source = arr[i][j].ContentServer;
- result.Target = arr[i][j].ContentServer;
- arrResult.push(result);
- } else {
- var source = arr[i][j].Content;
- that.uploadFileToServer(source, function (data) {
- if (data) {
- data = JSON.parse(data);
- var result = data.result;
- result.Target = app.globalData.uploadImageUrl + result.Target;
- arrResult.push(result);
- }
- });
- }
- b = true;
- }
- }
- }
- if (b) {
- wx.showLoading({
- title: '正在上传',
- mask: true,
- });
- timeoutUploadImage = setTimeout(function () {
- wx.hideLoading();
- }, 30000);
- }
- interval = setInterval(function () {
- //console.log(arrResult.length);
- if (arrResult.length >= arrSource.length) {
- wx.hideLoading();
- //console.log("arrResult:" + JSON.stringify(arrResult));
- clearInterval(interval);
- var success = true;
- var ari = 0;
- for (var i = 0; i < arr.length; i++) {
- for (var j = 0; j < arr[i].length; j++) {
- if (arr[i][j].Type == "image" && arr[i][j].Content) {
- var tempUrl = arr[i][j].Content;
- var serverUrl = "";
- for (var k = 0; k < arrResult.length; k++) {
- if (tempUrl.indexOf(arrResult[k].Source) >= 0) {
- serverUrl = arrResult[k].Target;
- break;
- }
- }
- //console.log("serverUrl:" + serverUrl);
- //console.log("tempUrl:" + tempUrl);
- if (serverUrl == "")
- serverUrl = main.getServerImage(tempUrl);
- main.saveTempImage(serverUrl, tempUrl);
- arr[i][j].Content = serverUrl;
- arr[i][j].ContentServer = serverUrl;
- if (serverUrl == "") {
- success = false;
- break;
- }
- }
- }
- }
- //console.log(JSON.stringify(arr));
- callback(success, arr);
- }
- }, 500);
- },
- uploadFileToServer: function (file, callback) {
- var url = common.Encrypt("MiaoguoUploadFile2");
- wx.uploadFile({
- url: app.globalData.serverUrl + url,
- filePath: file,
- name: 'file',
- success(res) {
- callback(res.data);
- },
- fail: function (err) {
- wx.hideLoading();
- wx.showModal({
- title: '上传文件失败',
- showCancel: false,
- content: JSON.stringify(err),
- });
- }
- });
- },
- saveLocalCardList: function (param1) {
- var that = this;
- var list = app.globalData.CardList;
- for (var i = 0; i < list.length; i++) {
- if (that.data.MiaoguoCardID == list[i].MiaoguoCardID) {
- for (var j = 0; j < 4; j++) {
- if (j == 0) {
- if (param1.tags && param1.tags.length > 0)
- list[i].Content[j].Content = param1.tags.join(",");
- } else
- list[i].Content[j].Content = param1["Field" + j];
- }
- if (param1.LimitTime)
- list[i].LimitTime = common.formatTime(param1.LimitTime);
-
- app.globalData.CardList = list;
- break;
- }
- }
- },
- initAddCard: function () {
- var card = {};
- card.MiaoguoCardID = 0;
- card.Content = [];
- for (var i = 0; i < 4; i++) {
- var obj = {};
- obj.ContentType = i;
- obj.Content = [];
- card.Content.push(obj);
- }
- app.globalData.CardList = [card];
- this.setData({
- MiaoguoCardID: 0,
- Field: [
- [],
- [],
- [],
- []
- ],
- Tags: [],
- UpdateType: "add2",
- BtnSaveSelectCss:"",
- });
- },
- onBindError: function (e) {
- for (var i = 1; i < this.data.Field.length; i++) {
- for (var j = 0; j < this.data.Field[i].length; j++) {
- if (this.data.Field[i][j].Type == "image") {
- this.data.Field[i][j].Url = this.data.Field[i][j].Content;
- }
- }
- }
- this.setData({
- Field: this.data.Field,
- });
- },
- deleteItem: function (e) {
- var that = this;
- var index = e.currentTarget.dataset.id;
- if (e.currentTarget.dataset.type==1){
- that.setData({
- TagIndex: index,
- });
- }
- else if (e.currentTarget.dataset.type==2){
- that.data.TagTemp.splice(index, 1);
- that.setData({
- TagTemp: that.data.TagTemp,
- TagIndex: -1,
- });
- }
- else if (e.currentTarget.dataset.type==3){
- that.setData({
- Tags: that.data.TagTemp,
- TagsStr:that.data.TagTemp.join("、"),
- TagIndex: -1,
- });
- var list = app.globalData.CardList;
- for (var i = 0; i < list.length; i++) {
- if (that.data.MiaoguoCardID == list[i].MiaoguoCardID) {
- list[i].Content[0].Content = that.data.Tags;
- break;
- }
- }
- app.globalData.CardList = list;
-
- that.closeTagShow();
- }
- },
- onGotoList: function () {
- var that = this;
- if (isFirstAdd == true || !that.data.Field) {
- wx.showModal({
- title: '提醒',
- content: '本功能用于在连续新建题卡时一键复查「上一张题卡」。请在连续新建到第二张时再来试一试。',
- confirmText: '知道了',
- showCancel: false,
- });
- }
- else if (that.data.Field[1].length > 0 || that.data.Field[2].length > 0 || that.data.Field[2].length > 0) {
- wx.showModal({
- title: '提醒',
- content: '您所做的编辑还没有保存,要放弃保存吗?',
- confirmText: '取消',
- cancelText: "不保存",
- success(res) {
- if (!res.confirm) {
- goto();
- setTimeout(function () {
- wx.removeStorageSync("TempCardNoSaved");
- }, 1000);
- }
- }
- });
- }
- else {
- goto();
- }
- function goto() {
- wx.showLoading({
- title: '请稍候',
- });
- setTimeout(function () {
- wx.hideLoading();
- }, 5000);
- var url = 'GetMiaoguoCardList2?UserID=' + app.globalData.userInfo.UserID;
- main.getData(url, function (data) {
- wx.hideLoading();
- if (data) {
- app.globalData.CardList = data.List;
- that.setData({
- UpdateType: "add",
- });
- wx.navigateTo({
- url: './mainlist?type=3&Count=' + data.Count,
- })
- }
- });
- }
- },
- //段落编辑**************************
- //字段输入
- bindinputField: function (e) {
- //console.log("bindinputField:" + e.detail.value + " isEdit:" + isEdit);
- var that = this;
- if (app.globalData.IsAndroid && !isEdit) {
- return;
- }
- this.setData({
- FieldContent: e.detail.value,
- });
- },
- //加符号
- addSymbol: function (e) {
- //console.log("addSymbol");
- isEdit = true;
- var that = this;
- btnName = e.currentTarget.dataset.id;
- if (btnName == "[读]") {
- this.setData({
- SoundSign: "[/读]",
- });
- } else if (btnName == "[/读]") {
- this.setData({
- SoundSign: "[读]",
- });
- } else if (btnName == "[线]") {
- this.setData({
- LineSign: "[/线]",
- });
- } else if (btnName == "[/线]") {
- this.setData({
- LineSign: "[线]",
- });
- } else if (btnName == "[光]") {
- this.setData({
- HighlighterSign: "[/光]",
- });
- } else if (btnName == "[/光]") {
- this.setData({
- HighlighterSign: "[光]",
- });
- }
- if (btnName == "( )")
- btnName = "( )";
- else if (btnName == "_")
- btnName = "_____";
- //console.log("addSymbol_btnName:" + btnName);
- if (!this.data.Focus) {
- var obj = { detail: { cursor: tempCursor } };
- this.onBindblur(obj);
- }
- //console.log("addSymbol:" + this.data.FieldContent);
- setTimeout(function () {
- that.setData({
- Focus: true,
- });
- }, 300);
- },
- //焦点聚焦
- onBindFocus: function () {
- //console.log("onBindFocus");
- btnName = "";
- this.setData({
- Focus: true,
- });
- },
- //失焦
- onBindblur: function (e) {
- var that = this;
- //console.log("onBindblur:" + isEdit + " Filed:" + this.data.FieldContent);
- if (app.globalData.IsAndroid && !isEdit) {
- setTimeout(function () {
- isEdit = true;
- //console.log("onBindblur2:" + isEdit);
- }, 500);
- return;
- }
- isEdit = false;
- if (app.globalData.IsAndroid && !isEdit) {
- setTimeout(function () {
- isEdit = true;
- //console.log("onBindblur2:" + isEdit);
- }, 500);
- }
- //console.log("onBindblur:"+isEdit);
- this.updateField();
- tempCursor = e.detail.cursor;
- //console.log("tempCursor:" + tempCursor);
- if (tempCursor == undefined)
- tempCursor = this.data["FieldContent"].length;
- var str1 = "",
- str2 = "";
- if (this.data.FieldContent.length > 0) {
- str1 = this.data.FieldContent.substr(0, tempCursor);
- str2 = this.data.FieldContent.substring(tempCursor, this.data.FieldContent.length);
- }
- //console.log("str1:" + str1);
- //console.log("btnName:" + btnName);
- //console.log("str2:" + str2);
- var cur = 0;
- if (btnName) {
- cur = 1;
- if (btnName == "[读]" || btnName == "[线]" || btnName == "[光]") {
- cur = 3;
- } else if (btnName == "[/读]" || btnName == "[/线]" || btnName == "[/光]") {
- cur = 4;
- } else if (btnName === "( )") {
- cur = 7;
- } else if (btnName === "_____") {
- cur = 5;
- }
- }
- this.data.FieldContent = str1 + btnName + str2;
- this.setData({
- FieldContent: this.data.FieldContent,
- Focus: false,
- Cursor: tempCursor + cur,
- });
- btnName = "";
- },
- bindscrollHandler: function () {
- //console.log("bindscrollHandler");
- btnName = "";
- },
- onSearchField: function (e) {
- app.globalData.TempFieldNumber = this.data.FieldNumber;
- wx.navigateTo({
- url: './addInfomation',
- });
- this.updateField();
- setTimeout(function () {
- isEdit = true;
- //console.log("onSearchEnd");
- }, 1000);
- },
- clear: function () {
- var that = this;
- //console.log("clear");
- this.setData({
- FieldContent: "",
- Focus: true,
- Cursor: 0,
- });
- btnName = "";
- isEdit = false;
- this.updateField();
- },
- closeAddItem: function (e) {
- var that = this;
- var isSave = e.currentTarget.dataset.idsave;
- if (isSave == "true") {
- isUnload = false;
- if (that.data.FieldContent) {
- var content = that.data.FieldContent;
- main.postData("MsgSecCheck2",
- { Content: content, },
- function (data) {
- if (data && data.errcode == 0) {
- next(that);
- } else {
- if (data.errmsg) {
- wx.showToast({
- title: data.errmsg,
- duration: 2000,
- image: "../images/universalpic_wrong_white_120x120.png",
- });
- isViolate = true;
- }
- }
- });
- } else {
- next(that);
- }
- } else if (isSave == "false") {
- var content = wx.getStorageSync("TempCardInfoAddItem");
- this.setData({
- FieldContent: content,
- });
- next(that);
- }
-
- function next(obj) {
- isViolate = false;
- obj.updateField();
- obj.setData({
- HiddenFieldEdit: true,
- });
- var title = "编辑题卡";
- if (obj.data.UpdateType == "add2") {
- title = "新建题卡";
- }
- that.setData({
- PageTitle: title,
- });
- that.setBtnSaveCss();
- }
- },
- setBtnSaveCss:function(){
- var that=this;
- if (that.data.Field && that.data.Field[1] && that.data.Field[1] != ""){
- that.setData({
- BtnSaveSelectCss:"MenuBtnSelect",
- });
- }
- else{
- that.setData({
- BtnSaveSelectCss:"",
- });
- }
- },
- updateField: function () {
- var str = this.data.FieldContent;
- var list = app.globalData.CardList;
- var card = {};
- for (var i = 0; i < list.length; i++) {
- if (this.data.MiaoguoCardID == list[i].MiaoguoCardID) {
- list[i].Content[this.data.FieldNumber].Content = str;
- card = main.changeStringToView(list[i].Content);
- break;
- }
- }
- app.globalData.CardList = list;
- this.setData({
- Field: card.Field,
- Tags: card.Tags,
- });
- },
- //选择图片上传
- uploadImageField: function () {
- //console.log("uploadImageStart");
- var that = this;
- //若是安卓机
- if (app.globalData.IsAndroid) {
- selectImage(that);
- } else {
- wx.showActionSheet({
- itemList: ['拍照', '从手机相册选择'],
- success(res) {
- if (res.tapIndex == 0) {
- wx.chooseImage({
- count: 1,
- sizeType: ['compressed'],
- sourceType: ['camera'],
- success(res2) {
- wx.showLoading({
- title: '请稍候',
- mask: true,
- });
- setTimeout(function () {
- wx.hideLoading();
- selectImage(that);
- }, 2000);
- },
- });
- } else if (res.tapIndex == 1) {
- selectImage(that);
- }
- },
- fail(res) {
- console.log(res.errMsg)
- }
- });
- }
- function selectImage(that) {
- var sizeType = ['album'];
- //若是安卓机
- if (app.globalData.IsAndroid)
- sizeType = ['album', 'camera'];
- wx.chooseImage({
- count: 1,
- sizeType: ['compressed'],
- sourceType: sizeType,
- success(res) {
- // tempFilePath可以作为img标签的src属性显示图片
- const tempFilePaths = res.tempFilePaths;
- //console.log(tempFilePaths[0]);
- //that.data.FieldContent = that.data.FieldContent + "[图 url='" + tempFilePaths[0] + "']" + tempFilePaths[0] + "[/图]";
- wx.getImageInfo({
- src: res.tempFilePaths[0],
- success(res) {
- //console.log(res.width)
- //console.log(res.height)
- if (tempCursor == undefined)
- tempCursor = that.data.FieldContent.length;
- var str1 = "",
- str2 = "";
- if (that.data.FieldContent.length > 0) {
- str1 = that.data.FieldContent.substr(0, tempCursor);
- str2 = that.data.FieldContent.substring(tempCursor, that.data.FieldContent.length);
- }
- var width = res.width;
- if (isNaN(width))
- width = 650;
- var height = res.height;
- if (isNaN(height))
- height = 650;
- var str0 = "[图 w='" + width + "' h='" + height + "']" + tempFilePaths[0] + "[/图]";
- that.data.FieldContent = str1 + str0 + str2;
- tempCursor = that.data.FieldContent.length;
- //console.log("uploadImageEnd:" + that.data.FieldContent);
- that.setData({
- FieldContent: that.data.FieldContent,
- Focus: false,
- });
- that.updateField();
- if (!wx.getStorageSync("NoRemindImage")) {
- wx.showModal({
- title: '提醒',
- showCancel: true,
- content: "“图片记号”以符号[图]开始…以符号[/图]结尾。如要剪切请确保完整性。",
- confirmText: "好的",
- cancelText: "不再提醒",
- success(res) {
- if (res.confirm) { } else {
- wx.setStorageSync("NoRemindImage", true);
- }
- },
- });
- }
- }
- });
- },
- fail: function () {
- }
- });
- }
- },
- showPracticeTime: function () {
- if (this.data.MiaoguoCardID){
- wx.navigateTo({
- url: './previewMenu?IsSave=0&ID='+this.data.MiaoguoCardID+'&CardType='+this.data.CardType+"&LimitTime="+this.data.LimitTime,
- });
- }
- else{
- var limitTime=common.formatTime(new Date(),"-",true);
- if (this.data.LimitTime)
- limitTime=this.data.LimitTime;
- var cardType=0;
- if (this.data.CardType)
- cardType=this.data.CardType;
- wx.navigateTo({
- url: './previewMenu?IsSave=0&ID=0&CardType='+cardType+'&LimitTime='+limitTime,
- });
- }
- },
- //录音授权
- recorderAccredit: function () {
- var that = this;
- if (app.globalData.IsRecorderAccredit == 1)
- that.showRecorder();
- else if (app.globalData.IsRecorderAccredit == 0) {
- recorderManager.stop();
- app.globalData.IsRecorderAccredit = 1;
- that.showRecorder();
- } else if (app.globalData.IsRecorderAccredit == -1) {
- wx.getSetting({
- success(res) {
- if (res.authSetting['scope.record'] === true) {
- app.globalData.IsRecorderAccredit = 1;
- that.showRecorder();
- } else if (res.authSetting['scope.record'] === false) {
- wx.navigateTo({
- url: '../other/openSetting',
- });
- }
- }
- });
- }
- },
- showRecorder: function () {
- var that = this;
- if (that.checkRecorderCount()) {
- that.recorderInit();
- tempRecorderFile = "";
- that.setData({
- PageTitle: '录音',
- });
- that.setData({
- IsRecorder: true,
- IsRecorderFinished: false,
- BtnRecorderName: "按住录音1分钟",
- RecorderTime: "00:00",
- RecorderTimeCss: "",
- RecorderPlayName: "播放",
- });
- innerAudioContext = wx.createInnerAudioContext();
- innerAudioContext.onPlay(() => {
- console.log('开始播放');
- that.setData({
- RecorderTimeCss: "RecorderPanel1121",
- RecorderTime: "00:00",
- RecorderPlayName: "停止",
- });
- });
- innerAudioContext.onEnded(() => {
- console.log('结束播放');
- clearInterval(intervalRecorder);
- that.setData({
- RecorderTime: "00:00",
- RecorderTimeCss: "",
- RecorderPlayName: "播放",
- });
- });
- }
- },
- closeRecorder: function () {
- var that = this;
- this.recorderInit();
- if (tempRecorderFile) {
- wx.showModal({
- title: '提醒',
- content: '这段录音还没有上传,要放弃录音吗?',
- showCancel: true,
- confirmText: "取消",
- cancelText: "不上传",
- success(res) {
- if (res.cancel) {
- closeRecorder2();
- }
- },
- })
- } else {
- closeRecorder2();
- }
- function closeRecorder2() {
- that.setData({
- PageTitle: '编辑 段落' + that.data.FieldNumber,
- });
- that.setData({
- IsRecorder: false,
- IsRecorderFinished: false,
- });
- tempRecorderFile = "";
- }
- },
- //录音初始化
- recorderInit: function () {
- if (innerAudioContext)
- innerAudioContext.stop();
- if (recorderManager)
- recorderManager.stop();
- clearInterval(intervalRecorder);
- },
- checkRecorderCount: function (arr) {
- var that = this;
- var count = 0;
- if (that.data.FieldContent.indexOf("[音 url=") >= 0 ||
- that.data.FieldContent.indexOf("[/音]") >= 0) {
- count = 1;
- }
- if (count > 0) {
- wx.showToast({
- title: '仅能上传一段',
- image: "../images/universalpic_exclamation_white_120x120.png",
- });
- return false;
- } else
- return true;
- },
- btnRecorderStart: function () {
- var that = this;
- if (app.globalData.IsRecorderAccredit == 1) {
- that.setData({
- BtnRecorderName: "松手结束",
- RecorderTimeCss: "RecorderPanel1121",
- });
- that.showRecorderTime();
- recorderManager.start();
- }
- },
- btnRecorderEnd: function () {
- var that = this;
- if (app.globalData.IsRecorderAccredit == 1) {
- if (that.data.RecorderTime == "00:00") {
- //小于1秒处理
- wx.showToast({
- title: '时间过短',
- image: "../images/universalpic_exclamation_white_120x120.png",
- });
- that.showRecorder();
- } else {
- that.setData({
- IsRecorderFinished: true,
- RecorderTimeCss: "",
- });
- that.recorderInit();
- }
- } else {
- that.recorderAccredit();
- }
- },
- showRecorderTime: function () {
- var that = this;
- var second = 0;
- clearInterval(intervalRecorder);
- intervalRecorder = setInterval(function () {
- second++;
- var secondStr = second.toString();
- if (second < 10)
- secondStr = "0" + secondStr;
- that.setData({
- RecorderTime: "00:" + secondStr,
- });
- if (second >= 59) {
- that.setData({
- IsRecorderFinished: true,
- RecorderTimeCss: "",
- });
- that.recorderInit();
- if (that.data.RecorderPlayName == "播放") {
- wx.showToast({
- title: '录音超时',
- image: "../images/universalpic_exclamation_white_120x120.png",
- });
- }
- }
- }, 1000);
- },
- btnRecorderPlay: function () {
- var that = this;
- if (tempRecorderFile && this.data.RecorderPlayName == "播放") {
- innerAudioContext.src = tempRecorderFile;
- innerAudioContext.play();
- this.showRecorderTime();
- } else if (this.data.RecorderPlayName == "停止") {
- if (innerAudioContext)
- innerAudioContext.stop();
- clearInterval(intervalRecorder);
- that.setData({
- RecorderTime: "00:00",
- RecorderTimeCss: "",
- RecorderPlayName: "播放",
- });
- }
- },
- btnRecorderSave: function () {
- var that = this;
- this.recorderInit();
- wx.showLoading({
- title: '正在上传',
- });
- setTimeout(function () {
- wx.hideLoading();
- }, 60000);
- that.uploadFileToServer(tempRecorderFile, function (data) {
- if (data) {
- data = JSON.parse(data);
- //console.log(data);
- wx.hideLoading();
- var result = data.result;
- result.Target = app.globalData.uploadImageUrl + result.Target;
- that.data.FieldContent = that.data.FieldContent + "[音 url='" + result.Target + "'][/音]";
- that.data.FieldContent = main.encryptUrl(that.data.FieldContent);
- that.setData({
- FieldContent: that.data.FieldContent,
- });
- tempRecorderFile = "";
- that.closeRecorder();
- if (!wx.getStorageSync("NoRemindRecorder")) {
- wx.showModal({
- title: '提醒',
- showCancel: true,
- content: "“录音记号”以符号[录]开始…以符号[/录]结尾。如要剪切请确保完整性。",
- confirmText: "好的",
- cancelText: "不再提醒",
- success(res) {
- if (res.confirm) { } else {
- wx.setStorageSync("NoRemindRecorder", true);
- }
- },
- });
- }
- }
- });
- },
- goto: function (e) {
- var url=e.currentTarget.dataset.url;
- wx.navigateTo({
- url: url,
- });
- if (url=="./folderEdit?type=add"){
- isAddFolder=true;
- }
- },
- showTagShow:function(){
- var tagTemp=this.data.Tags.join(",");
- this.setData({
- IsTagShow:true,
- TagTemp:tagTemp.split(","),
- TagIndex:-1,
- });
- this.setData({
- PageTitle: '自动记号',
- });
- },
- closeTagShow:function(){
- this.setData({
- IsTagShow:false,
- });
- this.setData({
- PageTitle: '编辑题卡',
- });
- },
- setCardTypeInit:function(){
- this.setData({
- CardType:0,
- PracticeCardType:constant1.arrStudyPattern[0]+"题卡",
- PracticeTimeStr:"",
- LimitTime:common.formatTime(new Date(),"-",true),
- });
- wx.showToast({
- title: '已恢复默认',
- image: "../images/universalpic_restore_white_120x120.png",
- });
- },
- gotoAddInfomationDetail:function(param){
- main.searchInfomation(param.Word,param.SearchType,param.Author,app.globalData.TempStr,function(list,obj){
- main.updateSearchList(obj,function(){
- app.globalData.TempSearchBackNumber=1;
- wx.navigateTo({
- url: './addInfomationDetail',
- });
- });
- });
- },
- showPanel: function (e) {
- var that = this;
- that.hiddenPanel(true);
- switch(e.currentTarget.dataset.type){
- case "help":
- that.setData({
- IsHelp: true,
- });
- break;
- case "menu":
- that.setData({
- IsShowMenu: true,
- IsShowAddHelp:1,
- });
- wx.setStorageSync("IsShowAddHelp",that.data.IsShowAddHelp);
- break;
- case "folder":
- that.setData({
- IsFolder: true,
- });
- that.getFolderList();
- break;
- case "limittime":
- var arrLimitTime=constant1.arrLimitTime;
- for(var i=0;i<arrLimitTime.length;i++){
- arrLimitTime[i].Selected="";
- }
- //arrLimitTime[0].Selected="MenuBtnSelect";
-
- that.setData({
- Today:common.formatTime(new Date()),
- IsLimitTime: true,
- LimitTimeTemp:that.data.LimitTime,
- PracticeTimeStrTemp: common.formatDateCHS(that.data.LimitTime),
- LimitTimeArr:arrLimitTime,
- });
- break;
- case "fontsize":
- if (!that.data.FontSize)
- that.data.FontSize=48;
- var fontSize=constant1.arrFontSize;
- var fontSizeName="";
- for(var i=0;i<fontSize.length;i++){
- fontSize[i].Selected="";
- if (fontSize[i].Value==that.data.FontSize){
- fontSize[i].Selected="MenuBtnSelect";
- fontSizeName=fontSize[i].Name;
- }
- }
- that.setData({
- IsFontsize: true,
- FontSizeArr:fontSize,
- FontSizeTemp:that.data.FontSize,
- FontSizeName:fontSizeName,
- });
- break;
- case "cardtype":
- var obj={};
- if (!that.data.CardType)
- that.data.CardType=0;
- if (that.data.CardType==0){
- obj.NormalCss="MenuBtnSelect";
- obj.UrgentCss="";
- }
- else if (that.data.CardType==1){
- obj.NormalCss="";
- obj.UrgentCss="MenuBtnSelect";
- }
- else if (that.data.CardType==-1){
- obj.NormalCss="MenuBtnDisabled";
- obj.UrgentCss="MenuBtnDisabled";
- }
-
- that.setData({
- IsCardType: true,
- CardTypeCss:obj,
- CardTypeTemp:that.data.CardType,
- CardNumberUrgent:app.globalData.TaskToday.CardNumberUrgent,
- });
- break;
- }
- },
- hiddenPanel:function(e){
- var that=this;
-
- that.setData({
- IsShowMenu:false,
- IsHelp: false,
- IsFontsize:false,
- IsFolder:false,
- IsLimitTime:false,
- IsCardType:false,
- });
- if (that.data.IsFolder){
- for(var i=0;i<that.data.FolderArr.length;i++){
- that.data.FolderArr[i].Selected="";
- }
- that.setData({
- FolderArr:that.data.FolderArr,
- });
- }
- },
- setFontSize:function(e){
- var that=this;
- var fontSize=constant1.arrFontSize;
- var fontSizeName;
- for(var i=0;i<fontSize.length;i++){
- fontSize[i].Selected="";
- if (fontSize[i].Value==e.currentTarget.dataset.fontsize){
- fontSize[i].Selected="MenuBtnSelect";
- fontSizeName=fontSize[i].Name;
- }
- }
- that.setData({
- FontSizeTemp:e.currentTarget.dataset.fontsize,
- FontSizeArr:fontSize,
- FontSizeNameTemp:fontSizeName,
- });
- },
- saveFontSize:function(){
- var fontSizeName;
- var fontSize=constant1.arrFontSize;
- for(var i=0;i<fontSize.length;i++){
- if (fontSize[i].Value==this.data.FontSizeTemp){
- fontSizeName=fontSize[i].Name;
- }
- }
- this.setData({
- FontSize:this.data.FontSizeTemp,
- FontSizeName:fontSizeName,
- });
- this.hiddenPanel();
- },
- getFolderList:function(e){
- var that=this;
- if (app.globalData.FolderList.length==0){
- var url="GetUserFolderList?UserID="+app.globalData.userInfo.UserID;
- main.getData(url, function (data) {
- if (data) {
- if (isAddFolder){
- that.setData({
- FolderID:data[0].ID,
- });
- isAddFolder=false;
- }
- update(data);
- }
- });
- }
- else{
- update(app.globalData.FolderList);
- }
- function update(arr){
- for(var i=0;i<arr.length;i++){
- arr[i].Selected="";
- if (that.data.FolderID){
- if (arr[i].ID==that.data.FolderID){
- arr[i].Selected="MenuBtnSelect";
- }
- }
- }
-
- that.setData({
- FolderArr:arr,
- });
- app.globalData.FolderList=arr;
- }
- },
- selectFolder:function(e){
- var that=this;
- var id=e.currentTarget.dataset.id;
- for(var i=0;i<that.data.FolderArr.length;i++){
- if (id==that.data.FolderArr[i].ID)
- that.data.FolderArr[i].Selected="MenuBtnSelect";
- else
- that.data.FolderArr[i].Selected="";
- }
- var nullFolder="";
- if (id==0){
- nullFolder="MenuBtnSelect";
- }
- that.setData({
- FolderArr:that.data.FolderArr,
- NullFolder:nullFolder,
- });
- },
- setFolder:function(){
- var that=this;
- var id=0;
- var FolderName="";
- for(var i=0;i<that.data.FolderArr.length;i++){
- if (that.data.FolderArr[i].Selected=="MenuBtnSelect"){
- id=that.data.FolderArr[i].ID;
- FolderName=that.data.FolderArr[i].Name;
- }
- }
- that.setData({
- FolderID:id,
- FolderName:FolderName,
- });
- that.hiddenPanel();
- },
- selectLimitTime:function(e){
- var that=this;
- var limitTime="";
- var daynumber=e.currentTarget.dataset.daynumber;
- for(var i=0;i<that.data.LimitTimeArr.length;i++){
- if (daynumber==that.data.LimitTimeArr[i].DayNumber){
- that.data.LimitTimeArr[i].Selected="MenuBtnSelect";
- limitTime=common.formatTime(common.addDate("d",daynumber,new Date()),"-",true);
- }
- else
- that.data.LimitTimeArr[i].Selected="";
- }
-
- that.setData({
- LimitTimeTemp: limitTime,
- PracticeTimeStrTemp: common.formatDateCHS(limitTime),
- LimitTimeArr:that.data.LimitTimeArr,
- });
- },
- selectLimitTime2:function(e){
- var that=this;
- var limitTime=e.detail.value;
- var today=common.formatTime(new Date(),"-",true);
- console.log(today);
- if (limitTime<today){
- wx.showModal({
- title: '提醒',
- content: '指定日期只能是今天或未来某日,您可重新选择。',
- confirmText: "知道了",
- showCancel:false,
- });
- }
- else{
- for(var i=0;i<that.data.LimitTimeArr.length;i++){
- that.data.LimitTimeArr[i].Selected="";
- }
- that.setData({
- LimitTimeTemp: limitTime,
- PracticeTimeStrTemp: common.formatDateCHS(limitTime),
- LimitTimeArr:that.data.LimitTimeArr,
- });
- }
- },
- setLimitTime:function(e){
- var that=this;
-
- that.setData({
- LimitTime: that.data.LimitTimeTemp,
- PracticeTimeStr: common.formatDateCHS(that.data.LimitTimeTemp),
- });
- that.hiddenPanel();
- },
- setCollect:function(){
- var that=this;
- var IsCollectStr="";
- if (that.data.IsCollect==1){
- that.data.IsCollect=0;
- }
- else{
- that.data.IsCollect=1;
- }
- that.setData({
- IsCollect: that.data.IsCollect,
- });
- that.hiddenPanel();
- },
- setLimitTime:function(e){
- var that=this;
-
- that.setData({
- LimitTime: that.data.LimitTimeTemp,
- PracticeTimeStr: common.formatDateCHS(that.data.LimitTimeTemp),
- });
- that.hiddenPanel();
- },
- selectCardType:function(e){
- var that=this;
- var cardtype=0;
- if (!e.currentTarget.dataset.disabled){
- if (e.currentTarget.dataset.cardtype){
- cardtype=e.currentTarget.dataset.cardtype;
- }
- if (e.detail.value===true)
- cardtype=-1;
- else if (e.detail.value===false)
- cardtype=0;
-
- var obj={};
- if (cardtype==0){
- obj.NormalCss="MenuBtnSelect";
- }
- if (cardtype==1){
- obj.UrgentCss="MenuBtnSelect";
- }
- if (cardtype==-1){
- obj.NormalCss="MenuBtnDisabled";
- obj.UrgentCss="MenuBtnDisabled";
- }
- if (that.data.CardType==1 && (cardtype==0 || cardtype==-1))
- app.globalData.TaskToday.CardNumberUrgent--;
-
- if (app.globalData.TaskToday.CardNumberUrgent+1>200){
- obj.UrgentCss="MenuBtnDisabled";
- }
-
- that.setData({
- CardTypeTemp: cardtype,
- CardTypeCss:obj,
- });
- }
- },
- setCardType:function(e){
- var that=this;
- if (that.data.CardTypeTemp==1 || that.data.CardType==-1){
- var limittime=common.formatTime(new Date(),"-",true);
- that.setData({
- LimitTime:limittime,
- PracticeTimeStr:common.formatDateCHS(limittime),
- });
- }
- that.setData({
- CardType: Number(that.data.CardTypeTemp),
- PracticeCardType: constant1.arrStudyPattern[that.data.CardTypeTemp]+"题卡",
- });
- that.hiddenPanel();
- },
- deleteCard:function(){
- app.globalData.TempStr="deleteCard";
- this.onClose();
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|