13404089107
2026-04-20 03ea6417827d2dab4f7dd33626d084ff28a3de19
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
<script setup lang="ts">
import { reactive } from 'vue'
 
definePage({
  name: 'addPerson',
  layout: 'default',
  style: {
    navigationStyle: 'custom'
  },
})
 
const router = useRouter()
 
// 状态栏高度
const sysInfo = uni.getSystemInfoSync()
const statusBarHeight = sysInfo.statusBarHeight || 0
const navBarHeight = 44
 
const formData = reactive({
  name: '',
  phone: '',
  company: '',
  idCard: '',
  gender: 'male',
})
 
const errors = reactive({
  name: '',
  phone: '',
  company: '',
  idCard: '',
})
 
function validate() {
  let isValid = true
  errors.name = ''
  errors.phone = ''
  errors.company = ''
  errors.idCard = ''
 
  if (!formData.name) {
    errors.name = '请输入来访人姓名'
    isValid = false
  }
  
  if (!formData.phone) {
    errors.phone = '请输入来访人电话'
    isValid = false
  } else if (!/^1[3-9]\d{9}$/.test(formData.phone)) {
    errors.phone = '请确保电话号码录入正确!'
    isValid = false
  }
  
  if (!formData.company) {
    errors.company = '请输入来访人单位'
    isValid = false
  }
  
  if (!formData.idCard) {
    errors.idCard = '请输入身份证号码'
    isValid = false
  } else if (!/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(formData.idCard)) {
    errors.idCard = '请确保身份证号码录入正确!'
    isValid = false
  }
 
  return isValid
}
 
function handleSave() {
  if (validate()) {
    uni.showToast({ title: '保存成功', icon: 'success' })
    setTimeout(() => {
      router.back()
    }, 1500)
  }
}
</script>
 
<template>
  <view class="min-h-screen bg-[#F6FBFF] box-border relative pb-[200rpx]">
    
    <!-- 自定义导航栏 -->
    <view class="relative z-50 w-full bg-[#F6FBFF]" :style="{ height: (statusBarHeight + navBarHeight) + 'px' }">
      <view class="flex items-center justify-between w-full absolute left-0"
        :style="{ top: statusBarHeight + 'px', height: navBarHeight + 'px' }">
        <view class="flex h-full w-[88rpx] items-center justify-center relative z-10" @click="router.back()">
          <wd-icon name="arrow-left" size="40rpx" color="#333333" />
        </view>
        <view class="absolute left-0 w-full text-center text-[34rpx] font-medium text-[#333333] z-0">
          选择来访人
        </view>
        <view class="w-[88rpx]"></view>
      </view>
    </view>
 
    <!-- 表单区域 -->
    <view class="bg-white px-[64rpx] py-[48rpx]">
      
      <!-- 来访人姓名 -->
      <view class="py-[28rpx] flex items-start justify-between border-b1">
        <view class="flex flex-col shrink-0 mr-[32rpx]">
          <view class="flex items-center h-[40rpx]">
            <text class="text-[28rpx] text-[#000000]">来访人姓名</text>
            <text class="text-[28rpx] text-[#F5222D] ml-[4rpx]">*</text>
          </view>
          <text v-if="errors.name" class="text-[20rpx] text-[#F5222D] mt-[8rpx]">{{ errors.name }}</text>
        </view>
        <input 
          v-model="formData.name" 
          placeholder="请输入来访人姓名" 
          placeholder-class="text-[#B3B3B3] text-[28rpx]" 
          class="text-[28rpx] text-right text-[#333333] flex-1 h-[40rpx] min-h-[40rpx]"
        />
      </view>
 
      <!-- 来访人电话 -->
      <view class=" py-[28rpx] flex items-start justify-between border-b1">
        <view class="flex flex-col shrink-0 mr-[32rpx]">
          <view class="flex items-center h-[40rpx]">
            <text class="text-[28rpx] text-[#000000]">来访人电话</text>
            <text class="text-[28rpx] text-[#F5222D] ml-[4rpx]">*</text>
          </view>
          <text v-if="errors.phone" class="text-[20rpx] text-[#F5222D] mt-[8rpx]">{{ errors.phone }}</text>
        </view>
        <input 
          v-model="formData.phone" 
          type="number"
          maxlength="11"
          placeholder="请输入来访人电话" 
          placeholder-class="text-[#B3B3B3] text-[28rpx]" 
          class="text-[28rpx] text-right text-[#333333] flex-1 h-[40rpx] min-h-[40rpx]"
        />
      </view>
 
      <!-- 来访人单位 -->
      <view class=" py-[28rpx] flex items-start justify-between border-b1">
        <view class="flex flex-col shrink-0 mr-[32rpx]">
          <view class="flex items-center h-[40rpx]">
            <text class="text-[28rpx] text-[#000000]">来访人单位</text>
            <text class="text-[28rpx] text-[#F5222D] ml-[4rpx]">*</text>
          </view>
          <text v-if="errors.company" class="text-[20rpx] text-[#F5222D] mt-[8rpx]">{{ errors.company }}</text>
        </view>
        <input 
          v-model="formData.company" 
          placeholder="请输入来访人单位" 
          placeholder-class="text-[#B3B3B3] text-[28rpx]" 
          class="text-[28rpx] text-right text-[#333333] flex-1 h-[40rpx] min-h-[40rpx]"
        />
      </view>
 
      <!-- 身份证号码 -->
      <view class=" py-[28rpx] flex items-start justify-between border-b1">
        <view class="flex flex-col shrink-0 mr-[32rpx]">
          <view class="flex items-center h-[40rpx]">
            <text class="text-[28rpx] text-[#000000]">身份证号码</text>
            <text class="text-[28rpx] text-[#F5222D] ml-[4rpx]">*</text>
          </view>
          <text v-if="errors.idCard" class="text-[20rpx] text-[#F5222D] mt-[8rpx]">{{ errors.idCard }}</text>
        </view>
        <input 
          v-model="formData.idCard" 
          type="idcard"
          placeholder="请输入身份证号码" 
          placeholder-class="text-[#B3B3B3] text-[28rpx]" 
          class="text-[28rpx] text-right text-[#333333] flex-1 h-[40rpx] min-h-[40rpx]"
        />
      </view>
 
      <!-- 性别 -->
      <view class="py-[28rpx] flex items-start justify-between">
        <view class="flex flex-col shrink-0 mr-[32rpx]">
          <view class="flex items-center h-[40rpx]">
            <text class="text-[28rpx] text-[#000000]">性别</text>
            <text class="text-[28rpx] text-[#F5222D] ml-[4rpx]">*</text>
          </view>
        </view>
        <view class="flex items-center space-x-[48rpx] h-[40rpx]">
          <view class="flex items-center" @click="formData.gender = 'male'">
            <view class="w-[32rpx] h-[32rpx] rounded-full border-[2rpx] border-solid flex items-center justify-center transition-colors duration-200"
              :class="formData.gender === 'male' ? 'border-[#0068FF]' : 'border-[#CFCFCF]'">
              <view v-if="formData.gender === 'male'" class="w-[24rp x] h-[24rpx] rounded-full bg-[#0068FF]"></view>
            </view>
            <text class="ml-[12rpx] text-[28rpx] text-[#333333]">男</text>
          </view>
          <view class="flex items-center" @click="formData.gender = 'female'">
            <view class="w-[32rpx] h-[32rpx] rounded-full border-[2rpx] border-solid flex items-center justify-center transition-colors duration-200"
              :class="formData.gender === 'female' ? 'border-[#0068FF]' : 'border-[#CFCFCF]'">
              <view v-if="formData.gender === 'female'" class="w-[24rpx] h-[24rpx] rounded-full bg-[#0068FF]"></view>
            </view>
            <text class="ml-[12rpx] text-[28rpx] text-[#333333]">女</text>
          </view>
        </view>
      </view>
      
    </view>
 
    <!-- 保存按钮 -->
    <view class="fixed bottom-[94rpx] left-0 w-full px-[32rpx] box-border z-[10]">
      <view 
        class="h-[96rpx] rounded-full bg-[#0068FF] flex items-center justify-center shadow-[0_8rpx_24rpx_rgba(0,104,255,0.2)]"
        @click="handleSave"
      >
        <text class="text-[32rpx] text-white font-medium">保存</text>
      </view>
    </view>
 
  </view>
</template>
 
<style scoped>
.border-b1 {
  border-bottom: 1rpx solid #F5F5F5;
}
</style>