index.vue 7.6 KB

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