123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- <template>
- <view style="background-color: #fff;" >
- <ujp-navbar title="活动公告"></ujp-navbar>
-
- <view class="options-item">
- <u-tabs :font-size="elderStatus ? 36 : 30" :list="tabList" :current="current" @change="change" :show-bar="false" active-color="#333" inactive-color="#c4c0c0"></u-tabs>
- </view>
-
- <view class="swiper-box"
- style="margin-bottom: 20px;"
- v-if="list.length">
- <u-swiper bg-color="#fff" :list="list" @click="clickBanner" height="292" :img-mode="'aspectFit'" :name="'picUrl'" >
- </u-swiper>
- </view>
-
- <view class="news" >
- <view class="news-content" v-for="(item,index) in newsList" :key="item.id" @click="gotoUrl('pages/article/articleDetails?id=' + item.id)">
- <view class="content-text">
- <view class="content-title oldTextjp2" oldstyle="font-size: 18px;">{{item.title}}</view>
- <view class="news-time">{{item.createTime ? item.createTime.slice(5,16) : ''}}</view>
- </view>
- <view class="content-img">
- <img :src="item.pic ? item.pic : 'static/img/image_default.png'" alt="">
- </view>
- </view>
- </view>
- <u-divider v-if="newsList.length!=0&&newsList.length ==recordsTotal">已经到底了</u-divider>
- </view>
- </template>
- <script>
- import * as newsApi from '@/apis/news.js'
-
- export default {
- data() {
- return {
- tabList: [
- {name: '通知公告',type: 'TZGG'},
- {name: '行业新闻',type: 'HYXW'},
- {name: '优惠活动',type: 'YHHD'},
- ],
- current: 0,
- newsList: [],
- newsType: 'TZGG',
- pageIndex: 1,
- recordsTotal: 0,
- list: [
-
- ],
- elderStatus: false,
- }
- },
- onReachBottom() {
- if (this.newsList.length < this.recordsTotal) {
- this.myLoadmore();
- }
- },
- onReady() {
- if(this.carhelp.get("getElderModeClass") == "长辈模式") {
- this.elderStatus = true;
- } else {
- this.elderStatus = false;
- }
-
- this.getNewsList();
- this.getBannerInfo("NEWS")
- },
- methods: {
- getBannerInfo(code){
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- newsApi.getBannerInfo(code).then((res) => {
- this.list =res.data;
- uni.hideLoading()
- }).catch(error => {
- uni.showToast({
-
- title: error,icon: "none"
- })
- })
- },
- clickBanner(index){
- var mod= this.list[index]
-
- if(mod.linkUrl.indexOf('http')==0){
- window.location=mod.linkUrl;
- }else if(mod.linkUrl.indexOf('#/')==0){
- if(mod.linkUrl.indexOf("?")==-1){
- mod.linkUrl+='?';
- }
-
- var url=mod.clickUrl.split("#")[1]
- //window.location = mod.clickUrl;
- uni.navigateTo({
- url: url
- })
- // window.location=mod.linkUrl;
- }
- else if(mod.linkUrl=='#'||mod.linkUrl==''){
-
- }
- else{
- uni.navigateTo({
- url:mod.linkUrl
- })
- }
-
- },
- change(index) {
- this.current = index;
- this.newsType = this.tabList[index].type;
-
- this.getNewsList(true)
- },
- getNewsList(bl) {
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- if (bl) {
- this.newsList = [];
- this.pageIndex = 1;
- }
-
- newsApi.newsInfoList({
- pageIndex: this.pageIndex,
- pageSize: 20,
- shortName: this.newsType
- }).then((res) => {
- uni.hideLoading()
-
- this.newsList = [
- ...this.newsList,
- ...res.data.data
- ];
- this.recordsTotal = res.data.recordsTotal
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- myLoadmore() {
- this.pageIndex += 1;
- this.getNewsList()
- },
- }
- }
-
-
- </script>
- <style lang="scss">
-
- .options{
-
- width: 60%;
- height: 44px;
- line-height: 44px;
- display: flex;
- justify-content: space-between;
- margin: 0px 16px ;
- }
- .swiper-box{
- margin: 0 16px;
- }
- .news {
- background-color: #fff;
- margin: 0 16px ;
- border-radius: 8px;
- .news-content {
- display: flex;
- justify-content: space-between;
- margin-bottom: 24px;
-
- .content-text {
- width: 56.2%;
- height: 100%;
- line-height: 21px;
- color: #101010;
- text-align: left;
- font-size: 14px;
- }
-
- .content-title {
- width: 100%;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 3;
- }
-
- .content-img {
- width: 40.57%;
- height: 100%;
- border-radius: 4px;
- overflow: hidden;
-
- img {
- width: 100%;
- height: 80%;
- }
- }
-
- .news-time {
- margin-top: 10%;
- color: #999999;
- width: 100px;
- height: 20px;
- font-size: 14px;
- }
- }
- }
-
-
-
- </style>
|