123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- <template>
- <view class="content">
- <u-card :title="classInfo.name" :show-foot="false" title-size="32" margin="0px 0px 10px 0px" :head-style="cardStyle">
- <view slot="body">
- <view class="class-info-text">
- <u-icon name="clock"></u-icon>
- {{classInfo.classStartDate}} ~ {{classInfo.classEndDate}}
- </view>
- <view class="class-info-text" v-for="(item, index) in classInfo.classExtrasList" :key="index">
- <u-icon name="calendar" style="visibility: hidden;"></u-icon>
- <text>{{item.week}} {{item.startTime}}-{{item.endTime}}</text>
- </view>
- <view class="class-info-text">
- <u-icon name="map"></u-icon>
- {{classInfo.address}}
- </view>
- </view>
- </u-card>
- <u-card :title="'学员信息(' + getStudentsNumber() + ')'" title-size="32" margin="0px 0px 10px 0px" :head-style="cardStyle">
- <u-grid :col="3" slot="body" :border="false">
- <u-grid-item v-for="(item, index) in classInfo.studentSignList" :key="index" :custom-style="gridCustomStyle" @click="goToStudentInfo(item)">
- <view class="class-student-col" :class="item.state ? 'student-active' : ''">
- {{item.name}}
- <u-icon name="bookmark" :color="mainColor" size="48"></u-icon>
- </view>
- </u-grid-item>
- </u-grid>
- </u-card>
- <u-card title="班级近况" :sub-title="imgEdit ? '完成' : '管理'" :sub-title-color="imgEdit ? '#19be6b' : '#909399'" :show-foot="false"
- title-size="32" margin="0px" :head-style="cardStyle" @sub-click="imgEdit = !imgEdit">
- <view class="class-show-box" slot="body">
- <view v-for="(item, index) in classShowList" :key="index" class="class-show-card">
- <u-image :src="item.url" mode="aspectFill" height="30vw" border-radius="10px" v-if="item.type == 0"></u-image>
- <view class="video-col" v-if="item.type == 1">
- <video :src="item.url" object-fit="cover" controls :id="'video' + index"></video>
- </view>
- <view class="class-show-name">{{item.name}}</view>
- <u-icon name="close-circle-fill" color="#fa3534" size="48" v-if="imgEdit" class="delete-icon" @click="deleteClassShow(item)"></u-icon>
- </view>
- <view class="class-show-card" style="width: calc(100% - 16px);text-align: center;" v-if="imgEdit">
- <u-icon name="plus-circle-fill" size="100" :color="mainColor" @click="uploadTypeShow = true"></u-icon>
- </view>
- </view>
- </u-card>
- <view class="handle-fix-box">
- <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="goToSignForm()">立即签到</u-button>
- </view>
- <u-action-sheet :list="uploadTypeList" v-model="uploadTypeShow" @click="selectUploadType"></u-action-sheet>
- <u-top-tips ref="uTips"></u-top-tips>
- </view>
- </template>
- <script>
- import {
- mapGetters
- } from 'vuex'
- const NET = require('@/utils/request')
- const API = require('@/config/api')
- export default {
- computed: {
- ...mapGetters([
- 'mainColor',
- 'customStyle',
- ])
- },
- data() {
- return {
- classId: '',
- classInfo: {
- name: '',
- classStartDate: '',
- classStartHours: '',
- classEndDate: '',
- classEndHours: '',
- residue: '',
- address: '',
- classExtrasList: [],
- studentSignList: [],
- showList: [],
- },
- classShowList: [],
- uploadTypeShow: false,
- uploadTypeList: [{
- text: '图片'
- },
- {
- text: '视频'
- }
- ],
- imgEdit: false,
- cardStyle: {
- fontWeight: 'bold'
- },
- gridCustomStyle: {
- padding: '0 2px'
- }
- }
- },
- onLoad(options) {
- this.classId = options.id
- this.initialize()
- this.getClassShow()
- },
- onReady() {},
- onPullDownRefresh() {
- this.initialize()
- this.getClassShow()
- },
- methods: {
- // 获取初始化数据
- initialize() {
- NET.request(API.getClassDetail, {
- id: this.classId
- }, 'POST').then(res => {
- this.classInfo = res.data
- uni.stopPullDownRefresh();
- }).catch(error => {
- this.$refs.uTips.show({
- title: error.message,
- type: 'warning',
- })
- })
- },
- // 文件上传成功回调
- getClassShow() {
- NET.request(API.getClassDetailShowList, {
- id: this.classId,
- page: 0,
- size: 1000
- }, 'POST').then(res => {
- this.classShowList = res.data.row
- }).catch(error => {
- this.$refs.uTips.show({
- title: error.message,
- type: 'warning',
- })
- })
- },
- // 获取学生数量
- getStudentsNumber() {
- return this.classInfo.studentSignList.length
- },
- // 选择上传文件类型
- selectUploadType(index) {
- if (index == 0) {
- uni.chooseImage({
- count: 1,
- success: (res) => {
- this.uploadFile(res.tempFilePaths[0])
- },
- fail: (error) => {
- }
- });
- } else if (index) {
- uni.chooseVideo({
- count: 1,
- success: (res) => {
- this.uploadFile(res.tempFilePath)
- },
- fail: (error) => {
- }
- });
- }
- },
- // 上传文件
- uploadFile(path) {
- let that = this
- uni.uploadFile({
- url: API.uploadFile,
- filePath: path,
- name: 'file',
- header: {
- Authorization: uni.getStorageSync('token')
- },
- success: (uploadFileRes) => {
- that.uploadSuccess(JSON.parse(uploadFileRes.data).data.id)
- }
- });
- },
- // 文件上传成功回调
- uploadSuccess(id) {
- NET.request(API.insertClassShow, {
- fileId: [id],
- id: this.classId,
- }, 'POST').then(res => {
- this.getClassShow()
- this.$refs.uTips.show({
- title: '班级近况发布成功',
- type: 'success',
- })
- }).catch(error => {
- this.$refs.uTips.show({
- title: error.message,
- type: 'warning',
- })
- })
- },
- // 删除班级近况
- deleteClassShow(site) {
- NET.request(API.deleteClassShow, {
- id: site.id,
- }, 'POST').then(res => {
- this.getClassShow()
- this.$refs.uTips.show({
- title: '删除成功',
- type: 'success',
- })
- }).catch(error => {
- this.$refs.uTips.show({
- title: error.message,
- type: 'warning',
- })
- })
- },
- // 跳转学生详情
- goToStudentInfo(item) {
- uni.navigateTo({
- url: '/pagesMain/studentInfo?type=1&id=' + item.id + '&classId=' + this.classId
- });
- },
- // 跳转签到表单
- goToSignForm() {
- uni.removeStorageSync('signUserList')
- uni.navigateTo({
- url: '/pagesClass/signForm?id=' + this.classId + '&status=' + this.classInfo.signStatus
- });
- },
- },
- }
- </script>
- <style>
- page {
- width: 100%;
- height: 100%;
- background-color: #f7f7f7;
- position: relative;
- }
- </style>
- <style lang="scss" scoped>
- @import "@/static/css/themes.scss";
- .content {
- width: 100%;
- float: left;
- padding-bottom: 60px;
- .class-info-text {
- color: #999999;
- line-height: 18px;
- u-icon {
- margin-right: 4px;
- }
- }
- .class-student-col {
- height: 28px;
- display: flex;
- padding: 0 10px;
- line-height: 28px;
- color: $mainColor;
- white-space: nowrap;
- border: 1px solid $mainColor;
- border-radius: 5px;
- /deep/u-icon {
- margin-left: 5px;
- }
- }
- .student-active {
- background-color: $mainColor;
- color: #FFFFFF;
- }
- .class-student-box {
- display: flex;
- justify-content: space-around;
- }
- .class-show-box {
- width: 100%;
- float: left;
- .class-show-card {
- width: calc(50% - 16px);
- margin: 0 8px 16px 8px;
- float: left;
- position: relative;
- .class-show-name {
- width: 100%;
- text-align: center;
- line-height: 20px;
- font-size: 14px;
- margin-top: 5px;
- }
- .delete-icon {
- position: absolute;
- right: -5px;
- top: -5px;
- }
- .video-col {
- width: 100%;
- height: 30vw;
- border-radius: 10px;
- video {
- width: 100%;
- height: 30vw;
- }
- }
- }
- }
- }
- </style>
|