k94314517
2024-10-16 17efddc6a667670dca682bf36b51a43e99615e6d
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<template>
    <view class="container">
        <view class="visitor-form">
            <view class="cell">
                <view class="title">姓名<b>*</b></view>
                <view class="content">
                    <input class="input" placeholder-style="color: #999999;" maxlength="20" v-model="visitorData.name" placeholder="请输入您的真实姓名" />
                </view>
            </view>
            <view class="cell">
                <view class="title">手机号<b>*</b></view>
                <view class="content">
                    <input class="input" maxlength="11" placeholder-style="color: #999999;" v-model="visitorData.phone" placeholder="请输入您的手机号" />
                </view>
            </view>
            <view class="cell">
                <view class="title">证件号码<b>*</b></view>
                <view class="content">
                    <input class="input" maxlength="18" placeholder-style="color: #999999;" v-model="visitorData.cardId" placeholder="请输入您的身份证号码" />
                </view>
            </view>
            <view class="cell">
                <view class="title">人脸照片<b>*</b></view>
                <view class="content1">
                    <u-upload
                        :fileList="fileList"
                        @afterRead="afterRead"
                        @delete="deletePic"
                        name="5"
                        multiple
                        :maxCount="1"
                    ></u-upload>
                </view>
            </view>
            <view class="cell">
                <view class="title">健康证</view>
                <view class="content1">
                    <u-upload
                        :fileList="fileList"
                        @afterRead="afterRead"
                        @delete="deletePic"
                        name="5"
                        multiple
                        :maxCount="1"
                    ></u-upload>
                </view>
            </view>
        </view>
        <view class="footer-box">
            <view class="submit-button">提交</view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                fileList: [],
                visitorData: {
                    name: '',
                    phone: '',
                    cardId: '',
                    healthImg: '',
                    faceImg: '',
                    faceList: [],
                    healthImgList: []
                }
            }
        },
 
        methods: {
            // 删除图片
            deletePic(event) {
                this[`fileList${event.name}`].splice(event.index, 1)
            },
            // 新增图片
            async afterRead(event) {
                // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
                let lists = [].concat(event.file)
                let fileListLen = this[`fileList${event.name}`].length
                lists.map((item) => {
                    this[`fileList${event.name}`].push({
                        ...item,
                        status: 'uploading',
                        message: '上传中'
                    })
                })
                for (let i = 0; i < lists.length; i++) {
                    const result = await this.uploadFilePromise(lists[i].url)
                    let item = this[`fileList${event.name}`][fileListLen]
                    this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
                        status: 'success',
                        message: '',
                        url: result
                    }))
                    fileListLen++
                }
            },
            uploadFilePromise(url) {
                return new Promise((resolve, reject) => {
                    let a = uni.uploadFile({
                        url: 'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址
                        filePath: url,
                        name: 'file',
                        formData: {
                            user: 'test'
                        },
                        success: (res) => {
                            setTimeout(() => {
                                resolve(res.data.data)
                            }, 1000)
                        }
                    });
                })
            },
        }
    }
</script>
 
<style>
    page {
        background-color: #F7F7F7 !important;
    }
    .u-upload__button {
        margin: 0 !important;
    }
    .title {
        font-size: 30rpx;
        font-weight: 400;
        color: #222222;
        display: flex;
        align-items: center;
    }
 
    .title b {
        color: red;
        font-weight: bold;
    }
 
    .add-other {
        border: 1rpx solid #025eef;
        color: #025eef;
        font-size: 11rpx;
        padding: 0 12rpx;
        height: 32rpx;
        line-height: 32rpx;
        width: 120rpx;
        text-align: center;
        border-radius: 24rpx;
        margin: 20rpx auto;
    }
 
    .footer-box {
        width: 100%;
        position: fixed;
        bottom: 30rpx;
        height: 80rpx;
        display: flex;
        justify-content: center;
        align-items: center;
    }
 
    .submit-button {
        width: calc(100% - 60rpx);
        height: 88rpx;
        line-height: 88rpx;
        background: #025eef;
        border-radius: 4rpx;
        color: #fff;
        border-radius: 44rpx;
        font-size: 32rpx;
        display: flex;
        align-items: center;
        justify-content: center;
    }
</style>
 
<style lang="scss" scoped>
    .popup-content {
        padding: 20rpx;
        height: 100%;
        overflow: hidden;
        display: flex;
        flex-flow: column;
 
        .input {
            border: 1rpx solid #ccc;
            border-radius: 4rpx;
            padding: 4rpx 12rpx;
            font-size: 28rpx;
            font-weight: 400;
            color: #333333;
        }
 
        .respondent-item {
            padding: 10rpx;
            border-bottom: 1rpx solid #eee;
            cursor: pointer;
 
            &:hover {
                background-color: #eee;
            }
        }
 
        .van-list {
            flex: 1;
            overflow: auto;
        }
    }
</style>