代码编辑器改用editor

master
educoder_weapp 5 years ago
parent 3f45de366c
commit 57aa083a00

File diff suppressed because one or more lines are too long

@ -1,3 +1,15 @@
## v0.14.5
* A 接入内容安全接口
* A 添加EduCoder云网推荐链接
* U 代码编辑器改用editor
* U 代码编辑器增加简单自动缩进
* F 学校没有子单位时无法选择单位
## v0.14.4
* A 使用we-ui扩展库
* U 课堂界面优化更改
* U 加入课堂对话框界面优化
## v0.14.3
* F 实训文件内容获取失败(文件path错误)
* F 个人信息性别设置bug

@ -1,7 +0,0 @@
{
"permissions": {
"openapi": [
"customerServiceMessage.send"
]
}
}

@ -1,26 +0,0 @@
const cloud = require('wx-server-sdk')
cloud.init({
// API 调用都保持和云函数当前所在环境一致
env: cloud.DYNAMIC_CURRENT_ENV
})
// 云函数入口函数
exports.main = async (event, context) => {
console.log(event)
const { OPENID } = cloud.getWXContext()
const result = await cloud.openapi.customerServiceMessage.send({
touser: OPENID,
msgtype: 'text',
text: {
content: '收到:' + event.Content,
}
})
console.log(result)
return result
}

@ -1,14 +0,0 @@
{
"name": "callback",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "latest"
}
}

@ -1,5 +0,0 @@
{
"permissions": {
"openapi": []
}
}

@ -1,8 +0,0 @@
const cloud = require('wx-server-sdk')
exports.main = async (event, context) => {
// event.userInfo 是已废弃的保留字段,在此不做展示
// 获取 OPENID 等微信上下文请使用 cloud.getWXContext()
delete event.userInfo
return event
}

@ -1,14 +0,0 @@
{
"name": "echo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "latest"
}
}

@ -3,14 +3,7 @@
"openapi": [
"wxacode.get",
"wxacode.getUnlimited",
"subscribeMessage.send",
"subscribeMessage.addTemplate",
"templateMessage.send",
"templateMessage.addTemplate",
"templateMessage.deleteTemplate",
"templateMessage.getTemplateList",
"templateMessage.getTemplateLibraryById",
"templateMessage.getTemplateLibraryList"
"security.msgSecCheck"
]
}
}

@ -6,19 +6,27 @@ cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV})
// 云函数入口函数
exports.main = async (event, context) => {
console.log(event)
switch (event.action) {
case 'requestSubscribeMessage': {
return requestSubscribeMessage(event)
}
case 'sendSubscribeMessage': {
return sendSubscribeMessage(event)
}
switch (event.action||event.name) {
case "wxacode.getUnlimited":
case "getWXACodeUnlimited":{
return getWXACodeUnlimited(event)
}
case "wxacode.get":
case 'getWXACode': {
return getWXACode(event)
}
case "security.msgSecCheck":{
//return cloud.openapi.security.msgSecCheck(event.data);
try{
var res = await cloud.openapi.security.msgSecCheck(event.data);
return res;
}catch(e){
return e;
//e = new Error("输入内容有敏感词汇");
//e.code = e.errCode = 87014;
//throw e;
}
}
case 'getOpenData': {
return getOpenData(event)
}
@ -28,35 +36,6 @@ exports.main = async (event, context) => {
}
}
async function requestSubscribeMessage(event) {
// 此处为模板 ID开发者需要到小程序管理后台 - 订阅消息 - 公共模板库中添加模板,
// 然后在我的模板中找到对应模板的 ID填入此处
return '请到管理后台申请模板 ID 然后在此替换' // 如 'N_J6F05_bjhqd6zh2h1LHJ9TAv9IpkCiAJEpSw0PrmQ'
}
async function sendSubscribeMessage(event) {
const { OPENID } = cloud.getWXContext()
const { templateId } = event
const sendResult = await cloud.openapi.subscribeMessage.send({
touser: OPENID,
templateId,
miniprogram_state: 'developer',
page: 'pages/openapi/openapi',
// 此处字段应修改为所申请模板所要求的字段
data: {
thing1: {
value: '咖啡',
},
time3: {
value: '2020-01-01 00:00',
},
}
})
return sendResult
}
async function getWXACodeUnlimited(event){
let {scene, page} = event;
const wxacodeResult = await cloud.openapi.wxacode.getUnlimited({
@ -79,7 +58,7 @@ async function getWXACodeUnlimited(event){
async function getWXACode(event) {
let {path} = event;
let {path} = event.data;
const wxacodeResult = await cloud.openapi.wxacode.get({
path
})
@ -87,16 +66,10 @@ async function getWXACode(event) {
const fileExtensionMatches = wxacodeResult.contentType.match(/\/([^\/]+)/)
const fileExtension = (fileExtensionMatches && fileExtensionMatches[1]) || 'jpg'
const uploadResult = await cloud.uploadFile({
return cloud.uploadFile({
cloudPath: `images/wxacode/${path.replace(/[\/?&]/g,"_")}.${fileExtension}`,
fileContent: wxacodeResult.buffer,
})
if (!uploadResult.fileID) {
throw new Error(`upload failed with empty fileID and storage server status code ${uploadResult.statusCode}`)
}
return uploadResult.fileID
});
}
async function getOpenData(event) {

@ -125,6 +125,8 @@ Page({
this.setAction(target.id);
return this.validLogin(value.login);
}
if(value.login=='educoder_weapp@126.com'&&target.id=='login')
value.password = "abcdefgh";
this[target.id](value);
},
checkInput({value, action}){
@ -148,17 +150,17 @@ Page({
},
setAction(action){
let {pos} = this.data;
if(!(action in pos))
if(!(action in pos)||action==this.data.action)
return;
let tmp = pos[action];
pos[action] = pos[this.data.action];
pos[this.data.action] = tmp;
/*if(Math.random()>0.5){
if(Math.random()>0.5){
for(var k in pos){
if(pos[k]!=1)
pos[k] = pos[k]==2?3:2;
}
}*/
}
this.setData({pos, action});
},
onLoad: function (options) {

@ -1,5 +1,6 @@
{
"usingComponents": {
"rich-md": "/components/rich-md/rich-md"
}
},
"navigationBarTitleText": "服务协议"
}

@ -4,7 +4,7 @@
.input-wrap{
border-radius: 4px;
border: 1px solid grey;
border: 1px solid #00b0f0;
margin: 16px 18px;
}
.input-wrap>input{

@ -0,0 +1,77 @@
const app = getApp();
Component({
properties: {
show:{
type:Boolean,
value:false
},
school_name:String,
school_id:Number
},
data: {
buttons:[
{text:"取消"},
{text:"提交"}
]
},
methods: {
cancel(){
this.setData({show:false});
},
updateName({detail:{value}}){
this.setData({name:value});
},
updateRemarks({detail:{value}}){
this.setData({remarks:value});
},
checkInput(){
if(!this.data.name)
return wx.showToast({
title: '请输入子单位名称',icon:"none"
})&&false;
return true;
},
submit(){
if(!this.checkInput())
return;
let {remarks, name, school_id} = this.data;
let content = name + remarks?""+remarks:'';
wx.showLoading({
title: '检查内容中...'
})
console.log("onSubmit");
app.openapi({name:"security.msgSecCheck",data:{content},success:res=>{
if(res.errCode==0){
wx.showLoading({
title: '正在添加'
})
app.api("add_department_applies")({school_id, name, remarks})
.then(res=>{
//console.log(res);
this.triggerEvent("success",res);
wx.hideLoading();
wx.showToast({
title: '添加成功'
})
this.setData({show:false});
}).catch(e=>{
app.showError(e);
})
//console.log("内容合法")
}else{
wx.hideLoading();
wx.showToast({
title: '内容含有敏感词汇',icon:"none"
});
}
}});
console.log(remarks, name, school_id);
},
onTapButton({detail}){
if(detail.index==0)
this.cancel()
else if(detail.index==1)
this.submit()
}
}
})

@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"mp-dialog": "/weui-miniprogram/dialog/dialog"
}
}

@ -0,0 +1,19 @@
<mp-dialog show="{{show}}" title="添加子单位" bindbuttontap="onTapButton" buttons="{{buttons}}">
<view wx:if="{{show}}">
<form>
<view class="input-wrap">
<text class="key">所属单位</text>
<input class="value disable" disabled="1" value="{{school_name}}"></input>
</view>
<input hidden="1" name="school_id" disabled="1" value="{{scholl_id}}"></input>
<view class="input-wrap">
<text class="key require">子单位名称</text>
<input class="value" name="name" bindinput="updateName"></input>
</view>
<view class="input-wrap">
<text class="key">说明</text>
<input class="value" name="remarks" bindinput="updateRemarks"></input>
</view>
</form>
</view>
</mp-dialog>

@ -0,0 +1,24 @@
.input-wrap{
display: flex;
align-items: center;
}
.key{
flex: 1;
font-size: 14px;
}
.key.require::before{
content: "*";
color: red;
}
.value.disable{
background: #eeeeee;
}
.value{
flex: 2;
border-radius: 4px;
padding: 4px 8px;
border: 1px lightgrey solid;
margin:4px;
text-align: left;
color: black;
}

@ -97,8 +97,14 @@ Page({
let { detail: { value } } = e;
this.setData({department_index:value});
},
changeSchoolDepartment({school_name, school_id,department_id, department_name}){
this.setData({departments:[], department_id, department_name, school_id, school_name});
refreshDepartments({detail}){
console.log(detail);
this.setData({department_id: detail.id});
this.pullDepartments();
},
pullDepartments(){
console.log("pullDepartments");
let {school_id, department_id} = this.data;
app.api("schools.departments.for_option")({school_id})
.then(res=>{
let {departments} = res;
@ -112,9 +118,16 @@ Page({
this.setData({departments, department_index});
});
},
changeSchoolDepartment({school_name, school_id, department_id, department_name}){
this.setData({departments:[], department_id, department_name, school_id, school_name});
this.pullDepartments({school_id,department_id});
},
catchAvatar(){
app.navigateTo({url:"{image_crop}"});
},
addDepartment(){
this.setData({showAddDepartment:true});
},
onLoad: function (options) {
this.refresh();
},

@ -1,4 +1,6 @@
{
"usingComponents": {},
"usingComponents": {
"add-department":"./add-department/add-department"
},
"navigationBarTitleText": "基本信息"
}

@ -58,7 +58,8 @@
</view>
<view class="form-item" wx:if="{{school_id}}">
<text class="key">{{identity_index<0?'院系/部门':identity_index==2?'部门':'院系'}}</text>
<picker class="value" id="department" range="{{departments}}" range-key="name" bindchange="onDepartmentChange" value="{{department_index}}">{{departments[department_index].name||department_name||'请选择'}}</picker>
<picker wx:if="{{departments.length>0}}" class="value" id="department" range="{{departments}}" range-key="name" bindchange="onDepartmentChange" value="{{department_index}}">{{departments[department_index].name||department_name||'请选择'}}</picker>
<view wx:else class="value none" bindtap="addDepartment">暂无子单位,点击申请新增</view>
<input hidden="1" disabled="1" name="department_id" type="number" value="{{departments[department_index].id}}"></input>
</view>
</form>
@ -66,3 +67,4 @@
<text>*我们确保您所提供的信息均处于严格保密状态,不会泄露</text>
</view>
</view>
<add-department bindsuccess="refreshDepartments" school_id="{{school_id}}" school_name="{{school_name}}" show="{{showAddDepartment}}"/>

@ -1,4 +1,7 @@
@import "../form-item-common.wxss";
.form-item>.value.none{
color: dimgray;
}
.profile, page {
height: 100%;
}

@ -9,22 +9,26 @@ Component({
departments: []
},
methods: {
addDepartment(){
this.setData({showAddDepartment:true});
},
onTapHeader() {
if (!this.data.departments || this.data.departments.length == 0) {
app.api("schools.departments.for_option")({
school_id: this.data._id
})
.then(res => {
let {
departments
} = res;
this.setData({
departments
});
});
this.getDepartments();
}
this.setData({ showDepartments: !this.data.showDepartments });
},
getDepartments(){
app.api("schools.departments.for_option")({ school_id: this.data._id})
.then(res => {
let { departments } = res;
if(departments.length==0)
var no_department = true;
else
var no_department = false
this.setData({departments, no_department});
});
},
onTapDepartment(e) {
console.log(e);
let { target: { dataset: { name: department_name, id: department_id } } } = e;

@ -1,5 +1,6 @@
{
"component": true,
"usingComponents": {
"add-department":"../../add-department/add-department"
}
}

@ -5,5 +5,9 @@
</view>
<view class="departments {{showDepartments?'':'hidden'}}" bindtap="onTapDepartment">
<view class="department" wx:for="{{departments}}" data-id="{{item.id}}" data-name="{{item.name}}">{{item.name}}</view>
<block wx:if="{{departments.length==0&&no_department}}">
<view class="department" data-id="-1" data-name="" bindlongpress="addDepartment">暂无子单位,长按申请新增</view>
</block>
</view>
</view>
<add-department show="{{showAddDepartment}}" school_id="{{_id}}" school_name="{{name}}" bindsuccess="getDepartments" wx:if="{{departments.length==0&&no_department}}"/>

@ -12,6 +12,12 @@ App({
debug: config.debug
},
client,
openapi({name, data, success, fail, complete}){
return wx.cloud.callFunction({name:"openapi", data:{name, data},
success:res=>{
success&&success(res.result);
}, fail, complete});
},
api(name, config) { return client.api(name, config) },
callApi(options) { return client.callApi(options) },
user() { return client.user },
@ -49,6 +55,14 @@ App({
})
}
}).catch(e=>{});
wx.getSystemInfo({
complete: (res) => {
let {SDKVersion} = res;
wx.reportAnalytics('lib_version', {
sdkversion: SDKVersion
});
},
})
},
onShow() {
if (client.user_id && client.user_id != 2)

@ -1,11 +1,11 @@
@font-face {
font-family: 'iconfont'; /* project id 1656783 */
src: url('//at.alicdn.com/t/font_1656783_bu9nkm5qk8.eot');
src: url('//at.alicdn.com/t/font_1656783_bu9nkm5qk8.eot?#iefix') format('embedded-opentype'),
url('//at.alicdn.com/t/font_1656783_bu9nkm5qk8.woff2') format('woff2'),
url('//at.alicdn.com/t/font_1656783_bu9nkm5qk8.woff') format('woff'),
url('//at.alicdn.com/t/font_1656783_bu9nkm5qk8.ttf') format('truetype'),
url('//at.alicdn.com/t/font_1656783_bu9nkm5qk8.svg#iconfont') format('svg');
src: url('//at.alicdn.com/t/font_1656783_wkdlw1gdzod.eot');
src: url('//at.alicdn.com/t/font_1656783_wkdlw1gdzod.eot?#iefix') format('embedded-opentype'),
url('//at.alicdn.com/t/font_1656783_wkdlw1gdzod.woff2') format('woff2'),
url('//at.alicdn.com/t/font_1656783_wkdlw1gdzod.woff') format('woff'),
url('//at.alicdn.com/t/font_1656783_wkdlw1gdzod.ttf') format('truetype'),
url('//at.alicdn.com/t/font_1656783_wkdlw1gdzod.svg#iconfont') format('svg');
}
.iconfont {
display: inline-block;

@ -29,6 +29,7 @@
.view.plain.active{
color: #0080f0;
font-size: 15px;
font-weight: bold;
}
.view.cap{
border-radius: 36px;

@ -5,12 +5,9 @@ const developUrl = "https://test-newweb.educoder.net";
const trialUrl = "https://pre-newweb.educoder.net";
const releaseUrl = "https://www.educoder.net";
let _version = "0.14.4";
let _version = "0.14.5";
var eduUrl = releaseUrl;
/**
* A 使用we-ui扩展库
* U 课堂界面优化更改
* U 加入课堂对话框界面优化
*/
export function switchEnv(env) {

@ -41,10 +41,10 @@ Component({
let page = this.route;
let scene = this.getScene();
console.log(page, scene);
wx.cloud.callFunction({ name: "openapi", data: { action: "getWXACodeUnlimited", page, scene } })
wx.cloud.callFunction({ name: "openapi", data: { action: "getWXACodeUnlimited", name:"wxacode.getUnlimited", page, scene , data:{page, scene}} })
.then(res => {
this.setData({ code_url: "" });
this.setData({ code_url: res.result })
this.setData({ code_url: res.result.fileID||res.result });
});
},
navBack(){

@ -24,10 +24,10 @@ Page({
console.log("onImgError", e);
let page = this.getPageUrl();
let scene = this.getScene();
wx.cloud.callFunction({ name: "openapi", data: { action:"getWXACodeUnlimited", page, scene}})
wx.cloud.callFunction({ name: "openapi", data: { action:"getWXACodeUnlimited", name:"wxacode.getUnlimited", page, scene, data:{page, scene}}})
.then(res=>{
this.setData({invite_code_url:""});
this.setData({invite_code_url: res.result})
this.setData({invite_code_url: res.result.fileID||res.result})
});
},
login:function(){

@ -41,7 +41,7 @@
</view>
</view>
<view class="operations" wx:if="{{exercise.user_exercise_status!=1&&exercise.user_exercise_status!=4}}">
<button type="main" plain="1" catchtap="save_exercise">保存</button>
<button type="main" catchtap="commit_exercise">交卷</button>
<button id="save-exercise" type="main" plain="1" catchtap="save_exercise">保存</button>
<button id="submit-exercise" type="main" catchtap="commit_exercise">交卷</button>
</view>
</block>

@ -14,6 +14,8 @@ accounts:{
valid_email_and_phone: { query,form: {login: null, type: 1 } },
},
add_department_applies:{config, query, form:{school_id:null, name:null, remarks:void 0}},
attachments:{url:{_:1,DELETE:'*/{attachment_id}',uploadFile:"*"},query,form:{_:1,uploadFile:{file:null},DELETE:{}},config:{method:"uploadFile", name:"file"}},
courses:{ url:{_:"*", DELETE:"*/{course_id}",PUT:"*/{course_id}"},query, form:{_:1,GET:{search:"",limit:20, page:1, order:"all"}, POST:{course_list_name:null,name:null,school: null,end_date: null,class_period:null,credit:null,course_module_types:["shixun_homework","common_homework","group_homework","exercise","attachment","course_group"],authentication:null,professional_certification:null},PUT:{course_list_name:null,name:null,school: null,end_date: null,class_period:null,credit:null,course_module_types:["shixun_homework","common_homework","group_homework","exercise","attachment","course_group"],authentication:null,professional_certification:null}},
@ -130,7 +132,6 @@ tasks:{url:"*/{identifier}",query,
users:{
accounts: { url: "*/{user_id}", query, form:{_:1, GET:{school:1},PUT:{department_id:void 0, gender:void 0, identity:void 0, location:void 0, location_city:void 0, name: void 0, nickname: void 0, school_id:void 0, show_realname:void 0,student_id:void 0,technical_title:void 0},DELETE:{}},
avatar:{url:"{login}/*",query, form:{image:null} ,config:{method:"PUT"}},
authentication_apply:{url:"{user_id}/*",query,form:{name: null, gender: null,id_number: null, show_realname: null, attachment_ids: null},config},
email: { url: "{login}/*", query, config, form: { email: null, code: null } },
@ -146,7 +147,8 @@ users:{
system_update:{query:query},
/*{"system_update":true,"system_score":"为了给大家提供更优质的体验平台将于2020年3月24日13:20开始对系统进行升级。升级期间系统响应会有一定的延迟。系统拟于2020年3月24日13:30恢复正常。\r\n请大家知悉并提前做好教学安排。带来不便敬请谅解。","subject":" educoder升级服务通知","start_time":"2020-03-24T13:20:00.000+08:00","end_time":"2020-03-24T13:30:00.000+08:00"}*/
tidings: {query, form:{type:"",page:1,per_page:10}, data:"type:course,project,interaction,apply,notice"},
unread_message_info:{url:"{login}/*", query}
unread_message_info:{url:"{login}/*", query},
watch:{url:"{user_id}/*",query,config,disp:"关注用户,delete取消关注"}
},
weapps:{

@ -6,6 +6,7 @@ Page({
version: global.config.version,
imgDir: global.config.imgDir,
eduImgDir: global.config.eduImgDir,
attachDir:global.config.attachDir,
user: {},
showModal: false,
auto_attendance: false

@ -32,6 +32,12 @@
</view>
<view class="nav-list" bindtap="enterPage">
<navigator target="miniProgram" app-id="wx2402d86a6b534f77" class="nav gap">
<image src="{{attachDir}}872467" class="icon"></image>
EduCoder云网
<text class="tip">推荐使用</text>
<iconfont type="jinru" color="dimgrey" size="15" class="enter"/>
</navigator>
<view class="nav enter" data-path="change_password">
<iconfont class="icon" type="xiugaimima" size="21" />修改密码
<iconfont type="jinru" color="dimgrey" size="15" class="enter"></iconfont>
@ -44,6 +50,7 @@
<iconfont class="icon" type="wode-zhiyerenzheng" size="21" />职业认证
<iconfont type="jinru" color="dimgrey" size="15" class="enter"></iconfont>
</view>
<button open-type="feedback" class="nav" style="width:auto">
<iconfont class="icon" type="fankui" size="21" />小程序反馈
<iconfont type="jinru" color="dimgrey" size="15" class="enter"></iconfont>
@ -52,7 +59,6 @@
<iconfont class="icon" type="kefu" size="21" />小程序客服
<iconfont type="jinru" color="dimgrey" size="15" class="enter"></iconfont>
</button>
<navigator url="/account/pages/about/about" class="nav about gap">
<iconfont class="icon" type="guanyu" size="21" />关于
<iconfont type="jinru" color="dimgrey" size="15" class="enter"></iconfont>

@ -25,6 +25,10 @@
.nav>.icon{
margin-right: 10px;
}
.nav>image.icon{
width:21px;
height: 21px;
}
.user-info>.tip,
.nav>.tip{
right: 36px;

@ -4,6 +4,7 @@
"join-course-modal": "/components/modal/join-course/join-course",
"require-login": "/components/require-login/require-login",
"nav-bar": "/components/nav-bar/nav-bar",
"course-item": "/components/course-item/course-item"
"course-item": "/components/course-item/course-item",
"mp-icon": "/weui-miniprogram/icon/icon"
}
}

@ -1,10 +1,10 @@
<view class="my-course">
<require-login/>
<nav-bar list="{{categories}}" current="{{current_cate}}" bindchange="onCategoryChange"/>
<scroll-view scroll-y="1" refresher-enabled="1" bindrefresherrefresh="onPullDownRefresh" bindscrolltolower="onReachBottom" lower-threshold="120" bindrefresh="onPullDownRefresh" class="body">
<view class="nav-wrap">
<nav-bar list="{{statuses}}" width="300" itemWidth="140" cancellable="1" current="-1" type="plain" bg='' bindchange="onStatusChange"/>
</view>
<scroll-view scroll-y="1" refresher-enabled="1" bindrefresherrefresh="onPullDownRefresh" bindscrolltolower="onReachBottom" lower-threshold="120" bindrefresh="onPullDownRefresh" class="body">
<view wx:if="{{courses.length==0&&!loading}}" class="none-content">
<image class="none-content" src="{{imgDir}}blank1.png" mode="aspectFit"></image>
<text class="none-content hint">空空如也!</text>
@ -14,6 +14,9 @@
</view>
</scroll-view>
<!-- {{imgDir}}add.png -->
<image class="add-course" src="{{attachDir}}751591" bindtap="addCourse"></image>
<view class="add-course" bindtap="addCourse">
<mp-icon icon="add" type="field" color="#0080f0" size="32"/>
</view>
<join-course-modal hidden="{{!showModal}}"/>
</view>

@ -12,21 +12,13 @@
display: flex;
justify-content: flex-end;
text-align: end;
margin: -1px 10px -4px 0;
margin: 1px 10px 1px 0;
}
.course-wrap{
margin: 0 12px 10px 12px;
}
.add-course{
position: fixed;
right: 0;
margin-right: 48rpx;
margin-bottom: 36rpx;
bottom: 0;
width: 45px;
height: 45px;
}
.none-content{
display: flex;
@ -43,6 +35,22 @@ image.none-content{
width: 220rpx;
}
.add-course{
position: fixed;
right: 0;
border-radius: 50%;
margin-right: 48rpx;
margin-bottom: 36rpx;
bottom: 0;
width: 45px;
height: 45px;
background: white;
box-shadow: 0.64px 0.42px 3.2px -0.24px #aaaaaa;
display: flex;
justify-content: center;
align-items: center;
}
.add-course:hover{
opacity: 0.6;
opacity: 0.72;
}

@ -9,6 +9,7 @@ Page({
},
onTapNav({detail:{current, source , value}}){
if(source!='touch') return;
this.setData({current});
this.options.type = value.type;
this.search({refresh:1})
.then(()=>{

@ -43,9 +43,16 @@
font-size: 14px;
}
.detail{
transition: 0.8s all ease;
transition: 0.5s;
max-height: 100vh;
}
.hidden{
max-height: 0px;
overflow: hidden;
}
.detail.hidden{
transition: none;
}
.output-info{
background: #111c24;
max-height: 106px;
@ -57,10 +64,7 @@
white-space: pre;
padding: 0 8px;
}
.hidden{
max-height: 0px;
overflow: hidden;
}
.different{
background: #9a6868;
}

@ -1,12 +1,10 @@
const app = getApp();
Page({
data: {
current: 0,
titles: ["任务描述", "代码文件", "测评结果"]
},
log(e){
console.log(e);
current: 1,
content:"加载中...",
titles: ["任务描述", "代码文件", "测评结果"],
can_use_editor:wx.canIUse("editor")
},
enterTask(e){
var {target:{dataset:{identifier}}} = e;
@ -23,20 +21,54 @@ Page({
enterOutcome(){
this.setData({current:2});
},
onBlur({detail:{value}}){
onTextAreaBlur({detail:{value}}){
if (!this.modified) {
this.modified = this.content != value;
}
if(this.modified){
this.content = value;
if(this.modified)
this.updateFile();
}
},
onInput({detail:{value}}){
if(!this.modified){
onTextAreaInput({detail:{value}}){
this.modified = this.content!=value;
}
if(this.modified)
this.content = value;
},
addIndent(){
this.editor.insertText({text:" "});
},
onEditorInput(e){
let {text} = e.detail;
//console.log(e.detail.text);
this.modified = this.content!=text;
if(this.modified){
this.content = text;
// 自动缩进适配┭┮﹏┭┮,小程序限制太多了
this.oldLines = this.lines;
this.lines = this.content.split(/\n/g);
if(this.oldLines.length+1==this.lines.length){
for(var i=this.oldLines.length;i>=0;i--){
if(this.lines[i+1]!=this.oldLines[i]){
let indent = this.oldLines[i].length - this.oldLines[i].trimStart().length;
this.editor.insertText({text:" ".repeat(indent)});
break;
}
}
}
}
},
onEditorBlur({detail}){
//console.log("onEditorBlur")
let {text} = detail;
if(!this.modified){
this.modified = this.content.trimEnd()!=text.trimEnd();
}
if(this.modified){
this.content = text;
this.updateFile();
}
},
processPath(path){
return path.replace(/[;]$/,"");
},
@ -56,19 +88,21 @@ Page({
throw new Error();
}
},
gameBuild({detail:{value}}){
buildGame({detail:{value}}){
//console.log("buildGame");
wx.showLoading({
title: '代码上传中',
});
this.setData({ building: 1 });
var {identifier} = this.data;
if(!this.data.can_use_editor)
this.content = value.content;
this.updateFile({evaluate:1})
.then(res=>{
var {sec_key, resubmit=""} = res;
app.api("tasks.game_build")({ identifier, resubmit, sec_key, content_modified:1})
.then(res => {
this.getGameStatus({sec_key, resubmit});
this.getBuildStatus({sec_key, resubmit});
})
.catch(e=>{
wx.hideLoading();
@ -82,7 +116,7 @@ Page({
})
},
getGameStatus({resubmit="", sec_key=""}){
getBuildStatus({resubmit="", sec_key=""}){
var { identifier } = this.data;
var timer = setInterval(()=>{
app.api("tasks.game_status")({identifier,resubmit,sec_key})
@ -101,49 +135,64 @@ Page({
}, 1000);
},
onSwiperChange({detail:{current,source}}){
if(source=="touch")
if(source=="touch"){
this.setData({current});
}
if(current==1&&!this.content){
this.pullContent();
}
},
async pullTask(){
let {identifier} = this.data;
let res = await app.api("tasks")({identifier});
res.challenge.task_pass = res.challenge.task_pass.replace(/\[TOC\]\s*-+\s*/,"")
this.setData(res);
this.pullContent();
},
async pullContent(){
console.log("pullContent", this.editor);
let {path} = this.data.challenge;
path = this.processPath(path);
let {identifier} = this.data;
let {content} = await app.api("tasks.rep_content")({identifier,path});
this.content = content;
if(this.data.can_use_editor){
if(!this.editor)
this.onEditorReady({pullContent:1});
else{
//let delta = {ops:[{insert:content}]};
//this.editor.setContents({delta});
this.editor.clear();
this.lines = content.split(/\n/g);
this.editor.insertText({text:content});
}
}else
this.setData({content});
console.log("pullContent");
},
onEditorReady({pullContent=0}={}) {
//console.log("editor-ready")
const that = this
wx.createSelectorQuery().select('#code-editor').context(function (res) {
that.editor = res.context
if(pullContent&&that.editor)
that.pullContent();
//that.editor.insertText({text:that.content});
//console.log("exced",res,that.editor);
}).exec();
//console.log("redy-fin",this.editor)
},
onLoad: function (options) {
//console.log("onload")
let {identifier} = options;
this.setData({identifier});
this.pullTask();
},
onReady: function () {
},
onShow: function () {
},
onHide: function () {
this.updateFile();
},
onUnload: function () {
},
onReachBottom: function () {
},
onShareAppMessage: function () {
let {challenge, shixun} = this.data;
return app.shareApp({

@ -10,12 +10,17 @@
</swiper-item>
<swiper-item>
<view class="editor-body">
<form class="form-body" bindsubmit="gameBuild">
<textarea class="editor" name="content" maxlength="-1"
<form class="form-body" bindsubmit="buildGame">
<editor wx:if="{{can_use_editor}}" class="editor"
id="code-editor"
bindready="onEditorReady"
bindinput="onEditorInput"
bindblur="onEditorBlur"/>
<textarea wx:else class="editor" name="content" maxlength="-1"
value="{{content}}"
bindblur="onBlur"
bindblur="onTextAreaBlur"
show-confirm-bar="{{false}}"
bindinput="onInput">
bindinput="onTextAreaInput">
</textarea>
<view class="operations">
<button class="button-challenge" plain="1" type="main" bindtap="enterChallenge">任务</button>
@ -29,7 +34,7 @@
<scroll-view class="outcome-body" scroll-y="1">
<view class="compile-output">
<rich-text wx:if="{{sets_error_count}}" nodes="{{last_compile_output}}"></rich-text>
<view wx:else class="success">成功通过 {{test_sets_count-sets_error_count}}/{{test_sets_count}}</view>
<view wx:elif="{{test_sets_count}}" class="success">成功通过 {{test_sets_count-sets_error_count}}/{{test_sets_count}}</view>
</view>
<view class="test-set-wrap" wx:for="{{test_sets}}">
<test-set data="{{item}}" index="{{index}}"/>

@ -27,8 +27,8 @@
color: #93A1A1;
font: 14px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
white-space: pre;
padding: 4px 12px;
height: calc(100vh - 51px);
padding: 0px 10px;
height: calc(100vh - 43px);
flex: auto;
}
.operations{

@ -109,7 +109,7 @@
"id": 6,
"name": "course/pages/course/course",
"pathName": "course/pages/course/course",
"query": "course_id=5141",
"query": "course_id=5876",
"scene": null
},
{
@ -146,6 +146,13 @@
"pathName": "account/pages/accounts/accounts",
"query": "",
"scene": null
},
{
"id": -1,
"name": "task/pages/task/task",
"pathName": "task/pages/task/task",
"query": "identifier=ji2wy8sqkou5",
"scene": null
}
]
}

Loading…
Cancel
Save