newsNotice.vue 4.5 KB

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