【前端】纸掌柜h5端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.6 KiB

import http from '../utils/http/index.js'
import store from '@/store/index'
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)
}
})
}
})
}
// 处理store同步问题
function syncStore(res) {
if (res.enterpriseList && res.enterpriseList.length > 0) {
let companyInfo = res.enterpriseList[0]
store.commit('setCompanyInfo', {
id: companyInfo.id,
name: companyInfo.name,
fddEnterpriseStatus: companyInfo.fddEnterpriseStatus
})
store.commit('setUserInfo', {
name: companyInfo.employeeName,
userId: res.userId,
mobile: res.mobile,
avatar: null
})
}
}
let baseInfo = null
/**
* 获取当前账号的基础信息
* @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, data })
}
/**
* 获取当前账号企业的飞算额度
* @param {object} data 参数 enterpriseId
*/
export function getFsCredit(data = {}) {
return http.get({ url: '/yyt-uec/credit/get/enterprise-feisuan-credit', data })
}
/**
* 获取当前账号企业的被担保的月结额度
* @param {object} data 参数 enterpriseId supplierId
*/
export function getMonthCredit(data = {}) {
return http.get({ url: '/yyt-uec/customer/get/supplier-credit', data })
}