#
whycq
2023-01-01 9c34e8cc2ff136db5c27a5adc2eb2e140ac0580a
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
<template>
    <view>
        <!-- 搜索框 -->
        <view class="search-bg">
            <uni-search-bar placeholder="客户代号/名称" bgColor="#f4f4f4"  @confirm="search" />
        </view>
        <view>
            <!-- 客户列表 -->
            <view class="c-list" @click="getDetails(item.id)" v-for="(item,index) in csmtrList" :key="index">
                <view class="titles"><y-title :title="item.name"></y-title></view><view></view>
                <!-- <view class="list-item1 title">{{item.name}}</view><view class="list-item"></view> -->
                <view class="list-item1">客户代号</view><view class="list-item2">{{item.uuid}}</view>
                <view class="list-item1">详细地址</view><view class="list-item2">{{item.addr}}</view>
                <view class="list-item1">电话</view><view class="list-item2">{{item.tel}}</view>
                <view class="list-item1">备注</view><view class="list-item2">{{item.remarks  ? item.remarks : '--'}}</view>
                <view class="list-item1">客户类别</view><view class="list-item2">{{item.cstmrType$}}</view>
                <view class="list-item1">创建人</view><view class="list-item2">{{item.createBy$}}</view>
                <view class="list-item1">创建时间</view><view class="list-item2">{{item.createTime$}}</view>
            </view>
        </view>
        <uni-load-more :status="status" :icon-size="16" :content-text="contentText" />
    </view>
</template>
 
<script>
    export default { 
        data() {
            return {
                csmtrList: [],
                last_id: '',
                reload: false,
                status: 'more',
                curr:1,
                contentText: {
                    contentdown: '上拉加载更多',
                    contentrefresh: '加载中',
                    contentnomore: '没有更多'
                }
            }
        },
        // 新建按钮事件
        onNavigationBarButtonTap(e) {
            uni.navigateTo({
                url:'/pages/business/cstmr/addCsmtr',
            })
        },
        onShow() {
            this.getCsmtr()
        },
        onReachBottom() {
            this.status = 'more';
            this.getCsmtr();
        },
        methods: {
            getCsmtr() {
                let that = this
                uni.request({
                    url: that.baseUrl + '/cstmr/page/auth',
                    fail(result) {
                        uni.showToast({title: '请求失败'})
                        setTimeout(() => {
                            uni.reLaunch({
                                url: '../../login/login'
                            });
                        }, 1000);
                    },
                    header: {'token' : uni.getStorageSync('token'),},
                    data: {curr:that.curr,limit:4},
                    method:'GET',
                    success(result) {
                        if (result.statusCode ===  404) {
                            uni.showToast({title: '请重新登录', icon: "none", position: 'top'})
                            return
                        }
                        var res = result.data
                        if (res.code === 200) {
                            let list = res.data.records
                            that.csmtrList = that.reload ? list : that.csmtrList.concat(list);
                            that.curr = that.curr + 1
                            if (res.data.records.length == 0) {
                                that.status = 'noMore'
                            }
                        } else if (res.code === 403) {
                            uni.showToast({title: res.msg, icon: "none", position: 'top'})
                            setTimeout(() => {
                                uni.reLaunch({
                                    url: '../../login/login'
                                });
                            }, 1000);
                        } else {
                            uni.showToast({title: res.msg, icon: "none",position: 'top'})
                        }
                    }
                })
            },
            getDetails(id) {
                uni.navigateTo({
                    url: '/pages/business/cstmr/cstmrDetails?id=' + id
                })
            }
            // ---
        }
    }
</script>
 
<style>
    .c-list {
        width: 96%;
        min-height: 100rpx;
        background-color: #fff;
        border-radius: 10rpx;
        margin: 20rpx 2% 0 2%;
        display: grid;
        grid-template-columns: 1fr 3fr;
        font-size: 24rpx;
    }
    /* 父view 换 scroll-view */
    .c-list:last-child {
        margin-bottom: 20px;
    }
    .list-item1 {
        height: 45rpx;
        line-height: 45rpx;
        color: #909399;
        text-indent: 30rpx;
    }
    .list-item2 {
        height: 45rpx;
        line-height: 45rpx;
        color: black;
    }
    .titles {
        padding-left: 10rpx;
        text-indent: 5rpx;
        margin-top: 10rpx;
    }
    /* .title {
        height: 60rpx;
        line-height: 70rpx;
        font-size: 28rpx;
        font-weight: 900;
        color: #303133;
    } */
</style>