classDetail.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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.classStartHours}}&nbsp;&nbsp;{{classInfo.residue}}课时
  8. </view>
  9. <view class="class-info-text">
  10. <u-icon name="map"></u-icon>
  11. {{classInfo.address}}
  12. </view>
  13. </view>
  14. </u-card>
  15. <u-card title="授课教练" :show-foot="false" title-size="32" margin="0px 0px 10px 0px" :head-style="cardStyle">
  16. <view class="techaer-info-box" slot="body">
  17. <u-image :src="classInfo.coachUrl" mode="aspectFill" width="80px" height="80px" border-radius="10px" style=""></u-image>
  18. <view class="techaer-info">
  19. <view class="class-info-title">{{classInfo.coachName}}</view>
  20. <view class="class-info-text">{{classInfo.coachName}}</view>
  21. </view>
  22. </view>
  23. </u-card>
  24. <u-card title="班级简介" title-size="32" :show-foot="true" margin="0px 0px 10px 0px" :head-style="cardStyle">
  25. <view slot="body">
  26. <u-read-more :toggle="true" show-height="100" color="#333333" :shadow-style="shadowStyle">
  27. <view class="class-info-text">{{classInfo.desc}}</view>
  28. </u-read-more>
  29. </view>
  30. </u-card>
  31. <u-card title="班级展示" sub-title="查看更多" :show-foot="false" title-size="32" margin="0px" :head-style="cardStyle">
  32. <view class="class-show-box" slot="body">
  33. <view v-for="(item, index) in classInfo.showList" :key="index" class="class-show-card">
  34. <u-image :src="item.url" mode="aspectFill" height="30vw" border-radius="10px"></u-image>
  35. <view class="class-show-name">{{item.name}}</view>
  36. </view>
  37. </view>
  38. </u-card>
  39. <u-popup v-model="enlistShow" mode="bottom" border-radius="30" :closeable="true">
  40. <scroll-view scroll-y class="student-box">
  41. <u-card :title="item.studentName" title-size="32" :head-style="cardStyle" :head-border-bottom="false" :show-foot="false"
  42. margin="10px" borderRadius="20" v-for="(item, index) in studentList1" :key="index" @click="enlistStudent(item)">
  43. <view class="student-card" slot="body">
  44. <view class="class-info-text">性别:{{item.sex}}&nbsp;&nbsp;年龄:{{item.age}}</view>
  45. </view>
  46. </u-card>
  47. </scroll-view>
  48. <u-button type="warning" shape="circle" :ripple="true" :custom-style="{...customStyle,margin:'15px'}" @click="goToSubscribelForm()">新增学员</u-button>
  49. </u-popup>
  50. <u-popup v-model="subscribeShow" mode="bottom" border-radius="30">
  51. <scroll-view scroll-y class="student-box">
  52. <u-card :title="item.studentName" title-size="32" :head-style="cardStyle" :head-border-bottom="false" :show-foot="false"
  53. margin="10px" borderRadius="20" v-for="(item, index) in studentList2" :key="index" @click="subscribeStudent(item)">
  54. <view class="student-card" slot="body">
  55. <view class="class-info-text">性别:{{item.sex}}&nbsp;&nbsp;年龄:{{item.age}}</view>
  56. </view>
  57. </u-card>
  58. </scroll-view>
  59. <u-button type="warning" shape="circle" :ripple="true" :custom-style="{...customStyle,margin:'15px'}" @click="goToSubscribelForm()">新增学员</u-button>
  60. </u-popup>
  61. <view class="handle-fix-box">
  62. <u-button type="warning" shape="circle" :ripple="true" :custom-style="{...customStyle,...handleStyleLeft}" @click="subscribeShow = true">预约体验</u-button>
  63. <u-button type="warning" shape="circle" :ripple="true" :custom-style="{...customStyle,...handleStyleRight}" @click="enlistShow = true">立即报名</u-button>
  64. </view>
  65. <u-top-tips ref="uTips" zIndex="100000"></u-top-tips>
  66. </view>
  67. </template>
  68. <script>
  69. import {
  70. mapGetters
  71. } from 'vuex'
  72. const NET = require('@/utils/request')
  73. const API = require('@/config/api')
  74. export default {
  75. computed: {
  76. ...mapGetters([
  77. 'customStyle',
  78. ])
  79. },
  80. data() {
  81. return {
  82. classId: '',
  83. classInfo: {
  84. name: '',
  85. classStartDate: '',
  86. classStartHours: '',
  87. residue: '',
  88. address: '',
  89. coachName: '',
  90. coachDesc: '',
  91. coachUrl: '',
  92. desc: '',
  93. showList: [],
  94. },
  95. handleStyleLeft: {
  96. borderRadius: '40px 0 0 40px',
  97. borderRight: '1px solid #ffffff'
  98. },
  99. handleStyleRight: {
  100. borderRadius: '0 40px 40px 0',
  101. borderLeft: '1px solid #ffffff'
  102. },
  103. cardStyle: {
  104. fontWeight: 'bold'
  105. },
  106. shadowStyle: {
  107. backgroundImage: 'linear-gradient(to bottom, transparent 80rpx, #ffffff 80rpx, #ffffff 100rpx)',
  108. paddingTop: "100rpx",
  109. marginTop: "-100rpx"
  110. },
  111. enlistShow: false,
  112. studentList1: [],
  113. subscribeShow: false,
  114. studentList2: [],
  115. }
  116. },
  117. onLoad(options) {
  118. this.classId = options.id
  119. this.initialize()
  120. },
  121. onShow() {
  122. NET.request(API.getEnlistAbleStudent, {}, 'POST').then(res => {
  123. this.studentList1 = res.data.row
  124. }).catch(error => {
  125. this.$refs.uTips.show({
  126. title: error.message,
  127. type: 'warning',
  128. })
  129. })
  130. NET.request(API.getSubscribeAbleList, {}, 'POST').then(res => {
  131. this.studentList2 = res.data.row
  132. }).catch(error => {
  133. this.$refs.uTips.show({
  134. title: error.message,
  135. type: 'warning',
  136. })
  137. })
  138. },
  139. onPullDownRefresh() {
  140. this.initialize()
  141. setTimeout(() => {
  142. uni.stopPullDownRefresh();
  143. }, 500)
  144. },
  145. methods: {
  146. // 获取初始化数据
  147. initialize() {
  148. NET.request(API.getClassDetail, {
  149. id: this.classId
  150. }, 'POST').then(res => {
  151. this.classInfo = res.data
  152. }).catch(error => {
  153. this.$refs.uTips.show({
  154. title: error.message,
  155. type: 'warning',
  156. })
  157. })
  158. },
  159. // 学员报名
  160. enlistStudent(item) {
  161. NET.request(API.enlistStudent, {
  162. classId: this.classId,
  163. studentId: item.studentId,
  164. }, 'POST').then(res => {
  165. this.enlistShow = false
  166. this.$refs.uTips.show({
  167. title: res.message,
  168. type: 'success',
  169. })
  170. }).catch(error => {
  171. this.$refs.uTips.show({
  172. title: error.message,
  173. type: 'warning',
  174. })
  175. })
  176. },
  177. // 学员预约
  178. subscribeStudent(item) {
  179. NET.request(API.subscribeStudent, {
  180. classId: this.classId,
  181. studentId: item.studentId,
  182. }, 'POST').then(res => {
  183. this.subscribeShow = false
  184. this.$refs.uTips.show({
  185. title: res.message,
  186. type: 'success',
  187. })
  188. }).catch(error => {
  189. this.$refs.uTips.show({
  190. title: error.message,
  191. type: 'warning',
  192. })
  193. })
  194. },
  195. // 跳转新增学员表单
  196. goToSubscribelForm() {
  197. uni.navigateTo({
  198. url: '/pagesMember/subscribelForm'
  199. });
  200. },
  201. },
  202. }
  203. </script>
  204. <style>
  205. page {
  206. width: 100%;
  207. height: 100%;
  208. background-color: #f7f7f7;
  209. position: relative;
  210. }
  211. </style>
  212. <style lang="scss" scoped>
  213. @import "@/static/css/themes.scss";
  214. .content {
  215. width: 100%;
  216. float: left;
  217. padding-bottom: 60px;
  218. .class-info-text {
  219. color: #999999;
  220. line-height: 18px;
  221. u-icon {
  222. margin-right: 2px;
  223. }
  224. }
  225. .student-box {
  226. max-height: 200px;
  227. padding: 0 15px;
  228. margin: 25px 0 0 0;
  229. box-sizing: border-box;
  230. overflow: auto;
  231. /deep/.u-card__head {
  232. padding-bottom: 0px !important;
  233. }
  234. }
  235. .techaer-info-box {
  236. display: flex;
  237. .techaer-info {
  238. flex: 1;
  239. margin-left: 10px;
  240. .class-info-title {
  241. font-size: 14px;
  242. font-weight: bold;
  243. margin-bottom: 5px;
  244. }
  245. }
  246. }
  247. .class-show-box {
  248. width: calc(100% + 32px);
  249. margin: 0 -16px;
  250. float: left;
  251. .class-show-card {
  252. width: calc(50% - 16px);
  253. margin: 0 8px 16px 8px;
  254. float: left;
  255. .class-show-name {
  256. width: 100%;
  257. text-align: center;
  258. line-height: 20px;
  259. font-size: 14px;
  260. margin-top: 5px;
  261. }
  262. }
  263. }
  264. .handle-fix-box {
  265. u-button {
  266. width: 50%;
  267. display: inline-block;
  268. }
  269. }
  270. }
  271. </style>