story.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <view class="content">
  3. <!-- 头部导航 -->
  4. <view class="nav-bar flex">
  5. <view class="nav-item" v-for="(item,index) in navList" :key="index"
  6. :class="{'active': currentIndex == index}" @click="navClick(index)">
  7. {{item.tit}}
  8. </view>
  9. </view>
  10. <!-- 分类列表 -->
  11. <swiper :duration="400" class="swiper-wrapper" :style="{'height': height}" :current="currentIndex" @change="swiperChange">
  12. <swiper-item>
  13. <scroll-view scroll-y="true" :style="{'height': height}" class="scroll-wrapper">
  14. <view class="list" v-for="(item,index) in 100">
  15. <template v-if="index == 0">
  16. <view class="list-top-tit clamp2">竹胎酵素饮】正一健康竹胎酵素饮相关纪录片在浙江卫视热播</view>
  17. <image src="" mode="" class="list-top-img"></image>
  18. <view class="list-top-time">
  19. 更新时间:2019-12-06
  20. </view>
  21. </template>
  22. <template v-else>
  23. <view class="list-scend">
  24. <image src="" mode="" class="list-img"></image>
  25. <view class="list-info">
  26. <view class="list-tit clamp">竹胎酵素饮】正一健康竹胎酵素饮相关纪录片在浙江卫视热播</view>
  27. <view class="list-time">
  28. 更新时间:2019-12-06
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. </view>
  34. </scroll-view>
  35. </swiper-item>
  36. <swiper-item>
  37. <scroll-view scroll-y="true" :style="{'height': height}" class="scroll-wrapper">
  38. <view class="list" v-for="(item,index) in 100">
  39. <template v-if="index == 0">
  40. <view class="list-top-tit clamp2">竹胎酵素饮】正一健康竹胎酵素饮相关纪录片在浙江卫视热播</view>
  41. <image src="" mode="" class="list-top-img"></image>
  42. <view class="list-top-time">
  43. 更新时间:2019-12-06
  44. </view>
  45. </template>
  46. <template v-else>
  47. <view class="list-scend">
  48. <image src="" mode="" class="list-img"></image>
  49. <view class="list-info">
  50. <view class="list-tit clamp">竹胎酵素饮】正一健康竹胎酵素饮相关纪录片在浙江卫视热播</view>
  51. <view class="list-time">
  52. 更新时间:2019-12-06
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. </view>
  58. </scroll-view>
  59. </swiper-item>
  60. <swiper-item>
  61. <scroll-view scroll-y="true" :style="{'height': height}" class="scroll-wrapper">
  62. <view class="list" v-for="(item,index) in 100">
  63. <template v-if="index == 0">
  64. <view class="list-top-tit clamp2">竹胎酵素饮】正一健康竹胎酵素饮相关纪录片在浙江卫视热播</view>
  65. <image src="" mode="" class="list-top-img"></image>
  66. <view class="list-top-time">
  67. 更新时间:2019-12-06
  68. </view>
  69. </template>
  70. <template v-else>
  71. <view class="list-scend">
  72. <image src="" mode="" class="list-img"></image>
  73. <view class="list-info">
  74. <view class="list-tit clamp">竹胎酵素饮】正一健康竹胎酵素饮相关纪录片在浙江卫视热播</view>
  75. <view class="list-time">
  76. 更新时间:2019-12-06
  77. </view>
  78. </view>
  79. </view>
  80. </template>
  81. </view>
  82. </scroll-view>
  83. </swiper-item>
  84. </swiper>
  85. </view>
  86. </template>
  87. <script>
  88. export default {
  89. components: {
  90. },
  91. onReady(res) {
  92. var _this = this;
  93. uni.getSystemInfo({
  94. success: resu => {
  95. const query = uni.createSelectorQuery();
  96. query.select('.swiper-wrapper').boundingClientRect();
  97. query.exec(function(res) {
  98. console.log(res, 'ddddddddddddd');
  99. _this.height = resu.windowHeight - res[0].top + 'px';
  100. console.log('打印页面的剩余高度', _this.height);
  101. });
  102. },
  103. fail: res => {}
  104. });
  105. },
  106. data() {
  107. return {
  108. height: '', //swiper 高度
  109. currentIndex: 0, //当前头部导航位置
  110. navList: [{
  111. cid: 1,
  112. tit: '公司简介',
  113. list: [],
  114. page: 1,
  115. limit: 10,
  116. loadingType: 'more'
  117. },
  118. {
  119. cid: 2,
  120. tit: '产品简介',
  121. list: [],
  122. page: 1,
  123. limit: 10,
  124. loadingType: 'more'
  125. },
  126. {
  127. cid: 1,
  128. tit: '案例分享',
  129. list: [],
  130. page: 1,
  131. limit: 10,
  132. loadingType: 'more'
  133. }
  134. ]
  135. }
  136. },
  137. onLoad() {
  138. this.getData()
  139. },
  140. methods: {
  141. navClick(index) {
  142. this.currentIndex = index
  143. },
  144. swiperChange(e) {
  145. console.log(e,'swiperChange')
  146. this.currentIndex = e.detail.current
  147. this.getData('tabChange')
  148. },
  149. getData(source) {
  150. let obj = this
  151. let index = this.currentIndex;
  152. let navItem = this.navList[index];
  153. if (source === 'tabChange' && navItem.loaded === true) {
  154. //tab切换只有第一次需要加载数据
  155. return;
  156. }
  157. if (navItem.loadingType === 'loading') {
  158. //防止重复加载
  159. return;
  160. }
  161. if (navItem.loadingType === 'noMore') {
  162. //防止重复加载
  163. return;
  164. }
  165. navItem.loadingType = 'loading';
  166. getCricleList({
  167. page: navItem.page,
  168. limit: navItem.limit
  169. }).then(({data}) => {
  170. console.log(res)
  171. let list = data.list.map( item => {
  172. return item
  173. })
  174. navItem.list = navItem.list.concat(list);
  175. console.log(arr);
  176. if (navItem.limit == data.list.data.length) {
  177. //判断是否还有数据, 有改为 more, 没有改为noMore
  178. navItem.loadingType = 'more';
  179. navItem.page++;
  180. } else {
  181. //判断是否还有数据, 有改为 more, 没有改为noMore
  182. navItem.loadingType = 'noMore';
  183. }
  184. this.$set(navItem, 'loaded', true);
  185. })
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. page {
  192. height: 100%;
  193. background-color: #eee;
  194. padding-top: 20rpx;
  195. }
  196. .content {
  197. height: 100%;
  198. background-color: #fff;
  199. .nav-bar {
  200. line-height: 86rpx;
  201. font-size: 32rpx;
  202. font-family: PingFang SC;
  203. font-weight: bold;
  204. color: #333333;
  205. justify-content: space-around;
  206. border-bottom: #E0E0E0 1px solid;
  207. .active {
  208. color: #3F7C1F;
  209. border-bottom: 3rpx solid #3F7C1F;
  210. }
  211. .nav-item {
  212. // flex-grow: 1;
  213. text-align: center;
  214. }
  215. }
  216. }
  217. .swiper-wrapper {
  218. background-color: #eee;
  219. .scroll-wrapper {
  220. padding: 0 22rpx 0 23rpx;
  221. }
  222. .list {
  223. padding: 18rpx 0;
  224. border-bottom: 1px solid #E0E0E0;
  225. .list-top-tit {
  226. font-size: 32rpx;
  227. font-family: PingFang SC;
  228. font-weight: bold;
  229. color: #333333;
  230. line-height: 42rpx;
  231. }
  232. .list-top-img {
  233. margin-top: 15rpx;
  234. width: 705rpx;
  235. height: 399rpx;
  236. background-color: #999;
  237. }
  238. .list-top-time {
  239. font-size: 26rpx;
  240. font-family: PingFang SC;
  241. font-weight: 500;
  242. color: #999999;
  243. line-height: 32rpx;
  244. }
  245. .list-scend {
  246. display: flex;
  247. .list-img {
  248. flex-shrink: 0;
  249. background-color: #999;
  250. width: 224rpx;
  251. height: 160rpx;
  252. }
  253. .list-info {
  254. padding:10rpx 0 19rpx 23rpx;
  255. position: relative;
  256. .list-tit {
  257. width: 420rpx;
  258. font-size: 32rpx;
  259. font-family: PingFang SC;
  260. font-weight: bold;
  261. color: #333333;
  262. line-height: 32px;
  263. }
  264. .list-time {
  265. font-size: 28rpx;
  266. font-family: PingFang SC;
  267. font-weight: 500;
  268. color: #666666;
  269. line-height: 32rpx;
  270. position: absolute;
  271. bottom: 19rpx;
  272. }
  273. }
  274. }
  275. }
  276. }
  277. </style>