classDetail.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <view class="content">
  3. <u-card :title="classInfo.name" :show-foot="false" title-size="32" margin="0px 0px 10px 0px" :head-style="cardStyle">
  4. <view slot="body">
  5. <view class="class-info-text">
  6. <u-icon name="clock"></u-icon>
  7. {{classInfo.classStartDate}}&nbsp;~&nbsp;{{classInfo.classEndDate}}
  8. </view>
  9. <view class="class-info-text" v-for="(item, index) in classInfo.classExtrasList" :key="index">
  10. <u-icon name="calendar" style="visibility: hidden;"></u-icon>
  11. <text>{{item.week}}&nbsp;{{item.startTime}}-{{item.endTime}}</text>
  12. </view>
  13. <view class="class-info-text">
  14. <u-icon name="map"></u-icon>
  15. {{classInfo.address}}
  16. </view>
  17. </view>
  18. </u-card>
  19. <u-card :title="'学员信息(' + getStudentsNumber() + ')'" title-size="32" margin="0px 0px 10px 0px" :head-style="cardStyle">
  20. <u-grid :col="3" slot="body" :border="false">
  21. <u-grid-item v-for="(item, index) in classInfo.studentSignList" :key="index" :custom-style="gridCustomStyle" @click="goToStudentInfo(item)">
  22. <view class="class-student-col" :class="item.state ? 'student-active' : ''">
  23. {{item.name}}
  24. <u-icon name="bookmark" :color="mainColor" size="48"></u-icon>
  25. </view>
  26. </u-grid-item>
  27. </u-grid>
  28. </u-card>
  29. <u-card title="班级近况" :sub-title="imgEdit ? '完成' : '管理'" :sub-title-color="imgEdit ? '#19be6b' : '#909399'" :show-foot="false"
  30. title-size="32" margin="0px" :head-style="cardStyle" @sub-click="imgEdit = !imgEdit">
  31. <view class="class-show-box" slot="body">
  32. <view v-for="(item, index) in classShowList" :key="index" class="class-show-card">
  33. <u-image :src="item.url" mode="aspectFill" height="30vw" border-radius="10px" v-if="item.type == 0"></u-image>
  34. <view class="video-col" v-if="item.type == 1">
  35. <video :src="item.url" object-fit="cover" controls :id="'video' + index"></video>
  36. </view>
  37. <view class="class-show-name">{{item.name}}</view>
  38. <u-icon name="close-circle-fill" color="#fa3534" size="48" v-if="imgEdit" class="delete-icon" @click="deleteClassShow(item)"></u-icon>
  39. </view>
  40. <view class="class-show-card" style="width: calc(100% - 16px);text-align: center;" v-if="imgEdit">
  41. <u-icon name="plus-circle-fill" size="100" :color="mainColor" @click="uploadTypeShow = true"></u-icon>
  42. </view>
  43. </view>
  44. </u-card>
  45. <view class="handle-fix-box">
  46. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="goToSignForm()">立即签到</u-button>
  47. </view>
  48. <u-action-sheet :list="uploadTypeList" v-model="uploadTypeShow" @click="selectUploadType"></u-action-sheet>
  49. <u-top-tips ref="uTips"></u-top-tips>
  50. </view>
  51. </template>
  52. <script>
  53. import {
  54. mapGetters
  55. } from 'vuex'
  56. const NET = require('@/utils/request')
  57. const API = require('@/config/api')
  58. export default {
  59. computed: {
  60. ...mapGetters([
  61. 'mainColor',
  62. 'customStyle',
  63. ])
  64. },
  65. data() {
  66. return {
  67. classId: '',
  68. classInfo: {
  69. name: '',
  70. classStartDate: '',
  71. classStartHours: '',
  72. classEndDate: '',
  73. classEndHours: '',
  74. residue: '',
  75. address: '',
  76. classExtrasList: [],
  77. studentSignList: [],
  78. showList: [],
  79. },
  80. classShowList: [],
  81. uploadTypeShow: false,
  82. uploadTypeList: [{
  83. text: '图片'
  84. },
  85. {
  86. text: '视频'
  87. }
  88. ],
  89. imgEdit: false,
  90. cardStyle: {
  91. fontWeight: 'bold'
  92. },
  93. gridCustomStyle: {
  94. padding: '0 2px'
  95. }
  96. }
  97. },
  98. onLoad(options) {
  99. this.classId = options.id
  100. this.initialize()
  101. this.getClassShow()
  102. },
  103. onReady() {},
  104. onPullDownRefresh() {
  105. this.initialize()
  106. this.getClassShow()
  107. },
  108. methods: {
  109. // 获取初始化数据
  110. initialize() {
  111. NET.request(API.getClassDetail, {
  112. id: this.classId
  113. }, 'POST').then(res => {
  114. this.classInfo = res.data
  115. uni.stopPullDownRefresh();
  116. }).catch(error => {
  117. this.$refs.uTips.show({
  118. title: error.message,
  119. type: 'warning',
  120. })
  121. })
  122. },
  123. // 文件上传成功回调
  124. getClassShow() {
  125. NET.request(API.getClassDetailShowList, {
  126. id: this.classId,
  127. page: 0,
  128. size: 1000
  129. }, 'POST').then(res => {
  130. this.classShowList = res.data.row
  131. }).catch(error => {
  132. this.$refs.uTips.show({
  133. title: error.message,
  134. type: 'warning',
  135. })
  136. })
  137. },
  138. // 获取学生数量
  139. getStudentsNumber() {
  140. return this.classInfo.studentSignList.length
  141. },
  142. // 选择上传文件类型
  143. selectUploadType(index) {
  144. if (index == 0) {
  145. uni.chooseImage({
  146. count: 1,
  147. success: (res) => {
  148. this.uploadFile(res.tempFilePaths[0])
  149. },
  150. fail: (error) => {
  151. }
  152. });
  153. } else if (index) {
  154. uni.chooseVideo({
  155. count: 1,
  156. success: (res) => {
  157. this.uploadFile(res.tempFilePath)
  158. },
  159. fail: (error) => {
  160. }
  161. });
  162. }
  163. },
  164. // 上传文件
  165. uploadFile(path) {
  166. let that = this
  167. uni.uploadFile({
  168. url: API.uploadFile,
  169. filePath: path,
  170. name: 'file',
  171. header: {
  172. Authorization: uni.getStorageSync('token')
  173. },
  174. success: (uploadFileRes) => {
  175. that.uploadSuccess(JSON.parse(uploadFileRes.data).data.id)
  176. }
  177. });
  178. },
  179. // 文件上传成功回调
  180. uploadSuccess(id) {
  181. NET.request(API.insertClassShow, {
  182. fileId: [id],
  183. id: this.classId,
  184. }, 'POST').then(res => {
  185. this.getClassShow()
  186. this.$refs.uTips.show({
  187. title: '班级近况发布成功',
  188. type: 'success',
  189. })
  190. }).catch(error => {
  191. this.$refs.uTips.show({
  192. title: error.message,
  193. type: 'warning',
  194. })
  195. })
  196. },
  197. // 删除班级近况
  198. deleteClassShow(site) {
  199. NET.request(API.deleteClassShow, {
  200. id: site.id,
  201. }, 'POST').then(res => {
  202. this.getClassShow()
  203. this.$refs.uTips.show({
  204. title: '删除成功',
  205. type: 'success',
  206. })
  207. }).catch(error => {
  208. this.$refs.uTips.show({
  209. title: error.message,
  210. type: 'warning',
  211. })
  212. })
  213. },
  214. // 跳转学生详情
  215. goToStudentInfo(item) {
  216. uni.navigateTo({
  217. url: '/pagesMain/studentInfo?type=1&id=' + item.id + '&classId=' + this.classId
  218. });
  219. },
  220. // 跳转签到表单
  221. goToSignForm() {
  222. uni.removeStorageSync('signUserList')
  223. uni.navigateTo({
  224. url: '/pagesClass/signForm?id=' + this.classId + '&status=' + this.classInfo.signStatus
  225. });
  226. },
  227. },
  228. }
  229. </script>
  230. <style>
  231. page {
  232. width: 100%;
  233. height: 100%;
  234. background-color: #f7f7f7;
  235. position: relative;
  236. }
  237. </style>
  238. <style lang="scss" scoped>
  239. @import "@/static/css/themes.scss";
  240. .content {
  241. width: 100%;
  242. float: left;
  243. padding-bottom: 60px;
  244. .class-info-text {
  245. color: #999999;
  246. line-height: 18px;
  247. u-icon {
  248. margin-right: 4px;
  249. }
  250. }
  251. .class-student-col {
  252. height: 28px;
  253. display: flex;
  254. padding: 0 10px;
  255. line-height: 28px;
  256. color: $mainColor;
  257. white-space: nowrap;
  258. border: 1px solid $mainColor;
  259. border-radius: 5px;
  260. /deep/u-icon {
  261. margin-left: 5px;
  262. }
  263. }
  264. .student-active {
  265. background-color: $mainColor;
  266. color: #FFFFFF;
  267. }
  268. .class-student-box {
  269. display: flex;
  270. justify-content: space-around;
  271. }
  272. .class-show-box {
  273. width: 100%;
  274. float: left;
  275. .class-show-card {
  276. width: calc(50% - 16px);
  277. margin: 0 8px 16px 8px;
  278. float: left;
  279. position: relative;
  280. .class-show-name {
  281. width: 100%;
  282. text-align: center;
  283. line-height: 20px;
  284. font-size: 14px;
  285. margin-top: 5px;
  286. }
  287. .delete-icon {
  288. position: absolute;
  289. right: -5px;
  290. top: -5px;
  291. }
  292. .video-col {
  293. width: 100%;
  294. height: 30vw;
  295. border-radius: 10px;
  296. video {
  297. width: 100%;
  298. height: 30vw;
  299. }
  300. }
  301. }
  302. }
  303. }
  304. </style>