index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view class="lli-index-page">
  3. <!-- banner -->
  4. <view class="index-imgbox">
  5. <img :src="banners||defultbanners" class="index-banner-img"/>
  6. </view>
  7. <!-- meul-box -->
  8. <view class="index-meul-box">
  9. <uni-grid :column="4" :show-border="false" :square="false" @change="change">
  10. <uni-grid-item v-for="(item ,index) in menuList" :index="index" :key="index">
  11. <view class="lli-grid-item">
  12. <image class="grid-item-image" :src="item.url" mode="aspectFill" />
  13. <text class="grid-item-text">{{item.text}}</text>
  14. <view v-if="item.badge" class="grid-dot">
  15. <uni-badge :text="item.badge" :type="item.type" :customStyle="{background: '#FF5551'}" />
  16. </view>
  17. </view>
  18. </uni-grid-item>
  19. </uni-grid>
  20. </view>
  21. <!-- 课程list -->
  22. <view class="lli-index-title-box">
  23. <text class="index-title">最热课程</text>
  24. <text class="index-sub-title">查看更多 ></text>
  25. </view>
  26. <!-- 考试list -->
  27. <view class="lli-card-box">
  28. <uni-card padding="0" margin="0" spacing="0" :is-shadow="false" :border="false" v-for="(item ,index) in examCardList" :index="index" :key="index" class="lli-card-item">
  29. <template v-slot:cover>
  30. <view class="custom-cover">
  31. <image class="lli-card-image" mode="aspectFill" :src="item.cover"></image>
  32. <view class="cover-content">
  33. <text class="uni-subtitle uni-white">{{item.tag}}</text>
  34. </view>
  35. </view>
  36. </template>
  37. <text class="lli-card-name">{{item.name}}</text>
  38. </uni-card>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. data() {
  45. return {
  46. banners: null,
  47. defultbanners:'/static/images/index/index-banner.png',
  48. menuList: [{
  49. url: '/static/images/index/index-kc-img.png',
  50. text: '我的课程',
  51. },
  52. {
  53. url: '/static/images/index/index-ks-img.png',
  54. text: '我的考试',
  55. },
  56. {
  57. url: '/static/images/index/index-lx-img.png',
  58. text: '每日一练',
  59. },
  60. {
  61. url: '/static/images/index/index-gg-img.png',
  62. text: '公告',
  63. badge: '99',
  64. },
  65. ],
  66. examCardList: [{
  67. cover: 'https://saas-mta.oss-cn-beijing.aliyuncs.com/defaultPic/kecheng/pic/kc2.png',
  68. name: '我的课程',
  69. tag: '已学完',
  70. },
  71. {
  72. cover: 'https://saas-mta.oss-cn-beijing.aliyuncs.com/defaultPic/kecheng/pic/kc1.png',
  73. name: '我的考试',
  74. tag: '待学习',
  75. },
  76. {
  77. cover: 'https://saas-mta.oss-cn-beijing.aliyuncs.com/defaultPic/kecheng/pic/kc3.png',
  78. name: '每日一练',
  79. tag: '已学完',
  80. },
  81. {
  82. cover: 'https://saas-mta.oss-cn-beijing.aliyuncs.com/defaultPic/kecheng/pic/kc4.png',
  83. name: '北京市出租汽车驾驶员从业资格考试',
  84. tag: '待学习',
  85. },
  86. ],
  87. }
  88. },
  89. methods: {
  90. change(e){
  91. let {index} = e.detail
  92. switch (index) {
  93. case 0:
  94. uni.switchTab({
  95. url: '/pages/course/index'
  96. });
  97. break;
  98. case 1:
  99. uni.switchTab({
  100. url: '/pages/exam/index'
  101. });
  102. break;
  103. case 2:
  104. uni.showToast({
  105. icon: 'none',
  106. title: '开发中,敬请期侍!',
  107. });
  108. break;
  109. case 3:
  110. uni.showToast({
  111. icon: 'none',
  112. title: '开发中,敬请期侍!',
  113. });
  114. break;
  115. }
  116. console.log(index,'change')
  117. },
  118. }
  119. }
  120. </script>
  121. <style lang="scss">
  122. .lli-index-page{
  123. padding: 24rpx;
  124. background: #FCFBFC;
  125. // min-height: 100vh;
  126. // banner
  127. .index-imgbox {
  128. text-align: center;width: 100%;
  129. .index-banner-img {
  130. width: 702rpx;
  131. height: 242rpx;
  132. display: inline-block;
  133. border-radius: 4px;
  134. }
  135. }
  136. //meul-box
  137. .index-meul-box{
  138. .lli-grid-item {
  139. flex: 1;
  140. /* #ifndef APP-NVUE */
  141. display: flex;
  142. /* #endif */
  143. flex-direction: column;
  144. align-items: center;
  145. justify-content: center;
  146. padding: 15px 0;
  147. }
  148. .grid-item-image {width: 99rpx;height: 113rpx;}
  149. .grid-item-text {font-size: 24rpx;color: $uni-text-color;}
  150. .grid-dot {position: absolute;top: 5px;right: 15px;}
  151. }
  152. // title-box
  153. .lli-index-title-box{
  154. margin: 44rpx 0 32rpx;display: flex;justify-content: space-between;align-items: center;
  155. .index-title{font-size: 32rpx;color: #333;font-weight: 800;display: inline-flex;align-items: center;}
  156. .index-title:before{content:'';width: 3px;height: 30rpx;background: $uni-primary;margin-right: 8px;display: block;}
  157. .index-sub-title{font-size: 24rpx;color: #9c9c9c;font-weight: normal;}
  158. }
  159. // card
  160. .lli-card-box{width: 100%;display: flex;display: -webkit-flex; /* 兼容性写法 */justify-content: space-between;flex-wrap: wrap;margin-bottom: 8px;}
  161. .lli-card-item{
  162. width: 49%;flex: unset;padding: 12rpx 12rpx 0;box-sizing: border-box;
  163. border-radius: 20rpx;background-color: #ffffff;margin-bottom: 20rpx;
  164. .lli-card-image{max-width: 100%;height: 180rpx;border-radius: 8rpx;}
  165. .custom-cover {max-width: 100%;height: 180rpx;border-radius: 8rpx;overflow: hidden;position: relative;}
  166. .cover-content {
  167. position: absolute;bottom: 0;left: 0;padding: 8rpx 10rpx 8rpx 20rpx;background: rgba(0, 0, 0, 0.29);
  168. color: #fff;font-size: 22rpx;border-radius: 0 10rpx 0 10rpx;
  169. }
  170. .lli-card-name{
  171. font-size: 28rpx;line-height: 36rpx;color: #565656;margin: 20rpx 0;
  172. display: -webkit-box;-webkit-line-clamp: 2;overflow: hidden;
  173. text-overflow: ellipsis;-webkit-box-orient: vertical;
  174. }
  175. }
  176. }
  177. </style>