myClassDetail.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view class="content">
  3. <u-card title="剩余课时" :show-foot="false" title-size="32" margin="0px 0px 10px 0px" :head-style="cardStyle">
  4. <view slot="body">{{ residue }}</view>
  5. </u-card>
  6. <u-card title="签到记录" sub-title="查看更多" :show-foot="false" title-size="32" margin="0px 0px 10px 0px" :head-style="cardStyle"
  7. @head-click="getSignInList">
  8. <view class="signIn-box" slot="body">
  9. <view class="signIn-col" v-for="(item, index) in signInList" :key="index" @click="handleSignClick(item.id,index)">
  10. <u-icon name="bookmark" :color="signIndex === index ? '#41b0fe' : '#666666'" size="64" v-if="!item.status"></u-icon>
  11. <u-icon name="bookmark-fill" :color="signIndex === index ? '#41b0fe' : mainColor" size="64" v-else></u-icon>
  12. <view class="signIn-date">{{item.date}}</view>
  13. </view>
  14. </view>
  15. </u-card>
  16. <u-card v-if="Object.keys(rateRecordInfo).length && rateRecordInfo.userRemark" title="课程评价" :show-foot="false" title-size="32" margin="0px 0px 10px 0px" :head-style="cardStyle">
  17. <!-- <u-cell-group slot="body" :border="false" style="padding: 0px;">
  18. <u-cell-item :title="(item.type? '家长' : '教练') + '-' + item.name" :value="item.time" :label="item.content" v-for="(item, index) in classInfo.growList"
  19. :key="index" :arrow="false" :title-style="cellTitleStyle"></u-cell-item>
  20. </u-cell-group> -->
  21. <view slot="body">
  22. <u-rate :count="10" :current="rateRecordInfo.star" :size="40" :gutter="10" :active-color="mainColor" isClick></u-rate>
  23. <view class="rate-info">学生评价: {{ rateRecordInfo.userRemark }}</view>
  24. <view class="rate-info" v-if="rateRecordInfo.coachRemark">教练回复: {{ rateRecordInfo.coachRemark }}</view>
  25. </view>
  26. </u-card>
  27. <!-- <view class="handle-fix-box" v-if="Object.keys(rateRecordInfo).length"> -->
  28. <view class="handle-fix-box" v-if="Object.keys(rateRecordInfo).length && !rateRecordInfo.userRemark">
  29. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="goToCourseForm()">填写评价</u-button>
  30. </view>
  31. <u-calendar v-model="signInShow" mode="date" :active-bg-color="mainColor" btn-type="error" availableText="未签到"
  32. activeText="已签到" :available="availableList" :activeList="activeList" @change="setSingTime"></u-calendar>
  33. <u-top-tips ref="uTips"></u-top-tips>
  34. </view>
  35. </template>
  36. <script>
  37. import {
  38. mapGetters
  39. } from 'vuex'
  40. const NET = require('@/utils/request')
  41. const API = require('@/config/api')
  42. export default {
  43. computed: {
  44. ...mapGetters([
  45. 'mainColor',
  46. 'customStyle',
  47. ])
  48. },
  49. data() {
  50. return {
  51. allDateList:[],
  52. classId: '',
  53. classId_b: '',
  54. signIndex: 0,
  55. signInShow: false,
  56. // 签到记录
  57. signInList: [],
  58. availableList: [],
  59. activeList: [],
  60. rateRecordInfo: {},
  61. // 签到id
  62. recordId: 0,
  63. // 剩余课时数
  64. residue: 0,
  65. cardStyle: {
  66. fontWeight: 'bold'
  67. },
  68. cellTitleStyle: {
  69. fontSize: '14px',
  70. fontWeight: 'bold',
  71. },
  72. }
  73. },
  74. onLoad(options) {
  75. this.classId = options.id
  76. },
  77. onShow() {
  78. this.initialize()
  79. this.signIndex = 0
  80. },
  81. onPullDownRefresh() {
  82. this.initialize()
  83. setTimeout(() => {
  84. uni.stopPullDownRefresh();
  85. }, 500)
  86. },
  87. methods: {
  88. setSingTime(object) {
  89. console.log(this.formatDatedel0(object.result))
  90. let selectDate=this.formatDatedel0(object.result)
  91. let newArr=[]
  92. for(var i=0;i<this.allDateList.length;i++){
  93. if(this.formatDatedel0(this.allDateList[i].lastDate)==selectDate){
  94. newArr=this.allDateList.slice(i,8)
  95. break
  96. }
  97. }
  98. if(newArr.length==0){
  99. return false
  100. }
  101. for(var i=0;i<newArr.length;i++){
  102. newArr[i].date=newArr[i].lastDate
  103. }
  104. this.signInList=newArr
  105. if(newArr[0].id==null){
  106. this.rateRecordInfo={}
  107. }
  108. NET.request(API.getSignRemark, {id: newArr[0].id}, 'POST').then( res => {
  109. this.rateRecordInfo = { ...res.data }
  110. }
  111. )
  112. },
  113. // 获取初始化数据
  114. initialize() {
  115. console.log(123123)
  116. // 获取会员服务班级详情
  117. NET.request(API.getMemberClassDetail, {
  118. id: this.classId
  119. }, 'POST').then(res => {
  120. this.residue = res.data.residue
  121. this.classId_b = res.data.classId
  122. this.signInList = res.data.signInList
  123. if(res.data.signInList.length) {
  124. const result = res.data.signInList
  125. if(result[0].status == 1) {
  126. let id=result[0].id
  127. this.recordId = id
  128. NET.request(API.getSignRemark, {id: id}, 'POST').then( res => {
  129. this.rateRecordInfo = { ...res.data }
  130. }
  131. )
  132. } else {
  133. this.rateRecordInfo = {}
  134. }
  135. }
  136. }).catch(error => {
  137. this.$refs.uTips.show({
  138. title: error.message,
  139. type: 'warning',
  140. })
  141. })
  142. // 获取我的班级全部请假列表
  143. NET.request(API.getAllLeaveList, {
  144. id: this.classId
  145. }, 'POST').then(res => {
  146. this.allDateList = res.data
  147. this.availableList = res.data.filter(site => site.status == 0).map(site => {
  148. return this.formatDatedel0(site.lastDate)
  149. })
  150. this.activeList = res.data.filter(site => site.status == 1).map(site => {
  151. return this.formatDatedel0(site.lastDate)
  152. })
  153. }).catch(error => {
  154. this.$refs.uTips.show({
  155. title: error.message,
  156. type: 'warning',
  157. })
  158. })
  159. },
  160. formatDatedel0(str) {
  161. // 根据 - 符号拆分
  162. return str
  163. .split("-")
  164. .map((item) => {
  165. // +item 将item字符串转换为数字
  166. // 小于10的时候就补全一个前缀0
  167. if (+item < 10) {
  168. return Number(item);
  169. }
  170. // 大于10的时候不用补0
  171. return item;
  172. })
  173. .join("-"); // 最后重组回来
  174. },
  175. // 根据签到时间显示不同评价
  176. handleSignClick(id,index) {
  177. this.signIndex = index
  178. if(id) {
  179. this.recordId = id
  180. NET.request(API.getSignRemark, {id: id}, 'POST').then( res => {
  181. this.rateRecordInfo = { ...res.data }
  182. }
  183. )
  184. } else {
  185. this.rateRecordInfo = {}
  186. }
  187. },
  188. getSignInList(index) {
  189. this.signInShow = true
  190. },
  191. // 跳转历程表单
  192. goToCourseForm() {
  193. uni.navigateTo({
  194. url: '/pagesMember/courseForm?id=' + this.recordId + '&classId='+this.classId_b
  195. });
  196. },
  197. },
  198. }
  199. </script>
  200. <style>
  201. page {
  202. width: 100%;
  203. height: 100%;
  204. background-color: #f7f7f7;
  205. position: relative;
  206. }
  207. </style>
  208. <style lang="scss" scoped>
  209. @import "@/static/css/themes.scss";
  210. .content {
  211. width: 100%;
  212. float: left;
  213. padding-bottom: 60px;
  214. .signIn-box {
  215. display: flex;
  216. justify-content: space-around;
  217. .signIn-col {
  218. width: 40px;
  219. text-align: center;
  220. .signIn-date {
  221. margin-top: 5px;
  222. font-size: 10px;
  223. text-align: center;
  224. }
  225. }
  226. }
  227. /deep/.u-cell {
  228. padding: 26rpx 0;
  229. }
  230. }
  231. .rate-info {
  232. width: 100%;
  233. margin-top: 20rpx;
  234. margin-left: 5rpx;
  235. word-wrap: break-word;
  236. }
  237. </style>