You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
apply-assistant-v3/root/home/editTownsman.vue

386 lines
8.7 KiB
Vue

6 months ago
<template>
<view class="p-root-detail-fellow g_w_all g_h_all g_bg_f_5 g_kuaishou">
<view>
5 months ago
<view class="g_h_10"></view>
6 months ago
<g-panel-form-slot
:list="[
{
icon: '',
label: '老乡电话',
result: '',
path: '',
value: info.tel,
tip: 'slot-mobile',
placeholder: '请输入联系电话',
type: 'slot',
pColumn: 8,
require: true,
},
]"
@changeMobile="handleClickMobile"
></g-panel-form-slot>
<view class="g_h_10"></view>
<g-panel-form-slot
:list="[
{
icon: '',
label: '姓名',
result: '',
value: info.name,
path: '',
tip: 'slot-upID',
5 months ago
img: info.idCardImageUrl,
6 months ago
placeholder: '手动输入或拍照自动识别 → ',
type: 'slot',
pColumn: 8,
require: true,
},
{
icon: '',
label: '身份证号',
result: '',
value: info.idCard,
path: '',
tip: 'slot-code-idcard',
placeholder: '请输入身份证号',
type: 'slot',
pColumn: 8,
require: true,
},
{
icon: '',
label: '性别',
result: '',
value: info.sex,
path: '',
tip: 'slot-sex',
type: 'slot',
pColumn: 12,
require: true,
5 months ago
customRequire: true,
6 months ago
},
{
icon: '',
label: '年龄',
result: '',
value: info.age,
path: '',
tip: 'slot-age',
placeholder: '请输入年龄',
type: 'slot',
pColumn: 8,
require: true,
},
{
icon: '',
label: '民族',
result: '',
value: info.nation,
nationIndex: nationIndex,
path: '',
tip: 'slot-nation',
pColumn: 12,
require: true,
5 months ago
type: 'slot',
customRequire: true,
6 months ago
},
{
icon: '',
label: '家庭住址',
result: '',
value: info.address,
placeholder: '请输入家庭住址',
path: '',
tip: 'slot-address',
type: 'slot',
pColumn: 8,
},
5 months ago
]"
@changeName="handleClickName"
@changeSex="handleClickSex"
@changeAge="handleClickAge"
@changeNation="handleClickNation"
@changeIDcard="handleClickIDcard"
@changeAddress="handleClickAddress"
@updateFile="updateFile"
@updateIDInfo="handlerIDInfo"
>
</g-panel-form-slot>
<view class="g_h_10"></view>
<g-panel-form-slot
:list="[
6 months ago
{
icon: '',
label: '上传附件',
result: '',
path: '',
type: 'slot',
tip: 'slot-update-file',
pColumn: 16,
},
]"
@updateFile="updateFile"
>
<template v-slot:after>
<view class="g_flex_row_start g_p_10" v-if="imgList.length > 0">
<view v-for="(item, index) in imgList" class="g_position_rela" :class="index <= 2 ? 'g_mr_18' : ''" :key="index">
<i class="iconfont icon-guanbi img-close" @click="delImg(index)"></i>
<image :src="item" class="g_w_56 g_h_56 g_radius_8" />
</view>
5 months ago
</view> </template
></g-panel-form-slot>
6 months ago
<g-panel-fixed>
<slot>
<view class="g_flex_row_center">
<g-button btnText="取消" class="g_mr_16" size="small" type="default" @clickBtn="goReturn"></g-button>
<g-button btnText="确定" class=" " @clickBtn="handleSubmit" size="small" type="primary"></g-button>
</view>
</slot>
</g-panel-fixed>
</view>
</view>
</template>
<script>
import { nationlist } from "../../utils/nation.js";
export default {
onReady() {
this.G.setNavStyle();
},
onShareAppMessage() {
return this.G.shareFun();
},
data() {
return {
cdnBaseImg: this.G.store().cdnBaseImg,
info: {
nation: "汉族",
},
nation: nationlist.map((item, index) => {
return item.name;
}),
nationIndex: 0,
imgList: [],
};
},
onLoad(options) {
let that = this;
console.log("快速报名:", options);
if (options) {
if (options.sex) {
options.sex = Number(options.sex);
} else {
options.sex = 1;
}
if (options.nation) {
options.nation = options.nation;
} else {
options.nation = "汉族";
}
this.info = options;
if (this.info.imgs) {
this.imgList = this.info.imgs.split(",");
}
}
console.log("获取老乡信息:", options);
},
onShow() {
let that = this;
// that.nation.forEach((item, index) => {
// if (item == that.info.nation) {
// console.log(that.info.nation);
// console.log(index);
// that.nationIndex = index;
// }
// });
// that.speed = 0;
// setTimeout(() => {
// }, 300);
},
created() {
let that = this;
},
methods: {
handleClickName(e) {
this.info.name = this.info.userName = e;
},
handleClickSex(e) {
this.info.sex = e;
},
handleClickAge(e) {
this.info.age = e;
},
handleClickMobile(e) {
this.info.tel = e;
},
handleClickNation(e) {
let that = this;
console.log(e.name);
this.info.nation = e.name;
that.nation.forEach((item, index) => {
if (item == e.name) {
// console.log(that.info.nation)
// console.log(index)
that.nationIndex = index;
}
});
},
/**
* 获取上传的身份信息
*/
handlerIDInfo(res) {
console.log("res", res);
let that = this;
that.info.name = res.info.name;
that.info.sex = res.info.sex ? (res.info.sex == "男" ? 1 : 2) : "";
that.info.age = res.info.age;
that.info.nation = res.info.nationality + "族";
that.info.idCard = res.info.num;
that.info.idCardImageUrl = res.image;
that.info.userName = res.info.name;
that.info.address = res.info.address;
that.nation.forEach((item, index) => {
console.log("item1", item);
console.log('that.info.nation + "族"', that.info.nation + "族");
if (item == that.info.nation) {
console.log("item2", item);
that.nationIndex = index;
}
});
console.log("that.info", that.info);
console.log("that.nationIndex", that.nationIndex);
that.$forceUpdate();
},
// 删除图片
delImg(ind) {
this.imgList.splice(
this.imgList.findIndex((item, index) => index == ind),
1
);
},
// 上传图片
updateFile(e) {
let that = this;
if (that.imgList.length < 4) {
that.imgList.push(e);
uni.hideLoading();
} else {
uni.showToast({
title: "最多只能上传4张",
icon: "none",
});
}
},
handleClickIDcard(e) {
this.info.idCard = e;
if (this.info.idCard.length == 15 || this.info.idCard.length == 18) {
let info = this.G.getInfoByIDcard(this.info.idCard);
this.info.age = info.age;
this.info.sex = info.sex ? (info.sex == "男" ? 1 : 2) : "";
this.$forceUpdate();
}
// console.log(this.G.getInfoByIDcard(this.info.idCard));
},
handleClickAddress(e) {
this.info.address = e;
},
goReturn() {
uni.navigateBack();
},
handleSubmit() {
let that = this;
console.log("that.info.imgs", that.info.imgs);
console.log("that.imgList", that.imgList);
if (!that.info.name) {
uni.showToast({
icon: "none",
title: "请输入姓名",
});
return false;
}
if (!that.info.sex) {
uni.showToast({
icon: "none",
title: "请选择性别",
});
return false;
}
if (!that.info.age) {
uni.showToast({
icon: "none",
title: "请输入年龄",
});
return false;
}
if (!that.info.nation) {
uni.showToast({
icon: "none",
title: "请选择民族",
});
return false;
}
if (!that.G.setReg(that.info.tel, "tel")) {
uni.showToast({
icon: "none",
title: "请输入正确的手机号",
});
return false;
}
if (!that.G.setReg(that.info.idCard, "idcard")) {
uni.showToast({
icon: "none",
title: "请输入正确的身份证号",
});
return false;
}
console.log(that.info);
if (that.imgList.length > 0) {
that.info.imgs = that.imgList;
}
console.log("that.info.imgs", that.info.imgs);
uni.$emit("getTownsman", { info: that.info });
uni.navigateBack();
},
handleClickInfo() {
let that = this;
that.G.uploadImg((res) => {
console.log("res", res);
that.info.name = res.info.name;
that.info.sex = res.info.sex ? (res.info.sex == "男" ? 1 : 2) : "";
that.info.age = res.info.age;
that.info.nation = res.info.nationality;
that.info.idCard = res.info.num;
that.info.idCardImageUrl = res.image;
that.info.userName = res.info.name;
that.info.address = res.info.address;
that.nation.forEach((item, index) => {
if (item == that.info.nation) {
that.nationIndex = index;
}
});
that.$forceUpdate();
}, "idcard");
},
},
};
</script>
<style>
.img-close {
position: absolute;
width: 18px;
height: 18px;
right: -6px;
top: -6px;
z-index: 99;
background-color: #666;
color: #fff;
font-size: 8px;
text-align: center;
line-height: 18px;
border-radius: 50%;
}
</style>