| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856 |
- <template>
- <view class="container">
- <view class="header">注:请按照自己的真实情况填写</view>
- <view class="form">
- <view class="form_box">
- <view class="form_key">手机号码:</view>
- <view class="form_value">
- <input class="input" type="text" placeholder="请输入手机号码" placeholder-style="color:#ccc;font-size:28rpx" v-model="studentInfo.phone" />
- </view>
- </view>
- <view class="form_box">
- <view class="form_key">籍贯:</view>
- <view class="form_select">
- <!-- 省 -->
- <picker @change="bindPickerChange" :value="currtIndex" :range="provinceList" range-key="name">
- <view class="select_box" :class="{ active: currtIndex != null }">
- <view class="box_text">
- {{ currtIndex != null ? provinceList[currtIndex].name : '请选择省' }}
- </view>
- <uni-icons type="down" size="16" color="#ccc"></uni-icons>
- </view>
- </picker>
- <!-- 市 -->
- <picker @change="bindPickerChange_city" :value="currtIndex_city" :range="cityList" range-key="name" :disabled="!provinceId">
- <view class="select_box" :class="{ active: currtIndex_city != null }">
- <view class="box_text">
- {{ currtIndex_city != null ? cityList[currtIndex_city].name : '请选择市' }}
- </view>
- <uni-icons type="down" size="16" color="#ccc"></uni-icons>
- </view>
- </picker>
- <!-- 区 -->
- <picker @change="bindPickerChange_district" :value="currtIndex_district" :range="districtList" range-key="name" :disabled="!cityId">
- <view class="select_box" :class="{ active: currtIndex_district != null }">
- <view class="box_text">
- {{ currtIndex_district != null ? districtList[currtIndex_district].name : '请选择区' }}
- </view>
- <uni-icons type="down" size="16" color="#ccc"></uni-icons>
- </view>
- </picker>
- </view>
- </view>
- <view class="form_box">
- <view class="form_key">家庭住址:</view>
- <view class="form_select">
- <!-- 省 -->
- <picker @change="bindPickerChange2" :value="currtIndex2" :range="provinceList2" range-key="name">
- <view class="select_box" :class="{ active: currtIndex2 != null }">
- <view class="box_text">{{ currtIndex2 != null ? provinceList2[currtIndex2].name : '请选择省' }}</view>
- <uni-icons type="down" size="16" color="#ccc"></uni-icons>
- </view>
- </picker>
- <!-- 市 -->
- <picker @change="bindPickerChange_city2" :value="currtIndex_city2" :range="cityList2" range-key="name" :disabled="!provinceId2">
- <view class="select_box" :class="{ active: currtIndex_city2 != null }">
- <view class="box_text">
- {{ currtIndex_city2 != null ? cityList2[currtIndex_city2].name : '请选择市' }}
- </view>
- <uni-icons type="down" size="16" color="#ccc"></uni-icons>
- </view>
- </picker>
- <!-- 区 -->
- <picker @change="bindPickerChange_district2" :value="currtIndex_district2" :range="districtList2" range-key="name" :disabled="!cityId2">
- <view class="select_box" :class="{ active: currtIndex_district2 != null }">
- <view class="box_text">{{ currtIndex_district2 != null ? districtList2[currtIndex_district2].name : '请选择区' }}</view>
- <uni-icons type="down" size="16" color="#ccc"></uni-icons>
- </view>
- </picker>
- </view>
- </view>
- <view class="form_box">
- <view class="form_key"></view>
- <view class="form_value">
- <input class="input" type="text" placeholder="请输入家庭住址" placeholder-style="color:#ccc;font-size:28rpx" v-model="studentInfo.address" />
- </view>
- </view>
- <view class="form_box">
- <view class="form_key">邮编:</view>
- <view class="form_value">
- <input class="input" type="text" placeholder="请输入邮编" placeholder-style="color:#ccc;font-size:28rpx" v-model="studentInfo.zipCode" />
- </view>
- </view>
- </view>
- <!-- 家庭成员区域 -->
- <view class="family">
- <view class="family_top">
- <uni-icons type="staff" size="30"></uni-icons>
- <view class="top_title">家庭成员</view>
- <uni-icons style="margin-left: auto" type="personadd" size="26" color="#0061FF" @click="handleAdd"></uni-icons>
- </view>
- <view class="family_table" v-if="fvs.length">
- <view class="table_box top">
- <view class="title">称谓</view>
- <view class="name">姓名</view>
- <view class="work">工作单位</view>
- <view class="phone">联系方式</view>
- </view>
- <view class="table_box" v-for="(item, index) in fvs" :key="index">
- <view class="title">{{ item.familyShip }}</view>
- <view class="name">{{ item.name }}</view>
- <view class="work">{{ item.workUnit }}</view>
- <view class="phone">{{ item.phone }}</view>
- </view>
- </view>
- </view>
- <!-- 温馨提示区域 -->
- <view class="tips">
- <view class="tips_box">
- <view class="box_title">温馨提示:</view>
- <view class="box_text">{{ info }}</view>
- </view>
- </view>
- <!-- 按钮区域 -->
- <view class="btns">
- <view class="btn up" @click="handleUp">上一步</view>
- <view class="btn down" @click="handleNext">下一步</view>
- </view>
- <!-- 添加家庭成员弹窗区域 -->
- <uni-popup ref="popup" :is-mask-click="false">
- <view class="pop">
- <image class="pop_img" src="/static/3.png" mode="aspectFill"></image>
- <!-- 关闭图标 -->
- <uni-icons class="pop_close" type="closeempty" color="#808080" size="20" @click="handleClose"></uni-icons>
- <view class="pop_box">
- <view class="box_key">称谓:</view>
- <view class="box_value">
- <input class="input" type="text" placeholder="请输入称谓" placeholder-style="color:#CCCCCC;font-size:28rpx;" v-model="popObj.familyShip" />
- </view>
- </view>
- <view class="pop_box">
- <view class="box_key">姓名:</view>
- <view class="box_value">
- <input class="input" type="text" placeholder="请输入姓名" placeholder-style="color:#CCCCCC;font-size:28rpx;" v-model="popObj.name" />
- </view>
- </view>
- <view class="pop_box">
- <view class="box_key">工作单位:</view>
- <view class="box_value">
- <input class="input" type="text" placeholder="请输入工作单位" placeholder-style="color:#CCCCCC;font-size:28rpx;" v-model="popObj.workUnit" />
- </view>
- </view>
- <view class="pop_box">
- <view class="box_key">联系方式:</view>
- <view class="box_value">
- <input class="input" type="text" placeholder="请输入联系方式" placeholder-style="color:#CCCCCC;font-size:28rpx;" v-model="popObj.phone" />
- </view>
- </view>
- <view class="pop_btn" @click="handleConfirm">确定</view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script setup>
- import { onLoad } from '@dcloudio/uni-app'
- import { ref } from 'vue'
- import { getProvinceGroupReq, getCityGroupReq, getDistrictGroupReq } from '@/api/index.js'
- // 学生信息
- const studentInfo = ref({})
- // 家庭成员数据
- const fvs = ref([])
- // 弹窗DOM
- const popup = ref()
- // 省数组
- const provinceList = ref([])
- const currtIndex = ref(null)
- const provinceId = ref()
- // 市数组
- const cityList = ref([])
- const currtIndex_city = ref(null)
- const cityId = ref()
- // 区数组
- const districtList = ref([])
- const currtIndex_district = ref(null)
- const districtId = ref()
- // 省数组
- const provinceList2 = ref([])
- const currtIndex2 = ref(null)
- const provinceId2 = ref()
- // 市数组
- const cityList2 = ref([])
- const currtIndex_city2 = ref(null)
- const cityId2 = ref()
- // 区数组
- const districtList2 = ref([])
- const currtIndex_district2 = ref(null)
- const districtId2 = ref()
- // 弹窗对象数据
- const popObj = ref({
- familyShip: '',
- name: '',
- workUnit: '',
- phone: ''
- })
- const info = ref()
- onLoad(() => {
- studentInfo.value = uni.getStorageSync('studentInfo') || {}
- info.value = uni.getStorageSync('settingInfo').familyInfo || ''
- fvs.value = studentInfo.value.fvs || []
- // console.log(studentInfo.value)
- // 获取省分组
- getProvinceGroup()
- })
- // 获取省分组
- const getProvinceGroup = async () => {
- const res = await getProvinceGroupReq()
- // console.log(res)
- if (res.code == 200) {
- provinceList.value = res.data
- provinceList2.value = res.data
- if (studentInfo.value.oprovinceId) {
- provinceList.value.forEach((ele, index) => {
- if (ele.id == studentInfo.value.oprovinceId) {
- currtIndex.value = index
- }
- })
- provinceId.value = studentInfo.value.oprovinceId
- getCityGroup()
- }
- if (studentInfo.value.provinceId) {
- provinceList2.value.forEach((ele, index) => {
- if (ele.id == studentInfo.value.provinceId) {
- currtIndex2.value = index
- }
- })
- provinceId2.value = studentInfo.value.provinceId
- getCityGroup2()
- }
- }
- }
- // 选择省回调
- const bindPickerChange = (e) => {
- cityId.value = null
- cityList.value = []
- currtIndex_city.value = null
- districtId.value = null
- districtList.value = []
- currtIndex_district.value = null
- currtIndex.value = e.detail.value
- provinceId.value = provinceList.value[currtIndex.value].id
- studentInfo.value.oprovinceId = provinceId.value
- studentInfo.value.oprovince = provinceList.value[currtIndex.value].name
- // 获取市分组
- getCityGroup()
- }
- // 获取市分组
- const getCityGroup = async () => {
- const res = await getCityGroupReq({
- provinceId: provinceId.value
- })
- // console.log(res)
- if (res.code == 200) {
- cityList.value = res.data
- if (studentInfo.value.ocityId) {
- cityList.value.forEach((ele, index) => {
- if (ele.id == studentInfo.value.ocityId) [(currtIndex_city.value = index)]
- })
- cityId.value = studentInfo.value.ocityId
- getDistrictGroup()
- }
- }
- }
- // 选择市回调
- const bindPickerChange_city = (e) => {
- districtId.value = null
- districtList.value = []
- currtIndex_district.value = null
- currtIndex_city.value = e.detail.value
- cityId.value = cityList.value[currtIndex_city.value].id
- studentInfo.value.ocityId = cityId.value
- studentInfo.value.ocity = cityList.value[currtIndex_city.value].name
- // 获取区分组
- getDistrictGroup()
- }
- // 获取区分组
- const getDistrictGroup = async () => {
- const res = await getDistrictGroupReq({
- cityId: cityId.value
- })
- // console.log(res)
- if (res.code == 200) {
- districtList.value = res.data
- if (studentInfo.value.odistrictId) {
- districtList.value.forEach((ele, index) => {
- if (ele.id == studentInfo.value.odistrictId) {
- currtIndex_district.value = index
- }
- })
- }
- }
- }
- // 选择区回调
- const bindPickerChange_district = (e) => {
- currtIndex_district.value = e.detail.value
- districtId.value = districtList.value[currtIndex_district.value].id
- studentInfo.value.odistrictId = districtId.value
- studentInfo.value.odistrict = districtList.value[currtIndex_district.value].name
- }
- // 点击上一步按钮回调
- const handleUp = () => {
- uni.navigateBack()
- }
- // 点击下一步按钮回调
- const handleNext = () => {
- if (!studentInfo.value.phone) {
- uni.showToast({
- title: '请输入手机号码',
- icon: 'none'
- })
- return
- }
- let reg = /^1[3-9]\d{9}$/
- if (!reg.test(studentInfo.value.phone)) {
- uni.showToast({
- title: '手机号码格式错误',
- icon: 'none'
- })
- return
- }
- if (currtIndex.value == null) {
- uni.showToast({
- title: '请选择籍贯省',
- icon: 'none'
- })
- return
- }
- if (currtIndex_city.value == null) {
- uni.showToast({
- title: '请选择籍贯市',
- icon: 'none'
- })
- return
- }
- if (currtIndex_district.value == null) {
- uni.showToast({
- title: '请选择籍贯区',
- icon: 'none'
- })
- return
- }
- if (currtIndex2.value == null) {
- uni.showToast({
- title: '请选择家庭住址省',
- icon: 'none'
- })
- return
- }
- if (currtIndex_city2.value == null) {
- uni.showToast({
- title: '请选择家庭住址市',
- icon: 'none'
- })
- return
- }
- if (currtIndex_district2.value == null) {
- uni.showToast({
- title: '请选择家庭住址区',
- icon: 'none'
- })
- return
- }
- if (!studentInfo.value.address) {
- uni.showToast({
- title: '请输入家庭住址',
- icon: 'none'
- })
- return
- }
- if (!studentInfo.value.zipCode) {
- uni.showToast({
- title: '请输入邮编',
- icon: 'none'
- })
- return
- }
- if (!fvs.value.length) {
- uni.showToast({
- title: '请至少添加一名家庭成员',
- icon: 'none'
- })
- return
- }
- studentInfo.value.fvs = fvs.value
- uni.setStorageSync('studentInfo', studentInfo.value)
- uni.navigateTo({
- url: '/pages/arrive/arrive'
- })
- }
- // 添加家庭成员按钮回调
- const handleAdd = () => {
- popup.value.open()
- }
- // 弹窗关闭图标回调
- const handleClose = () => {
- popup.value.close()
- }
- // 点击弹窗确定按钮回调
- const handleConfirm = () => {
- if (!popObj.value.familyShip) {
- uni.showToast({
- title: '请输入称谓',
- icon: 'none'
- })
- return
- }
- if (!popObj.value.name) {
- uni.showToast({
- title: '请输入姓名',
- icon: 'none'
- })
- return
- }
- if (!popObj.value.workUnit) {
- uni.showToast({
- title: '请输入工作单位',
- icon: 'none'
- })
- return
- }
- if (!popObj.value.phone) {
- uni.showToast({
- title: '请输入联系方式',
- icon: 'none'
- })
- return
- }
- let reg = /^1[3-9]\d{9}$/
- if (!reg.test(popObj.value.phone)) {
- uni.showToast({
- title: '联系方式格式错误',
- icon: 'none'
- })
- return
- }
- uni.showModal({
- title: '提示',
- content: '确定添加吗?',
- success: (res) => {
- if (res.confirm) {
- fvs.value.push(popObj.value)
- popObj.value = {
- familyShip: '',
- name: '',
- workUnit: '',
- phone: ''
- }
- popup.value.close()
- }
- }
- })
- }
- // 选择省回调
- const bindPickerChange2 = (e) => {
- cityId2.value = null
- cityList2.value = []
- currtIndex_city2.value = null
- districtId2.value = null
- districtList2.value = []
- currtIndex_district2.value = null
- currtIndex2.value = e.detail.value
- provinceId2.value = provinceList2.value[currtIndex2.value].id
- studentInfo.value.provinceId = provinceId2.value
- studentInfo.value.province = provinceList2.value[currtIndex2.value].name
- // 获取市分组
- getCityGroup2()
- }
- // 获取市分组
- const getCityGroup2 = async () => {
- const res = await getCityGroupReq({
- provinceId: provinceId2.value
- })
- // console.log(res)
- if (res.code == 200) {
- cityList2.value = res.data
- if (studentInfo.value.cityId) {
- cityList2.value.forEach((ele, index) => {
- if (ele.id == studentInfo.value.cityId) {
- currtIndex_city2.value = index
- }
- })
- cityId2.value = studentInfo.value.cityId
- getDistrictGroup2()
- }
- }
- }
- // 选择市回调
- const bindPickerChange_city2 = (e) => {
- districtId2.value = null
- districtList2.value = []
- currtIndex_district2.value = null
- currtIndex_city2.value = e.detail.value
- cityId2.value = cityList2.value[currtIndex_city2.value].id
- studentInfo.value.cityId = cityId2.value
- studentInfo.value.city = cityList2.value[currtIndex_city2.value].name
- // 获取区分组
- getDistrictGroup2()
- }
- // 获取区分组
- const getDistrictGroup2 = async () => {
- const res = await getDistrictGroupReq({
- cityId: cityId2.value
- })
- // console.log(res)
- if (res.code == 200) {
- districtList2.value = res.data
- if (studentInfo.value.districtId) {
- districtList2.value.forEach((ele, index) => {
- if (ele.id == studentInfo.value.districtId) {
- currtIndex_district2.value = index
- }
- })
- }
- }
- }
- // 选择区回调
- const bindPickerChange_district2 = (e) => {
- currtIndex_district2.value = e.detail.value
- districtId2.value = districtList2.value[currtIndex_district2.value].id
- studentInfo.value.districtId = districtId2.value
- studentInfo.value.district = districtList2.value[currtIndex_district2.value].name
- }
- </script>
- <style lang="scss" scoped>
- .container {
- min-height: 100vh;
- background-color: #f5f9ff;
- .header {
- padding-left: 20rpx;
- height: 93rpx;
- line-height: 93rpx;
- font-size: 28rpx;
- font-weight: bold;
- background-color: #fff;
- }
- .form {
- padding: 25rpx 0;
- margin-top: 10rpx;
- background-color: #fff;
- .form_box {
- display: flex;
- align-items: center;
- margin-bottom: 20rpx;
- height: 75rpx;
- .form_key {
- width: 170rpx;
- font-size: 28rpx;
- text-align: end;
- }
- .form_value {
- box-sizing: border-box;
- padding: 0 25rpx;
- width: 560rpx;
- height: 100%;
- border-radius: 4rpx;
- border: 2rpx solid #cccccc;
- .input {
- height: 100%;
- }
- }
- .form_select {
- display: flex;
- justify-content: space-between;
- width: 560rpx;
- .select_box {
- display: flex;
- align-items: center;
- justify-content: space-around;
- width: 178rpx;
- height: 74rpx;
- color: #ccc;
- font-size: 28rpx;
- border-radius: 4rpx;
- border: 2rpx solid #cccccc;
- .box_text {
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- }
- .active {
- color: #000;
- }
- }
- }
- }
- .family {
- background-color: #fff;
- .family_top {
- display: flex;
- align-items: center;
- padding: 0 20rpx;
- height: 90rpx;
- .top_title {
- margin-left: 20rpx;
- font-size: 30rpx;
- font-weight: bold;
- }
- }
- .family_table {
- padding: 0 20rpx;
- font-size: 24rpx;
- .table_box {
- display: flex;
- justify-content: space-between;
- align-items: center;
- height: 70rpx;
- border-bottom: 2rpx solid #e6e6e6;
- .title {
- width: 140rpx;
- text-align: center;
- white-space: nowrap;
- text-overflow: ellipsis;
- overflow: hidden;
- }
- .name {
- width: 140rpx;
- text-align: center;
- white-space: nowrap;
- text-overflow: ellipsis;
- overflow: hidden;
- }
- .work {
- width: 200rpx;
- text-align: center;
- white-space: nowrap;
- text-overflow: ellipsis;
- overflow: hidden;
- }
- .phone {
- width: 200rpx;
- text-align: center;
- white-space: nowrap;
- text-overflow: ellipsis;
- overflow: hidden;
- }
- }
- .top {
- background-color: #f0f3f7;
- }
- }
- }
- .tips {
- padding: 15rpx;
- font-size: 24rpx;
- background-color: #fff;
- .tips_box {
- padding: 20rpx 0 20rpx 10rpx;
- line-height: 58rpx;
- background-color: #fff2f2;
- }
- }
- .btns {
- display: flex;
- align-items: center;
- justify-content: space-around;
- padding: 10rpx 0 50rpx;
- height: 100rpx;
- background-color: #fff;
- .btn {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 300rpx;
- height: 100rpx;
- font-size: 32rpx;
- border-radius: 8rpx;
- }
- .up {
- border: 2rpx solid #0061ff;
- }
- .down {
- color: #fff;
- background-color: #0061ff;
- }
- }
- .pop {
- position: relative;
- display: flex;
- flex-direction: column;
- align-items: center;
- box-sizing: border-box;
- padding: 150rpx 20rpx 50rpx;
- width: 659rpx;
- height: 728rpx;
- border-radius: 15rpx;
- background: linear-gradient(180deg, #ebf2ff 0%, #ffffff 100%);
- .pop_img {
- position: absolute;
- top: -103rpx;
- left: 227rpx;
- width: 206rpx;
- height: 206rpx;
- }
- .pop_close {
- position: absolute;
- top: 19rpx;
- right: 29rpx;
- }
- .pop_box {
- display: flex;
- align-items: center;
- margin-bottom: 20rpx;
- .box_key {
- width: 150rpx;
- font-size: 28rpx;
- text-align: end;
- }
- .box_value {
- width: 300rpx;
- height: 70rpx;
- border-radius: 4rpx;
- border: 2rpx solid #cccccc;
- .input {
- padding: 0 20rpx;
- height: 100%;
- }
- }
- }
- .pop_btn {
- display: flex;
- align-items: center;
- justify-content: center;
- margin-top: 30rpx;
- width: 460rpx;
- height: 100rpx;
- color: #fff;
- font-size: 32rpx;
- border-radius: 8rpx;
- background-color: #0061ff;
- }
- }
- }
- </style>
|