|
|
@@ -15,13 +15,13 @@
|
|
|
<div class="login-tip">请扫码登录企微</div>
|
|
|
<div id="login-container" ref="loginContainer" class="login-container"></div>
|
|
|
</div>
|
|
|
- <!-- 已登录但未选择员工 -->
|
|
|
- <div v-else-if="!staffUserId" class="empty-tip">
|
|
|
+ <!-- 已登录但未选择员工(群聊不需要员工) -->
|
|
|
+ <div v-else-if="!staffUserId && !chatId" class="empty-tip">
|
|
|
<i class="el-icon-info"></i>
|
|
|
<p>请选择员工</p>
|
|
|
</div>
|
|
|
- <!-- 已登录但未选择客户 -->
|
|
|
- <div v-else-if="!customerId" class="empty-tip">
|
|
|
+ <!-- 已登录但未选择客户(群聊不需要客户) -->
|
|
|
+ <div v-else-if="!customerId && !chatId" class="empty-tip">
|
|
|
<i class="el-icon-info"></i>
|
|
|
<p>请选择客户查看会话</p>
|
|
|
</div>
|
|
|
@@ -69,7 +69,8 @@ export default {
|
|
|
props: {
|
|
|
corpId: { type: String, default: null },
|
|
|
customerId: { type: String, default: null },
|
|
|
- staffUserId: { type: String, default: null }
|
|
|
+ staffUserId: { type: String, default: null },
|
|
|
+ chatId: { type: String, default: null }
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -94,7 +95,7 @@ export default {
|
|
|
},
|
|
|
watch: {
|
|
|
customerId(newId, oldId) {
|
|
|
- if (newId && newId !== oldId && this.isLoggedIn && this.staffUserId && this.configReady && !this.configError) {
|
|
|
+ if (newId && newId !== oldId && this.isLoggedIn && (this.staffUserId || this.chatId) && this.configReady && !this.configError) {
|
|
|
this.resetAndReload();
|
|
|
}
|
|
|
},
|
|
|
@@ -103,6 +104,11 @@ export default {
|
|
|
this.resetAndReload();
|
|
|
}
|
|
|
},
|
|
|
+ chatId(newVal, oldVal) {
|
|
|
+ if (newVal && newVal !== oldVal && this.isLoggedIn && this.configReady && !this.configError) {
|
|
|
+ this.resetAndReload();
|
|
|
+ }
|
|
|
+ },
|
|
|
corpId(newId, oldId) {
|
|
|
if (newId !== oldId) {
|
|
|
this.destroyChat();
|
|
|
@@ -256,7 +262,7 @@ export default {
|
|
|
await this.handleLogin(code);
|
|
|
this.storeLoginState(this.corpId);
|
|
|
this.isLoggedIn = true;
|
|
|
- if (this.customerId && this.staffUserId) await this.loadFirstPage();
|
|
|
+ if ((this.customerId && this.staffUserId) || this.chatId) await this.loadFirstPage();
|
|
|
} catch (err) {
|
|
|
this.clearLoginState(this.corpId);
|
|
|
this.isLoggedIn = false;
|
|
|
@@ -265,7 +271,7 @@ export default {
|
|
|
} else {
|
|
|
if (this.checkLoginState(this.corpId)) {
|
|
|
this.isLoggedIn = true;
|
|
|
- if (this.customerId && this.staffUserId) await this.loadFirstPage();
|
|
|
+ if ((this.customerId && this.staffUserId) || this.chatId) await this.loadFirstPage();
|
|
|
} else {
|
|
|
this.isLoggedIn = false;
|
|
|
this.safeEmitLogout();
|
|
|
@@ -308,7 +314,7 @@ export default {
|
|
|
onLoginSuccess: async ({ code }) => {
|
|
|
try {
|
|
|
await this.handleLogin(code);
|
|
|
- if (this.customerId && this.staffUserId) await this.loadFirstPage();
|
|
|
+ if ((this.customerId && this.staffUserId) || this.chatId) await this.loadFirstPage();
|
|
|
} catch (e) {
|
|
|
this.clearLoginState(this.corpId);
|
|
|
this.isLoggedIn = false;
|
|
|
@@ -386,7 +392,8 @@ export default {
|
|
|
staffUserId: this.staffUserId,
|
|
|
limit: 100,
|
|
|
cursor: this.cursor,
|
|
|
- corpid: this.corpId
|
|
|
+ corpid: this.corpId,
|
|
|
+ chatId: this.chatId || undefined
|
|
|
});
|
|
|
const data = this._extractResponse(res);
|
|
|
if (data.errcode !== 0) throw new Error(data.errmsg || '拉取失败');
|
|
|
@@ -414,7 +421,8 @@ export default {
|
|
|
staffUserId: this.staffUserId,
|
|
|
limit: 50,
|
|
|
cursor: this.cursor,
|
|
|
- corpid: this.corpId
|
|
|
+ corpid: this.corpId,
|
|
|
+ chatId: this.chatId || undefined
|
|
|
});
|
|
|
const data = this._extractResponse(res);
|
|
|
if (data.errcode !== 0) throw new Error(data.errmsg || '拉取更多失败');
|