路泰科技体检小程序UI设计新版本
1
wwl
5 天以前 a6cdbcfe28fcc40ebb4919f57d60fb20122e8e57
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<template>
    <div class="container">
        <image class="bg-image" src="/static/images/tabbar/loginbg.png" mode="scaleToFill"></image>
 
 
        <u-alert :title="title" type="warning"></u-alert>
        <div class="formbox">
            <u-form :model="formData" ref="uForm" :rules="rules" :label-width="200">
                <u-form-item label="体检人姓名" prop="cusName" required>
                    <u--input placeholder="请输入姓名" border="surround" v-model="formData.cusName" maxlength="5"
                        @input="trimSpaces('cusName', $event)"></u--input>
                </u-form-item>
                <u-form-item label="身份证号码" prop="idcard" required>
                    <u--input placeholder="请输入身份证号" border="surround" v-model="formData.idcard" maxlength="18"
                        @input="trimSpaces('idcard', $event)"></u--input>
                </u-form-item>
            </u-form>
        </div>
        <div @click="submit" class="chaxun">查询</div>
 
    </div>
</template>
<script>
    import {
        getRelativeReportList
    } from "@/api/system/report";
 
    export default {
        data() {
            return {
 
                title: "仅能查出该亲友最新体检报告哦",
                formData: {
                    cusName: '',
                    idcard: ''
                },
                rules: {
                    cusName: [{
                        required: true,
                        message: '姓名不能为空',
                        trigger: 'blur'
                    }],
                    idcard: [{
                        required: true,
                        message: '身份证号不能为空',
                        trigger: 'blur'
                    }, {
                        validator: (rule, value, callback) => {
                            const idCardReg =
                                /^[1-9]\d{5}(19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
                            if (!value) return callback(new Error('身份证号不能为空'));
                            if (!idCardReg.test(value)) return callback(new Error('身份证号格式不正确'));
 
                            const factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
                            const checkCode = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
                            let sum = 0;
                            for (let i = 0; i < 17; i++) {
                                sum += parseInt(value.charAt(i)) * factor[i];
                            }
                            const mod = sum % 11;
                            const lastChar = value.charAt(17).toUpperCase();
                            if (checkCode[mod] !== lastChar) {
                                return callback(new Error('身份证号校验码错误'));
                            }
                            callback();
                        },
                        trigger: 'blur'
                    }]
                }
            };
        },
        onLoad(options) {
            // 如果有 sfzh 参数,自动查询
            const sfzh = options.sfzh ? decodeURIComponent(options.sfzh) : '';
            if (sfzh) {
                uni.showLoading({
                    title: '查询中...'
                });
                getRelativeReportList({
                        card: sfzh
                    })
                    .then((response) => {
                        uni.hideLoading();
                        if (!response.data || response.data.length === 0) {
                            uni.showToast({
                                title: '暂无体检报告!',
                                icon: 'none'
                            });
                        } else {
                            const reportData = encodeURIComponent(JSON.stringify(response.data));
                            uni.navigateTo({
                                url: `/pages/friendReportOverview/friendReportOverview?reportData=${reportData}`
                            });
                        }
                    })
                    .catch(() => {
                        uni.hideLoading();
                        uni.showToast({
                            title: '查询失败,请稍后重试',
                            icon: 'none'
                        });
                    });
            }
        },
        methods: {
            click(item) {
                this.index = item.index;
                if (this.index === 1) {
                    this.formData = {
                        cusName: '',
                        idcard: ''
                    };
                    this.$nextTick(() => {
                        if (this.$refs.uForm) {
                            this.$refs.uForm.setRules(this.rules);
                            this.$refs.uForm.clearValidate();
                        }
                    });
                }
            },
            trimSpaces(field, value) {
                const trimmedValue = value.replace(/\s/g, '');
                if (this.formData[field] !== trimmedValue) {}
            },
            submit() {
                if (!this.$refs.uForm) {
                    uni.showToast({
                        title: '表单未加载',
                        icon: 'none'
                    });
                    return;
                }
                this.$refs.uForm.validate().then(() => {
                    const {
                        cusName,
                        idcard
                    } = this.formData;
                    uni.showLoading({
                        title: '查询中...'
                    });
                    getRelativeReportList({
                            card: idcard,
                            name: cusName
                        })
                        .then((response) => {
                            uni.hideLoading();
                            if (!response.data || response.data.length === 0) {
                                uni.showToast({
                                    title: '该亲友暂无体检报告!',
                                    icon: 'none'
                                });
                            } else {
                                const reportData = encodeURIComponent(JSON.stringify(response.data));
                                uni.navigateTo({
                                    url: `/pagesA/friendReportOverview/friendReportOverview?reportData=${reportData}`
                                });
                            }
                        })
                        .catch(() => {
                            uni.hideLoading();
                            uni.showToast({
                                title: '查询失败,请稍后重试',
                                icon: 'none'
                            });
                        });
                }).catch(() => {
                    uni.showToast({
                        title: '请检查输入信息是否正确',
                        icon: 'none'
                    });
                });
            }
        }
    };
</script>
 
<style lang="scss" scoped>
    ::v-deep .u-alert__content__title {
        font-size: 26rpx !important;
        text-align: center !important;
    }
 
    .container {
        position: relative;
        min-height: 100vh;
        padding: 0;
        overflow: auto;
        box-sizing: border-box;
    }
 
    .bg-image {
        position: absolute;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        z-index: -1;
        left: 50%;
        transform: translateX(-50%);
        object-fit: cover;
    }
 
    .formbox {
        width: 80vw;
        max-width: 600px;
        margin: 246rpx auto 315rpx;
    }
 
    .chaxun {
        width: 80vw;
        max-width: 600px;
        margin: 0 auto;
        font-weight: 500;
        font-size: 16px;
        color: #ffffff;
        text-align: center;
        padding: 15px 0;
        background: #419ffd;
        border-radius: 8px;
        box-sizing: border-box;
    }
 
    @media (-webkit-min-device-pixel-ratio: 1) and (max-width: 750px) {
        .formbox {
            width: 600rpx;
            margin: 246rpx auto 315rpx;
        }
 
        .chaxun {
            width: 600rpx;
            font-size: 36rpx;
            padding: 31rpx 0;
            border-radius: 8rpx;
        }
    }
 
    @media screen and (min-width: 751px) {
        .chaxun {
            width: 80vw;
            max-width: 600px;
            font-size: 16px;
            padding: 15px 0;
            border-radius: 8px;
        }
    }
 
    ::v-deep .u-form-item__body {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
    }
 
    ::v-deep .u-form-item__body__left {
        margin-bottom: 38rpx !important;
    }
 
    ::v-deep .u-form-item__body__left__content__label {
        font-size: 32rpx !important;
        color: #333 !important;
        white-space: nowrap !important;
    }
 
    ::v-deep .u-form-item {
        margin-bottom: 62rpx !important;
    }
 
    ::v-deep .u-form-item__body__right {
        width: 100% !important;
    }
 
    ::v-deep .u-form-item__body__right__message {
        text-align: left !important;
        margin-top: 10rpx !important;
    }
 
    ::v-deep .u-tabs__wrapper__nav__item {
        flex: 1 1 0% !important;
    }
</style>