resource.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view>
  3. <uni-search-bar bgColor="#f0f2f5" placeholder="搜索" cancelButton="none" clearButton="none" :focus="true"></uni-search-bar>
  4. <view class="links">
  5. <button class="link-button" :class="{ active: isActive1 }" @click="toggleActive1">资源库</button>
  6. <button class="link-button" :class="{ active: isActive2 }" @click="toggleActive2">精品课程</button>
  7. </view>
  8. <view class="" v-if="tab">
  9. <uni-section type="line">
  10. <uni-grid :column="2" :show-border="false" :square="false">
  11. <uni-grid-item v-for="(item, index) in list" :index="index" :key="index">
  12. <view class="grid-item-box">
  13. <view class="v1">
  14. <image class="image" :src="item.url" mode="aspectFill" />
  15. <text class="text">{{ item.text }}</text>
  16. <text class="text1">{{ item.text1 }}</text>
  17. </view>
  18. </view>
  19. </uni-grid-item>
  20. </uni-grid>
  21. </uni-section>
  22. </view>
  23. <view class="" v-else>
  24. <uni-section type="line">
  25. <uni-grid :column="2" :show-border="false" :square="false">
  26. <uni-grid-item v-for="(item, index) in list" :index="index" :key="index">
  27. <view class="grid-item-box">
  28. <view class="v1">
  29. <image class="image" :src="item.url" mode="aspectFill" />
  30. <text class="text">{{ item.text }}1</text>
  31. <text class="text1">{{ item.text1 }}</text>
  32. </view>
  33. </view>
  34. </uni-grid-item>
  35. </uni-grid>
  36. </uni-section>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. isActive1: true,
  45. isActive2: false,
  46. tab: true,
  47. list: [
  48. {
  49. url: '/static/resouce/jqr.png',
  50. text: '这里是课程名称课程名称课程名称...',
  51. badge: '0',
  52. text1: '主讲教师:苏某某'
  53. },
  54. {
  55. url: '/static/resouce/jqr.png',
  56. text: '这里是课程名称课程名称课程名称...',
  57. badge: '0',
  58. text1: '主讲教师:苏某某'
  59. },
  60. {
  61. url: '/static/resouce/jqr.png',
  62. text: '这里是课程名称课程名称课程名称...',
  63. badge: '0',
  64. text1: '主讲教师:苏某某'
  65. },
  66. {
  67. url: '/static/resouce/jqr.png',
  68. text: '这里是课程名称课程名称课程名称...',
  69. badge: '0',
  70. text1: '主讲教师:苏某某'
  71. },
  72. {
  73. url: '/static/resouce/jqr.png',
  74. text: '这里是课程名称课程名称课程名称...',
  75. badge: '0',
  76. text1: '主讲教师:苏某某'
  77. },
  78. {
  79. url: '/static/resouce/jqr.png',
  80. text: '这里是课程名称课程名称课程名称...',
  81. badge: '0',
  82. text1: '主讲教师:苏某某'
  83. },
  84. {
  85. url: '/static/resouce/jqr.png',
  86. text: '这里是课程名称课程名称课程名称...',
  87. badge: '0',
  88. text1: '主讲教师:苏某某'
  89. }
  90. ]
  91. };
  92. },
  93. methods: {
  94. toggleActive1() {
  95. this.isActive1 = !this.isActive1;
  96. this.isActive2 = false; // 清除第二个按钮的样式
  97. this.tab = !this.tab;
  98. },
  99. toggleActive2() {
  100. this.isActive2 = !this.isActive2;
  101. this.isActive1 = false; // 清除第二个按钮的样式
  102. this.tab = !this.tab;
  103. }
  104. }
  105. };
  106. </script>
  107. <style lang="scss" scoped>
  108. uni-search-bar {
  109. border-radius: 4px;
  110. }
  111. .links {
  112. display: flex;
  113. justify-content: space-evenly;
  114. align-items: center;
  115. margin-top: 16px;
  116. }
  117. .link-button {
  118. border: none; /* 无边框 */
  119. color: #c2c2c2; /* 文本颜色 */
  120. }
  121. .link-button:after {
  122. border: none;
  123. }
  124. .link-button.active {
  125. color: #616366;
  126. // background: url('../../static/resouce/bg.png') no-repeat;
  127. background: linear-gradient(to bottom, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0)), url('../../static/resouce/bg.png') no-repeat;
  128. background-position: 50% 95%;
  129. background-size: 85%;
  130. // box-shadow: 0px 5px 5px skyblue;
  131. }
  132. .image {
  133. width: 150px;
  134. height: 100px;
  135. border-radius: 4px;
  136. }
  137. .text {
  138. font-weight: 600;
  139. max-width: 120px;
  140. font-size: 14px;
  141. margin-top: 5px;
  142. }
  143. .text1 {
  144. margin-top: 5px;
  145. color: #999999;
  146. max-width: 120px;
  147. font-size: 10px;
  148. }
  149. .grid-dynamic-box {
  150. margin-bottom: 15px;
  151. }
  152. .uni-grid-item {
  153. height: 160px;
  154. }
  155. .grid-item-box {
  156. flex: 1;
  157. // position: relative;
  158. /* #ifndef APP-NVUE */
  159. display: flex;
  160. /* #endif */
  161. flex-direction: column;
  162. align-items: center;
  163. padding: 10px 0;
  164. height: 160px;
  165. .v1 {
  166. /* #ifndef APP-NVUE */
  167. display: flex;
  168. /* #endif */
  169. flex-direction: column;
  170. align-items: flex-start;
  171. height: 160px;
  172. }
  173. }
  174. .grid-item-box-row {
  175. flex: 1;
  176. // position: relative;
  177. /* #ifndef APP-NVUE */
  178. display: flex;
  179. /* #endif */
  180. flex-direction: row;
  181. align-items: center;
  182. justify-content: center;
  183. padding: 15px 0;
  184. }
  185. /* #ifdef H5 */
  186. @media screen and (min-width: 768px) and (max-width: 1425px) {
  187. .swiper {
  188. height: 630px;
  189. }
  190. }
  191. @media screen and (min-width: 1425px) {
  192. .swiper {
  193. height: 830px;
  194. }
  195. }
  196. </style>