|
@@ -15,7 +15,11 @@
|
|
|
<div class="info_box">
|
|
|
<div class="img" v-loading="imgLoading">
|
|
|
<img :src="info.headportrait ? info.headportrait : avator" alt="" />
|
|
|
- <div v-if="info.type == 1" class="mask" @click.stop="addImg($event)">
|
|
|
+ <div
|
|
|
+ v-if="info.type == 1"
|
|
|
+ class="mask"
|
|
|
+ @click.stop="addImg($event)"
|
|
|
+ >
|
|
|
<img src="../assets/info/camera_icon.png" alt="" />
|
|
|
<input
|
|
|
type="file"
|
|
@@ -46,7 +50,7 @@
|
|
|
v-model="info.username"
|
|
|
placeholder="请输入姓名"
|
|
|
></el-input>
|
|
|
- </div>
|
|
|
+ </div>
|
|
|
|
|
|
<div class="info_span">
|
|
|
<span>性别:</span>
|
|
@@ -58,7 +62,7 @@
|
|
|
|
|
|
<!-- 学生弹框数据 -->
|
|
|
<template v-if="info.type == 2">
|
|
|
- <div class="info_span" >
|
|
|
+ <div class="info_span">
|
|
|
<span>组织:</span>
|
|
|
<el-select disabled placeholder="请选择">
|
|
|
<el-option :label="orgName"></el-option>
|
|
@@ -77,7 +81,7 @@
|
|
|
</el-select>
|
|
|
</div>
|
|
|
</template>
|
|
|
-
|
|
|
+
|
|
|
<template v-if="info.type == 1">
|
|
|
<div
|
|
|
class="info_span"
|
|
@@ -107,7 +111,6 @@
|
|
|
</el-select>
|
|
|
</div>
|
|
|
</template>
|
|
|
-
|
|
|
|
|
|
<div class="info_span">
|
|
|
<span>微信登录:</span>
|
|
@@ -216,13 +219,11 @@ import avator from "../assets/info/teacher.jpg";
|
|
|
import { API_CONFIG } from "@/common/apiConfig";
|
|
|
import { updatePassword, getUser } from "@/api/user";
|
|
|
import store from "../store";
|
|
|
-import qs from "qs";
|
|
|
-import axios from "axios";
|
|
|
|
|
|
import "@/common/wxLogin.js";
|
|
|
|
|
|
export default {
|
|
|
- props: ["role", "userid", "oid","orgName"],
|
|
|
+ props: ["role", "userid", "oid", "orgName"],
|
|
|
watch: {
|
|
|
dialogVisibleInfo(newVal) {
|
|
|
if (newVal) {
|
|
@@ -247,7 +248,7 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- messageHandler:'',
|
|
|
+ messageHandler: "",
|
|
|
avator: avator,
|
|
|
info: {},
|
|
|
imgLoading: false,
|
|
@@ -642,51 +643,55 @@ export default {
|
|
|
}, 0);
|
|
|
}, 0);
|
|
|
},
|
|
|
+ addOpenid(openid) {
|
|
|
+ let params = [
|
|
|
+ {
|
|
|
+ functionName: API_CONFIG.ajax_UpdateOpenId.functionName, // 调用存储过程的名称
|
|
|
+ uid: this.userid,
|
|
|
+ openid: openid,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ this.$ajax
|
|
|
+ .post(API_CONFIG.baseUrl, params)
|
|
|
+ .then(() => {
|
|
|
+ this.$message.success("绑定成功");
|
|
|
+ this.wechatDialogVisible = false;
|
|
|
+ this.getData();
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ this.$message.error("绑定失败请重新扫码");
|
|
|
+ console.error(err);
|
|
|
+ setTimeout(() => {
|
|
|
+ this.wechatDialogVisible = true;
|
|
|
+ this.wechatLogin();
|
|
|
+ }, 1000);
|
|
|
+ });
|
|
|
+ },
|
|
|
setOpenId(openid) {
|
|
|
- axios.defaults.withCredentials = false;
|
|
|
- let params = {
|
|
|
- openid: openid,
|
|
|
- };
|
|
|
- let _this = this
|
|
|
- this.openid = openid;
|
|
|
- axios.defaults.withCredentials = true;
|
|
|
- axios
|
|
|
- .post(`https://beta.api.cocorobo.cn/api/user`, qs.stringify(params))
|
|
|
- .then(async (res) => {
|
|
|
- let _data = res.data[0][0];
|
|
|
- _this.$message.error('该微信已绑定'+_data.username+'账号');
|
|
|
- _this.wechatDialogVisible = false;
|
|
|
- if (_this.$refs.QRcode && _this.$refs.QRcode.innerHTML) {
|
|
|
- _this.$refs.QRcode.innerHTML = "";
|
|
|
+ let params = [
|
|
|
+ {
|
|
|
+ functionName: API_CONFIG.ajax_selectliyuanOpenid.functionName, // 调用存储过程的名称
|
|
|
+ pid: openid,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+ this.$ajax
|
|
|
+ .post(API_CONFIG.baseUrl, params)
|
|
|
+ .then((res) => {
|
|
|
+ console.log(res.data);
|
|
|
+ if (!res.data.length) {
|
|
|
+ this.addOpenid(openid);
|
|
|
+ } else {
|
|
|
+ let uname = res.data[0].map(item => item.username).join(',');
|
|
|
+ console.log('uname',uname);
|
|
|
+
|
|
|
+ this.$message.error("该微信已绑定" + uname + "账号");
|
|
|
+ this.wechatDialogVisible = false;
|
|
|
}
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- console.log('err',err);
|
|
|
-
|
|
|
- let params = [
|
|
|
- {
|
|
|
- functionName: API_CONFIG.ajax_UpdateOpenId.functionName, // 调用存储过程的名称
|
|
|
- uid: _this.userid,
|
|
|
- openid: openid,
|
|
|
- },
|
|
|
- ];
|
|
|
- _this.$ajax
|
|
|
- .post(API_CONFIG.baseUrl, params)
|
|
|
- .then(() => {
|
|
|
- _this.$message.success("绑定成功");
|
|
|
- _this.wechatDialogVisible = false;
|
|
|
- _this.getData();
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- _this.$message.error("绑定失败请重新扫码");
|
|
|
- console.error(err);
|
|
|
- setTimeout(() => {
|
|
|
- _this.wechatDialogVisible = true;
|
|
|
- _this.wechatLogin();
|
|
|
- }, 1000);
|
|
|
-
|
|
|
- });
|
|
|
- });
|
|
|
+ console.log("err", err);
|
|
|
+ });
|
|
|
},
|
|
|
Ochange() {
|
|
|
this.$forceUpdate();
|
|
@@ -696,11 +701,11 @@ export default {
|
|
|
let _this = this;
|
|
|
this.messageHandler = function (e) {
|
|
|
// 监听 message 事件
|
|
|
- console.log('userinfoA', e);
|
|
|
+ console.log("userinfoA", e);
|
|
|
if (e.data && e.data.method === "getOpenId") {
|
|
|
- console.log('eA', e);
|
|
|
- console.log('e.data.codeA', e.data.code);
|
|
|
- console.log('_this.loginTypeA', _this.loginType);
|
|
|
+ console.log("eA", e);
|
|
|
+ console.log("e.data.codeA", e.data.code);
|
|
|
+ console.log("_this.loginTypeA", _this.loginType);
|
|
|
|
|
|
if (e.data.code === 200) {
|
|
|
_this.setOpenId(e.data.data.openid);
|
|
@@ -719,7 +724,7 @@ export default {
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
window.removeEventListener("message", this.messageHandler);
|
|
|
- }
|
|
|
+ },
|
|
|
};
|
|
|
</script>
|
|
|
|