parent
76c4242bc1
commit
9b9053b5d4
@ -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);
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
"usingComponents": {
|
||||
"main":"/pages/home/home"
|
||||
}
|
||||
}
|
@ -1,4 +1 @@
|
||||
|
||||
<view>
|
||||
<button type="{{type}}" plain size="mini">登录</button>
|
||||
</view>
|
||||
<main id="main"/>
|
Loading…
Reference in new issue