list.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 id="list-box" class="list-box" :style="{ height: swiperHeight + 'px' }">
  9. <view class="guess-section">
  10. <view v-if="list.length == 0" class="no-data">暂无数据</view>
  11. <view v-for="(item, index) in list" class="guess-item" @click="ToDetail(item)">
  12. <view class="imagewrapper">
  13. <image :src="item.image"></image>
  14. <!-- <view class="type flex"><view class="tip"></view>直播中</view> -->
  15. </view>
  16. <view class="info">
  17. <view class="title ellipsis">{{item.title}}</view>
  18. <view class="flex name-item">
  19. <view class="name">{{item.abstract}}</view>
  20. <view class="tip-box flex">
  21. <image src="../../static/img/eay.png"></image>
  22. <view class="number">{{item.browse_count}}</view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import { unified,GetUnifiend } from '@/api/course.js';
  33. export default {
  34. data() {
  35. return {
  36. page:1,
  37. limit:100,
  38. list:'',
  39. swiperHeight:0,
  40. type:'',//分类类型
  41. id:'',//分类id
  42. title:'',//分类标题
  43. Recommendlist:'',//分类列表
  44. currentId:0,
  45. typesetting:'',
  46. };
  47. },
  48. watch:{
  49. // 初次加载页面高度时修改页面高度
  50. list(newValue, oldValue) {
  51. let obj = this;
  52. let bHeight = Math.ceil(newValue.length / 2);
  53. obj.$nextTick(function() {
  54. uni.createSelectorQuery()
  55. .select('#list-box')
  56. .fields(
  57. {
  58. size: true
  59. },
  60. function(data) {
  61. obj.pageProportion = data.width / 750;
  62. obj.swiperHeight = Math.ceil(obj.pageProportion * 450 * bHeight);
  63. }
  64. )
  65. .exec();
  66. });
  67. }
  68. },
  69. onLoad(option) {
  70. this.id = option.recommend_id;
  71. this.type = option.type;
  72. this.title = option.title;
  73. this.typesetting = option.typesetting;
  74. this.loadData();
  75. this.listDate();
  76. },
  77. methods: {
  78. //加载分类列表
  79. listDate(){
  80. let obj = this;
  81. unified({
  82. type: obj.type,
  83. title: obj.title,
  84. recommend_id:obj.id
  85. })
  86. .then(data => {
  87. obj.Recommendlist = data.data.Recommendlist;
  88. let newDate = {
  89. id: 0,
  90. title: '推荐'
  91. };
  92. obj.Recommendlist.unshift(newDate);
  93. })
  94. .catch(e => {
  95. console.log(e.message);
  96. });
  97. },
  98. //加载专题列表
  99. loadData() {
  100. let obj = this;
  101. GetUnifiend({
  102. page: obj.page,
  103. limit: obj.limit,
  104. recommend_id:obj.id,
  105. type:obj.type,
  106. typesetting:obj.typesetting,
  107. subject_id:obj.currentId
  108. })
  109. .then(data => {
  110. obj.list = data.data.list;
  111. })
  112. .catch(e => {
  113. console.log(e.message);
  114. });
  115. },
  116. //头部导航栏点击事件
  117. tabtap(item) {
  118. this.currentId = item;
  119. this.loadData();
  120. },
  121. ToDetail(item){
  122. uni.navigateTo({
  123. url: '/pages/live/details?id='+item.link_id
  124. });
  125. },
  126. navTo(url) {
  127. uni.navigateTo({
  128. url
  129. });
  130. }
  131. }
  132. };
  133. </script>
  134. <style lang="scss">
  135. page{
  136. width: 100%;
  137. height: 100%;
  138. background-color: #F8F6F6;
  139. }
  140. .container{
  141. width: 100%;
  142. height: 100%;
  143. background-color: #F8F6F6;
  144. }
  145. .scroll-list {
  146. width:100%;
  147. height: 70rpx;
  148. overflow: hidden;
  149. white-space: nowrap;
  150. padding: 0rpx 25rpx;
  151. font-size: 26rpx;
  152. background-color: #FFFFFF;
  153. margin-bottom: 25rpx;
  154. line-height: 60rpx;
  155. .scoll-box {
  156. margin-right: 35rpx;
  157. text-align: center;
  158. display: inline-block;
  159. .scoll-name {
  160. // margin-left: 25rpx;
  161. }
  162. &.active {
  163. color: #fa2740;
  164. border-bottom: 4rpx solid #fa2740;
  165. }
  166. }
  167. }
  168. /* 猜你喜欢 */
  169. .guess-section {
  170. display: flex;
  171. flex-wrap: wrap;
  172. padding: 0 20rpx;
  173. .no-data{
  174. width: 100%;
  175. font-size: 26rpx;
  176. text-align: center;
  177. }
  178. .guess-item {
  179. // height: 558rpx;
  180. position: relative;
  181. overflow: hidden;
  182. display: flex;
  183. flex-direction: column;
  184. border: 2rpx solid #eeeeee;
  185. width: 343rpx;
  186. margin-bottom: 4%;
  187. border-radius: $border-radius-sm;
  188. background-color: white;
  189. padding-bottom: 30rpx;
  190. &:nth-child(2n + 1) {
  191. margin-right: 24rpx;
  192. }
  193. }
  194. .imagewrapper {
  195. width: 100%;
  196. height: 289rpx;
  197. border-radius: 3px;
  198. margin-bottom: 15rpx;
  199. image {
  200. width: 100%;
  201. height: 100%;
  202. // opacity: 1;
  203. }
  204. }
  205. .type{
  206. position: absolute;
  207. top: 25rpx;
  208. right: 25rpx;
  209. font-size: 20rpx;
  210. background:rgba(62,62,62,0.5);
  211. padding: 5rpx 10rpx;
  212. color: #FFFFFF;
  213. .tip{
  214. width: 15rpx;
  215. height: 15rpx;
  216. border-radius: 100%;
  217. margin-right: 15rpx;
  218. background-color: #65D955;
  219. }
  220. }
  221. .info{
  222. padding:0rpx 25rpx;
  223. font-size: 26rpx;
  224. .title{
  225. }
  226. .name-item{
  227. padding-top: 15rpx;
  228. font-size: 24rpx;
  229. .name{
  230. }
  231. .tip-box{
  232. font-size: 22rpx;
  233. color: #999999;
  234. image{
  235. width: 50rpx;
  236. height: 45rpx;
  237. }
  238. }
  239. }
  240. }
  241. }
  242. </style>