You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

507 lines
12 KiB
Vue

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<script setup>
/**
* name
* usersa0ChunLuyu
* date2024年9月11日 19:24:50
*/
import {
ref
} from 'vue'
import {
$url,
$api,
$response
} from '@/api'
import {
onShow
} from '@dcloudio/uni-app'
import {
useStore
} from '@/store'
const $store = useStore()
import TitleComponent from '../src/title.vue'
const address_data = ref([])
const getAddressData = async () => {
const response = await $api('AddressData')
$response(response, () => {
address_data.value = response.data.data.map((i) => {
return {
text: i.name,
value: i.code,
children: i.children.map((ii) => {
return {
text: ii.name,
value: ii.code,
children: ii.children.map((iii) => {
return {
text: iii.name,
value: iii.code
}
})
}
})
}
})
getUserInfo();
})
}
const getUserInfo = async () => {
uni.showLoading({
title: "加载中",
});
const response = await $api('UserInfo')
uni.hideLoading();
$response(response, () => {
$store.setUser(response.data.info);
getUserHunjian()
})
}
const form_show = ref(false)
const getUserHunjian = async () => {
const response = await $api('UserHunjian', {
person_id: $store.user.person_id,
})
$response(response, () => {
if (!!response.data.info['姓名']) {
input_data.value = response.data.info
}
if (!!response.data.info['职业']) {
let index=zhiye_array.indexOf(response.data.info['职业'])
if(index != -1){
ZhiYeIndex.value=index
}
}
if (!!response.data.info['文化程度']) {
let index=wenhua_array.indexOf(response.data.info['文化程度'])
if(index != -1){
WenHuaIndex.value=index
}
}
form_show.value = true
})
}
const mountedAction = () => {
getAddressData()
}
const config_ref = ref(null)
const configRef = (e) => {
if (!config_ref.value) {
config_ref.value = e
mountedAction()
}
}
let msgCode=ref('');
const number_type_array = [{
value: 1,
label: '身份证'
},
{
value: 2,
label: '驾驶证'
},
{
value: 3,
label: '护照'
},
{
value: 4,
label: '港澳通行证'
},
{
value: 5,
label: '外国人永久居留身份证'
},
{
value: 6,
label: '其他'
},
]
const zhiye_array=[
"","国家公务员","专业技术人员","职员","企业管理人员","工人","农民","学生","现役军人","自由职业者","个体经营者","无业人员","退(离)休人员","其他"
]
const ZhiYeIndex=ref("");
const wenhua_array=[
"","小学","初中","高中","中专","大专","本科","其他"
]
const WenHuaIndex=ref("");
const getEndDate = () => {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
month = month > 9 ? month : '0' + month;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
}
const input_data_default = {
'国籍': '中国',
'证件类型': 0,
'证件号': "",
'姓名': "",
'生日': getEndDate(),
'民族': "",
'现地址省市区': [{
value: '11',
text: '北京市'
},
{
value: '1101',
text: '市辖区'
},
{
value: '110101',
text: '东城区'
},
],
'现地址': "",
// '详细地址省市区': [{
// value: '11',
// text: '北京市'
// },
// {
// value: '1101',
// text: '市辖区'
// },
// {
// value: '110101',
// text: '东城区'
// },
// ],
// '详细地址': "",
'户籍地址省市区': [{
value: '11',
text: '北京市'
},
{
value: '1101',
text: '市辖区'
},
{
value: '110101',
text: '东城区'
},
],
'户籍地址': "",
'工作单位': "",
'文化程度': "",
'职业': "",
'出生地': "",
'配偶姓名': "",
'配偶证件类型':0,
'配偶证件号': "",
'血缘关系': "无",
// '邮政编码': "",
'手机号码': "",
}
const input_data = ref(JSON.parse(JSON.stringify(input_data_default)))
const bindPickerChange = (e, key) => {
input_data.value[key] = e.detail.value
}
const bindZhiYePickerChange = (e,key) => {
ZhiYeIndex.value=e.detail.value
input_data.value[key] = zhiye_array[e.detail.value]
}
const bindWenHuaPickerChange = (e,key) => {
WenHuaIndex.value=e.detail.value
input_data.value[key] = wenhua_array[e.detail.value]
}
const bindDateChange = (e, key) => {
input_data.value[key] = e.detail.value
}
const radioChange = (e, key) => {
input_data.value[key] = e.detail.value
}
const editDoneClick = async() => {
let post_data = JSON.parse(JSON.stringify(input_data.value))
post_data['证件类型'] = input_data.value['证件类型']
post_data['配偶证件类型'] = input_data.value['配偶证件类型']
for (let i in post_data) {
if (!post_data[i] && post_data[i]!==0) {
return uni.$lu.toast(`请填写${i}`)
}
}
let PeiOuStatus=false;
PeiOuStatus = await CheckPeiOu()
if(PeiOuStatus===true){
let checkcode=false;
checkcode=await CheckMsgCode()
if(checkcode===true){
HunQianQuestionSubmit(post_data)
}
}
}
const GetMsgCode=async ()=>{
if(input_data.value['手机号码']==''){
uni.$lu.toast("验证码不能为空")
return false
}
uni.showLoading({
title: "加载中",
});
const response = await $api('SendMsgCode', {
mobile:input_data.value['手机号码']
})
uni.hideLoading();
$response(response, () => {
if(response.status){
uni.$lu.toast("发送成功")
}
})
}
const CheckMsgCode= async ()=>{
if(msgCode.value==''){
uni.$lu.toast("验证码不能为空")
return false
}
uni.showLoading({
title: "加载中",
});
const response = await $api('CheckMsgCode', {
mobile:input_data.value['手机号码'],
code:msgCode.value
})
uni.hideLoading();
let status=false;
$response(response, () => {
status=response.status
})
return status
}
const CheckPeiOu= async()=>{
let CheckStatus=false;
if(input_data.value['配偶证件号']==input_data.value['证件号']){
return uni.$lu.toast('配偶证件号不能与'+input_data.value['姓名']+'证件号相同')
}
//调用接口查询配偶是否建档
const response = await $api('hunjianBySFZ', {
sfz: input_data.value['配偶证件号'],
})
$response(response, async () => {
if(response.status){
if(response.data.info.code ==200){
let peiou_info=$store.getPeiOuUser()
peiou_info={
name:input_data.value['配偶姓名'],
sfz:input_data.value['配偶证件号']
}
$store.setPeiOuUser(peiou_info);
CheckStatus=true
}else{
uni.$lu.toast("配偶未建档,请先建档")
CheckStatus=false
}
}
})
return CheckStatus;
}
const HunQianQuestionSubmit = async (post_data) => {
const response = await $api('HunQianQuestionSubmit', {
person_id: $store.getUser()?.person_id,
content: post_data
})
$response(response, () => {
uni.navigateTo({
// url: '/pages/main/combo/combo',
url: '/pages/main/selectDoctor/selectDoctor?month=all'
})
})
}
const addressChange = (e, key) => {
input_data.value[key] = e.detail.value
}
onShow(() => {
if (!!config_ref.value) {
mountedAction()
}
})
</script>
<template>
<view>
<view v-if="!!$store.config">
<view :ref="configRef"></view>
</view>
<view v-if="form_show" class="page_wrapper">
<TitleComponent title="信息登记"></TitleComponent>
<view class="form_wrapper">
<view v-for="(i,k) in input_data" :key="k" class="form_item_wrapper">
<view class="form_title_wrapper">{{ k }}</view>
<view class="form_input_wrapper">
<template v-if="['证件类型','配偶证件类型'].includes(k)">
<view class="select_wrapper">
<picker class="select_picker_wrapper" @change="(e)=>{bindPickerChange(e, k)}" :value="input_data[k]"
:range="number_type_array" range-key="label">
<view>{{ number_type_array[input_data[k]].label }}</view>
</picker>
<view class="select_icon_wrapper">
<uni-icons color="#808080" type="right" size="20"></uni-icons>
</view>
</view>
</template>
<template v-else-if="k === '文化程度'">
<picker class="select_picker_wrapper" @change="(e)=>{bindWenHuaPickerChange(e, k)}" :value="WenHuaIndex"
:range="wenhua_array" >
<view :class="WenHuaIndex==''?'huizi':''">{{WenHuaIndex==""?"请选择文化程度":wenhua_array[WenHuaIndex]}}</view>
</picker>
</template>
<template v-else-if="k === '职业'">
<picker class="select_picker_wrapper" @change="(e)=>{bindZhiYePickerChange(e, k)}" :value="ZhiYeIndex"
:range="zhiye_array" >
<view :class="ZhiYeIndex==''?'huizi':''">{{ZhiYeIndex==""?"请选择职业":zhiye_array[ZhiYeIndex]}}</view>
</picker>
</template>
<template v-else-if="k === '生日'">
<picker mode="date" :value="input_data[k]" :end="getEndDate()" @change="(e)=>{bindDateChange(e, k)}">
<view>{{ input_data[k] }}</view>
</picker>
</template>
<template v-else-if="['现地址省市区','详细地址省市区','户籍地址省市区'].includes(k)">
<uni-data-picker v-if="address_data.length !== 0" v-model="input_data[k]" placeholder="请选择地址"
popup-title="请选择城市" :localdata="address_data" :step-searh="true" @change="(e)=>{addressChange(e,k)}">
</uni-data-picker>
</template>
<template v-else-if="k==='配偶证件号'">
<input style="font-size: 26rpx;" @blur="CheckPeiOu()" v-model="input_data[k]" :placeholder="`请输入${k}`" />
</template>
<template v-else-if="k === '血缘关系'">
<view>
<radio-group class="radio_wrapper" @change="(e)=>{radioChange(e, k)}">
<view class="radio_item_wrapper">
<radio style="transform:scale(0.7)" value="无" :checked="input_data[k] === '无'" />无
</view>
<view class="radio_item_wrapper">
<radio style="transform:scale(0.7)" value="有" :checked="input_data[k] === '有'" />有
</view>
</radio-group>
</view>
</template>
<template v-else-if="k === '手机号码'">
<view style="display: flex;align-items: center;">
<input style="font-size: 26rpx;" v-model="input_data[k]" :placeholder="`请输入${k}`" />
<view style="border: 1px solid #ccc;padding: 8rpx;border-radius: 10rpx;" @click="GetMsgCode()">获取验证码</view>
</view>
</template>
<template v-else>
<input style="font-size: 26rpx;" v-model="input_data[k]" :placeholder="`请输入${k}`" />
</template>
</view>
</view>
<view style="margin-top: 20rpx;display: flex;">
<view class="form_title_wrapper">验证码</view>
<input style="font-size: 26rpx;margin-left: 40rpx;" v-model="msgCode" placeholder="请输入验证码" />
</view>
</view>
<view @click="editDoneClick()" class="button_wrapper">提交</view>
<view style="height: 100rpx;"></view>
</view>
</view>
</template>
<style>
.uni-data-tree-dialog {
z-index: 999;
}
.input-value-border {
border: none !important;
}
.input-value {
padding: 0 !important;
}
.selected-area {
font-size: 30rpx !important;
}
.icon-clear {
display: none !important;
}
</style>
<style scoped>
.address_item_wrapper {
margin-right: 5rpx;
}
.radio_item_wrapper {
margin-right: 30rpx;
display: flex;
align-items: center;
}
.radio_wrapper {
display: flex;
align-items: center;
}
.select_icon_wrapper {
position: absolute;
top: 50%;
right: 20rpx;
transform: translateY(-50%);
}
.select_picker_wrapper {
position: relative;
z-index: 9;
width: 100%;
}
.select_wrapper {
position: relative;
}
.form_wrapper {
margin-top: 20rpx;
}
.form_input_wrapper {
width: calc(100% - 140rpx - 20px);
margin-left: 20px;
position: relative;
}
.form_title_wrapper {
width: 140rpx;
font-size: 26rpx;
}
.form_item_wrapper {
display: flex;
align-items: center;
padding: 20rpx 0;
font-size: 26rpx;
border-bottom: 1rpx solid #cccccc80;
}
.button_wrapper {
background: #279EA3;
color: #ffffff;
font-size: 28rpx;
text-align: center;
line-height: 90rpx;
height: 90rpx;
width: 600rpx;
border-radius: 10rpx;
margin: 50rpx auto 0;
}
.page_wrapper {
padding-top: 20rpx;
width: calc(100% - 50rpx);
margin: 0 auto;
}
.huizi{
color: #888888;
}
</style>