newsNotice.vue 4.5 KB

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