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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<template>
    <!--申请记录-->
    <div class="apply-record">
        <x-header :left-options.showBack="{backText: ''}" :title="'申请记录'" class="gradient-color"></x-header>
        <div class="tips">平台仅记录您的点击行为,实际申请和审核结果请以产品显示结果为准</div>
        <scroller lock-x height="-100px" :scrollbar-y=false ref="scroller" @on-pulldown-loading="refresh" :pulldown-config="pulldownConfig" use-pulldown>
            <FProdList :gutter="true" :lists="prodList" :showNone="showNone" @on-click-prodItem="handleProductJump"></FProdList>
        </scroller>
        <FSpace type="large"></FSpace>
    </div>
</template>
 
<script>
import { XHeader, Scroller } from 'vux';
import FProdList from '../../components/common/FProdList.vue';
import FSpace from '../../components/common/FSpace.vue';
import systemApi from '../../api/api';
import statusCodeManage from '../../api/statusCodeManage';
/**
 * Created by 吴彦祖 on 2018/3/30.
 * 我的--申请记录
 */
export default {
    name: 'f-apply-record',
    data() {
        return {
            prodList: [],
            showNone: false,
            pulldownConfig: {
                content: '下拉刷新',
                height: 40,
                autoRefresh: false,
                downContent: '释放刷新',
                upContent: '释放刷新',
                loadingContent: '加载中...'
            }
        };
    },
    components: {
        FProdList,
        XHeader,
        Scroller,
        FSpace
    },
    methods: {
        //下拉加载
        refresh() {
            let _this = this;
            systemApi.fetchApplyRecord().then(
                res => {
                    this.prodList = [];
                    res.body.forEach(item => {
                        this.prodList.push({
                            prodId: item.productListInfo.unit.prodId,
                            content: this.getAttrList(
                                item.productListInfo.showEles
                            ),
                            applyNumber:
                                item.productListInfo.unit.showNumPrefix +
                                item.productListInfo.unit.showNum,
                            applyTime: item.applyTime,
                            productType: item.productListInfo.unit.prodType
                        });
                    });
                    if (!_this.prodList.length) {
                        _this.showNone = true;
                    }
                    this.$nextTick(() => {
                        this.$refs.scroller.reset();
                        this.$refs.scroller.donePulldown();
                    });
                },
                error => {
                    this.$refs.scroller.reset();
                    statusCodeManage.showTipOfStatusCode(error, _this);
                }
            );
        },
        // 处理产品跳转
        handleProductJump(item) {
            // 极速贷款或者银行卡
            if (
                item.productType === 40000005 ||
                item.productType === 40000006
            ) {
                this.$router.push({
                    path: '/f-loan-detail',
                    query: {
                        id: item.prodId
                    }
                });
                // 信用卡
            } else if (item.productType === 40000007) {
                this.$router.push({
                    path: '/f-credit-detail',
                    query: {
                        id: item.prodId
                    }
                });
            }
        },
        // 获取Attr的列表, prodElements产品组件的元素列表
        getAttrList(prodElements) {
            // 获取用户修改的数据
            let attrList = [];
            if (prodElements instanceof Array) {
                prodElements.map(function(listItem) {
                    listItem.attrs.forEach(function(item) {
                        attrList.push(item.value);
                    });
                });
            }
            return attrList;
        },
        // 初始化
        init() {
            let _this = this;
            systemApi.fetchApplyRecord().then(
                res => {
                    _this.prodList = [];
                    res.body.forEach(function(item) {
                        _this.prodList.push({
                            prodId: item.productListInfo.unit.prodId,
                            content: _this.getAttrList(
                                item.productListInfo.showEles
                            ),
                            applyNumber:
                                item.productListInfo.unit.showNumPrefix +
                                item.productListInfo.unit.showNum,
                            applyTime: item.applyTime,
                            productType: item.productListInfo.unit.prodType
                        });
                    });
                    if (!_this.prodList.length) {
                        _this.showNone = true;
                    }
                },
                error => {
                    // _this.$refs.scroller.donePulldown();
                    statusCodeManage.showTipOfStatusCode(error, _this);
                }
            );
        }
    },
    activated() {
        this.init();
    },
    deactivated() {
        this.prodList = [];
        this.showNone = false;
    }
};
</script>
 
<style lang="less">
@import '../../style/mixin.less';
 
.apply-record {
    .vux-header {
        .color-linear-gradient(@color-primary-light, @color-primary, 90deg);
        .vux-header-title {
            font-size: 18px;
        }
        .vux-header-left {
            .left-arrow:before {
                border: solid 1px @color-white;
                border-width: 2px 0 0 2px;
            }
        }
    }
    .tips {
        padding: 4px 13px;
        box-sizing: border-box;
        background-color: @color-background-default;
        font-size: @font-size-small;
        color: @color-text-third;
    }
}
</style>