|
@@ -0,0 +1,146 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <common @asynCallBack="asynCallBack"></common>
|
|
|
+ <top-header :pageTitle="pageTitle"></top-header>
|
|
|
+
|
|
|
+ <div class="mui-content">
|
|
|
+ <div class="mui-content-padded">
|
|
|
+ <div class="mui-content-padded">
|
|
|
+ <h5>请上传照片</h5>
|
|
|
+ <div class="mui-h5 color999">
|
|
|
+ 照片将用于人脸识别设备,请上传清晰的免冠登记照或肩部以上近照。
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="mui-content-padded vongi-photo" @click="chooseImage">
|
|
|
+ <div class="faceaifyy-content-region" :style="subForm.faceImageUrl?'background:none':''">
|
|
|
+ <a v-if="!subForm.faceImageUrl"><span class="mui-icon iconfont icon-weibiaoti1"></span></a>
|
|
|
+ <img v-if="subForm.faceImageUrl" :src="subForm.faceImageUrl" width="100%" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="fyy-footer">
|
|
|
+ <div class="bindfyy-btn"><button type="submit" class="mui-btn mui-btn-primary" @click="submit">提交</button></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import * as API_Person from '@/apis/person'
|
|
|
+ import Common from '$project/components/Common.vue'
|
|
|
+ import Loading from '$project/components/Loading.vue'
|
|
|
+ import TopHeader from '$project/components/TopHeader.vue'
|
|
|
+ import {
|
|
|
+ mapGetters,
|
|
|
+ mapMutations
|
|
|
+ } from 'vuex'
|
|
|
+ import * as WxJsApi from '$project/utils/wxJsApi'
|
|
|
+ export default {
|
|
|
+ name: 'UploadPhoto',
|
|
|
+ components: {
|
|
|
+ Common,
|
|
|
+ Loading,
|
|
|
+ TopHeader
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ pageTitle: '上传登记照',
|
|
|
+
|
|
|
+ isLoading: false,
|
|
|
+
|
|
|
+ subForm: {
|
|
|
+ personId: this.$route.query.personId,
|
|
|
+ openId: '',
|
|
|
+ faceImageUrl: ''
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.subForm.openId = this.openId;
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ //微信选择图片
|
|
|
+ chooseImage() {
|
|
|
+ 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();
|
|
|
+ }).catch(error => {
|
|
|
+ mui.toast(error);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //上传图片
|
|
|
+ uploadpic() {
|
|
|
+ this.isLoading = true;
|
|
|
+ WxJsApi.uploadPic(this.imgBase64).then(response => {
|
|
|
+ this.isLoading = false;
|
|
|
+
|
|
|
+ this.subForm.faceImageUrl = response;
|
|
|
+ }).catch(error => {
|
|
|
+ this.isLoading = false;
|
|
|
+ mui.toast(error);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //表单检测
|
|
|
+ checkFrom() {
|
|
|
+ if (!this.subForm.personId) {
|
|
|
+ mui.toast('用户id未定义');
|
|
|
+ return false;
|
|
|
+ } else if (!this.subForm.openId) {
|
|
|
+ mui.toast('openId未获取到');
|
|
|
+ return false;
|
|
|
+ } else if (!this.subForm.faceImageUrl) {
|
|
|
+ mui.toast('请上传人脸照片');
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //提交
|
|
|
+ submit() {
|
|
|
+ if (this.checkFrom()) {
|
|
|
+ this.isLoading = true;
|
|
|
+ API_Person.save(this.subForm).then(response => {
|
|
|
+ this.isLoading = false;
|
|
|
+
|
|
|
+ this.$router.push({
|
|
|
+ name: 'Home',
|
|
|
+ query: {}
|
|
|
+ })
|
|
|
+
|
|
|
+ }).catch(error => {
|
|
|
+ this.isLoading = false;
|
|
|
+ mui.toast(error);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ asynCallBack() {
|
|
|
+
|
|
|
+ },
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ //获取微信配置
|
|
|
+ WxJsApi.getWxConfig();
|
|
|
+ },
|
|
|
+ destroyed() {},
|
|
|
+ computed: {
|
|
|
+ ...mapGetters({
|
|
|
+ openId: 'wx_openid',
|
|
|
+ token: 'token',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped src="$project/assets/css/xpwyfyy.css"></style>
|
|
|
+<style src="$project/assets/css/iconfont.css"></style>
|
|
|
+<style>
|
|
|
+</style>
|