lists.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view class="list">
  3. <view class="nav">
  4. <view class="nav-item" v-for="(nav , index) in navList" :class="{'action': currentIndex == index}" @click="navClick(index)">{{nav.tit}}</view>
  5. </view>
  6. <swiper :autoplay="false" :interval="3000" :duration="500" circular class="swiper-box" :style="{'height': height}" :current="currentIndex" disable-touch>
  7. <swiper-item v-for="navItem in navList">
  8. <scroll-view scroll-y="true" @scrolltolower="getList()" :style="{'height': height}">
  9. <empty v-if="navItem.loaded && navItem.list.length==0"></empty>
  10. <view class="list-item" v-for="item in navItem.list" @click="navTo('/pages/article/detail?id=' + item.id)">
  11. <view class="article-tit">{{item.title}}</view>
  12. <view class="article-time">{{item.release_time}}</view>
  13. </view>
  14. <uni-load-more :status="navItem.loadingType"></uni-load-more>
  15. </scroll-view>
  16. </swiper-item>
  17. </swiper>
  18. </view>
  19. </template>
  20. <script>
  21. import empty from '../../components/empty.vue'
  22. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  23. import {
  24. getArticleList
  25. } from '../../api/index.js'
  26. export default {
  27. components: {
  28. uniLoadMore,
  29. empty
  30. },
  31. data() {
  32. return {
  33. height: '',
  34. currentIndex: 0,
  35. navList: [{
  36. tit: '活动开展',
  37. list: [],
  38. page: 1,
  39. limit: 10,
  40. loadingType: 'more',
  41. loaded: false,
  42. cid: 14,
  43. },
  44. {
  45. tit: '应急救护名师工作室',
  46. list: [],
  47. page: 1,
  48. limit: 10,
  49. loadingType: 'more',
  50. loaded: false,
  51. cid: 15,
  52. },
  53. {
  54. tit: '最美红十字救护员',
  55. list: [],
  56. page: 1,
  57. limit: 10,
  58. loadingType: 'more',
  59. loaded: false,
  60. cid: 16,
  61. },
  62. {
  63. tit: '救在身边',
  64. list: [],
  65. page: 1,
  66. limit: 10,
  67. loadingType: 'more',
  68. loaded: false,
  69. cid: 16,
  70. }
  71. ],
  72. cid: '',
  73. openlink: ''
  74. }
  75. },
  76. onLoad(opt) {
  77. let obj = this
  78. if (opt.cid) {
  79. this.cid = opt.cid
  80. if(this.cid == 6 ) {
  81. this.currentIndex = 0
  82. }else {
  83. this.currentIndex = this.cid*1 - 14
  84. }
  85. }
  86. this.getList('tab')
  87. uni.request({
  88. url: 'https://sos.igxys.com/api/index/getScheme',
  89. data: {
  90. path: '/pages/index/index'
  91. },
  92. method: 'post',
  93. success(res){
  94. // console.log(res.data.data.openlink,'++++++++++++++++++++++++++')
  95. obj.openlink = res.data.data.openlink
  96. }
  97. })
  98. },
  99. onReady(res) {
  100. var _this = this;
  101. uni.getSystemInfo({
  102. success: resu => {
  103. const query = uni.createSelectorQuery();
  104. query.select('.swiper-box').boundingClientRect();
  105. query.exec(function(res) {
  106. console.log(res, 'ddddddddddddd');
  107. _this.height = resu.windowHeight - res[0].top + 'px';
  108. console.log('打印页面的剩余高度', _this.height);
  109. });
  110. },
  111. fail: res => {}
  112. });
  113. },
  114. methods: {
  115. navClick(index) {
  116. if(index == 3) {
  117. window.location.href = this.openlink
  118. }else {
  119. this.currentIndex = index
  120. this.getList('tab')
  121. }
  122. },
  123. navTo(url) {
  124. uni.navigateTo({
  125. url: url
  126. })
  127. },
  128. getList(opt) {
  129. let obj = this
  130. let index = obj.currentIndex
  131. let navItem = obj.navList[index]
  132. console.log(index,navItem)
  133. if(opt == 'tab' && navItem.loaded) {
  134. return
  135. }
  136. if (navItem.loadingType == 'loading' || navItem.loadingType == 'noMore') {
  137. return
  138. }
  139. navItem.loadingType = 'loading'
  140. getArticleList({
  141. page: navItem.page,
  142. limit: navItem.limit
  143. }, navItem.cid).then(({
  144. data
  145. }) => {
  146. console.log(data)
  147. navItem.list = navItem.list.concat(data.list)
  148. navItem.page++
  149. if (data.list.length == navItem.limit) {
  150. navItem.loadingType = 'more'
  151. return
  152. } else {
  153. navItem.loadingType = 'noMore'
  154. }
  155. obj.$set(navItem, 'loaded', true)
  156. })
  157. },
  158. //跳转到详情
  159. ToDetail(index) {
  160. if (index == 1) {
  161. uni.navigateTo({
  162. url: '/pages/cart/personal'
  163. })
  164. }
  165. if (index == 2) {
  166. uni.navigateTo({
  167. url: '/pages/cart/group'
  168. })
  169. }
  170. if (index == 3) {
  171. uni.navigateTo({
  172. url: '/pages/form/tovolApply'
  173. })
  174. }
  175. }
  176. }
  177. }
  178. </script>
  179. <style lang="scss" scoped>
  180. page {
  181. background-color: #fff;
  182. height: 100%;
  183. }
  184. .nav {
  185. display: flex;
  186. flex-wrap: wrap;
  187. background-color: #df001b;
  188. font-size: 32rpx;
  189. color: #fff;
  190. font-weight: 500;
  191. .action {
  192. font-size: 36rpx;
  193. font-weight: bold;
  194. }
  195. .nav-item {
  196. width: 100%;
  197. line-height: 70rpx;
  198. text-align: center;
  199. }
  200. }
  201. .list-item {
  202. border-bottom: 1px solid #ccc;
  203. border-top: 1px solid #ccc;
  204. padding: 20rpx 35rpx;
  205. line-height: 1.5;
  206. .article-tit {
  207. font-size: 34rpx;
  208. color: #000000;
  209. font-weight: 500;
  210. letter-spacing: 3rpx;
  211. }
  212. .article-time {
  213. font-size: 28rpx;
  214. color: #888;
  215. font-weight: 500;
  216. }
  217. }
  218. .order-item {
  219. width: 100%;
  220. padding: 0rpx 25rpx;
  221. padding-top: 25rpx !important;
  222. .list-cell {
  223. background-color: #ffffff;
  224. border-radius: 20rpx;
  225. width: 100%;
  226. box-shadow: 0px 0px 40px 0px rgba(0, 0, 0, 0.06);
  227. .image {
  228. width: 100%;
  229. height: 300rpx;
  230. border-top-left-radius: 25rpx;
  231. border-top-right-radius: 25rpx;
  232. }
  233. .list-tpl {
  234. padding: 25rpx 25rpx;
  235. padding-bottom: 35rpx !important;
  236. font-size: 34rpx;
  237. color: #222222;
  238. font-weight: 500;
  239. }
  240. }
  241. }
  242. </style>