ann0707
2018-08-16 c9bc8ec61cff4076132f6396d99d383a2cdf5a03
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<template>
    <div class="news-page">
        <!--轮播-->
        <swiper auto
                height="214px"
                :show-dots="true"
                v-if="swiperList.length">
            <swiper-item v-for="(item, index) in swiperList"
                         :key="index"
                         @click.native="handleBannerJump(item)">
                <img :src="item.context" class="swiperImg">
                <p class="swiper-item-title">{{item.name}}</p>
            </swiper-item>
        </swiper>
        <!--下拉列表-->
        <newsList :newsList="newsList" @on-click-news="handleNewsJump"></newsList>
        <FSpace type="large"></FSpace>
        <!--footer-->
        <FFooter :index="2"></FFooter>
    </div>
</template>
<script>
    /**
     * Created by z.x.q on 2018/3/22.
     * 资讯首页
     */
    import {XButton, Flexbox, FlexboxItem, Swiper, SwiperItem} from 'vux';
    import newsList from '../../components/NewsList';
    import FFooter from '../../components/common/FFooter.vue';
    import FSpace from '../../components/common/FSpace.vue';
    import sysApi from '../../api/api';
    import statusCodeManage from '../../api/statusCodeManage';
 
    export default {
        name: 'f-news',
        components: {
            newsList,
            Swiper,
            SwiperItem,
            FSpace,
            FFooter
        },
        data() {
            return {
                swiperList: [],
                newsList: [], // 资讯列表信息
                detailContent: '', // 资讯条目的内容
            }
        },
        methods: {
            // 初始化页面信息
            init() {
                let _this = this;
                sysApi.fetchNewsList({}).then((res) => {
                    _this.swiperList = res.body.banners;
                    _this.newsList = res.body.information;
                }, (error) => {
                    statusCodeManage.showTipOfStatusCode(error, _this);
                });
            },
            // banner的类型跳转
            //  1:为导航页面, 2:为分类页面, 3:为产品页面, 4:为第三方网页, 5:为空白不反应
            // detailContent, 跳转地址,有type 来决定是否使用跳转
            handleBannerJump(item) {
                switch (item.type) {
                    case 1:
                        //跳转到对应的导航页面
                        this.$router.push({path: item.detailContent});
                        break;
                    case 2:
                        //跳转到对应的贷款分类
                        this.$router.push({path: item.detailContent});
                        break;
                    case 3:
                        //跳转到贷款详情,需要产品ID
                        if (item.prodTypeId === 40000005) {
                            this.$router.push({path: '/f-loan-detail', query: {id: item.detailContent}});
                        } else if (item.prodTypeId === 40000006) {
                            this.$router.push({path: '/f-loan-detail', query: {id: item.detailContent}});
                        } else if (item.prodTypeId === 40000007) {
                            this.$router.push({path: '/f-credit-detail', query: {id: item.detailContent}});
                        }
                        break;
                    case 4:
                        //第三方页面
                        window.location.href = item.detailContent;
                        break;
                    case 5:
                        //什么都不做
                        break;
                    case 6:
                        //资讯
                        this.$router.push({path: '/f-news-detail',query:{id:item.detailContent}});
                        break;
                    default:
                        break;
                }
            },
            // 资讯的跳转
            handleNewsJump(item) {
                // 2 我们后台创建的文章
                // 1 类型(1为跳转第三方,2为内容直接展示)
                if (item.type === 1) {
                    // 获取资讯的详情, detailContent内容,有可能是地址,有可能是 html 代码片段
                    sysApi.fetchNewsDetail({noticeId: item.id}).then((res) =>{
                        window.location.href = res.body.detailContent;
                    }, (error)=>{
                        statusCodeManage.showTipOfStatusCode(error);
                    });
                } else if (item.type === 2) {
                    // 返回html片段,跳转到我们的页面
                    this.$router.push({
                        path: '/f-news-detail',query:{id:item.id}
                    });
                }
            }
        },
        activated: function () {
            this.init();
        }
    }
</script>
<style lang="less">
    @import "../../style/mixin.less";
 
    .news-page {
        background: @color-white;
        .vux-swiper-item {
            img {
                width: 100%;
                height: 100%;
            }
            .swiper-item-title {
                position: relative;
                width: 250px;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
                top: -34px;
                left: 12px;
                color: @color-white;
                font-size: @font-size-medium;
            }
        }
        .vux-indicator {
            a {
                .active {
                    background-color: @color-white !important;
                }
            }
        }
        .vux-icon-dot {
            width: 5px !important;
            height: 5px !important;
            border-radius: 50% !important;
        }
    }
</style>