<template>
|
<view>
|
<view class="block__title">房屋信息</view>
|
<view class="cu-form-group">
|
<view class="title">小区</view>
|
<picker bindchange="PickerChange" :value="communityIndex" :range="communitys" :range-key="'name'"
|
@change="communityChange">
|
<view class="picker">
|
{{communitys[communityIndex].name}}
|
</view>
|
</picker>
|
</view>
|
<view class="cu-form-group arrow" v-if="communityId" @tap="chooseRoom">
|
<view class="title">房屋</view>
|
<input readonly v-model="roomName" class="text-right" placeholder="请选择房屋" icon="arrow"></input>
|
<text class='cuIcon-right'></text>
|
</view>
|
<view class="block__title">人员信息</view>
|
<!-- <view class="cu-form-group">
|
<view class="title">人员名称</view>
|
<input v-model="ownerName" placeholder="请输入名称" class="text-right"></input>
|
</view> -->
|
<view class="cu-form-group">
|
<view class="title">手机号</view>
|
<input v-model="link" placeholder="请输入手机号" class="text-right"></input>
|
<text v-if="errorMessage" class="error-message">{{ errorMessage }}</text>
|
</view>
|
<view class="cu-form-group">
|
<view class="title">人员类型</view>
|
<picker :value="typeCdIndex" :range="typeCds" range-key="name" @change="_changeTypeCd">
|
<view class="picker">
|
{{typeCds[typeCdIndex].name}}
|
</view>
|
</picker>
|
</view>
|
|
<view class="flex flex-direction margin-top margin-bottom">
|
<button class="cu-btn bg-blue margin-tb-sm lg" @click="_doAuthOwner()">提交</button>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import {
|
getCommunitys
|
} from '../../api/community/communityApi.js';
|
import {
|
getUserTel
|
} from '../../api/user/userApi.js';
|
import {
|
authOwner
|
} from '../../api/owner/ownerApi.js';
|
|
export default {
|
data() {
|
return {
|
communityIndex: 0,
|
communityId: '',
|
roomId: '',
|
roomName: '',
|
link: '',
|
ownerName: '',
|
communitys: [{
|
communityId: '',
|
name: '请选择小区'
|
}],
|
typeCds: [{
|
value: '1001',
|
name: '业主'
|
},
|
{
|
value: '1002',
|
name: '成员'
|
}
|
],
|
typeCdIndex: 0,
|
ownerTypeCd: "1001",
|
errorMessage: '' // 新增一个用于存放错误信息的字段
|
}
|
},
|
onLoad(options) {
|
this._loadCommunitys();
|
this.link = getUserTel();
|
},
|
onShow() {
|
let _selectRoom = uni.getStorageSync('selectRoom');
|
if (_selectRoom) {
|
this.roomName = _selectRoom.roomName;
|
this.roomId = _selectRoom.roomId;
|
uni.removeStorageSync('selectRoom');
|
}
|
},
|
methods: {
|
communityChange: function(e) {
|
this.communityIndex = e.target.value //取其下标
|
let selected = this.communitys[this.communityIndex] //获取选中的数组
|
this.communityId = selected.communityId; //选中的id
|
},
|
_loadCommunitys: function() {
|
let _that = this;
|
getCommunitys({
|
page: 1,
|
row: 500
|
}).then(_communitys => {
|
_communitys.forEach(_c => {
|
_that.communitys.push(_c);
|
})
|
})
|
},
|
chooseRoom: function() {
|
uni.navigateTo({
|
url: '/pages/family/selectRoom?communityId=' + this.communityId
|
})
|
},
|
_changeTypeCd: function(e) {
|
this.typeCdIndex = e.detail.value;
|
this.ownerTypeCd = this.typeCds[this.typeCdIndex].value;
|
},
|
_doAuthOwner: function() {
|
正则验证手机号格式
|
const phoneRegex = /^1[3-9]\d{9}$/; // 正确的手机号格式
|
if (!phoneRegex.test(this.link)) {
|
this.errorMessage = '请输入有效的手机号'; // 设置错误信息
|
return; // 如果手机号格式不对,停止执行
|
} else {
|
this.errorMessage = ''; // 清除错误信息
|
}
|
|
authOwner({
|
communityId: this.communityId,
|
roomName: this.roomName,
|
roomId: this.roomId,
|
link: this.link,
|
ownerName: this.ownerName,
|
ownerTypeCd: this.ownerTypeCd,
|
}).then(_data => {
|
// todo 跳转到认证历史页面
|
uni.navigateTo({
|
url: '/pages/index/authOwnerLog'
|
})
|
}).catch(err => {
|
// 处理错误情况
|
wx.showToast({
|
icon: 'none',
|
title: err || '认证失败,请重试' // 提供一个默认的错误提示
|
});
|
});
|
|
}
|
}
|
}
|
</script>
|
|
<style>
|
.block__title {
|
margin: 0;
|
font-weight: 400;
|
font-size: 14px;
|
color: rgba(69, 90, 100, .6);
|
padding: 40rpx 30rpx 20rpx;
|
}
|
|
.error-message {
|
color: red;
|
/* 错误信息的红色字体 */
|
}
|
</style>
|