index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <!-- 咨询模块 -->
  3. <view :style="colorStyle">
  4. <view class='newsList'>
  5. <view class="w-full h-392 relative" v-if="imgUrls.length > 0">
  6. <swiper
  7. indicator-dots="true"
  8. autoplay
  9. circular
  10. :interval="3000"
  11. :duration="500"
  12. indicator-color="rgba(255,255,255,0.1)"
  13. indicator-active-color="#fff"
  14. class="w-full h-392 relative">
  15. <block v-for="(item,index) in imgUrls" :key="index">
  16. <swiper-item>
  17. <navigator :url="'/pages/extension/news_details/index?id='+item.id">
  18. <image :src="item.image_input[0]" class="w-full h-392" mode="aspectFill" />
  19. </navigator>
  20. </swiper-item>
  21. </block>
  22. </swiper>
  23. </view>
  24. <view class="bg--w111-f5f5f5 relative rd-t-32rpx pt-12 content">
  25. <view class="nab-box w-full flex-between-center">
  26. <scroll-view scroll-x="true"
  27. scroll-with-animation :scroll-left="scrollLeft"
  28. class="white-nowrap vertical-middle w-662 pl-32"
  29. show-scrollbar="false">
  30. <view class="inline-block fs-30 h-88 lh-88rpx mr-40 "
  31. v-for="(item, index) in navList" :key="index"
  32. :class="active == item.id ? 'active' : 'text--w111-999'"
  33. @tap="tabSelect(item.id,index)">{{item.title}}</view>
  34. </scroll-view>
  35. <view class="h-88 w-88 flex-center" @tap="checkGrid">
  36. <text class="iconfont icon-a-ic_Imageandtextsorting fs-32 text--w111-999"></text>
  37. </view>
  38. </view>
  39. <view class="mt-24 grid-column-2 grid-gap-18rpx px-24" v-show="grid">
  40. <view v-for="(item,index) in articleList" :key="index" @tap="getDetail(item.id)">
  41. <easy-loadimage
  42. mode="widthFix"
  43. :image-src="item.image_input[0]"
  44. width="100%"
  45. height="216rpx"
  46. borderRadius="16rpx 16rpx 0 0"></easy-loadimage>
  47. <view class="bg--w111-fff rd-b-16rpx p-20">
  48. <view class="w-full fs-28 h-80 lh-40rpx line2">{{item.title}}</view>
  49. <view class="flex-between-center mt-12 fs-24 text--w111-999">
  50. <text>{{item.add_time}}</text>
  51. <view class="flex-y-center">
  52. <text class="iconfont icon-ic_Eyes fs-28"></text>
  53. <text class="pl-8">{{item.visit}}</text>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="mt-24 px-24" v-show="!grid">
  60. <view class="flex justify-between mb-40" v-for="(item,index) in articleList" :key="index"
  61. @tap="getDetail(item.id)">
  62. <!-- <image :src="item.image_input[0]" class="w-240 h-152 rd-16rpx block"></image> -->
  63. <easy-loadimage
  64. mode="widthFix"
  65. :image-src="item.image_input[0]"
  66. width="240rpx"
  67. height="152rpx"
  68. borderRadius="16rpx"></easy-loadimage>
  69. <view class="flex-1 pl-24 h-152 flex-col justify-between">
  70. <view class="w-full line2 fs-30 lh-42rpx h-84">{{item.title}}</view>
  71. <view class="flex-between-center mt-12 fs-24 text--w111-999">
  72. <text>{{item.add_time}}</text>
  73. <view class="flex-y-center">
  74. <text class="iconfont icon-ic_Eyes fs-28"></text>
  75. <text class="pl-8">{{item.visit}}</text>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <view class='px-20' v-if="!articleList.length">
  82. <emptyPage title="暂无新闻信息~" src="/statics/images/noNews.gif"></emptyPage>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </template>
  88. <script>
  89. import {
  90. getArticleCategoryList,
  91. getArticleList,
  92. getArticleHotList,
  93. getArticleBannerList
  94. } from '@/api/api.js';
  95. import colors from "@/mixins/color";
  96. import {HTTP_REQUEST_URL} from '@/config/app';
  97. import emptyPage from '@/components/emptyPage.vue';
  98. export default {
  99. components: {
  100. emptyPage
  101. },
  102. mixins: [colors],
  103. data() {
  104. return {
  105. imgUrls: [],
  106. articleList: [],
  107. navList: [],
  108. active: 0,
  109. page: 1,
  110. limit: 8,
  111. status: false,
  112. scrollLeft: 0,
  113. imgHost:HTTP_REQUEST_URL,
  114. grid:true,
  115. };
  116. },
  117. onLoad(){
  118. this.getArticleHot();
  119. this.getArticleBanner();
  120. this.getArticleCate();
  121. },
  122. /**
  123. * 页面上拉触底事件的处理函数
  124. */
  125. onReachBottom: function () {
  126. this.getCidArticle();
  127. },
  128. onPageScroll(object) {
  129. uni.$emit('scroll');
  130. },
  131. methods: {
  132. getDetail(id){
  133. uni.navigateTo({
  134. url:'/pages/extension/news_details/index?id=' + id
  135. })
  136. },
  137. checkGrid(){
  138. this.grid = !this.grid;
  139. },
  140. getArticleHot: function() {
  141. let that = this;
  142. getArticleHotList().then(res => {
  143. that.$set(that, 'articleList', res.data);
  144. });
  145. },
  146. getArticleBanner: function() {
  147. let that = this;
  148. getArticleBannerList().then(res => {
  149. that.imgUrls = res.data;
  150. });
  151. },
  152. getCidArticle: function() {
  153. let that = this;
  154. if (that.active == 0) return;
  155. let articleList = that.articleList;
  156. if (that.status) return;
  157. getArticleList(that.active, {
  158. page: that.page,
  159. limit: that.limit
  160. }).then(res => {
  161. let len = res.data.length;
  162. that.articleList = that.articleList.concat(res.data);
  163. that.page++;
  164. that.status = that.limit > len;
  165. });
  166. },
  167. getArticleCate: function() {
  168. let that = this;
  169. getArticleCategoryList().then(res => {
  170. that.$set(that, 'navList', res.data);
  171. });
  172. },
  173. tabSelect(active,e) {
  174. this.active = active;
  175. this.scrollLeft = e * 60;
  176. // this.scrollLeft = (active - 1) * 50;
  177. if (this.active == 0) this.getArticleHot();
  178. else {
  179. this.$set(this, 'articleList', []);
  180. this.page = 1;
  181. this.status = false;
  182. this.getCidArticle();
  183. }
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="scss">
  189. .h-392{
  190. height: 392rpx;
  191. }
  192. .content{
  193. left: 0;
  194. top: -32rpx;
  195. }
  196. .active{
  197. color: #333;
  198. font-size: 32rpx;
  199. font-weight: 500;
  200. position: relative;
  201. &::after{
  202. position: absolute;
  203. content: '';
  204. width: 36rpx;
  205. height: 10rpx;
  206. background-image: url('@/static/images/titleBg.png');
  207. background-repeat: no-repeat;
  208. background-size: 100% 100%;
  209. left:50%;
  210. bottom: 10rpx;
  211. margin-left: -18rpx;
  212. }
  213. }
  214. // #ifdef APP-PLUS || H5
  215. .newsList /deep/uni-swiper .uni-swiper-dots-horizontal{
  216. bottom: 50rpx;
  217. }
  218. .newsList /deep/uni-swiper .uni-swiper-dots-horizontal .uni-swiper-dot{
  219. width: 10rpx;
  220. height: 10rpx;
  221. border-radius: 50%;
  222. }
  223. .newsList /deep/uni-swiper .uni-swiper-dots-horizontal .uni-swiper-dot-active{
  224. width: 18rpx;
  225. height: 10rpx;
  226. border-radius: 6rpx;
  227. background-color: #fff;
  228. }
  229. .newsList .swiper /deep/.uni-swiper-dot ~ .uni-swiper-dot {
  230. margin-left: 5rpx;
  231. }
  232. // #endif
  233. // #ifdef MP
  234. .newsList /deep/wx-swiper .wx-swiper-dots-horizontal{
  235. bottom: 50rpx;
  236. }
  237. .newsList .swiper /deep/.wx-swiper-dot~.wx-swiper-dot {
  238. width: 10rpx;
  239. height: 10rpx;
  240. border-radius: 50%;
  241. margin-left: 5rpx;
  242. }
  243. // #endif
  244. </style>