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.
208 lines
4.5 KiB
208 lines
4.5 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">
|
|
<view class="list-item-title">手机号</view>
|
|
<view class="list-item-input"><input type="number" v-model="mobile" placeholder="请输入手机号"
|
|
maxlength="11" /></view>
|
|
</view>
|
|
<view class="list-item">
|
|
<view class="list-item-title">身份证号</view>
|
|
<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-switch">
|
|
<switch style="transform:scale(0.7)" :checked="idDefault" @change="switchChange" color="#96684F"/>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="btn" @click="submit">保存</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
username: '',
|
|
mobile: '',
|
|
idNumber: '',
|
|
|
|
show: false,
|
|
|
|
document_type: 'DAM01001',
|
|
id: '',
|
|
type: '',
|
|
idDefault: false,
|
|
}
|
|
},
|
|
onLoad(option) {
|
|
if (option) {
|
|
this.id = option.id
|
|
}
|
|
if(option && option.type){
|
|
this.type = option.type
|
|
}
|
|
},
|
|
onShow() {
|
|
if (this.id) {
|
|
this.getDetail()
|
|
}
|
|
uni.setNavigationBarTitle({
|
|
title: this.type == 'edit'?"修改出行人":"添加出行人"
|
|
})
|
|
// 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: {
|
|
switchChange(e){
|
|
this.idDefault = e.detail.value
|
|
},
|
|
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
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
// 提交
|
|
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.idCardNumber(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,
|
|
is_default: this.idDefault ? '1' : '0',
|
|
}, this.type=='edit'?'/api/user/editContact':'/api/user/addContact').then(res => {
|
|
if (res.code == 1) {
|
|
uni.showModal({
|
|
title: '提示',
|
|
content: '成功',
|
|
showCancel: false,
|
|
confirmColor: '#000000',
|
|
success: res => {
|
|
if (res.confirm) {
|
|
uni.navigateBack({})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.bg {
|
|
min-height: calc(100vh - 44px);
|
|
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;
|
|
align-items: center;
|
|
|
|
.list-item-title {
|
|
font-weight: 500;
|
|
font-size: 28rpx;
|
|
margin-right: 20rpx;
|
|
}
|
|
|
|
.list-item-switch {
|
|
display: flex;
|
|
flex: 1;
|
|
justify-content: flex-end;
|
|
}
|
|
|
|
.list-item-input {
|
|
flex: 1;
|
|
|
|
input {
|
|
width: 100%;
|
|
height: 100%;
|
|
padding: 0;
|
|
margin: 0;
|
|
border: 0;
|
|
background-color: transparent;
|
|
line-height: 34rpx;
|
|
font-size: 28rpx;
|
|
text-align: right;
|
|
font-weight: 500;
|
|
}
|
|
|
|
input::placeholder {
|
|
font-size: 28rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.btn {
|
|
width: 697rpx;
|
|
height: 80rpx;
|
|
background: #96684F;
|
|
border-radius: 7rpx;
|
|
font-weight: 500;
|
|
font-size: 36rpx;
|
|
color: #FFFFFF;
|
|
line-height: 80rpx;
|
|
text-align: center;
|
|
position: fixed;
|
|
bottom: 53rpx;
|
|
left: 26rpx;
|
|
|
|
}
|
|
</style>
|
|
|