<template>
|
<view>
|
<view class="content bgc-ff">
|
<u-form labelPosition="left" :model="info" :rules="rules" ref="form" labelWidth="90"
|
:labelStyle="{fontSize:'28rpx'}">
|
<u-form-item label="姓名" prop="name" borderBottom required>
|
<u-input v-model="info.name" border="none" placeholder="请输入姓名" placeholderClass="f-28 c-99"
|
inputAlign="right"></u-input>
|
</u-form-item>
|
|
<u-form-item label="电话" prop="phone" borderBottom required>
|
<u-input v-model="info.phone" type="number" border="none" placeholder="请输入电话"
|
placeholderClass="f-28 c-99" inputAlign="right"></u-input>
|
</u-form-item>
|
|
<u-form-item label="身份证号码" prop="idCard" borderBottom required>
|
<u-input v-model="info.idCard" type="idcard" border="none" placeholder="请输入身份证号码"
|
placeholderClass="f-28 c-99" inputAlign="right"></u-input>
|
</u-form-item>
|
|
<u-form-item label="地址" prop="address" borderBottom required>
|
<u-textarea v-model="info.address" border="none" placeholder="请输入地址" placeholderClass="f-28 c-99"
|
inputAlign="right"></u-textarea>
|
</u-form-item>
|
|
<u-form-item label="申请事由" prop="remak" :borderBottom="false">
|
<u-textarea v-model="info.remak" border="none" placeholder="请输入申请事由" placeholderClass="f-28 c-99"
|
inputAlign="right"></u-textarea>
|
</u-form-item>
|
</u-form>
|
</view>
|
|
|
|
<button class="submit-btn" @click="sumitInfo">提交</button>
|
<button class="list-btn" @click="navigatorPage">我申请的记录</button>
|
|
|
</view>
|
|
</template>
|
|
<script>
|
import {
|
saveResideApply,
|
getResideApplyDetail,
|
updateResideApply
|
} from "@/api/reside/reside.js"
|
export default {
|
data() {
|
return {
|
info: {
|
name: "",
|
phone: "",
|
idCard: "",
|
address: "",
|
remak: "",
|
houseCode: ""
|
},
|
rules: {
|
name: [{
|
type: 'string',
|
required: true,
|
message: '请输入姓名',
|
trigger: ['blur', 'change']
|
}],
|
phone: [{
|
type: 'string',
|
required: true,
|
message: '请输入手机号',
|
trigger: ['blur', 'change']
|
},
|
{
|
validator: (rule, value, callback) => {
|
return uni.$u.test.mobile(value);
|
},
|
message: '手机号码不正确',
|
trigger: ['change', 'blur']
|
}
|
],
|
idCard: [{
|
type: 'string',
|
required: false,
|
message: '请输入身份证号码',
|
trigger: ['change', 'blur']
|
},
|
{
|
validator: (rule, value, callback) => {
|
const idCardRegex =
|
/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
|
return idCardRegex.test(value)
|
},
|
|
message: '身份证号码有误',
|
trigger: ['change', 'blur']
|
}
|
],
|
address: [{
|
type: 'string',
|
required: true,
|
message: '请选择地址',
|
trigger: ['blur', 'change']
|
}],
|
},
|
isEdit: false
|
}
|
},
|
|
onLoad(option) {
|
if (option.id) {
|
this.isEdit = true;
|
this.getDetail(option.id)
|
} else {
|
this.$set(this.info, "houseCode", uni.getStorageSync("siteInfo").houseCode)
|
}
|
},
|
|
onReady() {
|
//onReady 为uni-app支持的生命周期之一
|
this.$refs.form.setRules(this.rules)
|
},
|
|
methods: {
|
getDetail(id) {
|
getResideApplyDetail({
|
id
|
}).then(res => {
|
if (res.code == 200) {
|
for (let i in this.info) {
|
this.info[i] = res.data[i];
|
}
|
}
|
})
|
},
|
|
sumitInfo() {
|
this.$refs.form.validate().then(valid => {
|
if (this.id) {
|
this.updateInfoRequest();
|
} else {
|
this.addInfoRequst();
|
}
|
})
|
},
|
|
addInfoRequst() {
|
saveResideApply(this.info).then(res => {
|
if (res.code == 200) {
|
this.$showTips("提交成功", "success")
|
setTimeout(() => {
|
uni.navigateBack();
|
}, 300)
|
}
|
})
|
},
|
|
updateInfoRequest() {
|
updateResideApply(this.info).then(res => {
|
if (res.code == 200) {
|
this.$showTips("提交成功", "success")
|
setTimeout(() => {
|
uni.navigateBack();
|
}, 300)
|
}
|
})
|
},
|
|
navigatorPage() {
|
uni.navigateTo({
|
url: "record"
|
})
|
}
|
|
}
|
}
|
</script>
|
|
<style lang="less">
|
page {
|
background-color: #F5F5F5;
|
}
|
|
.content {
|
margin: 20rpx 30rpx;
|
padding: 0 30rpx;
|
}
|
|
.row {
|
padding: 20rpx 0;
|
border-bottom: 1px solid
|
}
|
|
.location-btn {
|
width: 116rpx;
|
height: 46rpx;
|
line-height: 46rpx;
|
border-radius: 4rpx;
|
border: 1px solid currentColor;
|
padding: 0;
|
background-color: #fff;
|
}
|
|
.upload {
|
margin: 0 30rpx;
|
padding: 30rpx;
|
|
.upload-item {
|
width: 140rpx;
|
height: 140rpx;
|
border: 1px solid #EEEEEE;
|
}
|
}
|
|
.address-row {
|
flex: 1;
|
justify-content: flex-end;
|
align-items: center;
|
}
|
|
.address-content {
|
width: calc(100% - 116rpx - 20rpx);
|
margin-right: 20rpx;
|
text-align: right;
|
}
|
|
.location-btn {
|
width: 116rpx;
|
height: 46rpx;
|
line-height: 46rpx;
|
border-radius: 4rpx;
|
border: 1px solid currentColor;
|
padding: 0;
|
background-color: #fff;
|
text-align: center;
|
}
|
|
.submit-btn {
|
width: 690rpx;
|
height: 78rpx;
|
line-height: 78rpx;
|
background: linear-gradient(163deg, #01BDFC 0%, #017BFC 100%);
|
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
font-size: 32rpx;
|
color: #fff;
|
margin-top: 50rpx;
|
}
|
|
.list-btn {
|
width: 690rpx;
|
height: 78rpx;
|
line-height: 78rpx;
|
background: linear-gradient(163deg, #c7d7dc 0%, #c3cdd8 100%);
|
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
font-size: 32rpx;
|
color: #fff;
|
margin-top: 50rpx;
|
}
|
</style>
|