courseDetails.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. <template>
  2. <view>
  3. <u-navbar :title="classDetail.className"></u-navbar>
  4. <view class="picture" v-if="courseBase.posterUrl != null">
  5. <img :src="courseBase.posterUrl" alt="">
  6. </view>
  7. <view class="space">
  8. </view>
  9. <view class="main">
  10. <view class="infos">
  11. <view class="title">
  12. {{classDetail.className}}
  13. </view>
  14. <!-- <view class="price">
  15. <text>¥1000元</text> / 36课次(春季班)
  16. </view> -->
  17. <view class="time" v-if="classDetail.scheduleBuilderList != null">
  18. <view class="name">
  19. 时间
  20. </view>
  21. <view class="content">
  22. 周{{classWeek}} {{classTime}}
  23. </view>
  24. </view>
  25. <view class="location">
  26. <view class="name">
  27. 地址
  28. </view>
  29. <view class="content">
  30. <view class="text" v-if="courseBase.suitSchool == '1'">
  31. 青少年宫校区
  32. </view>
  33. <view class="text" v-if="courseBase.suitSchool == '2'">
  34. 分校区
  35. </view>
  36. <view class="img">
  37. <img src="../../../assets/img/riFill-navigation-fill@1x.png" alt="">
  38. </view>
  39. </view>
  40. </view>
  41. <view class="classroom">
  42. <view class="name">
  43. 教室
  44. </view>
  45. <view class="content">
  46. {{classDetail.classRoomN}}
  47. </view>
  48. </view>
  49. </view>
  50. <view class="teacher">
  51. <view class="title">
  52. 授课老师
  53. </view>
  54. <view class="teacher-card">
  55. <view class="item"
  56. @click="gotoUrl('pages/youth/teacherHomepage/teacherHomepage?id=' + classDetail.courseTeachers)">
  57. <view class="photo">
  58. <u-avatar class="avatar"
  59. :src="classDetail.teachersHeadPhoto!=null ?
  60. classDetail.teachersHeadPhoto : '../../assets/img/head.png'" size="96">
  61. </u-avatar>
  62. </view>
  63. <view class="teacher-name">
  64. <view class="name">
  65. {{classDetail.courseTeachersN}}
  66. </view>
  67. <view class="status">
  68. 主讲老师
  69. </view>
  70. </view>
  71. <view class="more">
  72. <u-icon name="arrow-right" color="#cccccc"></u-icon>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. <view class="tag">
  78. <view class="item">
  79. <view class="name">
  80. 咨询电话:
  81. </view>
  82. <view class="phone-teacher">
  83. {{classDetail.consultPhone != null ? classDetail.consultPhone : '暂无'}}
  84. </view>
  85. </view>
  86. </view>
  87. <view class="class-detail">
  88. <view class="title">
  89. 课程详情
  90. </view>
  91. <view class="detail">
  92. {{courseBase.remark!=null ? courseBase.remark : '无'}}
  93. </view>
  94. </view>
  95. </view>
  96. <view class="bottom">
  97. <view class="shopping-car" @click="toShoppingCar">
  98. <view class="icon">
  99. <u-icon name="shopping-cart" color="#777777" size="40"></u-icon>
  100. </view>
  101. <view class="text">
  102. 购物车
  103. </view>
  104. </view>
  105. <button class="add" @click="popShowClick">加入购物车</button>
  106. </view>
  107. <u-toast ref="uToast" />
  108. <!-- 弹出层 -->
  109. <view >
  110. <u-popup v-model="popShow" mode="bottom" :closeable='true'>
  111. <view class="popup">
  112. <view class="class-infos">
  113. <view class="picture" v-if="courseBase.posterUrl != null">
  114. <img :src="courseBase.posterUrl" alt="">
  115. </view>
  116. <view class="picture" v-else>
  117. <img src="../../../assets/img/courseD.png" alt="">
  118. </view>
  119. <view class="infos">
  120. <view class="class-name">
  121. {{courseBase.courseName}}
  122. </view>
  123. <view class="price">
  124. {{packageDetail.unitPrice!=null && packageDetail.courseAmount!=null ?
  125. Math.round(packageDetail.unitPrice*packageDetail.courseAmount+packageDetail.waterElectricityAmount) : '0.00'}}元
  126. </view>
  127. <!-- <view class="price-detail" v-if="packageDetail.unitPrice!=null && packageDetail.courseAmount!=null">
  128. (包含报名费{{(packageDetail.unitPrice*packageDetail.courseAmount).toFixed(2)}}元 水电费{{packageDetail.waterElectricityAmount.toFixed(2)}}元)
  129. </view> -->
  130. </view>
  131. </view>
  132. <!-- 报名班级 -->
  133. <view class="sign-up">
  134. <view class="title">
  135. 报名班级
  136. </view>
  137. <view class="options">
  138. <view class="item" v-for="(item,index) in tclassList" :key="index"
  139. :class="activeClass==index ? '' : 'item-state2'" @click="choseClass(item,index)">
  140. {{item.className}}
  141. </view>
  142. </view>
  143. </view>
  144. <!-- 选择套餐 -->
  145. <view class="set-meal" v-if="coursePackageList.length != 0">
  146. <view class="title">
  147. 选择套餐
  148. </view>
  149. <view class="options">
  150. <view class="item" v-for="(item,index) in coursePackageList" :key="index"
  151. :class="activePackage==index ? '' : 'item-state2'" @click="chosePackage(item,index)">
  152. {{item.packageName}}班 {{item.courseAmount}}课时
  153. </view>
  154. </view>
  155. </view>
  156. <!-- 加入购物车 -->
  157. <view class="btn-box">
  158. <button class="add" @click="addShoppingCart">加入购物车</button>
  159. </view>
  160. <view class="" style="height: 24rpx;">
  161. </view>
  162. </view>
  163. </u-popup>
  164. </view>
  165. </view>
  166. </template>
  167. <script>
  168. import * as mineApi from '@/apis/youth/mine.js'
  169. import * as courseApi from '@/apis/youth/course.js'
  170. import * as shoppingCarApi from '@/apis/youth/shoppingCar.js'
  171. import * as loginApi from '@/apis/login.js'
  172. export default {
  173. data() {
  174. return {
  175. swiperList: [{
  176. image: 'https://cdn.uviewui.com/uview/swiper/1.jpg'
  177. }
  178. ],
  179. courseId: '',
  180. classId: '',
  181. courseBase: {},
  182. coursePackageList: [],
  183. tclassList: [],
  184. classDetail: {},
  185. packageDetail: {},
  186. studentId: '',
  187. stuDetail: {},
  188. show: false,
  189. studentList: [],
  190. popShow:false,
  191. activeClass: 0,
  192. activePackage: 0,
  193. activeStudent: 0,
  194. shoppingCartList: [],
  195. shoppDetail: {},
  196. classWeek: '',
  197. classTime: ''
  198. }
  199. },
  200. onLoad(op) {
  201. if(op.id) {
  202. this.courseId = op.id;
  203. this.classId = op.classId;
  204. this.getCourseDetail();
  205. if(this.carhelp.getNsStudentId()) {
  206. this.studentId = this.carhelp.getNsStudentId().studentId;
  207. }
  208. }
  209. },
  210. methods: {
  211. popShowClick() {
  212. this.popShow = true;
  213. },
  214. toShoppingCar() {
  215. uni.redirectTo({
  216. url: '/pages/youth/course/shoppingCar'
  217. });
  218. },
  219. addShoppingCart() {
  220. this.popShow = false;
  221. var data = {
  222. studentId: this.studentId,
  223. packageId: this.packageDetail.packageId,
  224. classId: this.classDetail.classId,
  225. studentType: '2'
  226. }
  227. uni.showLoading({
  228. title: "加载中",
  229. mask: true,
  230. })
  231. shoppingCarApi.add(data).then((res) => {
  232. uni.hideLoading();
  233. uni.showToast({
  234. title: '加入购物车成功',
  235. icon: "none"
  236. })
  237. }).catch(error => {
  238. uni.showToast({
  239. title: error,
  240. icon: "none"
  241. })
  242. })
  243. },
  244. choseClass(item,index) {
  245. this.activeClass = index;
  246. this.classDetail = item;
  247. },
  248. chosePackage(item,index) {
  249. this.activePackage = index;
  250. this.packageDetail = item;
  251. if(this.packageDetail.unitPrice == null) {
  252. this.packageDetail.unitPrice = 0;
  253. }
  254. if(this.packageDetail.waterElectricityAmount == null) {
  255. this.packageDetail.waterElectricityAmount = 0;
  256. }
  257. },
  258. getCourseDetail() {
  259. uni.showLoading({
  260. title: "加载中",
  261. mask: true,
  262. })
  263. courseApi.getCourseDetail({
  264. courseId: this.courseId,
  265. classId: this.classId
  266. }).then((res) => {
  267. uni.hideLoading();
  268. this.courseBase = res.data.courseBase;
  269. this.coursePackageList = res.data.coursePackageList;
  270. if(this.coursePackageList.length != 0) {
  271. this.packageDetail = this.coursePackageList[0];
  272. if(this.packageDetail.unitPrice == null) {
  273. this.packageDetail.unitPrice = 0;
  274. }
  275. if(this.packageDetail.waterElectricityAmount == null) {
  276. this.packageDetail.waterElectricityAmount = 0;
  277. }
  278. }
  279. this.tclassList = res.data.nsClassList;
  280. for (var i = 0; i < this.tclassList.length; i++) {
  281. if(this.tclassList[i].classId == this.classId) {
  282. this.classDetail = this.tclassList[i];
  283. this.activeClass = i;
  284. }
  285. }
  286. var week = this.classDetail.scheduleBuilderList[0].repeatSet;
  287. if(week.indexOf('1') != -1) {
  288. week = week.replace('1','一');
  289. }
  290. if(week.indexOf('2') != -1) {
  291. week = week.replace('2','二');
  292. }
  293. if(week.indexOf('3') != -1) {
  294. week = week.replace('3','三');
  295. }
  296. if(week.indexOf('4') != -1) {
  297. week = week.replace('4','四');
  298. }
  299. if(week.indexOf('5') != -1) {
  300. week = week.replace('5','五');
  301. }
  302. if(week.indexOf('6') != -1) {
  303. week = week.replace('6','六');
  304. }
  305. if(week.indexOf('0') != -1) {
  306. week = week.replace('0','日');
  307. }
  308. this.classWeek = week;
  309. this.classTime = this.classDetail.scheduleBuilderList[0].coursePeriods
  310. }).catch(error => {
  311. uni.showToast({
  312. title: error,
  313. icon: "none"
  314. })
  315. })
  316. },
  317. }
  318. }
  319. </script>
  320. <style lang="scss" scoped>
  321. page {
  322. padding-bottom: 132px;
  323. background-color: #fff;
  324. }
  325. .picture {
  326. height: 280px;
  327. position: relative;
  328. .icon {
  329. position: absolute;
  330. left: 10px;
  331. top: 10px;
  332. z-index: 1;
  333. font-size: 20px;
  334. }
  335. .tag {
  336. width: 120rpx;
  337. line-height: 64rpx;
  338. border-radius: 50px;
  339. background-color: rgba(0, 0, 0, 0.5);
  340. color: rgba(255, 255, 255, 1);
  341. font-size: 14px;
  342. text-align: center;
  343. position: absolute;
  344. right: 16px;
  345. bottom: 23px;
  346. }
  347. img {
  348. width: 100%;
  349. height: 100%;
  350. }
  351. }
  352. .space {
  353. background-color: #fff;
  354. border-radius: 24rpx 24rpx 0px 0px;
  355. height: 22px;
  356. width: 100%;
  357. margin-top: -12px;
  358. position: absolute;
  359. left: 0;
  360. right: 0;
  361. border-bottom: none;
  362. }
  363. .main {
  364. background-color: rgba(255, 255, 255, 1);
  365. padding: 16rpx 40rpx;
  366. .infos {
  367. .title {
  368. line-height: 26px;
  369. color: rgba(51, 51, 51, 1);
  370. font-size: 20px;
  371. font-weight: bold;
  372. }
  373. .price {
  374. margin-top: 16px;
  375. font-size: 18px;
  376. text {
  377. color: rgba(255, 61, 0, 1);
  378. }
  379. }
  380. .time,
  381. .location,
  382. .classroom {
  383. display: flex;
  384. margin-top: 12px;
  385. line-height: 24px;
  386. .name {
  387. color: rgba(119, 119, 119, 1);
  388. }
  389. .content {
  390. color: rgba(51, 51, 51, 1);
  391. margin-left: 12px;
  392. flex: 1;
  393. display: flex;
  394. justify-content: space-between;
  395. .img {
  396. width: 20px;
  397. height: 20px;
  398. img {
  399. width: 100%;
  400. height: 100%;
  401. vertical-align: middle;
  402. }
  403. }
  404. }
  405. }
  406. }
  407. .title {
  408. color: rgba(51, 51, 51, 1);
  409. font-size: 18px;
  410. font-weight: bold;
  411. }
  412. .teacher {
  413. margin-top: 40px;
  414. .teacher-card {
  415. margin-top: 24rpx;
  416. display: flex;
  417. justify-content: space-between;
  418. .item {
  419. width: 47.5%;
  420. padding: 24rpx 0 24rpx 24rpx;
  421. border-radius: 24rpx;
  422. background-color: rgba(236, 236, 236, 1);
  423. display: flex;
  424. }
  425. .photo {
  426. width: 96rpx;
  427. height: 96rpx;
  428. overflow: hidden;
  429. border-radius: 100rpx;
  430. img {
  431. width: 100%;
  432. height: 100%;
  433. }
  434. }
  435. .teacher-name {
  436. display: flex;
  437. flex-direction: column;
  438. justify-content: space-between;
  439. margin-left: 16rpx;
  440. .name {
  441. line-height: 44rpx;
  442. font-size: 32rpx;
  443. color: rgba(51, 51, 51, 1);
  444. }
  445. .status {
  446. color: rgba(119, 119, 119, 1);
  447. line-height: 40rpx;
  448. }
  449. }
  450. .more {
  451. display: flex;
  452. align-items: center;
  453. margin-left: 16rpx;
  454. }
  455. }
  456. }
  457. .tag {
  458. margin-top: 48rpx;
  459. padding: 18px 12px;
  460. border-radius: 12px;
  461. background-color: rgba(13, 186, 199, 0.1);
  462. height: 120rpx;
  463. display: flex;
  464. justify-content: space-between;
  465. align-items: center;
  466. .item {
  467. display: flex;
  468. align-items: center;
  469. .name {
  470. margin-left: 8rpx;
  471. color: rgba(16, 16, 16, 1);
  472. }
  473. .phone-teacher {
  474. margin-left: 8px;
  475. }
  476. }
  477. }
  478. .class-detail {
  479. margin-top: 80rpx;
  480. .detail {
  481. color: rgba(119, 119, 119, 1);
  482. line-height: 20px;
  483. margin-top: 24rpx;
  484. }
  485. .img {
  486. margin-top: 40rpx;
  487. width: 100%;
  488. height: 200px;
  489. img {
  490. width: 100%;
  491. height: 100%;
  492. }
  493. }
  494. }
  495. .school-age,
  496. .target {
  497. margin-top: 80rpx;
  498. .content {
  499. margin-top: 12px;
  500. color: rgba(119, 119, 119, 1);
  501. }
  502. }
  503. }
  504. .bottom {
  505. width: 100%;
  506. background-color: rgba(255, 255, 255, 1);
  507. position: fixed;
  508. bottom: 0;
  509. left: 0;
  510. right: 0;
  511. padding: 20rpx 32rpx;
  512. display: flex;
  513. justify-content: space-between;
  514. .icon{
  515. text-align: center;
  516. }
  517. .text{
  518. color: rgba(16, 16, 16, 1);
  519. font-size: 24rpx;
  520. }
  521. .add {
  522. width:560rpx;
  523. border-radius: 50px;
  524. background-color: rgba(13, 186, 199, 1);
  525. line-height: 40px;
  526. color: rgba(255, 255, 255, 1);
  527. font-size: 16px;
  528. z-index: 999;
  529. margin-right: 0;
  530. }
  531. .registered{
  532. width: 100%;
  533. height: 80rpx;
  534. line-height: 80rpx;
  535. border-radius: 50px;
  536. background-color: rgba(153, 153, 153, 1);
  537. color: rgba(255, 255, 255, 1);
  538. font-size: 32rpx;
  539. }
  540. }
  541. // 弹出层
  542. .popup{
  543. padding: 32rpx;
  544. height:520px;
  545. padding-bottom:100rpx;
  546. .class-infos{
  547. display: flex;
  548. align-items: center;
  549. .picture{
  550. width: 152rpx;
  551. height: 152rpx;
  552. border-radius: 4px;
  553. overflow: hidden;
  554. img{
  555. width: 100%;
  556. height: 100%;
  557. }
  558. }
  559. .infos{
  560. margin-left: 24rpx;
  561. .class-name{
  562. color: rgba(51, 51, 51, 1);
  563. font-size: 36rpx;
  564. }
  565. .price{
  566. color: rgba(255, 61, 0, 1);
  567. font-size: 36rpx;
  568. margin-top: 20rpx;
  569. font-weight: bold;
  570. }
  571. .price-detail{
  572. color: rgba(119, 119, 119, 1);
  573. font-size: 24rpx;
  574. margin-top: 8rpx;
  575. }
  576. }
  577. }
  578. // 报名班级 选择套餐
  579. .sign-up,.set-meal{
  580. margin-top: 24rpx;
  581. .title{
  582. color: rgba(51, 51, 51, 1);
  583. }
  584. .options{
  585. margin-top: 16rpx;
  586. display: flex;
  587. flex-wrap: wrap;
  588. .item{
  589. height: 64rpx;
  590. line-height: 64rpx;
  591. text-align: center;
  592. border-radius: 4px;
  593. background-color: rgba(255, 255, 255, 1);
  594. color: rgba(13, 186, 199, 1);
  595. border: 1px solid rgba(13, 186, 199, 1);
  596. margin-right: 12rpx;
  597. margin-bottom: 16rpx;
  598. padding: 0 16rpx;
  599. }
  600. .item-state2{
  601. background-color: rgba(244, 246, 247, 1);
  602. color: rgba(51, 51, 51, 1);
  603. border: none;
  604. }
  605. }
  606. }
  607. // 报名学生
  608. .apply-student{
  609. margin-top: 24rpx;
  610. margin-bottom: 140rpx;
  611. .title{
  612. color: rgba(51, 51, 51, 1);
  613. }
  614. .options{
  615. margin-top: 16rpx;
  616. display: flex;
  617. flex-wrap:wrap;
  618. .item-checked{
  619. border: 1px solid rgba(13, 186, 199, 1);
  620. background-color: #fff !important;
  621. }
  622. .item{
  623. display: flex;
  624. align-items: center;
  625. padding: 16rpx;
  626. width: 320rpx;
  627. height: 112rpx;
  628. border-radius: 4px;
  629. margin-right: 16rpx;
  630. margin-bottom: 16rpx;
  631. background-color: #F4F6F7;
  632. .photo{
  633. width: 80rpx;
  634. height: 80rpx;
  635. border-radius: 2px;
  636. overflow: hidden;
  637. img{
  638. width: 100%;
  639. height: 100%;
  640. }
  641. }
  642. .infos{
  643. margin-left: 16rpx;
  644. .name-age{
  645. display: flex;
  646. align-items: baseline;
  647. .name{
  648. color: rgba(51, 51, 51, 1);
  649. font-size: 32rpx;
  650. }
  651. .age{
  652. color: rgba(119, 119, 119, 1);
  653. font-size: 24rpx;
  654. margin-left: 8rpx;
  655. }
  656. }
  657. .tel{
  658. color: rgba(119, 119, 119, 1);
  659. font-size: 24rpx;
  660. margin-top: 4rpx;
  661. }
  662. }
  663. }
  664. }
  665. }
  666. .btn-box{
  667. background-color:#fff;
  668. padding: 32rpx;
  669. position: fixed;
  670. bottom: 0rpx;
  671. left: 0rpx;
  672. right: 0rpx;
  673. z-index: 99;
  674. }
  675. .add{
  676. height: 80rpx;
  677. line-height: 80rpx;
  678. border-radius: 50px;
  679. background-color: rgba(13, 186, 199, 1);
  680. color: rgba(255, 255, 255, 1);
  681. font-size: 32rpx;
  682. text-align: center;
  683. }
  684. }
  685. </style>