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.
241 lines
5.4 KiB
241 lines
5.4 KiB
import http from '../utils/http/index.js'
|
|
import store from '@/store/index'
|
|
import { PAY_URL } 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)
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
// 处理store同步问题
|
|
function syncStore(res) {
|
|
if (res.enterpriseList && res.enterpriseList.length > 0) {
|
|
let companyInfo = res.enterpriseList[0]
|
|
let vipExpireTime = companyInfo.vipExpireTime || null
|
|
let isVip = false
|
|
if (vipExpireTime) {
|
|
// 适配ios时间戳
|
|
vipExpireTime = vipExpireTime.replace(/-/g, '/')
|
|
let now = new Date().getTime()
|
|
if (now < new Date(vipExpireTime).getTime()) {
|
|
isVip = true
|
|
}
|
|
}
|
|
store.commit('setUserInfo', {
|
|
name: companyInfo.employeeName,
|
|
userId: res.userId,
|
|
mobile: res.mobile,
|
|
avatar: null
|
|
})
|
|
store.commit('setCompanyInfo', {
|
|
id: companyInfo.id,
|
|
name: companyInfo.name,
|
|
fddEnterpriseStatus: companyInfo.fddEnterpriseStatus,
|
|
isVip: isVip,
|
|
vipExpireTime: vipExpireTime
|
|
})
|
|
} else {
|
|
if (res) {
|
|
store.commit('setUserInfo', {
|
|
name: '',
|
|
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 })
|
|
}
|
|
|
|
/**
|
|
* 转换合同成图片
|
|
* @param {object} data 图片地址链接 fileUrl
|
|
*/
|
|
export function transformFileToImg(data) {
|
|
return http.get({
|
|
url: '/document/get/enterprise-documents/file-image-base64',
|
|
data: data
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 获取飞算地址
|
|
*/
|
|
export function getFeisuanUrl(data = {}) {
|
|
return http.get({
|
|
url: '/yyt-uec/feisuan/feisuan-apply-url.json',
|
|
data: data
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 营业执照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
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 身份证背面OCR识别 image
|
|
*/
|
|
export function getBackIdCardOcr(data = {}) {
|
|
return http.post({
|
|
url: '/base-paper-trading/ocr/id-card/back',
|
|
data: data
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 纸盘商开通会员,创建订单
|
|
* @param {object} data
|
|
* @value {string} type
|
|
* @value {string} enterpriseId
|
|
*/
|
|
export function openVip(data = {}) {
|
|
return http.post({
|
|
url: `/yyt-uec/customer/apply/for/vip?type=${data.type}&enterpriseId=${data.enterpriseId}`,
|
|
data: data
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 纸盘商开通会员,真实支付
|
|
* @param {object} data
|
|
* @value {string} tradeOrderId
|
|
* @value {string} channelId
|
|
* @param {string} userOpenId 用户openId
|
|
*/
|
|
export function openVipPay(data = {}) {
|
|
return http.post({
|
|
url: PAY_URL + `?userOpenId=${data.userOpenId}`,
|
|
data: data
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 获取用户openId
|
|
* @param {object} data
|
|
* @value {string} authCode 授权码
|
|
* @value {string} authMethod 3:WeChatServiceAccount
|
|
*/
|
|
export function getOpenId(data = {}) {
|
|
return http.post({
|
|
url: '/uec/get/user-openid/by-oauth2',
|
|
data: data
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 绑定纸盘商销售id
|
|
* @param {object} data
|
|
* @value {string} customerEnterpriseId 客户企业id
|
|
* @value {string} customerId 客户id
|
|
* @value {string} sellerId 纸盘商销售id
|
|
* @value {string} sellerSupplierId 纸盘商id
|
|
*/
|
|
export function bindUser(data = {}) {
|
|
return http.post({
|
|
url: '/yyt-uec/seller/bound/customer',
|
|
data: data
|
|
})
|
|
}
|