Browse Source

add api

master
刘嘉炜 4 years ago
parent
commit
9bc5b3cf37
  1. 22
      src/App.vue
  2. 3
      src/js/api.js
  3. 25
      src/pages/course/class_list/class_list.vue
  4. 30
      src/pages/course/student_list/student_list.vue
  5. 112
      src/pages/course/student_review/student_review.vue
  6. 11
      src/pages/course/task/task.vue
  7. 92
      src/pages/course/task_finish/task_finish.vue
  8. 3
      src/pages/course/task_publish/task_publish.vue

22
src/App.vue

@ -54,17 +54,17 @@
color: #333;
background-color: #fff;
@include textHide(1);
&::after{
content: '';
margin-left: 24upx;
display: inline-block;
vertical-align: middle;
width: 0;
height: 0;
border-left: 16upx solid transparent;
border-right: 16upx solid transparent;
border-top: 16upx solid #333;
}
// &::after{
// content: '';
// margin-left: 24upx;
// display: inline-block;
// vertical-align: middle;
// width: 0;
// height: 0;
// border-left: 16upx solid transparent;
// border-right: 16upx solid transparent;
// border-top: 16upx solid #333;
// }
}
//

3
src/js/api.js

@ -12,6 +12,7 @@ export const API = {
coach_feedback: `${ORIGIN}/upload/file/coach_feedback`, // 上传文件 - 教练反馈
task_publish: `${ORIGIN}/upload/file/task_publish`, // 上传文件 - 布置作业
student_review: `${ORIGIN}/upload/file/student_review`, // 上传文件 - 学员点评
}
@ -21,6 +22,8 @@ API['course'] = {
getCourseStudentList: `${ORIGIN}/stadium/coach/getCourseStudentList`, // 小程序-学员列表
SaveStudentComment: `${ORIGIN}/stadium/coach/SaveStudentComment`, // 小程序-学员点评保存
homeworkList: `${ORIGIN}/stadium/coach/homework/list`, // 小程序-作业列表
homeworkRecords: `${ORIGIN}/stadium/coach/homework/records`, // 小程序-作业完成列表
homeworkRemind: `${ORIGIN}/stadium/coach/homework/remind`, // 小程序-作业提醒
homeworkAdd: `${ORIGIN}/stadium/coach/homework/add`, // 小程序-布置作业
}

25
src/pages/course/class_list/class_list.vue

@ -1,7 +1,7 @@
<template>
<view class="class-list">
<picker disabled>
<view class="cl-bar"><text>{{optionsQuery.course_name || '-'}}</text></view>
<view class="top-bar"><text>{{optionsQuery.course_name || '-'}}</text></view>
</picker>
<view class="cl-list">
<view class="cl-item" v-for="(e, i) in classList" :key="i">
@ -44,7 +44,6 @@ export default {
let _query = util.jsonPar(options.query);
this.optionsQuery = _query;
console.warn(_query);
this.getClassList(_query.course_id)
},
methods: {
@ -87,28 +86,6 @@ export default {
.class-list{
}
.cl-bar{
padding: 0 26upx;
height: 98upx;
width: 100%;
line-height: 98upx;
font-size: 32upx;
font-weight: 500;
color: #333;
background-color: #fff;
@include textHide(1);
&::after{
content: '';
margin-left: 24upx;
display: inline-block;
vertical-align: middle;
width: 0;
height: 0;
border-left: 16upx solid transparent;
border-right: 16upx solid transparent;
border-top: 16upx solid #333;
}
}
.cl-list{
padding: 24upx;
.cl-item{

30
src/pages/course/student_list/student_list.vue

@ -6,24 +6,24 @@
<view class="sl-list">
<view class="sl-item" v-for="(e, i) in studentList" :key="i">
<view class="si-content">
<image mode="aspectFit"></image>
<image mode="aspectFit" :src="e.user_info.avatar_url"></image>
<view>
<view class="sc-info">
<view class="si-name">
<view>{{e.name }} {{e.gender}}</view>
<image></image>
<view>{{e.name || '-'}}</view>
<image mode="aspectFit" :src="`/src/static/images/sex_${e.gender-1}.png`"></image>
</view>
<view class="si-phone">
<view>{{e.mobile || '-'}}</view>
<image></image>
<image mode="aspectFit" src="/static/images/phone_c33.png"></image>
</view>
</view>
<view class="sc-lave">剩余次数: {{e.number || 0}}</view>
</view>
</view>
<view class="si-btns">
<view hover-class="hover-active">点评</view>
<view hover-class="hover-active">调班</view>
<view hover-class="hover-active" @click="toReview(e)">点评</view>
<view hover-class="hover-active" @click="toShift(e)">调班</view>
</view>
</view>
</view>
@ -58,10 +58,24 @@ export default {
this.optionsQuery = _query;
this.getStudentList({
course_id: _query.course_id,
class_id: _query.class_id,
class_id: _query.class_id || 0,
})
},
methods: {
toReview(e){
let { optionsQuery } = this;
let _query = {
order_no: e.order_no,
user_id: e.user_id,
user_name: e.name,
...optionsQuery,
}
util.routeTo(`/pages/course/student_review/student_review?query=${util.jsonStr(_query)}`, 'nT');
},
toShift(){
let { optionsQuery } = this;
util.routeTo(`/pages/course/class_change/class_change`, 'nT');
},
getStudentList({
course_id,
class_id,
@ -106,7 +120,6 @@ export default {
width: 116upx;
height: 116upx;
border-radius: 50%;
background-color: skyblue;
}
>view{
flex-grow: 1;
@ -130,7 +143,6 @@ export default {
width: 34upx;
height: 34upx;
margin-left: 14upx;
background-color: skyblue;
}
}
.si-phone{

112
src/pages/course/student_review/student_review.vue

@ -2,22 +2,22 @@
<view class="student-review fixed-bot-padding">
<view class="sr-section">
<view class="ss-name">
<view>羽毛球课包学会(带体验课)</view>
<view>一班</view>
<view>{{ optionsQuery.course_name || '-' }}</view>
<view>{{ optionsQuery.class_name || '-' }}</view>
</view>
<view class="ss-user">
<view>学员名称:</view>
<picker class="su-picker">
<picker class="su-picker" disabled>
<view>
<input disabled placeholder="选择姓名" />
<image></image>
<input disabled placeholder="选择姓名" :value="optionsQuery.user_name || '-'" />
<!-- <image></image> -->
</view>
</picker>
</view>
<view class="ss-review">
<view>学员点评:</view>
<view>
<textarea placeholder="请输入您的点评、建议或者发现的问题"></textarea>
<textarea placeholder="请输入您的点评、建议或者发现的问题" v-model="descTxt"></textarea>
</view>
</view>
<view class="ss-title">
@ -25,25 +25,108 @@
(最多上传3张只支持.jpgpng 格式
</view>
<view class="ss-pics">
<view class="sp-item" v-for="i in 5" :key="i">
<image class="si-close"></image>
<image class="si-img"></image>
<view class="sp-item" v-for="(e, i) in imageList" :key="i">
<image class="si-close" mode="aspectFit" src="/static/images/close_c00.png" @click="clearImage(i)"></image>
<image class="si-img" mode="aspectFit" :src="e" @click="previewImage(e)"></image>
</view>
<view class="sp-item sp-add">
<view class="sp-item sp-add" @click="imgSelect">
<view></view>
<view>上传照片</view>
</view>
</view>
</view>
<view class="fixed-bot-btn">
<view hover-class="hover-active">确定</view>
<view hover-class="hover-active" @click="submitBtn">确定</view>
</view>
</view>
</template>
<script>
import { API } from '../../../js/api';
import { servers } from '../../../js/server';
import util from '../../../utils/util';
export default {
data(){
return {
imageList: [],
descTxt: '',
optionsQuery: {},
}
},
onLoad(options){
this.optionsQuery = util.jsonPar(options.query);
console.warn(util.jsonPar(options.query));
},
methods: {
//
clearImage(index){
let _imgs = [...this.imageList];
_imgs.splice(index,1);
this.imageList = _imgs;
},
//
previewImage(src) {
uni.previewImage({
current: src,
urls: this.imageList
})
},
submitBtn: util.debounce(function(){
let { descTxt, imageList, optionsQuery } = this;
console.warn(descTxt, 'descTxtdescTxtdescTxt')
if(descTxt == '')return util.showNone('请输入');
servers.post({
url: API.course.SaveStudentComment,
data: {
order_no: optionsQuery.order_no,
course_id: optionsQuery.course_id,
user_id: optionsQuery.user_id,
comment: descTxt,
imgs: imageList,
},
isDefaultGet: false,
})
.then(e=>{
if(e.data.code == 0){
console.warn(e);
util.showNone(e.data.message || '操作成功!');
setTimeout(util.routeTo, 1200);
}else{
util.showNone(e.data.message || '操作失败!');
}
})
}, 300, 300),
//
imgSelect() {
uni.chooseImage({
count: 1,
sizeType: [ 'compressed ' ],
success: res => {
util.showLoad();
servers.uploadFile({
url: API.student_review,
filePath: res.tempFilePaths[0],
})
.then(e=>{
util.hideLoad();
let _res = util.jsonPar(e.data);
if(_res.code == 0){
this.imageList = [_res.data.url, ...this.imageList]
}else{
console.error('上传图片失败--->',_res);
util.showNone(_res.message || '上传图片失败,请重试!')
}
})
.catch(err=>{
console.error('上传图片失败--->',err);
util.showNone('上传图片失败,稍后重试!')
})
},
})
},
}
}
</script>
@ -106,7 +189,6 @@ export default {
flex-shrink: 0;
width: 28upx;
height: 28upx;
background-color: skyblue;
}
}
}
@ -158,7 +240,6 @@ export default {
width: 200upx;
height: 200upx;
border-radius: 10upx;
background-color: greenyellow;
overflow: hidden;
&:not(:nth-child(3n)){
margin-right: 44upx;
@ -170,22 +251,21 @@ export default {
z-index: 2;
width: 40upx;
height: 40upx;
background-color: skyblue;
}
.si-img{
width: 100%;
height: 100%;
background-color: royalblue;
}
&.sp-add{
padding-top: 36upx;
border: 2upx solid #d8d8d8;
>view{
&:first-child{
position: relative;
margin: 0 auto 30upx;
width: 60upx;
height: 60upx;
background-color: springgreen;
&::before{
content: '';
position: absolute;

11
src/pages/course/task/task.vue

@ -16,7 +16,7 @@
<text>展开</text>
<image mode="aspectFit" src="/static/images/arrow_c874.png"></image>
</view>
<view class="cc-btn" hover-class="hover-active" @click="toFinish">完成列表</view>
<view class="cc-btn" hover-class="hover-active" @click="toFinish(e)">完成列表</view>
</view>
</view>
<view class="fixed-bot-btn"><view hover-class="hover-active" @click="toPublish">布置作业</view></view>
@ -48,8 +48,13 @@ export default {
util.routeTo(`/pages/course/task_publish/task_publish?query=${util.jsonStr(optionsQuery)}`, 'nT');
},
toFinish(){
util.routeTo(`/pages/course/task_finish/task_finish`, 'nT');
toFinish(e){
let { optionsQuery } = this;
let _query = {
homework_id: e.id,
...optionsQuery,
};
util.routeTo(`/pages/course/task_finish/task_finish?query=${util.jsonStr(_query)}`, 'nT');
},
getHomeworkList({
course_id= '',

92
src/pages/course/task_finish/task_finish.vue

@ -1,43 +1,111 @@
<template>
<view class="course-task-finish fixed-bot-padding">
<picker>
<view class="top-bar"><text>12</text></view>
<picker disabled>
<view class="top-bar"><text>{{optionsQuery.course_name || '-'}}</text></view>
</picker>
<view class="ctf-time">
<!-- <view class="ctf-time">
<picker class="ct-picker">
<view class="cp-con">
<input disabled value="2020年12月27日" />
<image mode="aspectFit" src="/static/images/triangle_c33.png"></image>
</view>
</picker>
</view>
</view> -->
<view class="ctf-list">
<view class="cl-item" v-for="i in 10" :key="i" @click="toTaskInfo">
<view class="ci-time">10:18</view>
<view class="cl-item" v-for="(e, i) in finishList" :key="i" @click="toTaskInfo">
<view class="ci-time"></view>
<view class="ci-content">
<view class="cc-user">
<image class="u-avatar" mode="aspectFit" src="/static/images/logo.png"></image>
<view class="u-name">Adjoin</view>
<image class="u-icon" mode="aspectFit" src="/static/images/sex_0.png"></image>
<image class="u-avatar" mode="aspectFit" :src="e.user.avatar_url"></image>
<view class="u-name">{{e.order.name || '-'}}</view>
<image class="u-icon" mode="aspectFit" :src="`/static/images/sex_${e.order.gender-1}.png`"></image>
</view>
<view class="cc-status">
<view :class="[i == 2?'active':'']">已完成</view>
<view :class="[i == 2&&false?'active':'']">{{e.record.completion || '-'}}</view>
<image mode="aspectFit" src="/static/images/arrow_cb2.png"></image>
</view>
</view>
</view>
</view>
<view class="fixed-bot-btn"><view hover-class="hover-active">批量提醒完成</view></view>
<view class="fixed-bot-btn"><view hover-class="hover-active" @click="remindAll">批量提醒完成</view></view>
</view>
</template>
<script>
import { API } from '../../../js/api';
import { servers } from '../../../js/server';
import util from '../../../utils/util'
export default {
data(){
return {
optionsQuery: {},
finishList: [],
page: 1,
}
},
onReachBottom(){
let { page, optionsQuery } = this;
let _page = page + 1
this.getFinishList({
homework_id: optionsQuery.homework_id,
page: _page
})
this.page = _page;
},
onLoad(options){
let _query = util.jsonPar(options.query);
this.optionsQuery = _query;
this.getFinishList({
homework_id: _query.homework_id
});
},
methods: {
remindAll: util.debounce(function(){
let { optionsQuery, finishList } = this;
console.warn(optionsQuery)
servers.post({
url: API.course.homeworkRemind,
data: {
homework_id: optionsQuery.homework_id,
homework_record_ids: finishList.map(e=>e.id),
},
isDefaultGet: false,
})
.then(res=>{
if(res.data.code == 0){
util.showNone(res.data.message || '操作成功!');
setTimeout(_=>util.routeTo(), 1200);
}else{
util.showNone(res.data.message || '操作失败!');
}
})
}, 300, 300),
toTaskInfo(){
console.warn(1);
util.routeTo(`/pages/course/task_info/task_info`, 'nT');
},
getFinishList({
homework_id= '',
page= 1,
page_size= 15,
}){
util.showLoad();
servers.get({
url: API.course.homeworkRecords,
data: {
homework_id,
page,
page_size
},
failMsg: '加载失败!'
})
.then(res=>{
util.hideLoad();
let _list = res.list || [];
if(page == 1)return this.finishList = _list;
if(_list.length <=0)return util.showNone('没有更多!');
this.finishList = [...this.finishList, ..._list];
})
}
}
}

3
src/pages/course/task_publish/task_publish.vue

@ -63,7 +63,6 @@ export default {
submitBtn: util.debounce(function(){
let { optionsQuery } = this;
let { desc, videoSrc, imgArr } = this.info;
console.warn(API.course.homeworkAdd)
servers.post({
url: API.course.homeworkAdd,
data: {
@ -74,7 +73,7 @@ export default {
video_url: videoSrc,
images: imgArr,
},
failMsg: '操作失败!'
isDefaultGet: false
})
.then(res=>{
if(res.data.code == 0){

Loading…
Cancel
Save