newsNotice.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view style="background-color: #fff;height:1135px;" >
  3. <u-navbar title="新闻公告" :title-size="elderStatus ? 40 : 35"></u-navbar>
  4. <view class="options">
  5. <view class="options-item">
  6. <u-tabs :font-size="elderStatus ? 36 : 30" :list="tabList" :current="current" @change="change" :show-bar="false" active-color="#333" inactive-color="#c4c0c0"></u-tabs>
  7. </view>
  8. </view>
  9. <view class="swiper-box"
  10. style="margin-bottom: 20px;"
  11. v-if="list.length">
  12. <u-swiper bg-color="#fff" :list="list" @click="clickBanner" height="292" :img-mode="'aspectFit'" :name="'picUrl'" >
  13. </u-swiper>
  14. </view>
  15. <view class="news" >
  16. <view class="news-content" v-for="(item,index) in newsList" :key="item.id" @click="gotoUrl('pages/article/articleDetails?id=' + item.id)">
  17. <view class="content-text">
  18. <view class="content-title oldTextjp2" oldstyle="font-size: 18px;">{{item.title}}</view>
  19. <view class="news-time">{{item.createTime ? item.createTime.slice(5,16) : ''}}</view>
  20. </view>
  21. <view class="content-img">
  22. <img :src="item.pic ? item.pic : 'static/img/image_default.png'" alt="">
  23. </view>
  24. </view>
  25. </view>
  26. <u-divider v-if="newsList.length ==recordsTotal">已经到底了</u-divider>
  27. </view>
  28. </template>
  29. <script>
  30. import * as newsApi from '@/apis/news.js'
  31. export default {
  32. data() {
  33. return {
  34. tabList: [
  35. {name: '通知公告',type: 'TZGG'},
  36. {name: '行业新闻',type: 'HYXW'},
  37. {name: '优惠活动',type: 'YHHD'},
  38. ],
  39. current: 0,
  40. newsList: [],
  41. newsType: 'TZGG',
  42. pageIndex: 1,
  43. recordsTotal: 0,
  44. list: [
  45. ],
  46. elderStatus: false,
  47. }
  48. },
  49. onReachBottom() {
  50. if (this.newsList.length < this.recordsTotal) {
  51. this.myLoadmore();
  52. }
  53. },
  54. onReady() {
  55. if (this.carhelp.getPersonInfo()) {
  56. if(this.carhelp.get("getElderModeClass") == "长辈模式") {
  57. this.elderStatus = true;
  58. } else {
  59. this.elderStatus = false;
  60. }
  61. }
  62. this.getNewsList();
  63. this.getBannerInfo("NEWS")
  64. },
  65. methods: {
  66. getBannerInfo(code){
  67. uni.showLoading({
  68. title: "加载中",
  69. mask: true,
  70. })
  71. newsApi.getBannerInfo(code).then((res) => {
  72. this.list =res.data;
  73. }).catch(error => {
  74. uni.showToast({
  75. title: error,icon: "none"
  76. })
  77. })
  78. },
  79. clickBanner(index){
  80. var mod= this.list[index]
  81. if(mod.linkUrl.indexOf('http')==0){
  82. window.location=mod.linkUrl;
  83. }
  84. else if(mod.linkUrl.indexOf('#/')==0){
  85. if(mod.linkUrl.indexOf("?")==-1){
  86. mod.linkUrl+='?';
  87. }
  88. window.location=mod.linkUrl;
  89. }
  90. else if(mod.linkUrl=='#'||mod.linkUrl==''){
  91. }
  92. else{
  93. uni.navigateTo({
  94. url:mod.linkUrl
  95. })
  96. }
  97. },
  98. change(index) {
  99. this.current = index;
  100. this.newsType = this.tabList[index].type;
  101. this.getNewsList(true)
  102. },
  103. getNewsList(bl) {
  104. uni.showLoading({
  105. title: "加载中",
  106. mask: true,
  107. })
  108. if (bl) {
  109. this.newsList = [];
  110. this.pageIndex = 1;
  111. }
  112. newsApi.newsInfoList({
  113. pageIndex: 1,
  114. pageSize: 10,
  115. shortName: this.newsType
  116. }).then((res) => {
  117. uni.hideLoading()
  118. this.newsList = [
  119. ...this.newsList,
  120. ...res.data.data
  121. ];
  122. this.recordsTotal = res.data.recordsTotal
  123. }).catch(error => {
  124. uni.showToast({
  125. title: error,
  126. icon: "none"
  127. })
  128. })
  129. },
  130. myLoadmore() {
  131. this.pageIndex += 1;
  132. this.getNewsList()
  133. },
  134. }
  135. }
  136. </script>
  137. <style lang="scss">
  138. .options{
  139. width: 60%;
  140. height: 44px;
  141. line-height: 44px;
  142. display: flex;
  143. justify-content: space-between;
  144. margin: 0px 16px ;
  145. }
  146. .swiper-box{
  147. margin: 0 16px;
  148. }
  149. .news {
  150. background-color: #fff;
  151. margin: 0 16px ;
  152. border-radius: 8px;
  153. .news-content {
  154. display: flex;
  155. justify-content: space-between;
  156. margin-bottom: 24px;
  157. .content-text {
  158. width: 56.2%;
  159. height: 100%;
  160. line-height: 21px;
  161. color: #101010;
  162. text-align: left;
  163. font-size: 14px;
  164. }
  165. .content-title {
  166. width: 100%;
  167. overflow: hidden;
  168. text-overflow: ellipsis;
  169. display: -webkit-box;
  170. -webkit-box-orient: vertical;
  171. -webkit-line-clamp: 3;
  172. }
  173. .content-img {
  174. width: 40.57%;
  175. height: 100%;
  176. border-radius: 4px;
  177. overflow: hidden;
  178. img {
  179. width: 100%;
  180. height: 80%;
  181. }
  182. }
  183. .news-time {
  184. margin-top: 10%;
  185. color: #999999;
  186. width: 100px;
  187. height: 20px;
  188. font-size: 14px;
  189. }
  190. }
  191. }
  192. </style>