import { Base64 } from 'js-base64' import { $fytz } from '../index' /** * 信用评估API接口 */ export default { /** * 下载用户环信码 * @param {*} userId * @param {*} userName */ downloadCode(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) 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) }) }, }