A 发送实训至课堂

master
educoder_weapp 5 years ago
parent 76c4242bc1
commit 9b9053b5d4

@ -117,7 +117,7 @@ App({
} }
}); });
/*
function getCurrentPath() { function getCurrentPath() {
let pages = getCurrentPages(); let pages = getCurrentPages();
return pages[pages.length - 1].route; return pages[pages.length - 1].route;
@ -136,3 +136,4 @@ function toAbsPath(current, path) {
} }
return path; return path;
} }
*/

@ -87,7 +87,7 @@ button[plain][disabled]{
} }
button[type=secondary]{ button[type=secondary]{
color: #00b0f0; color: #00b0f0;
background: #f0f0f0; background: #eee;
} }
button[type=error]{ button[type=error]{
background: #fa5151; background: #fa5151;

@ -0,0 +1,105 @@
const app = getApp();
let KEY = "no-nav-to-course-after-send";
Component({
properties: {
shixun_ids:Array,
subject_id:{
type:Number,
value:-1
},
show: {
type:Boolean,
value:false,
observer:function(v){
if(v){
if(this.data.status!=200)
this.pullCourse({refresh:1})
this.setData({auto_nav: !wx.getStorageSync(KEY)})
}
}
}
},
data: {
courses:[],
auto_nav: !wx.getStorageSync(KEY)
},
created(){
this.options = {page:1, limit:10};
},
methods: {
close(){
this.setData({show:false});
this.onClose();
},
onClose(){
this.setData({checked: false});
this.course_id = null;
},
changeOption(e){
//console.log(e);
this.setData({auto_nav: !this.data.auto_nav});
wx.setStorageSync(KEY, !this.data.auto_nav);
},
send(){
let {course_id} = this;
let {shixun_ids, subject_id} = this.data;
if(shixun_ids.length==0){
return wx.showToast({
title: '请选择实训',
icon:"none"
})
}
if(!course_id){
return wx.showToast({
title: '请选择课堂',
icon:"none"
})
}
//console.log(shixun_ids, course_id);
let api_name = subject_id>0?'paths.send_to_course':"shixuns.batch_send_to_course"
app.api(api_name)({subject_id, course_id, shixun_ids})
.then(res=>{
this.triggerEvent("success",{});
//console.log(res);
app.showMsg(res);
this.close();
this.onClose();
if(this.data.auto_nav)
setTimeout(()=>{
app.navigateTo({
url:`{course}?course_id=${res.course_id}&module_type=shixun_homework`
})
},400);
}).catch(e=>{
app.showError(e);
});
},
onChange(e){
let {detail:{value}} = e;
this.course_id = parseInt(value);
//console.log(e, value);
},
onReachBottom(){
this.pullCourse();
},
pullCourse({refresh=0}={}){
if(refresh){
this.options.page=1;
}else{
this.options.page++;
}
app.api("courses.search_slim")(this.options)
.then(res=>{
let {courses} = res;
if(!refresh)
courses = this.data.courses.concat(courses);
this.setData({courses, status:200});
}).catch(e=>{
global.realTimeLog.error(e, "courses.search_slim fail");
})
}
}
})

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

@ -0,0 +1,22 @@
<mp-halfScreenDialog show="{{show}}" bindclose="onClose">
<text slot="title">发送到课堂</text>
<view slot="desc" class="body">
<scroll-view scroll-y="1" class="courses" bindscrolltolower="onReachBottom">
<radio-group name="course_id" bindchange="onChange">
<view class="course" wx:for="{{courses}}">
<radio checked="{{checked}}" color="#00b0f0" value="{{item.id}}">
<view class="single-line course-name">{{item.name}}</view>
</radio>
</view>
<view class="empty-tip" wx:if="{{courses.length==0}}">
{{status==200?'暂无管理的课堂':'努力加载中'}}
</view>
</radio-group>
</scroll-view>
</view>
<view class="operations" slot="footer">
<button class="operation" type="secondary" bindtap="close">取消</button>
<button class="operation" type="main" bindtap="send">发送</button>
<radio class="option" color="#00b0f0" bindtap="changeOption" checked="{{auto_nav}}">发送后跳转到课堂</radio>
</view>
</mp-halfScreenDialog>

@ -0,0 +1,32 @@
.single-line{
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
}
.courses{
height: 26vh;
}
.course{
padding: 4px 12px;
}
.course-name{
padding-left: 6px;
}
.empty-tip{
text-align: center;
color: dimgray;
font-size: 15px;
padding-top: 10vh;
}
.operations{
text-align: center;
margin: -28px 0 -20px 0;
}
.operation{
width: 120px!important;
margin: 0 8px!important;
display: inline-block!important;
}
.option{
transform: scale(0.6);
}

@ -68,7 +68,7 @@
<view slot="desc" class="modules"> <view slot="desc" class="modules">
<view class="module-item" wx:for="{{course_modules}}" bindtap="onModuleTap" data-type="{{item.type}}"> <view class="module-item" wx:for="{{course_modules}}" bindtap="onModuleTap" data-type="{{item.type}}">
<image class="module-img" mode="aspectFit" src="/course/images/svg/{{item.type}}_select.svg"></image> <image class="module-img" mode="aspectFit" src="/course/images/svg/{{item.type}}_select.svg"></image>
<text class="singlw-ling module-name">{{item.name}}</text> <text class="single-line module-name">{{item.name}}</text>
</view> </view>
</view> </view>
</mp-halfScreenDialog> </mp-halfScreenDialog>

@ -10,13 +10,15 @@ Page({
type:"secondary" type:"secondary"
}, },
onScanCode(e){ onScanCode(e){
;
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
var p =this.selectComponent("#main")
p.onLoad();
p.onShow();
}, },
/** /**

@ -1,3 +1,5 @@
{ {
"usingComponents": {} "usingComponents": {
"main":"/pages/home/home"
}
} }

@ -1,4 +1 @@
<main id="main"/>
<view>
<button type="{{type}}" plain size="mini">登录</button>
</view>

@ -102,7 +102,8 @@ myshixuns:{
update_file:{url:"{identifier}/*",query,form:{path:null, content: null, evaluate:null, game_id:null},config} update_file:{url:"{identifier}/*",query,form:{path:null, content: null, evaluate:null, game_id:null},config}
}, },
paths:{url:"*/{subject_id}",query, paths:{url:"*/{subject_id}",query,
right_banner:{url:"{subject_id}/*",query} right_banner:{url:"{subject_id}/*",query},
send_to_course:{url:"{subject_id}/*", query, config, form:{course_id:null, shixun_ids:null}},
}, },
schools:{ schools:{

@ -150,7 +150,9 @@ export default class Client{
}, fail:e=>{ }, fail:e=>{
this.trigger("fail",name,e); this.trigger("fail",name,e);
fail&&fail(e); fail&&fail(e);
}, complete, }, complete:res=>{
global.realTimeLog.debug(name+" api was called");
},
}); });
} }
load_user() { load_user() {

@ -8,3 +8,7 @@ page{
flex: 1 1 1px; flex: 1 1 1px;
height: 1px; height: 1px;
} }
/* for tmp*/
.weui-half-screen-dialog__hd__side .weui-icon-btn.weui-icon-btn_more{
display: none;
}

@ -28,12 +28,8 @@ Component({
} }
}, },
onChange(e){
;
},
onSelect(e){ onSelect(e){
let {detail} = e; let {detail} = e;
;
this.selects[detail.name] = detail.value; this.selects[detail.name] = detail.value;
if(detail.value&&!this.data.select) if(detail.value&&!this.data.select)
this.setData({select: true}); this.setData({select: true});
@ -46,35 +42,32 @@ Component({
if(this.selects[i]) if(this.selects[i])
length++; length++;
} }
;
if(length==0){ if(length==0){
this.setData({select: false}); this.setData({select: false});
this.selects = {}; this.selects = {};
} }
} }
}, },
onReset(e){ reset(e){
;
this.setData({select:false}); this.setData({select:false});
this.selects = {} this.selects = {}
}, },
onSubmit(e){ onSubmit(e){
;
if(!this.data.select) if(!this.data.select)
this.setData({select: true}); this.setData({select: true});
else{ else{
let shixun_ids = []; let shixun_ids = [];
for(var i in this.selects){ for(var i in this.selects){
if(this.selects[i]) if(this.selects[i])
shixun_ids.push(i); shixun_ids.push(parseInt(i));
} }
;
if(shixun_ids.length==0){ if(shixun_ids.length==0){
wx.showToast({ wx.showToast({
title: '请选择实训',icon:"none" title: '请选择实训',icon:"none"
}) })
}else{ }else{
this.select_shixun_ids = shixun_ids; this.setData({shixun_ids});
console.info(shixun_ids);
this.setData({showSendDialog: true}); this.setData({showSendDialog: true});
} }

@ -2,6 +2,7 @@
"component": true, "component": true,
"usingComponents": { "usingComponents": {
"empty-page":"/components/empty-page/empty-page", "empty-page":"/components/empty-page/empty-page",
"shixun-item":"./shixun-item/shixun-item" "shixun-item":"./shixun-item/shixun-item",
"send-to-course":"/components/modal/send-to-course/send-to-course"
} }
} }

@ -9,7 +9,7 @@
<icon class="icon" type="search"></icon> <icon class="icon" type="search"></icon>
</view> </view>
</view> </view>
<form bindsubmit="onSubmit" bindselect="onSelect" bindreset="onReset"> <form bindsubmit="onSubmit" bindselect="onSelect" bindreset="reset">
<view class="sticky-top list-header"> <view class="sticky-top list-header">
<view class="subtitle">实训列表</view> <view class="subtitle">实训列表</view>
<view class="select-operations"> <view class="select-operations">
@ -24,3 +24,4 @@
<empty-page show="{{status==205}}" title="暂无相关内容" desc="获取更多请进入EduCoder官网"/> <empty-page show="{{status==205}}" title="暂无相关内容" desc="获取更多请进入EduCoder官网"/>
</view> </view>
</scroll-view> </scroll-view>
<send-to-course bindsuccess="reset" show="{{showSendDialog}}" shixun_ids="{{shixun_ids}}"/>

@ -49,3 +49,4 @@
.shixun-wrp{ .shixun-wrp{
margin-bottom: 2px; margin-bottom: 2px;
} }

@ -13,6 +13,10 @@ Page({
], ],
description:"" description:""
}, },
sendToCourse(){
let {id} = this.data.shixun;
this.setData({shixun_ids: [id], showSendDialog: true});
},
collect(){ collect(){
let {id, is_collect} = this.data.shixun; let {id, is_collect} = this.data.shixun;
let api_name = is_collect?"collections.cancel":"collections"; let api_name = is_collect?"collections.cancel":"collections";

@ -3,7 +3,8 @@
"rich-md":"/components/rich-md/rich-md", "rich-md":"/components/rich-md/rich-md",
"require-login":"/components/require-login/require-login", "require-login":"/components/require-login/require-login",
"challenge-item":"/shixun/components/challenge-item/challenge-item", "challenge-item":"/shixun/components/challenge-item/challenge-item",
"nav-bar":"/components/nav-bar/nav-bar" "nav-bar":"/components/nav-bar/nav-bar",
"send-to-course":"/components/modal/send-to-course/send-to-course"
}, },
"navigationBarBackgroundColor": "#0080f0", "navigationBarBackgroundColor": "#0080f0",
"navigationBarTextStyle": "white", "navigationBarTextStyle": "white",

@ -46,4 +46,6 @@
<view wx:if="{{shixun.task_operation[0]}}" class="operations"> <view wx:if="{{shixun.task_operation[0]}}" class="operations">
<button class="collect" bindtap="collect" type="main" plain>{{shixun.is_collect?'已收藏':'收藏'}}</button> <button class="collect" bindtap="collect" type="main" plain>{{shixun.is_collect?'已收藏':'收藏'}}</button>
<button bindtap="enterChallenge" loading="{{loading}}" disabled="{{loading}}" type="main">{{shixun.task_operation[0]}}</button> <button bindtap="enterChallenge" loading="{{loading}}" disabled="{{loading}}" type="main">{{shixun.task_operation[0]}}</button>
<button class="send" type="main" bindtap="sendToCourse" plain>发送至</button>
</view> </view>
<send-to-course show="{{showSendDialog}}" shixun_ids="{{shixun_ids}}"/>

@ -74,6 +74,10 @@
.operations>button{ .operations>button{
flex: 1; flex: 1;
} }
button.collect{ button.collect, button.send{
background: white!important; background: white!important;
} }
/* tmp solution*/
.weui-half-screen-dialog__hd__side .weui-icon-btn.weui-icon-btn_more{
display: none;
}

@ -1,7 +1,14 @@
{ {
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [ "rules": [
{
"action":"allow",
"page":"path/pages/path/path",
"params":[
"subject_id"
],
"matching":"inclusive"
},
{ {
"action": "allow", "action": "allow",
"page": "shixun/pages/shixun/shixun", "page": "shixun/pages/shixun/shixun",

Loading…
Cancel
Save