【前端】印包客app
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.

224 lines
5.3 KiB

import http from '../utils/http/index.js'
import store from '@/store/index'
import { XAPPID, PAY_URL, enterpriseType } 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 company = res.enterpriseList[0]
store.commit('setCompanyInfo', {
id: company.id,
name: company.name,
fddEnterpriseStatus: company.fddEnterpriseStatus,
enterpriseType: company.enterpriseType
})
let userInfo = {
name: company.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('removeCompanyInfo')
}
}
/**
* 获取当前账号的基础信息
* @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) {
// 排除供应商角色
if (res.enterpriseList && res.enterpriseList.length > 0 && res.enterpriseList[0].enterpriseType == enterpriseType.SUPPLIER) {
uni.showToast({
title: '您是供应商角色,请登陆纸掌柜app进行操作',
icon: ' error'
})
resolve(null)
} else {
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
})
}
/**
* 纸盘商开通会员,创建订单
* @param {object} data
* @value {string} type
* @value {string} mallSupplierId
*/
export function openVip(data = {}) {
return http.post({
url: `/yyt-uec/supplier/apply/for/vip?type=${data.type}&mallSupplierId=${data.mallSupplierId}`,
data: data
})
}
/**
* 纸盘商开通会员,真实支付
* @param {object} data
* @value {string} orderId
* @value {string} channelId
*/
export function openVipPay(data = {}) {
return http.post({
url: PAY_URL,
data: data
})
}
/**
* 获取账号下纸盘商收款码列表
* @param {object} data
* @value {string} mallSupplierId
* @value {string} payeeCodeUrl
*/
export function getReceiptCodeList(data = {}) {
return http.get({
url: '/yyt-uec/get/mall/supplier/payee/code/list',
data: data
})
}
/**
* 纸盘商绑定收款码
* @param {object} data
* @value {string} mallSupplierId
* @value {string} payeeCodeUrl
*/
export function bindingReceiptCode(data = {}) {
return http.post({
url: '/yyt-uec/save/mall/supplier/payee/code',
data: data
})
}