|
@@ -8,7 +8,8 @@
|
|
|
<form class="mui-input-group">
|
|
|
<div class="mui-input-row">
|
|
|
<label style="width: 40%">人脸识别照片</label>
|
|
|
- <button id="showUserPicker" class="mui-btn mui-btn-block mui-navigate-right" type="button" style="width: 60%">
|
|
|
+ <button @click="chooseImage('faceImageUrl') " class="mui-btn mui-btn-block mui-navigate-right" type="button"
|
|
|
+ style="width: 60%">
|
|
|
<img :src="person_data.faceImageUrl" />
|
|
|
</button>
|
|
|
</div>
|
|
@@ -32,10 +33,15 @@
|
|
|
<button type="submit" class="mui-btn mui-btn-primary" @click="save">保 存</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
+
|
|
|
+ <loading :visible="isLoading"></loading>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+ import * as API_WeiXin from '$project/apis/weixin'
|
|
|
+ import * as API_Common from '$project/apis/common'
|
|
|
+ import * as API_Master from '@/apis/Master/index'
|
|
|
import Common from '$project/components/Common.vue'
|
|
|
import Loading from '$project/components/Loading.vue'
|
|
|
import TopHeader from '$project/components/TopHeader.vue'
|
|
@@ -43,6 +49,7 @@
|
|
|
mapGetters,
|
|
|
mapMutations
|
|
|
} from 'vuex'
|
|
|
+ import wx from 'weixin-js-sdk'
|
|
|
export default {
|
|
|
name: 'MasterEditInfo',
|
|
|
components: {
|
|
@@ -54,12 +61,17 @@
|
|
|
return {
|
|
|
pageTitle: '修改个人中心',
|
|
|
|
|
|
+ isLoading: false,
|
|
|
+
|
|
|
subForm: {
|
|
|
name: '',
|
|
|
phone: '',
|
|
|
idCard: '',
|
|
|
+ faceImageUrl: '',
|
|
|
wechatNoticeEnabled: true,
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
+ imgBase64: ''
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
@@ -70,14 +82,95 @@
|
|
|
methods: {
|
|
|
//保存
|
|
|
save() {
|
|
|
+ this.isLoading = true;
|
|
|
+ API_Master.savePerson(subForm).then(response => {
|
|
|
+ this.isLoading = false;
|
|
|
|
|
|
+ mui.toast('保存成功');
|
|
|
+ this.$router.push({
|
|
|
+ name: 'Master',
|
|
|
+ query: {}
|
|
|
+ })
|
|
|
+ }).catch(error => {
|
|
|
+ this.isLoading = false;
|
|
|
+ mui.toast(error);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //获取微信配置
|
|
|
+ getWxConfig() {
|
|
|
+ this.isLoading = true;
|
|
|
+ API_WeiXin.getConfig().then(response => {
|
|
|
+ var wxconfig = response.wxConfig;
|
|
|
+ console.log(wxconfig.nonceStr)
|
|
|
+ this.wxConfig = wxconfig;
|
|
|
+ wx.config({
|
|
|
+ debug: false, // 开启调试模式,
|
|
|
+ appId: wxconfig.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
|
|
|
+ timestamp: wxconfig.timestamp, // 必填,生成签名的时间戳
|
|
|
+ nonceStr: wxconfig.nonceStr, // 必填,生成签名的随机串
|
|
|
+ signature: wxconfig.signature, // 必填,签名,见附录1
|
|
|
+ jsApiList: ['chooseImage', 'getLocalImgData'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
|
|
|
+ });
|
|
|
+
|
|
|
+ this.isLoading = false;
|
|
|
+ }).catch(error => {
|
|
|
+ this.isLoading = false;
|
|
|
+ mui.toast(error);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //微信选择图片
|
|
|
+ chooseImage(field) {
|
|
|
+ var _this = this;
|
|
|
+ wx.chooseImage({
|
|
|
+ count: 1,
|
|
|
+ sizeType: ['compressed'],
|
|
|
+ sourceType: ['album', 'camera'],
|
|
|
+ success: function(res) {
|
|
|
+ var localIds = res.localIds;
|
|
|
+ console.log(localIds);
|
|
|
+ wx.getLocalImgData({
|
|
|
+ localId: localIds[0],
|
|
|
+ success: function(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);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //上传图片
|
|
|
+ uploadpic() {
|
|
|
+ this.isLoading = true;
|
|
|
+ var _this = this;
|
|
|
+ var formData = new FormData();
|
|
|
+ formData.append('photoName', '1.jpg');
|
|
|
+ formData.append('photoBase64Data', this.imgBase64);
|
|
|
+
|
|
|
+ API_Common.uploadBase64(formData).then(response => {
|
|
|
+ this.isLoading = false;
|
|
|
+
|
|
|
+ this.subForm[field] = response;
|
|
|
+ }).catch(error => {
|
|
|
+ this.isLoading = false;
|
|
|
+ this.mui.toast(error);
|
|
|
+ })
|
|
|
},
|
|
|
asynCallBack() {
|
|
|
|
|
|
},
|
|
|
},
|
|
|
mounted() {
|
|
|
-
|
|
|
+ //获取微信配置
|
|
|
+ this.getWxConfig();
|
|
|
},
|
|
|
destroyed() {
|
|
|
|