edit
This commit is contained in:
@ -13,6 +13,7 @@ import { environment } from '@env/environment';
|
||||
import { EAEnvironmentService, EAUserService } from '@shared';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { catchError, mergeMap } from 'rxjs/operators';
|
||||
import { CoreService } from '../core.service';
|
||||
|
||||
@Injectable()
|
||||
export class BusinessInterceptor implements HttpInterceptor {
|
||||
@ -21,7 +22,8 @@ export class BusinessInterceptor implements HttpInterceptor {
|
||||
private eaUserSrv: EAUserService,
|
||||
@Optional()
|
||||
@Inject(DA_SERVICE_TOKEN)
|
||||
private tokenSrv: ITokenService
|
||||
private tokenSrv: ITokenService,
|
||||
private coreSrv: CoreService
|
||||
) {}
|
||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||
// 构造新的请求URL
|
||||
@ -52,12 +54,19 @@ export class BusinessInterceptor implements HttpInterceptor {
|
||||
* 附加额外的请求头
|
||||
*/
|
||||
private attachAdditionalHeaders(req: HttpRequest<any>): HttpRequest<any> {
|
||||
let position = {};
|
||||
if (this.coreSrv.position.lat && this.coreSrv.position.lng) {
|
||||
position = { lat: this.coreSrv.position.lat.toString(), lng: this.coreSrv.position.lng.toString() };
|
||||
}
|
||||
// 附加环境变量
|
||||
const header: any = {
|
||||
appId: this.envSrv.env.appId,
|
||||
tenantId: this.envSrv.env.tenantId,
|
||||
enterpriseId: '0'
|
||||
enterpriseId: '0',
|
||||
...position
|
||||
};
|
||||
console.log(header);
|
||||
|
||||
|
||||
// 附加授权声明
|
||||
const token = this.tokenSrv.get()?.token;
|
||||
|
||||
Reference in New Issue
Block a user