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

101 lines
2.5 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 获取验证码参数
* @returns 获取验证码结果
* swagger:http://api-ops-uec-test.qniao.cn/uec/swagger-ui/index.html?urls.primaryName=CustomerApi#/%E7%99%BB%E5%BD%95%E8%AE%A4%E8%AF%81/authorizeByCaptchaUsingPOST
*/
export const getAuthCaptcha = (data) => {
return http.post({
url: '/uec/get/auth-captcha',
data
})
}