newsNotice.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <view style="background-color: #fff;height:1135px;" >
  3. <u-navbar title="新闻公告"></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!=0&&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.get("getElderModeClass") == "长辈模式") {
  56. this.elderStatus = true;
  57. } else {
  58. this.elderStatus = false;
  59. }
  60. this.getNewsList();
  61. this.getBannerInfo("NEWS")
  62. },
  63. methods: {
  64. getBannerInfo(code){
  65. uni.showLoading({
  66. title: "加载中",
  67. mask: true,
  68. })
  69. newsApi.getBannerInfo(code).then((res) => {
  70. this.list =res.data;
  71. uni.hideLoading()
  72. }).catch(error => {
  73. uni.showToast({
  74. title: error,icon: "none"
  75. })
  76. })
  77. },
  78. clickBanner(index){
  79. var mod= this.list[index]
  80. if(mod.linkUrl.indexOf('http')==0){
  81. window.location=mod.linkUrl;
  82. }else if(mod.linkUrl.indexOf('#/')==0){
  83. if(mod.linkUrl.indexOf("?")==-1){
  84. mod.linkUrl+='?';
  85. }
  86. var url=mod.clickUrl.split("#")[1]
  87. //window.location = mod.clickUrl;
  88. uni.navigateTo({
  89. url: url
  90. })
  91. // window.location=mod.linkUrl;
  92. }
  93. else if(mod.linkUrl=='#'||mod.linkUrl==''){
  94. }
  95. else{
  96. uni.navigateTo({
  97. url:mod.linkUrl
  98. })
  99. }
  100. },
  101. change(index) {
  102. this.current = index;
  103. this.newsType = this.tabList[index].type;
  104. this.getNewsList(true)
  105. },
  106. getNewsList(bl) {
  107. uni.showLoading({
  108. title: "加载中",
  109. mask: true,
  110. })
  111. if (bl) {
  112. this.newsList = [];
  113. this.pageIndex = 1;
  114. }
  115. newsApi.newsInfoList({
  116. pageIndex: 1,
  117. pageSize: 10,
  118. shortName: this.newsType
  119. }).then((res) => {
  120. uni.hideLoading()
  121. this.newsList = [
  122. ...this.newsList,
  123. ...res.data.data
  124. ];
  125. this.recordsTotal = res.data.recordsTotal
  126. }).catch(error => {
  127. uni.showToast({
  128. title: error,
  129. icon: "none"
  130. })
  131. })
  132. },
  133. myLoadmore() {
  134. this.pageIndex += 1;
  135. this.getNewsList()
  136. },
  137. }
  138. }
  139. </script>
  140. <style lang="scss">
  141. .options{
  142. width: 60%;
  143. height: 44px;
  144. line-height: 44px;
  145. display: flex;
  146. justify-content: space-between;
  147. margin: 0px 16px ;
  148. }
  149. .swiper-box{
  150. margin: 0 16px;
  151. }
  152. .news {
  153. background-color: #fff;
  154. margin: 0 16px ;
  155. border-radius: 8px;
  156. .news-content {
  157. display: flex;
  158. justify-content: space-between;
  159. margin-bottom: 24px;
  160. .content-text {
  161. width: 56.2%;
  162. height: 100%;
  163. line-height: 21px;
  164. color: #101010;
  165. text-align: left;
  166. font-size: 14px;
  167. }
  168. .content-title {
  169. width: 100%;
  170. overflow: hidden;
  171. text-overflow: ellipsis;
  172. display: -webkit-box;
  173. -webkit-box-orient: vertical;
  174. -webkit-line-clamp: 3;
  175. }
  176. .content-img {
  177. width: 40.57%;
  178. height: 100%;
  179. border-radius: 4px;
  180. overflow: hidden;
  181. img {
  182. width: 100%;
  183. height: 80%;
  184. }
  185. }
  186. .news-time {
  187. margin-top: 10%;
  188. color: #999999;
  189. width: 100px;
  190. height: 20px;
  191. font-size: 14px;
  192. }
  193. }
  194. }
  195. </style>