riku
2025-05-16 6d479f9fbc15e96383fe25270575c976e4356e89
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { Base64 } from 'js-base64';
import { $fytz } from '../index';
 
/**
 * 信用评估API接口
 */
export default {
  /**
   * 下载用户环信码
   * @param {*} userId
   */
  downloadCode(userId) {
    return $fytz
      .get(`credit/ecCode/download?userId=${userId}`, { responseType: 'blob' })
      .then((res) => {
        const name = Base64.decode(res.headers.get('fileName'));
        const url = window.URL.createObjectURL(res.data);
        const link = document.createElement('a');
        link.href = url;
        link.setAttribute('download', name);
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
        window.URL.revokeObjectURL(url);
      });
  }
};