index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <view>
  3. <view class='newsList'>
  4. <view class='swiper' v-if="imgUrls.length > 0">
  5. <swiper indicator-dots="true" :autoplay="autoplay" :circular="circular" :interval="interval" :duration="duration"
  6. indicator-color="rgba(102,102,102,0.3)" indicator-active-color="#666">
  7. <block v-for="(item,index) in imgUrls" :key="index">
  8. <swiper-item>
  9. <navigator :url="'/pages/news_details/index?id='+item.id">
  10. <image :src="item.image_input[0]" class="slide-image" />
  11. </navigator>
  12. </swiper-item>
  13. </block>
  14. </swiper>
  15. </view>
  16. <view class='nav' v-if="navList.length > 0">
  17. <scroll-view class="scroll-view_x" scroll-x scroll-with-animation :scroll-left="scrollLeft" style="width:auto;overflow:hidden;">
  18. <block v-for="(item,index) in navList" :key="index">
  19. <view class='item' :class='active==item.article_category_id?"on":""' @click='tabSelect(item.article_category_id)'>
  20. <view>{{item.title}}</view>
  21. <view class='line bg-color' v-if="active==item.article_category_id"></view>
  22. </view>
  23. </block>
  24. </scroll-view>
  25. </view>
  26. <view class='list'>
  27. <block v-for="(item,index) in articleList" :key="index">
  28. <navigator :url='"/pages/news_details/index?id="+item.article_id' hover-class='none' class='item acea-row row-between-wrapper'>
  29. <view class='text acea-row row-column-between'>
  30. <view class='name line2'>{{item.title}}</view>
  31. <view>{{item.create_time}}</view>
  32. </view>
  33. <view class='pictrue'>
  34. <image :src='item.image_input'></image>
  35. </view>
  36. </navigator>
  37. </block>
  38. </view>
  39. </view>
  40. <view class='empty-box acea-row row-middle' v-if="articleList.length == 0 && (page != 1 || active== 0)">
  41. <view class='pictrue'>
  42. <image src='../../static/images/empty-box.png'></image>
  43. <view class="txt">暂无新闻信息~</view>
  44. </view>
  45. </view>
  46. <home></home>
  47. </view>
  48. </template>
  49. <script>
  50. // +----------------------------------------------------------------------
  51. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  52. // +----------------------------------------------------------------------
  53. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  54. // +----------------------------------------------------------------------
  55. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  56. // +----------------------------------------------------------------------
  57. // | Author: CRMEB Team <admin@crmeb.com>
  58. // +----------------------------------------------------------------------
  59. import {
  60. getArticleCategoryList,
  61. getArticleList,
  62. getArticleHotList,
  63. getArticleBannerList
  64. } from '@/api/api.js';
  65. import home from '@/components/home';
  66. export default {
  67. components: {
  68. home
  69. },
  70. data() {
  71. return {
  72. imgUrls: [],
  73. articleList: [],
  74. indicatorDots: false,
  75. circular: true,
  76. autoplay: true,
  77. interval: 3000,
  78. duration: 500,
  79. navList: [],
  80. active: 0,
  81. page: 1,
  82. limit: 8,
  83. status: false,
  84. scrollLeft: 0
  85. };
  86. },
  87. /**
  88. * 生命周期函数--监听页面显示
  89. */
  90. onShow: function() {},
  91. /**
  92. * 生命周期函数--监听页面显示
  93. */
  94. onLoad: function() {
  95. this.getArticleCate();
  96. this.status = false;
  97. this.page = 1;
  98. this.articleList = [];
  99. },
  100. /**
  101. * 页面上拉触底事件的处理函数
  102. */
  103. onReachBottom: function() {
  104. this.getCidArticle();
  105. },
  106. methods: {
  107. getArticleHot: function() {
  108. let that = this;
  109. getArticleHotList().then(res => {
  110. that.$set(that, 'articleList', res.data);
  111. });
  112. },
  113. getArticleBanner: function() {
  114. let that = this;
  115. getArticleBannerList().then(res => {
  116. that.imgUrls = res.data;
  117. });
  118. },
  119. getCidArticle: function() {
  120. let that = this;
  121. if (that.active == 0) return;
  122. let limit = that.limit;
  123. let page = that.page;
  124. let articleList = that.articleList;
  125. if (that.status) return;
  126. getArticleList(that.active, {
  127. page: page,
  128. limit: limit
  129. }).then(res => {
  130. let articleListNew = [];
  131. let len = res.length;
  132. articleListNew = articleList.concat(res.data.list);
  133. that.page++;
  134. that.$set(that, 'articleList', articleListNew);
  135. that.status = limit > len;
  136. that.page = that.page;
  137. });
  138. },
  139. getArticleCate: function() {
  140. let that = this;
  141. getArticleCategoryList().then(res => {
  142. this.active = res.data[0].article_category_id
  143. that.$set(that, 'navList', res.data);
  144. this.getCidArticle();
  145. });
  146. },
  147. tabSelect(active) {
  148. this.active = active;
  149. if (this.active == 0) this.getArticleHot();
  150. else {
  151. this.$set(this, 'articleList', []);
  152. this.page = 1;
  153. this.status = false;
  154. this.getCidArticle();
  155. }
  156. }
  157. }
  158. }
  159. </script>
  160. <style>
  161. page {
  162. background: #ffffff;
  163. }
  164. </style>
  165. <style lang="scss" scoped>
  166. .newsList .swiper {
  167. width: 100%;
  168. position: relative;
  169. box-sizing: border-box;
  170. padding: 0 30rpx;
  171. }
  172. .newsList .swiper swiper {
  173. width: 100%;
  174. height: 365rpx;
  175. position: relative;
  176. }
  177. .newsList .swiper .slide-image {
  178. width: 100%;
  179. height: 335rpx;
  180. border-radius: 6rpx;
  181. }
  182. // #ifdef MP-WEIXIN
  183. .newsList .swiper .wx-swiper-dot {
  184. width: 12rpx !important;
  185. height: 12rpx !important;
  186. border-radius: 0;
  187. transform: rotate(-45deg);
  188. transform-origin: 0 100%;
  189. }
  190. .newsList .swiper .wx-swiper-dot~.wx-swiper-dot {
  191. margin-left: 5rpx;
  192. }
  193. .newsList .swiper .wx-swiper-dots.wx-swiper-dots-horizontal {
  194. margin-bottom: -15rpx;
  195. }
  196. // #endif
  197. // #ifdef APP-PLUS || H5
  198. .newsList .swiper .uni-swiper-dot {
  199. width: 12rpx !important;
  200. height: 12rpx !important;
  201. border-radius: 0;
  202. transform: rotate(-45deg);
  203. transform-origin: 0 100%;
  204. }
  205. .newsList .swiper .uni-swiper-dot~.uni-swiper-dot {
  206. margin-left: 5rpx;
  207. }
  208. .newsList .swiper .uni-swiper-dots.uni-swiper-dots-horizontal {
  209. margin-bottom: -15rpx;
  210. }
  211. // #endif
  212. .newsList .nav {
  213. padding: 0 30rpx;
  214. width: 100%;
  215. white-space: nowrap;
  216. box-sizing: border-box;
  217. margin-top: 43rpx;
  218. }
  219. .newsList .nav .item {
  220. display: inline-block;
  221. font-size: 32rpx;
  222. color: #999;
  223. min-width: 130rpx;
  224. white-space: nowrap;
  225. overflow: hidden;
  226. text-overflow: ellipsis;
  227. position: relative;
  228. padding-bottom: 20rpx;
  229. text-align: center;
  230. }
  231. .newsList .nav .item.on {
  232. color: #282828;
  233. }
  234. .newsList .nav .item~.item {
  235. margin-left: 46rpx;
  236. }
  237. .newsList .nav .item .line {
  238. width: 24rpx;
  239. height: 4rpx;
  240. border-radius: 2rpx;
  241. margin: 10rpx auto 0 auto;
  242. position: absolute;
  243. bottom: 5rpx;
  244. left: 50%;
  245. margin-left: -12rpx;
  246. }
  247. .newsList .list .item {
  248. margin: 0 30rpx;
  249. border-bottom: 1px solid #f0f0f0;
  250. padding: 35rpx 0;
  251. }
  252. .newsList .list .item .pictrue {
  253. width: 250rpx;
  254. height: 156rpx;
  255. }
  256. .newsList .list .item .pictrue image {
  257. width: 100%;
  258. height: 100%;
  259. border-radius: 6rpx;
  260. }
  261. .newsList .list .item .text {
  262. width: 420rpx;
  263. height: 156rpx;
  264. font-size: 24rpx;
  265. color: #999;
  266. }
  267. .newsList .list .item .text .name {
  268. font-size: 30rpx;
  269. color: #282828;
  270. }
  271. .newsList .list .item .picList .pictrue {
  272. width: 335rpx;
  273. height: 210rpx;
  274. margin-top: 30rpx;
  275. }
  276. .newsList .list .item .picList.on .pictrue {
  277. width: 217rpx;
  278. height: 136rpx;
  279. }
  280. .newsList .list .item .picList .pictrue image {
  281. width: 100%;
  282. height: 100%;
  283. border-radius: 6rpx;
  284. }
  285. .newsList .list .item .time {
  286. text-align: right;
  287. font-size: 24rpx;
  288. color: #999;
  289. margin-top: 22rpx;
  290. }
  291. .noCommodity{
  292. border: none;
  293. }
  294. .empty-box{
  295. display: flex;
  296. flex-direction: column;
  297. justify-content: center;
  298. align-items: center;
  299. margin-top: 200rpx;
  300. image{
  301. width: 414rpx;
  302. height: 240rpx;
  303. }
  304. .txt{
  305. font-size: 26rpx;
  306. color: #999;
  307. text-align: center;
  308. }
  309. }
  310. </style>