餐饮油烟智能监测与监管一体化平台
riku
2026-03-17 b1a0d701cf898c8b7812e66a808a1c91f2bae6cc
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
28
29
30
31
32
33
34
35
import { Base64 } from 'js-base64'
import { $fytz } from '../index'
 
/**
 * 信用评估API接口
 */
export default {
  fetchCodeUrl(userId, userName) {
    return $fytz
      .get(`credit/ecCode/download?userId=${userId}`, { responseType: 'blob' })
      .then((res) => {
        const name = res.headers.get('fileName') || userName
        const fileName = Base64.decode(name)
        const url = window.URL.createObjectURL(res.data)
        return { fileName, url }
      })
  },
  /**
   * 下载用户环信码
   * @param {*} userId
   * @param {*} userName
   */
  downloadCode(userId, userName) {
    return this.fetchCodeUrl(userId, userName).then((res) => {
      const { fileName, url } = res
      const link = document.createElement('a')
      link.href = url
      link.setAttribute('download', fileName)
      document.body.appendChild(link)
      link.click()
      document.body.removeChild(link)
      window.URL.revokeObjectURL(url)
    })
  },
}