|
@@ -5,7 +5,7 @@ import { FormsModule } from '@angular/forms';
|
|
|
import { RouterModule, Router, ActivatedRoute } from '@angular/router';
|
|
|
import { ProjectService } from '../../../services/project.service';
|
|
|
import { Project, Task, CustomerFeedback } from '../../../models/project.model';
|
|
|
-import { FmodeQuery, FmodeObject, FmodeUser } from 'fmode-ng/core';
|
|
|
+import { FmodeQuery } from 'fmode-ng/core';
|
|
|
import { WxworkAuth } from 'fmode-ng/core';
|
|
|
|
|
|
@Component({
|
|
@@ -158,55 +158,35 @@ export class Dashboard implements OnInit, OnDestroy {
|
|
|
return date.toISOString().split('T')[0];
|
|
|
}
|
|
|
|
|
|
- private wxAuth: WxworkAuth | null = null;
|
|
|
- private currentUser: FmodeUser | null = null;
|
|
|
|
|
|
constructor(
|
|
|
private projectService: ProjectService,
|
|
|
private router: Router,
|
|
|
private activatedRoute: ActivatedRoute
|
|
|
) {
|
|
|
- this.initAuth();
|
|
|
- }
|
|
|
-
|
|
|
- // 初始化企业微信认证
|
|
|
- private initAuth(): void {
|
|
|
- try {
|
|
|
- this.wxAuth = new WxworkAuth({
|
|
|
- cid: 'cDL6R1hgSi' // 公司帐套ID
|
|
|
- });
|
|
|
- console.log('✅ 客服仪表板企业微信认证初始化成功');
|
|
|
- } catch (error) {
|
|
|
- console.error('❌ 客服仪表板企业微信认证初始化失败:', error);
|
|
|
+ this.loadProfile();
|
|
|
+ }
|
|
|
+
|
|
|
+ currentUser:any = {}
|
|
|
+ async loadProfile(){
|
|
|
+ let cid = localStorage.getItem("company");
|
|
|
+ if(cid){
|
|
|
+ let wwAuth = new WxworkAuth({cid:cid})
|
|
|
+ let profile = await wwAuth.currentProfile();
|
|
|
+ this.currentUser = {
|
|
|
+ name: profile?.get("name") || profile?.get("mobile"),
|
|
|
+ avatar: profile?.get("avatar"),
|
|
|
+ roleName: profile?.get("roleName")
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- async ngOnInit(): Promise<void> {
|
|
|
- await this.authenticateAndLoadData();
|
|
|
|
|
|
+ async ngOnInit(): Promise<void> {
|
|
|
// 添加滚动事件监听
|
|
|
window.addEventListener('scroll', this.onScroll.bind(this));
|
|
|
}
|
|
|
|
|
|
- // 认证并加载数据
|
|
|
- private async authenticateAndLoadData(): Promise<void> {
|
|
|
- try {
|
|
|
- // 执行企业微信认证和登录
|
|
|
- const { user } = await this.wxAuth!.authenticateAndLogin();
|
|
|
- this.currentUser = user;
|
|
|
-
|
|
|
- if (user) {
|
|
|
- console.log('✅ 客服登录成功:', user.get('username'));
|
|
|
- await this.loadDashboardData();
|
|
|
- } else {
|
|
|
- console.error('❌ 客服登录失败');
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('❌ 客服认证过程出错:', error);
|
|
|
- // 降级到模拟数据
|
|
|
- this.loadMockData();
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
// 加载仪表板数据
|
|
|
private async loadDashboardData(): Promise<void> {
|