yangan
2025-02-13 fc4c8b7e4f9d926a43903389afb21d5a09208f8e
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
<template>
    <view>
        <view class="main">
            <u-empty mode="data"
                icon="http://cdn.uviewui.com/uview/empty/data.png"
                text="暂无数据"
                textSize="30"
                iconSize="1000"
                v-if="addressList.length===0"></u-empty>
            <view class="information-block"
                v-for="item in addressList"
                :key="item.id">
                <view class="detail-block">
                    <view class="address">
                        {{item.customerName}}
                    </view>
                    <view class="edit-icon"
                        @click="editAddress(item)">
                        <u-icon name="trash"
                            size="40"
                            color="#ababab"></u-icon>
                    </view>
                </view>
            </view>
        </view>
        <view class="add-address">
            <view class="address-block">
                <u-button text="新建送货客户"
                    shape="circle"
                    type="primary"
                    @click="addAddress"></u-button>
            </view>
        </view>
        <u-modal :show="deleteCustomerShow"
            title="删除确认"
            showCancelButton
            :content="deleteCustomerName"
            @confirm="deleteCustomerConfirm"
            @cancel="deleteCustomerCancel">
        </u-modal>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                addressList: [],
                shipToId: "",
                shipToName: '',
                deleteCustomerShow: false
            };
        },
        computed: {
            deleteCustomerName() {
                return `是否确认删除${this.shipToName}`
            }
        },
        onShow() {
            this.init()
        },
        methods: {
            init() {
                uni.showLoading({
                    title: "加载中"
                })
                this.$reqGet('getShipToList').then(res => {
                    uni.hideLoading()
                    if (res.code == 0) {
                        this.addressList = res.data
                    } else {
                        this.$u.toast('加载失败')
                    }
                })
            },
            addAddress() {
                uni.navigateTo({
                    url: '/pages/driver-page/drvier-my/addressMange/addressEdit/addressEdit'
                })
            },
            editAddress(val) {
                this.shipToName = val.customerName
                this.shipToId = val.id
                this.deleteCustomerShow = true
            },
            deleteCustomerConfirm() {
                this.deleteCustomerShow = false
                uni.showLoading({
                    title: "加载中"
                })
                this.$reqPost('deleteShipTo', { shipToId: this.shipToId }, 'params').then(res => {
                    uni.hideLoading()
                    if (res.code == 0) {
                        this.$u.toast('删除成功')
                        setTimeout(() => {
                            this.init()
                        }, 1500)
                    } else {
                        this.$u.toast('删除失败')
                    }
                })
            },
            deleteCustomerCancel() {
                this.deleteCustomerShow = false
            },
        }
    }
</script>
 
<style lang="scss"
    scoped>
    @mixin flex {
        display: flex;
        justify-content: center;
        align-items: center;
    }
 
    .main {
        width: 98%;
        height: calc(100vh - 60px);
        margin: vww(8) auto;
        display: flex;
        align-items: center;
        flex-direction: column;
        overflow: scroll;
 
        .information-block {
            width: 100%;
            display: flex;
            justify-content: center;
 
            .detail-block {
                width: 690rpx;
                height: 120rpx;
                padding: vww(8);
                background: #ffffff;
                box-shadow: 0rpx 0rpx 14rpx 0rpx rgba(73, 120, 240, 0.14), 0rpx 7rpx 45rpx 0rpx rgba(73, 120, 240, 0.12);
                border-radius: 20rpx;
                display: flex;
                justify-content: space-between;
                margin-top: vww(14);
                position: relative;
 
                .address {
                    flex: 1;
                }
 
                .edit-icon {
                    width: vww(50);
                    height: 100%;
                    @include flex;
                }
            }
        }
    }
 
    .add-address {
        width: 100%;
        height: vww(60);
        position: fixed;
        bottom: 0;
        background-color: #ffffff;
        box-shadow: 0rpx 0rpx 14rpx 0rpx rgba(73, 120, 240, 0.14), 0rpx 7rpx 45rpx 0rpx rgba(73, 120, 240, 0.12);
 
        .address-block {
            width: 88%;
            margin: vww(8) auto;
        }
    }
</style>