123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- <template>
- <view style="background-color: #fff;">
- <ujp-navbar title="优惠活动" :is-back="false" v-if="false" ></ujp-navbar>
- <view>
-
- <view class="options-item">
- <u-tabs :list="tabList" :current="current" @change="change" :show-bar="false" active-color="#00B962 " inactive-color="#c4c0c0"></u-tabs>
- </view>
- <uni-view data-v-fd8981f8="" class="u-navbar-placeholder" style="width: 100%; height: 88rpx;"></uni-view>
- </view>
- <view class="background" v-show="current==0">
- <view class="banner" v-for="(item,i) in bannerList"
-
- :key="i">
- <u-image width="100%" @click="clickBanner(i)"
- mode="scaleToFill" height="250" border-radius ="12"
- :src="item.picUrl"></u-image>
- <view class="tag"
-
- v-if="item.isMain">
- <img src="@/assets/img/buy/tip.png">
- </view>
- </view>
- <u-divider bg-color="#F2F4F4" >已经到底了</u-divider>
-
- </view>
- <view class="news" v-show="current==1">
- <view class="news-content" v-for="(item,index) in newsList" :key="item.id"
-
- @click="gotoArticleDetails(item)"
-
- >
- <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 v-if="item.pic " :src="item.pic" alt="">
- <img v-else src="@/assets/static/img/image_default.png" alt="">
- </view>
- </view>
- <u-divider v-if="newsList.length!=0&&newsList.length ==recordsTotal">已经到底了</u-divider>
-
- </view>
-
-
-
-
- <Tabbar :spring="indexStyle.spring" :current="1" ref="tabbarMain"></Tabbar>
-
- </view>
- </template>
- <script>
- import Tabbar from '@/components/Tabbar.vue';
- import * as newsApi from '@/apis/news.js'
-
- export default {
- data() {
- return {
- tabList: [
-
- {name: '优惠活动',type: 'YHHD'},
- {name: '通知公告',type: 'TZGG'},
-
- ],
- current: 0,
- newsList: [],
- pageIndex: 1,
- newsType: 'TZGG',
- recordsTotal: 0,
- bannerList: [],
- indexStyle: {
- noticeBarBgColor: "#fff",
- noticeBarColor: "#FF3D00",
- backgroundClass: "background",
- spring: false,
- }
- }
- },
- components: {
- Tabbar
- },
- onShow() {
-
- if (this.$refs.tabbarMain) {
- this.$refs.tabbarMain.setcount(1);
- }
-
- },onLoad() {
- this.getBannerInfo("HDYM");
- this.spring()
- },
- onReachBottom() {
- if (this.current==1&&this.newsList.length < this.recordsTotal) {
- this.myLoadmore();
- }
- },
- methods: {
- spring() {
- this.springShow=false;
- try{
- if(this.carhelp.getConfig().spring2025){
- var spring2025=this.carhelp.getConfig().spring2025
- var sz=spring2025.split(',')
- if(sz&&sz.length==2){
- var time1=new Date(sz[0])
- var time2=new Date(sz[1])
- var time0=new Date()
- if(time0>time1&&time0<time2){
- this.springShow=true;
- }
- }
- }
- this.$forceUpdate()
- }catch(e){
-
- }
-
- if(!this.springShow){
- return
- }
-
- this.indexStyle.noticeBarBgColor = "#C00000"
- this.indexStyle.noticeBarColor = "#FFD695"
- this.indexStyle.backgroundClass = "background-spring"
- this.indexStyle.spring = true;
-
-
- },
- gotoArticleDetails(item){
-
- if(item.linkType=="2"){
- this.gotoUrl2(item.externalUrl)
-
- }else{
- this.gotoUrl('pages/article/articleDetails?id=' + item.id)
-
- }
- },
- change(index) {
- this.current = index;
- //this.newsType = this.tabList[index].type;
- if(this.newsList.length==0){
- this.getNewsList()
- }
-
- },
- 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()
- },
- getBannerInfo(code) {
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- newsApi.getBannerInfo(code).then((res) => {
- this.bannerList = res.data;
- uni.hideLoading()
- //document.getElementsByClassName("uni-swiper-wrapper")[0].parentNode.style="background-color: rgb(255, 255, 255); height: 120px;"
- }).catch(error => {
- uni.showToast({
-
- title: error,
- icon: "none"
- })
- })
- },
- clickBannerTopI(i) {
- var mod = this.bannerListTop[i];
- //this.showTop = false;
- this.clickBanner(0, true, mod)
- },
- clickBannerTop() {
- var mod = this.bannerListTop[this.showTopIndex];
- this.showTop = false;
- this.clickBanner(0, true, mod)
- },
- clickBanner(index, bl, modout) {
- var uurl = "";
- var mod = {}
- if (modout) {
- mod = modout;
- }else{
- mod =this.bannerList[index]
- }
- mod.clickUrl = mod.linkUrl
-
- if (mod.linkPicUrl && !bl) {
-
- this.showOss = true;
- this.showOssImg = mod.linkPicUrl;
- this.showOssIndex = index;
-
- } else if (mod.clickUrl == null) {
-
- } else if (mod.clickUrl.indexOf('http') == 0) {
-
- window.location = mod.clickUrl + uurl;
- } else if (mod.clickUrl.slice(-5) == 'login' && this.userId) {
-
- } else if (mod.clickUrl.indexOf('#/') == 0) {
- if (mod.clickUrl.indexOf("?") == -1) {
- mod.clickUrl += '?';
- }
- var url = mod.clickUrl.split("#")[1]
- //window.location = mod.clickUrl;
- uni.navigateTo({
- url: url + uurl
- })
- } else if (mod.clickUrl == '#' || mod.clickUrl == '') {
-
- } else {
- uni.navigateTo({
- url: mod.clickUrl + uurl
- })
- }
- },
- }
- }
- </script>
- <style lang="scss" scoped>
-
- .tag {
-
- width: 120px;
- top: -100rpx;
- left: 464rpx;
- position: relative;
- border-radius: 4px 4px 4px 0px;
- color: #fff;
- padding: 2px 6px;
- font-size: 20rpx;
- line-height: 20rpx;
- height: 1rpx;
- //background: linear-gradient(to right bottom, rgba(255, 255, 255, 0.4), transparent) var(--bg, #EA3447);
- background-blend-mode: soft-light;
- img{
- height: 74rpx;
- width: 240rpx;
- }
- }
-
- .background{
- padding-bottom: 30px;
- }
- .banner{
- margin: 24rpx;
-
- }
- .options-item{
- width: 100%;
- display: flex;
- justify-content: center;
- background: rgb(255, 255, 255);
- position: relative;
- position: fixed;
-
- left: 0;
- right: 0;
- top: 0;
- z-index: 991;
- }
-
- .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;
- }
- }
- }
- ::v-deep .springclass{
- .u-tabbar__content__item{
- .u-icon__img {
- width:56rpx !important;
- height:56rpx !important
- }
- }
- .u-tabbar__content__item:nth-child(2){
- .u-icon__img {
- width:72rpx !important;
- height:72rpx !important
- }
- }
- }
- </style>
|