test.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view class="list_box">
  3. <view class="left">
  4. <scroll-view scroll-y="true" :style="{ 'height':scrollHeight }">
  5. <view class="item" v-for="(item,index) in leftArray" :key="index" :class="{ 'active':index==leftIndex }"
  6. :data-index="index" @tap="leftTap">{{item}}</view>
  7. </scroll-view>
  8. </view>
  9. <view class="main">
  10. <swiper class="swiper" :style="{ 'height':scrollHeight }" :current="leftIndex" @change="swiperChange" vertical="true"
  11. duration="300">
  12. <swiper-item v-for="(item,index) in mainArray" :key="index">
  13. <scroll-view scroll-y="true" :style="{ 'height':scrollHeight }">
  14. <view class="item">
  15. <view class="title">
  16. <view>
  17. <a :href="item.url">{{item.title}}</a>
  18. </view>
  19. <image :src="item.thumbnail_pic_s" style="width: 250rpx; height: 250rpx;margin-left: 6rpx;" mode=""></image>
  20. <image :src="item.thumbnail_pic_s02" style="width: 250rpx; height: 250rpx;margin-left: 6rpx;" mode=""></image>
  21. </view>
  22. </view>
  23. </scroll-view>
  24. </swiper-item>
  25. </swiper>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. scrollHeight: '500px',
  34. leftArray: ['生活', '娱乐', '社会'],
  35. mainArray: [{
  36. "uniquekey": "6c4caa0c3ba6e05e2a272892af43c00e",
  37. "title": "杨幂的发际线再也回不去了么?网友吐槽像半秃",
  38. "date": "2017-01-05 11:03",
  39. "category": "yule",
  40. "author_name": "腾讯娱乐",
  41. "url": "http://mini.eastday.com/mobile/170105110355287.html?qid=juheshuju",
  42. "thumbnail_pic_s": "http://03.imgmini.eastday.com/mobile/20170105/20170105110355_806f4ed3fe71d04fa452783d6736a02b_1_mwpm_03200403.jpeg",
  43. "thumbnail_pic_s02": "http://03.imgmini.eastday.com/mobile/20170105/20170105110355_806f4ed3fe71d04fa452783d6736a02b_2_mwpm_03200403.jpeg",
  44. "thumbnail_pic_s03": "http://03.imgmini.eastday.com/mobile/20170105/20170105110355_806f4ed3fe71d04fa452783d6736a02b_3_mwpm_03200403.jpeg"
  45. }],
  46. leftIndex: 0
  47. }
  48. },
  49. onLoad() {
  50. /* 设置当前滚动容器的高,若非窗口的高度,请自行修改 */
  51. uni.getSystemInfo({
  52. success: (res) => {
  53. this.scrollHeight = `${res.windowHeight}px`;
  54. }
  55. });
  56. },
  57. methods: {
  58. /* 左侧导航点击 */
  59. leftTap(e) {
  60. let index = e.currentTarget.dataset.index;
  61. this.leftIndex = Number(index);
  62. },
  63. /* 轮播图切换 */
  64. swiperChange(e) {
  65. let index = e.detail.current;
  66. this.leftIndex = Number(index);
  67. }
  68. }
  69. }
  70. </script>
  71. <style >
  72. .list_box {
  73. display: flex;
  74. flex-direction: row;
  75. flex-wrap: nowrap;
  76. justify-content: flex-start;
  77. align-items: flex-start;
  78. align-content: flex-start;
  79. font-size: 28rpx;
  80. .left {
  81. width: 200rpx;
  82. background-color: #f6f6f6;
  83. line-height: 80rpx;
  84. box-sizing: border-box;
  85. font-size: 32rpx;
  86. .item {
  87. padding-left: 20rpx;
  88. position: relative;
  89. &:not(:first-child) {
  90. margin-top: 1px;
  91. &::after {
  92. content: '';
  93. display: block;
  94. height: 0;
  95. border-top: #d6d6d6 solid 1px;
  96. width: 620upx;
  97. position: absolute;
  98. top: -1px;
  99. right: 0;
  100. transform: scaleY(0.5);
  101. /* 1px像素 */
  102. }
  103. }
  104. &.active,
  105. &:active {
  106. color: #42b983;
  107. background-color: #fff;
  108. }
  109. }
  110. }
  111. .main {
  112. background-color: #fff;
  113. padding-left: 20rpx;
  114. width: 0;
  115. flex-grow: 1;
  116. box-sizing: border-box;
  117. .swiper {
  118. height: 500px;
  119. }
  120. .title {
  121. line-height: 64rpx;
  122. font-size: 24rpx;
  123. font-weight: bold;
  124. color: #666;
  125. background-color: #fff;
  126. position: sticky;
  127. top: 0;
  128. z-index: 999;
  129. }
  130. .item {
  131. padding-bottom: 10rpx;
  132. }
  133. .goods {
  134. display: flex;
  135. flex-direction: row;
  136. flex-wrap: nowrap;
  137. justify-content: flex-start;
  138. align-items: center;
  139. align-content: center;
  140. margin-bottom: 10rpx;
  141. &>image {
  142. width: 120rpx;
  143. height: 120rpx;
  144. margin-right: 16rpx;
  145. }
  146. .describe {
  147. font-size: 24rpx;
  148. color: #999;
  149. }
  150. .money {
  151. font-size: 24rpx;
  152. color: #efba21;
  153. }
  154. }
  155. }
  156. }
  157. </style>