import http from '../utils/http/index.js' import store from '@/store/index' import { XAPPID } from '@/enums/index.js' let areaCache = null /** * 获取省市区街道 * @returns array */ export function getArea(data = {}) { return new Promise((resolve, reject) => { if (areaCache) { resolve(areaCache) } else { http.get({ url: '/yyt-uec/get/regions', data }).then((res) => { if (res) { areaCache = res resolve(res) } else { resolve(null) } }) } }) } let baseInfo = null // 处理store同步问题 function syncStore(res) { if (res.enterpriseList && res.enterpriseList.length > 0) { let supplierInfo = res.enterpriseList[0] let vipExpireTime = supplierInfo.supplier.vipExpireTime || null let isVip = false if (vipExpireTime) { let now = new Date().getTime() if (now < new Date(vipExpireTime).getTime()) { isVip = true } } store.commit('setSupplierInfo', { id: supplierInfo.id, name: supplierInfo.name, fddEnterpriseStatus: supplierInfo.fddEnterpriseStatus, supplierId: supplierInfo.supplier.id, isVip, vipExpireTime }) let userInfo = { name: supplierInfo.employeeName, // 没有企业就没有name, userId: res.userId, mobile: res.mobile, avatar: null } store.commit('setUserInfo', userInfo) } else { let userInfo = { name: '', // 没有企业就没有name, userId: res.userId, mobile: res.mobile, avatar: null } store.commit('setUserInfo', userInfo) // 移除企业信息 store.commit('removeSupplierInfo') } } /** * 获取当前账号的基础信息 * @param {object} data 参数,暂时不需要,可以传{} * @param {boolean} refresh 是否强制刷新,默认false拿缓存数据 * @returns object */ export function getBaseInfo(data = {}, refresh = false) { return new Promise((resolve, reject) => { if (!refresh && baseInfo) { resolve(baseInfo) } else { http.get({ url: '/yyt-uec/get/base-info', data }, { hideLoading: true }).then((res) => { if (res) { baseInfo = res syncStore(res) resolve(res) } else { resolve(null) } }) } }) } /** * 获取当前账号的企业实名认证地址 * @param {object} data 参数 enterpriseId */ export function getVerifyUrl(data = {}) { return http.post({ url: '/yyt-uec/get/fdd-enterprise-verify-url?enterpriseId=' + data.enterpriseId, data }) } /** * 生成担保合同的签约地址,同意纸盘商只需要签约一次即可 * @param {object} data 参数 mallSupplierId */ export function getGuaranteeContract(data = {}) { return http.post({ url: `/yyt-uec/create/supplier/guarantee-contract?mallSupplierId=${data.mallSupplierId}&customerEnterpriseId=${data.customerEnterpriseId}`, data }) } /** * 转换合同成图片 * @param {object} data 图片地址链接 fileUrl */ export function transformFileToImg(data) { return http.get({ url: '/document/get/enterprise-documents/file-image-base64', data: data }) } /** * 推送客户绑定 * */ export function pushCustomerBind(cid, platformType = 'android', appId = XAPPID) { return http.post({ url: '/base-paper-trading/user/binding/geTui/cid', data: { cid, appId, platformType } }) } /** * 推送客户绑定 * */ export function pushCustomerOff(cid, platformType = 'android', appId = XAPPID) { return http.post({ url: '/base-paper-trading/user/geTui/offline', data: { cid, appId, platformType } }) } /** * 营业执照OCR识别 photoUrl */ export function getLicenseOcr(data = {}) { return http.post({ url: '/base-paper-trading/ocr/business-license', data: data }) } /** * 身份证正面OCR识别 image */ export function getFrontIdCardOcr(data = {}) { return http.post({ url: '/base-paper-trading/ocr/id-card/face', data: data }) } /** * 获取当前应用版本号 * @param {object} data * @value {string} version */ export function checkUpdate(data = {}) { return http.get({ url: '/base-paper-trading/get/app/version', data: data }) }