course.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <view class="container">
  3. <scroll-view class="scroll-list" scroll-x>
  4. <view class="scoll-box" v-for="ls in Recommendlist" :class="{ active: ls.id === currentId }" @click="tabtap(ls.id)">
  5. <view class="scoll-name">{{ ls.title }}</view>
  6. </view>
  7. </scroll-view>
  8. <view class="big-box">
  9. <view v-if="courseList.length == 0" class="no-data">暂无数据</view>
  10. <view class="activitylist" v-for="(item, index) in courseList" :key="index" @click="ToDetail(item)">
  11. <view class="act_box">
  12. <view class="act_left"><image :src="item.image"></image></view>
  13. <view class="act_right">
  14. <view class="right_top">
  15. <view class="act_tit">{{ item.title }}</view>
  16. <view class="act_icon"><image src="../../static/img/hot.png"></image></view>
  17. </view>
  18. <view class="act_txt">{{ item.abstract }}</view>
  19. <view class="tip-box flex_item">
  20. <view v-for="ls in item.label" class="tip">{{ ls }}</view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="act_time flex">
  25. <view class="time_date"></view>
  26. <view class="act_mony">¥{{ item.money }}</view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import { unified, GetUnifiend } from '@/api/course.js';
  34. export default {
  35. data() {
  36. return {
  37. page: 1,
  38. limit: 100,
  39. courseList: '', //专题列表
  40. type: '', //分类类型
  41. id: '', //分类id
  42. title: '', //分类标题
  43. Recommendlist: '', //分类列表
  44. currentId: 0,
  45. typesetting: ''
  46. };
  47. },
  48. onLoad(option) {
  49. this.id = option.recommend_id;
  50. this.type = option.type;
  51. this.title = option.title;
  52. this.typesetting = option.typesetting;
  53. this.loadData();
  54. this.listDate();
  55. },
  56. methods: {
  57. //加载分类列表
  58. listDate(){
  59. let obj = this;
  60. unified({
  61. type: obj.type,
  62. title: obj.title,
  63. recommend_id:obj.id
  64. })
  65. .then(data => {
  66. obj.Recommendlist = data.data.Recommendlist;
  67. let newDate = {
  68. id: 0,
  69. title: '推荐'
  70. };
  71. obj.Recommendlist.unshift(newDate);
  72. })
  73. .catch(e => {
  74. console.log(e.message);
  75. });
  76. },
  77. //加载专题列表
  78. loadData() {
  79. let obj = this;
  80. GetUnifiend({
  81. page: obj.page,
  82. limit: obj.limit,
  83. recommend_id:obj.id,
  84. type:obj.type,
  85. typesetting:obj.typesetting,
  86. subject_id:obj.currentId
  87. })
  88. .then(data => {
  89. obj.courseList = data.data.list;
  90. })
  91. .catch(e => {
  92. console.log(e.message);
  93. });
  94. },
  95. //头部导航栏点击事件
  96. tabtap(item) {
  97. this.currentId = item;
  98. this.loadData();
  99. },
  100. ToDetail(item) {
  101. let id = item.id;
  102. uni.navigateTo({
  103. url: '/pages/course/detail?id=' + id
  104. });
  105. },
  106. navTo(url) {
  107. uni.navigateTo({
  108. url
  109. });
  110. }
  111. }
  112. };
  113. </script>
  114. <style lang="scss">
  115. page {
  116. width: 100%;
  117. height: 100%;
  118. background-color: #f8f6f6;
  119. }
  120. .container {
  121. width: 100%;
  122. height: 100%;
  123. background-color: #f8f6f6;
  124. }
  125. .scroll-list {
  126. width: 100%;
  127. height: 70rpx;
  128. overflow: hidden;
  129. white-space: nowrap;
  130. padding: 0rpx 25rpx;
  131. font-size: 26rpx;
  132. background-color: #ffffff;
  133. margin-bottom: 25rpx;
  134. line-height: 60rpx;
  135. .scoll-box {
  136. margin-right: 35rpx;
  137. text-align: center;
  138. display: inline-block;
  139. .scoll-name {
  140. // margin-left: 25rpx;
  141. }
  142. &.active {
  143. color: #fa2740;
  144. border-bottom: 4rpx solid #fa2740;
  145. }
  146. }
  147. }
  148. .big-box {
  149. padding: 0 13rpx;
  150. padding-bottom: 25rpx;
  151. .no-data{
  152. width: 100%;
  153. font-size: 26rpx;
  154. text-align: center;
  155. }
  156. .activitylist {
  157. margin-top: 20rpx;
  158. background: rgba(255, 255, 255, 1);
  159. box-shadow: 0px 5rpx 5rpx 0px rgba(35, 24, 21, 0.06);
  160. border-radius: 7rpx;
  161. padding: 0 20rpx;
  162. .act_box {
  163. display: flex;
  164. overflow: hidden;
  165. padding: 31rpx 0rpx 25rpx 0rpx;
  166. border-bottom: 1rpx solid rgba(232, 232, 232, 1);
  167. .act_left {
  168. width: 240rpx;
  169. height: 160rpx;
  170. margin-right: 25rpx;
  171. image {
  172. width: 240rpx;
  173. height: 160rpx;
  174. border-radius: 10rpx;
  175. }
  176. }
  177. .act_right {
  178. flex: 1;
  179. .right_top {
  180. display: flex;
  181. justify-content: space-between;
  182. .act_tit {
  183. font-size: 30rpx;
  184. font-weight: bold;
  185. color: rgba(51, 51, 51, 1);
  186. }
  187. .act_icon {
  188. width: 31rpx;
  189. height: 44rpx;
  190. image {
  191. width: 30rpx;
  192. height: 44rpx;
  193. }
  194. }
  195. }
  196. .act_txt {
  197. width: 90%;
  198. font-size: 22rpx;
  199. color: rgba(153, 153, 153, 1);
  200. overflow: hidden;
  201. text-overflow: ellipsis;
  202. display: -webkit-box;
  203. -webkit-line-clamp: 2;
  204. -webkit-box-orient: vertical;
  205. height: 70rpx;
  206. }
  207. .tip-box {
  208. display: flex;
  209. flex-wrap: wrap;
  210. font-size: 24rpx;
  211. .tip {
  212. background: rgba(103, 134, 251, 0.18);
  213. color: #6786fb;
  214. margin-right: 15rpx;
  215. margin-top: 10rpx;
  216. padding: 2rpx 10rpx;
  217. }
  218. }
  219. }
  220. }
  221. .act_time {
  222. padding: 25rpx 0rpx;
  223. .time_date {
  224. font-size: 24rpx;
  225. font-weight: bold;
  226. color: rgba(102, 102, 102, 1);
  227. }
  228. .act_mony {
  229. font-size: 26rpx;
  230. font-weight: bold;
  231. color: rgba(255, 0, 0, 1);
  232. }
  233. }
  234. }
  235. }
  236. .Search-box {
  237. height: 100rpx;
  238. background: #ffffff;
  239. padding: 0 24rpx;
  240. display: flex;
  241. justify-content: space-between;
  242. align-items: center;
  243. margin-bottom: 26rpx;
  244. .Search-text {
  245. font-size: 28rpx;
  246. font-weight: 500;
  247. color: rgba(102, 102, 102, 1);
  248. }
  249. .Search-box-size {
  250. width: 620rpx;
  251. border-radius: 32rpx;
  252. background-color: #f1f1f1;
  253. padding-left: 36rpx;
  254. display: flex;
  255. align-items: center;
  256. .box-img {
  257. height: 32rpx;
  258. width: 32rpx;
  259. margin-right: 16rpx;
  260. }
  261. .input-box {
  262. font-size: 26rpx;
  263. height: 65rpx;
  264. line-height: 65rpx;
  265. }
  266. .box-word {
  267. font-size: 22rpx;
  268. font-weight: 500;
  269. color: rgba(205, 203, 203, 1);
  270. line-height: 55rpx;
  271. }
  272. }
  273. }
  274. </style>