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

247 lines
5.9 KiB

<template>
<view class="bg">
<view class="list-forms">
<view class="list-item">
<view class="list-item-title">姓名:</view>
<view class="list-item-input"><input type="text" v-model="username" placeholder="请输入姓名" /></view>
</view>
<view class="list-item">
<picker mode="selector" :range="idcardTypeList" range-key="title" @change="changeIdType">
<view class="list-item-title flex-center"
style="border: 1rpx solid #999999;border-radius: 7rpx;padding: 18rpx 19rpx;">{{idcardTypeValue}}
<image src="https://static.ticket.sz-trip.com/yandu/images/user/dui.png" mode=""
style="width: 40rpx;height: 40rpx;margin-left: 48rpx;"></image>
</view>
</picker>
<view class="list-item-input"><input type="text" v-model="idNumber" placeholder="请输入正确的证件号" /></view>
</view>
<view class="list-item">
<view class="list-item-title">手机号:</view>
<view class="list-item-input"><input type="number" v-model="mobile" placeholder="请输入手机号"
maxlength="11" /></view>
</view>
</view>
<view class="btn" @click="submit">保存</view>
</view>
</template>
<script>
export default {
data() {
return {
username: '',
mobile: '',
idNumber: '',
idcardTypeValue: '身份证',
show: false,
idcardTypeList: [],
document_type: 'DAM01001',
id: '',
type: ''
}
},
onLoad(option) {
if (option) {
this.id = option.id
}
if(option && option.type){
this.type = option.type
}
},
onShow() {
this.getIdcardTypeList()
if (this.id) {
this.getDetail()
}
// uni.setNavigationBarTitle({
// title: ''
// })
var pages = getCurrentPages();//获取页面
var beforePage = pages[pages.length - 2];//上个页面
if(beforePage.route == 'subPackages/scenic/scenicOrder' || beforePage.route == 'subPackages/venue/venueOrder'){
uni.setStorageSync('route', 1)
}
},
methods: {
getDetail() {
this.Post({
id: this.id
}, '/api/user/contactDetail').then(res => {
if (res.code === 1) {
res = res.data
if (res && res.id > 0) {
this.username = res.name
this.mobile = res.tel
this.idNumber = res.id_number
this.idDefault = res.is_default == 1 ? true : false
this.idcardType = res.idcard_type
this.idcardTypeValue = res.document_type_text
}
}
})
},
//获取证件类型
getIdcardTypeList() {
this.Post({}, '/api/user/getIdcardTypeList').then(res => {
this.idcardTypeList = res.data
})
},
// 选择证件类型
changeIdType(e) {
this.idcardTypeValue = this.idcardTypeList[e.detail.value].title
this.document_type = this.idcardTypeList[e.detail.value].document_type
},
// 提交
submit() {
this.username = this.username.trim()
this.mobile = this.mobile.trim()
this.idNumber = this.idNumber.trim()
if (this.username.length < 1) {
uni.showToast({
title: '请输入姓名',
icon: 'none'
})
return
}
if (!this.IsTel(this.mobile)) {
uni.showToast({
title: '请输入正确的手机号',
icon: 'none'
})
return
}
if (this.idcardTypeValue == '身份证') {
if (!this.idCardNumber(this.idNumber)) {
uni.showToast({
title: '请输入正确的身份证',
icon: 'none'
})
return
}
} else if (this.idcardTypeValue == '护照') {
if (!this.passportValid(this.idNumber)) {
uni.showToast({
title: '请输入正确的护照',
icon: 'none'
})
return
}
} else if (this.idcardTypeValue == '台胞证') {
if (!this.taiwanValid(this.idNumber)) {
uni.showToast({
title: '请输入正确的台胞证',
icon: 'none'
})
return
}
} else if (this.idcardTypeValue == '港澳通行证') {
if (!this.gangaoValid(this.idNumber)) {
uni.showToast({
title: '请输入正确的港澳通行证',
icon: 'none'
})
return
}
} else if (this.idcardTypeValue == '外国人永久居留证') {
if (!this.foreignerValid(this.idNumber)) {
uni.showToast({
title: '请输入正确的外国人永久居留证',
icon: 'none'
})
return
}
} else if (this.idcardTypeValue == '军官证') {
if (!this.officerValid(this.idNumber)) {
uni.showToast({
title: '请输入正确的军官证',
icon: 'none'
})
return
}
}
this.Post({
id: this.type == 'edit'?this.id:'',
id_number: this.idNumber,
name: this.username,
tel: this.mobile,
document_type: this.document_type
}, this.type=='edit'?'/api/user/editContact':'/api/user/addContact').then(res => {
if (res.code == 1) {
uni.showModal({
title: '提示',
content: '成功',
showCancel: false,
success: res => {
if (res.confirm) {
uni.navigateBack({})
}
}
})
}
})
}
}
}
</script>
<style scoped lang="scss">
.bg {
min-height: 100vh;
background-color: #FFFFFF;
position: relative;
}
.list-forms {
padding: 0 33rpx;
.list-item {
display: flex;
border-bottom: 1rpx solid #D8D8D8;
padding: 30rpx 0;
height: 60rpx;
box-sizing: content-box;
.list-item-title {
font-size: 34rpx;
margin-right: 20rpx;
}
.list-item-input {
flex: 1;
input {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
border: 0;
background-color: transparent;
line-height: 34rpx;
font-size: 34rpx;
text-align: right;
}
input::placeholder {
font-size: 26rpx;
}
}
}
}
.btn {
width: 697rpx;
height: 80rpx;
background: linear-gradient(90deg, #9EE4FE, #7FD491);
border-radius: 40rpx;
text-align: center;
line-height: 80rpx;
font-size: 36rpx;
font-family: PingFang SC;
font-weight: 500;
color: #FFFFFF;
position: absolute;
bottom: 53rpx;
left: 27rpx;
}
</style>