|
|
@ -1,4 +1,5 @@
|
|
|
|
const app = getApp();
|
|
|
|
const app = getApp();
|
|
|
|
|
|
|
|
import {navigateToUrl} from '../../../js/utils';
|
|
|
|
Page({
|
|
|
|
Page({
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
theme: 'light',
|
|
|
|
theme: 'light',
|
|
|
@ -7,10 +8,46 @@ Page({
|
|
|
|
titles: ["任务描述", "代码文件", "测评结果"],
|
|
|
|
titles: ["任务描述", "代码文件", "测评结果"],
|
|
|
|
can_use_editor:wx.canIUse("editor")
|
|
|
|
can_use_editor:wx.canIUse("editor")
|
|
|
|
},
|
|
|
|
},
|
|
|
|
initTheme(){
|
|
|
|
/*onTap(e){
|
|
|
|
|
|
|
|
console.log(e);
|
|
|
|
|
|
|
|
let {detail:{tag, attr}} = e;
|
|
|
|
|
|
|
|
if(tag=='navigator'&&attr.href)
|
|
|
|
|
|
|
|
navigateToUrl({url: attr.href});
|
|
|
|
|
|
|
|
//console.log(detail);
|
|
|
|
|
|
|
|
},*/
|
|
|
|
|
|
|
|
checkTime(){
|
|
|
|
|
|
|
|
if(this.timeChecked)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
let date = new Date();
|
|
|
|
|
|
|
|
let hours = date.getHours();
|
|
|
|
|
|
|
|
let min = date.getMinutes();
|
|
|
|
|
|
|
|
if(hours>=0&&hours<=3||hours>=23&&min>=30){
|
|
|
|
|
|
|
|
this.timeChecked = true;
|
|
|
|
|
|
|
|
let y = date.getFullYear();
|
|
|
|
|
|
|
|
let m = date.getMonth();
|
|
|
|
|
|
|
|
let d = date.getDate();
|
|
|
|
|
|
|
|
if(hours>=23)
|
|
|
|
|
|
|
|
d += 1;
|
|
|
|
|
|
|
|
let t = y+'-'+m+'-'+d;
|
|
|
|
|
|
|
|
let key = 'task-show-go-to-sleep-last-time'
|
|
|
|
|
|
|
|
let last = wx.getStorageSync(key);
|
|
|
|
|
|
|
|
if(last==t)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
this.setData({showGoToSleep:true});
|
|
|
|
|
|
|
|
wx.reportAnalytics('show_go_to_sleep_in_task', {});
|
|
|
|
|
|
|
|
wx.setStorageSync(key, t);
|
|
|
|
|
|
|
|
}else if(hours<=21){
|
|
|
|
|
|
|
|
this.timeChecked = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onTapTopTip(){
|
|
|
|
|
|
|
|
this.setData({showGoToSleep:false});
|
|
|
|
|
|
|
|
wx.reportAnalytics('tap_go_to_sleep', {});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
setNavigationTheme(){
|
|
|
|
let {theme} = this.data;
|
|
|
|
let {theme} = this.data;
|
|
|
|
if(theme=='dark'){
|
|
|
|
if(theme=='dark'){
|
|
|
|
wx.setNavigationBarColor({backgroundColor:"#333333",frontColor:"#ffffff",animation:'linear'});
|
|
|
|
wx.setNavigationBarColor({backgroundColor:"#303030",frontColor:"#ffffff",animation:'linear'});
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
wx.setNavigationBarColor({backgroundColor:"#fbfbfb",frontColor:"#000000",animation:"linear"});
|
|
|
|
wx.setNavigationBarColor({backgroundColor:"#fbfbfb",frontColor:"#000000",animation:"linear"});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -20,7 +57,7 @@ Page({
|
|
|
|
let {value} = detail;
|
|
|
|
let {value} = detail;
|
|
|
|
let theme = value?'dark':'light';
|
|
|
|
let theme = value?'dark':'light';
|
|
|
|
this.setData({theme});
|
|
|
|
this.setData({theme});
|
|
|
|
this.initTheme();
|
|
|
|
this.setNavigationTheme();
|
|
|
|
wx.setStorageSync('config-task-theme', theme);
|
|
|
|
wx.setStorageSync('config-task-theme', theme);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
enterTask(e){
|
|
|
|
enterTask(e){
|
|
|
@ -52,9 +89,6 @@ Page({
|
|
|
|
if(this.modified)
|
|
|
|
if(this.modified)
|
|
|
|
this.content = value;
|
|
|
|
this.content = value;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
addIndent(){
|
|
|
|
|
|
|
|
this.editor.insertText({text:" "});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onEditorInput(e){
|
|
|
|
onEditorInput(e){
|
|
|
|
let {text} = e.detail;
|
|
|
|
let {text} = e.detail;
|
|
|
|
//console.log(e.detail.text);
|
|
|
|
//console.log(e.detail.text);
|
|
|
@ -152,13 +186,16 @@ Page({
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}, 1000);
|
|
|
|
}, 1000);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onSwiperChange({detail:{current,source}}){
|
|
|
|
onSwiperChange(e){
|
|
|
|
|
|
|
|
//console.log(e);
|
|
|
|
|
|
|
|
let {detail:{current,source}} = e;
|
|
|
|
if(source=="touch"){
|
|
|
|
if(source=="touch"){
|
|
|
|
this.setData({current});
|
|
|
|
this.setData({current});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(current==1&&!this.content){
|
|
|
|
if(current==1&&!this.content){
|
|
|
|
this.pullContent();
|
|
|
|
this.pullContent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.checkTime();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
async pullTask(){
|
|
|
|
async pullTask(){
|
|
|
|
let {identifier} = this.data;
|
|
|
|
let {identifier} = this.data;
|
|
|
@ -168,7 +205,7 @@ Page({
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
async pullContent(){
|
|
|
|
async pullContent(){
|
|
|
|
console.log("pullContent", this.editor);
|
|
|
|
//console.log("pullContent", this.editor);
|
|
|
|
let {path} = this.data.challenge;
|
|
|
|
let {path} = this.data.challenge;
|
|
|
|
path = this.processPath(path);
|
|
|
|
path = this.processPath(path);
|
|
|
|
let {identifier} = this.data;
|
|
|
|
let {identifier} = this.data;
|
|
|
@ -186,7 +223,7 @@ Page({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else
|
|
|
|
}else
|
|
|
|
this.setData({content});
|
|
|
|
this.setData({content});
|
|
|
|
console.log("pullContent");
|
|
|
|
//console.log("pullContent");
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onEditorReady({pullContent=0}={}) {
|
|
|
|
onEditorReady({pullContent=0}={}) {
|
|
|
|
//console.log("editor-ready")
|
|
|
|
//console.log("editor-ready")
|
|
|
@ -204,12 +241,15 @@ Page({
|
|
|
|
//console.log("onload")
|
|
|
|
//console.log("onload")
|
|
|
|
let theme = wx.getStorageSync('config-task-theme');
|
|
|
|
let theme = wx.getStorageSync('config-task-theme');
|
|
|
|
this.setData({theme});
|
|
|
|
this.setData({theme});
|
|
|
|
this.initTheme();
|
|
|
|
this.setNavigationTheme();
|
|
|
|
|
|
|
|
|
|
|
|
let {identifier} = options;
|
|
|
|
let {identifier} = options;
|
|
|
|
this.setData({identifier});
|
|
|
|
this.setData({identifier});
|
|
|
|
this.pullTask();
|
|
|
|
this.pullTask();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
onReady(){
|
|
|
|
|
|
|
|
this.checkTime();
|
|
|
|
|
|
|
|
},
|
|
|
|
onHide: function () {
|
|
|
|
onHide: function () {
|
|
|
|
this.updateFile();
|
|
|
|
this.updateFile();
|
|
|
|
},
|
|
|
|
},
|
|
|
|