index.vue 2.6 KB

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