signForm.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view class="content">
  3. <u-card :title="'总数(' + studentList.length + ')人'" title-size="32" margin="0px 0px 10px 0px" :head-style="cardStyle">
  4. <u-grid :col="3" slot="body" :border="false">
  5. <u-grid-item v-for="(item, index) in studentList" :key="index" :custom-style="gridCustomStyle">
  6. <u-avatar :src="item.url" mode="circle" size="128" :show-level="item.state == 1 || item.checked" level-icon="checkbox-mark"
  7. :level-bg-color="mainColor" v-if="item.hasHead == 1" @click="setSignCheck(item)"></u-avatar>
  8. <u-upload :custom-btn="true" :max-count="1" @on-success="uploadSuccess" @on-error="uploadError" v-else>
  9. <view slot="addBtn" class="slot-btn">
  10. <u-icon name="camera-fill" size="60" color="#999999"></u-icon>
  11. </view>
  12. </u-upload>
  13. <view class="grid-text">{{item.name}}</view>
  14. </u-grid-item>
  15. <u-grid-item :custom-style="gridCustomStyle" @click="goToSelectStudent">
  16. <view class="slot-btn">
  17. <u-icon name="plus" size="60" color="#999999"></u-icon>
  18. </view>
  19. </u-grid-item>
  20. </u-grid>
  21. </u-card>
  22. <view class="handle-fix-box">
  23. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" :disabled="status != 0" @click="goToSignForm()">{{status == 1 ? '签到确认' : '今日已签到'}}</u-button>
  24. </view>
  25. <u-top-tips ref="uTips"></u-top-tips>
  26. </view>
  27. </template>
  28. <script>
  29. import {
  30. mapGetters
  31. } from 'vuex'
  32. const NET = require('@/utils/request')
  33. const API = require('@/config/api')
  34. export default {
  35. computed: {
  36. ...mapGetters([
  37. 'mainColor',
  38. 'customStyle',
  39. ])
  40. },
  41. data() {
  42. return {
  43. classId: '',
  44. status: '',
  45. studentList: [{
  46. "hasHead": 1,
  47. "name": "即预约",
  48. "state": 0,
  49. "checked": false,
  50. "url": ""
  51. }, {
  52. "hasHead": 1,
  53. "name": "即预约",
  54. "state": 0,
  55. "checked": false,
  56. "url": ""
  57. }, {
  58. "hasHead": 1,
  59. "name": "即预约",
  60. "state": 1,
  61. "checked": false,
  62. "url": ""
  63. }, {
  64. "hasHead": 0,
  65. "name": "即预约",
  66. "state": 0,
  67. "checked": false,
  68. "url": ""
  69. }, {
  70. "hasHead": 1,
  71. "name": "即预约",
  72. "state": 1,
  73. "checked": false,
  74. "url": ""
  75. }, ],
  76. cardStyle: {
  77. fontWeight: 'bold'
  78. },
  79. gridCustomStyle: {
  80. padding: '0 2px'
  81. }
  82. }
  83. },
  84. onLoad(options) {
  85. this.classId = options.id
  86. this.status = options.status
  87. },
  88. onShow() {
  89. this.initialize()
  90. },
  91. methods: {
  92. // 获取初始化数据
  93. initialize() {
  94. NET.request(API.getSignStudentList, {
  95. id: this.classId
  96. }, 'POST').then(res => {
  97. res.data.forEach(site => site.checked = false)
  98. this.studentList = res.data.concat(uni.getStorageSync('extraLessonsUserList'))
  99. }).catch(error => {
  100. this.$refs.uTips.show({
  101. title: '获取本课程学员列表失败',
  102. type: 'warning',
  103. })
  104. })
  105. },
  106. // 文件上传成功回调
  107. uploadSuccess(res, index, lists, name) {
  108. this.$refs.uTips.show({
  109. title: '文件上传成功',
  110. type: 'success',
  111. })
  112. return true
  113. },
  114. // 文件上传失败回调
  115. uploadError(res, index, lists, name) {
  116. this.$refs.uTips.show({
  117. title: '文件上传失败',
  118. type: 'warning',
  119. })
  120. },
  121. // 设置是否签到
  122. setSignCheck(item) {
  123. if (this.status == 0) {
  124. item.checked = item.checked ? false : true
  125. }
  126. },
  127. // 跳转选择学生页面
  128. goToSelectStudent() {
  129. uni.navigateTo({
  130. url: '/pagesClass/signStudentList'
  131. });
  132. },
  133. // 跳转签到表单
  134. goToSignForm() {
  135. uni.navigateTo({
  136. url: '/pagesMember/signForm?id=' + this.classId
  137. });
  138. },
  139. },
  140. }
  141. </script>
  142. <style>
  143. page {
  144. width: 100%;
  145. height: 100%;
  146. position: relative;
  147. }
  148. </style>
  149. <style lang="scss" scoped>
  150. @import "@/static/css/themes.scss";
  151. .content {
  152. width: 100%;
  153. float: left;
  154. padding-bottom: 60px;
  155. /deep/.u-avatar__level {
  156. left: 50%;
  157. transform: translateX(-50%);
  158. bottom: -6px !important;
  159. }
  160. .grid-text {
  161. line-height: 18px;
  162. }
  163. .slot-btn {
  164. width: 128rpx;
  165. height: 128rpx;
  166. border-radius: 50%;
  167. border: 1px solid #999999;
  168. display: flex;
  169. justify-content: center;
  170. align-items: center;
  171. }
  172. }
  173. </style>