index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view class="content p20">
  3. <view class="banner" v-if="advImgs.length>0">
  4. <u-swiper
  5. :list="advImgs"
  6. keyName="imageUrl"
  7. indicator
  8. indicatorMode="line"
  9. circular
  10. @click="handleAdvClick"
  11. ></u-swiper>
  12. </view>
  13. <view class="p20" style="width: 100%;">
  14. <view class="yangshengbox bg-white p20 radius12">
  15. <view>养生讲堂</view>
  16. <view class="justify-between align-center" @click="goClassList(1)">
  17. <view class="fs24">查看更多</view>
  18. <u-icon name="arrow-right" size="20"></u-icon>
  19. </view>
  20. </view>
  21. <view class="courseBox">
  22. <view class="listbox" v-for="(item,index) in looklist" :key="index" @click="goClass(item.courseId,1)">
  23. <view>
  24. <image :src="item.imgUrl" mode="aspectFill" ></image>
  25. </view>
  26. <view class="mt20 ">
  27. <view class="ellipsis bold">{{item.courseName}}</view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import {getAdvList} from '@/api/index'
  36. import {courseList} from '@/api/class'
  37. export default {
  38. data() {
  39. return {
  40. title: '',
  41. advImgs:[],
  42. looklist:[]
  43. }
  44. },
  45. onLoad() {
  46. this.getimgList()
  47. this.getcourselist()
  48. },
  49. methods: {
  50. goClass(id,type) {
  51. console.log(id)
  52. uni.navigateTo({
  53. url:'/pages_course/learn?courseId='+id+'&type='+type
  54. })
  55. },
  56. goClassList(type) {
  57. uni.navigateTo({
  58. url: '/pages_course/teacherClassroom?type='+type
  59. })
  60. },
  61. getcourselist(){
  62. courseList().then(res=>{
  63. if(res.code==200){
  64. this.looklist=res.data
  65. console.log(res.data)
  66. console.log(111,this.looklist)
  67. }else{
  68. uni.showToast({
  69. title: res.msg,
  70. icon:'none'
  71. });
  72. }
  73. })
  74. },
  75. getimgList(){
  76. getAdvList().then(res=>{
  77. console.log(res)
  78. if(res.code==200){
  79. this.advImgs=res.data
  80. }else{
  81. uni.showToast({
  82. title: res.msg,
  83. icon:'none'
  84. });
  85. }
  86. })
  87. },
  88. handleAdvClick(){
  89. },
  90. }
  91. }
  92. </script>
  93. <style lang="scss" scoped>
  94. .content {
  95. display: flex;
  96. flex-direction: column;
  97. align-items: center;
  98. justify-content: center;
  99. width: calc(100% - 40rpx);
  100. .banner{
  101. width: 100%;
  102. height: 236upx;
  103. border-radius: 10upx;
  104. }
  105. .yangshengbox{
  106. margin-top: 40rpx;
  107. display: flex;
  108. justify-content: space-between;
  109. }
  110. .courseBox{
  111. display: flex;
  112. justify-content: start;
  113. flex-wrap: wrap;
  114. margin-top: 20rpx;
  115. .listbox{
  116. display: flex;
  117. flex-direction: column;
  118. background-color: #fff;
  119. padding: 20rpx;
  120. margin: 10rpx;
  121. border-radius: 12rpx;
  122. width: calc(44% - 20rpx);
  123. image{
  124. width: 100%;
  125. height: 360rpx;
  126. }
  127. }
  128. }
  129. }
  130. </style>