123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- <template>
- <div>
- <common @asynCallBack="asynCallBack"></common>
- <top-header :pageTitle="pageTitle" :rightLink="rightLink" :doRightLink="doRightLink"></top-header>
- <div class="mui-content">
- <div class="mui-content-padded vongi-qingjiadt">
- <form class="mui-input-group">
- <div class="mui-input-row">
- <label>小区名称</label>
- <span v-text="subForm.companyName"></span>
- </div>
- <div class="mui-input-row">
- <label>房号</label>
- <span v-text="subForm.structureName"></span>
- </div>
- </form>
- </div>
- <div class="mui-content-padded vongi-qingjiadt vongi-editme marginbo">
- <form class="mui-input-group">
- <div class="mui-input-row">
- <label style="width:40%">租客姓名<i class="colorfe616c">*</i></label>
- <input type="text" style="width: 60%;" v-model="subForm.name" class="mui-input-clear" placeholder="请输入租客姓名">
- </div>
- <div class="mui-input-row">
- <label>手机号码</label>
- <input type="number" v-model="subForm.phone" class="mui-input-clear" placeholder="请输入手机号码">
- </div>
- <div class="mui-input-row">
- <label>身份证号</label>
- <input type="text" v-model="subForm.idCard" class="mui-input-clear" placeholder="请输入身份证号">
- </div>
- <div class="mui-input-row">
- <label style="width:50%">人脸识别照片<i class="colorfe616c">*</i><i class="iconfont icon-tishi color4fc5f7" @click="valert"></i></label>
- <button @click="chooseImage('faceImageUrl') " class="mui-btn mui-btn-block mui-navigate-right" type='button'
- style="width:50%">
- <img v-if="subForm.faceImageUrl" :src="subForm.faceImageUrl" />
- <a v-else>请选择</a>
- </button>
- </div>
- </form>
- </div>
- </div>
- <div class="fyy-footer">
- <div class="bindfyy-btn"><button type="button" @click="submit" class="mui-btn mui-btn-primary ">保 存</button></div>
- </div>
- <loading :visible="isLoading"></loading>
- <!--图片裁剪-->
- <cropper :cwidth="cropperWidth" :cheight="cropperHeight" :visible="cropperVisible" :field="cropperField" :cropper="cropper"
- @cropperFinish="cropperFinish" @cropperCancel="cropperCancel"></cropper>
- </div>
- </template>
- <script>
- import * as API_Family from '@/apis/Master/family'
- import Common from '$project/components/Common.vue'
- import Loading from '$project/components/Loading.vue'
- import isReachBottom from '$project/utils/isReachBottom'
- import TopHeader from '$project/components/TopHeader.vue'
- import {
- checkPhone,
- checkIdCard
- } from '$project/utils'
- import {
- mapGetters,
- mapMutations
- } from 'vuex'
- import Cropper from '$project/components/Cropper.vue'
- import * as WxJsApi from '$project/utils/wxJsApi'
- export default {
- name: 'MasterTenantAdd',
- components: {
- Common,
- Loading,
- TopHeader,
- Cropper
- },
- data() {
- return {
- pageTitle: '添加租客账号',
- isLoading: false,
- rightLink: {
- show: true,
- icon: 'mui-icon-trash',
- style: 'color:#FF6666',
- title: ''
- },
- subForm: {
- companyName: '',
- faceImageUrl: '',
- id: this.$route.query.id,
- idCard: '',
- name: '',
- phone: '',
- structureName: '',
- type: '1'
- },
- imgBase64: '',
- cropperVisible: '',
- cropperField: '',
- cropperWidth: 250,
- cropperHeight: 350,
- cropper: {
- img: '',
- info: true,
- size: 1,
- outputType: 'jpeg',
- canScale: false,
- autoCrop: true,
- // 只有自动截图开启 宽度高度才生效
- autoCropWidth: 250,
- autoCropHeight: 350,
- fixed: true,
- // 真实的输出宽高
- infoTrue: true,
- fixedNumber: [5, 7]
- },
- }
- },
- created() {
- if (this.person_popedom.companyName) {
- this.subForm.companyName = this.person_popedom.companyName;
- }
- if (this.person_popedom.structureName) {
- this.subForm.structureName = this.person_popedom.structureName;
- }
- },
- methods: {
- //获取详情
- getDetail() {
- this.isLoading = true;
- API_Family.getPersonInfo(this.subForm.id).then(response => {
- this.isLoading = false;
- this.subForm = response;
- }).catch(error => {
- this.isLoading = false;
- mui.toast(error);
- })
- },
- //检测
- checkForm() {
- let phoneResult = checkPhone(this.subForm.phone);
- let idCardResult = checkIdCard(this.subForm.idCard);
- if (!this.subForm.name) {
- mui.toast('请输入姓名');
- return false;
- } else if (this.subForm.phone&& typeof phoneResult == 'string') {
- mui.toast(phoneResult);
- return false;
- } else if (this.subForm.idCard && typeof idCardResult == 'string') {
- mui.toast(idCardResult);
- return false;
- } else if (!this.subForm.faceImageUrl) {
- mui.toast('请上传人脸识别照片');
- return false;
- } else {
- return true;
- }
- },
- //提交
- submit() {
- if (this.checkForm()) {
- this.isLoading = true;
- API_Family.addPerson(this.subForm).then(response => {
- this.isLoading = false;
- mui.toast(this.actionTitle + '成功');
- this.$router.go(-1);
- }).catch(error => {
- this.isLoading = false;
- mui.toast(error);
- })
- }
- },
- //微信选择图片
- chooseImage(field) {
- WxJsApi.chooseImage().then(res => {
- var localData = res.localData;
- if (localData.indexOf('data:image') != 0) {
- //判断是否有这样的头部
- localData = 'data:image/jpeg;base64,' + localData
- }
- localData = localData.replace(/\r|\n/g, '').replace('data:image/jgp', 'data:image/jpeg')
- this.imgBase64 = localData;
- //显示裁剪图片
- this.showCropper(field);
- //this.uploadpic(field);
- }).catch(error => {
- mui.toast(error);
- })
- },
- //显示裁剪图片
- showCropper(field) {
- this.cropper.img = this.imgBase64;
- this.cropperField = field;
- this.cropperVisible = true;
- },
- //裁剪图片
- cropperFinish(obj) {
- console.log(obj);
- this.imgBase64 = obj.data;
- this.uploadpic(obj.field);
- this.cropperVisible = false;
- },
- //隐藏裁剪图片
- cropperCancel() {
- this.cropperVisible = false;
- },
- //上传图片
- uploadpic(field) {
- this.isLoading = true;
- WxJsApi.uploadPic(this.imgBase64).then(response => {
- this.isLoading = false;
- this.subForm[field] = response;
- }).catch(error => {
- this.isLoading = false;
- mui.toast(error);
- })
- },
- //弹窗
- valert() {
- mui.alert("照片将用于人脸识别设备,请上传清晰的免冠登记照或肩部以上近照。", ' ', ['知道了'])
- },
- del() {
- this.isLoading = true;
- API_Family.delPerson(this.subForm.popedomId).then(response => {
- this.isLoading = false;
- mui.toast('删除成功');
- this.$router.go(-1);
- }).catch(error => {
- this.isLoading = false;
- mui.toast(error);
- })
- },
- //右上角点击事件
- doRightLink() {
- var _this = this;
- var btnArray = ['否', '是'];
- mui.confirm('确认删除此租户?', '确认删除', btnArray, function(e) {
- if (e.index == 1) {
- _this.del();
- }
- })
- },
- asynCallBack() {
- },
- },
- mounted() {
- //获取微信配置
- WxJsApi.getWxConfig();
- if (this.subForm.id) {
- //获取详情
- this.getDetail();
- } else {
- this.rightLink.show = false;
- }
- },
- destroyed() {
- },
- computed: {
- actionTitle: {
- // getter
- get: function() {
- return this.subForm.id ? '修改' : '添加';
- },
- // setter
- set: function(newValue) {
- console.log(newValue)
- }
- },
- ...mapGetters({
- openId: 'wx_openid',
- token: 'token',
- person_data: 'person_data',
- person_popedom: 'person_popedom',
- })
- }
- }
- </script>
- <style scoped src="$project/assets/css/xpwyfyy.css"></style>
- <style src="$project/assets/css/iconfont.css"></style>
- <style>
- </style>
|