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.
379 lines
8.5 KiB
379 lines
8.5 KiB
import http from '@/utils/http/index.js'
|
|
import store from '@/store/index'
|
|
import { XAPPID} from '@/enums/index.js'
|
|
import { wxAuthorize } from '@/apis/mineApi.js'
|
|
|
|
let priceMap = null
|
|
|
|
/**
|
|
* 获取价目表
|
|
* @param {boolean} refresh 是否刷新
|
|
* @returns
|
|
*/
|
|
export function getPriceMap(refresh = false) {
|
|
return new Promise((resolve) => {
|
|
if (!refresh && priceMap) {
|
|
resolve(priceMap)
|
|
} else {
|
|
http.get({ url: '/wukong-fast-print/get/printing/file/marked/price/by' }).then((res) => {
|
|
priceMap = res
|
|
resolve(res)
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
let postageMap = null
|
|
/**
|
|
* 获取邮费
|
|
* @param {boolean} refresh 是否刷新
|
|
* @returns
|
|
*/
|
|
export function getPostagePrice(refresh = true, goodsId = '') {
|
|
return new Promise((resolve) => {
|
|
if (!refresh && postageMap) {
|
|
resolve(postageMap)
|
|
} else {
|
|
let data = { goodsId }
|
|
let params = goodsId ? { url: '/wukong-fast-print/get/postage/conditions', data } : { url: '/wukong-fast-print/get/postage/conditions' }
|
|
http.get(params).then((res) => {
|
|
postageMap = res
|
|
resolve(res)
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 获取OSS上传信息
|
|
* @returns
|
|
*/
|
|
export function getOssInfo() {
|
|
return http.get({
|
|
url: '/wukong-fast-print/getOssSign'
|
|
})
|
|
}
|
|
|
|
let loading = false
|
|
let resolveQueue = []
|
|
let rejectQueue = []
|
|
/**
|
|
* 获取用户tmpAuthToken和openId
|
|
* @return {Promise}
|
|
*/
|
|
export function getUserAccountInfo() {
|
|
if (loading) {
|
|
return new Promise((resolve, reject) => {
|
|
resolveQueue.push(resolve)
|
|
rejectQueue.push(reject)
|
|
})
|
|
}
|
|
loading = true
|
|
return new Promise((resolve, reject) => {
|
|
uni.login({
|
|
provider: 'weixin',
|
|
success: (loginRes) => {
|
|
let code = loginRes.code
|
|
getSession({ authCode: code })
|
|
.then((res) => {
|
|
resolve(res)
|
|
resolveQueue.forEach((fn) => {
|
|
fn(res)
|
|
})
|
|
})
|
|
.catch((err) => {
|
|
reject(err)
|
|
rejectQueue.forEach((fn) => {
|
|
fn(err)
|
|
})
|
|
})
|
|
.finally(() => {
|
|
loading = false
|
|
resolveQueue = []
|
|
rejectQueue = []
|
|
})
|
|
},
|
|
fail: (err) => {
|
|
reject(err)
|
|
rejectQueue.forEach((fn) => {
|
|
fn(err)
|
|
})
|
|
loading = false
|
|
resolveQueue = []
|
|
rejectQueue = []
|
|
}
|
|
})
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 获取微信小程序认证会话
|
|
* @param {object} data 参数 authCode
|
|
*/
|
|
export function getSession(data = {}) {
|
|
return http.post(
|
|
{
|
|
url: `/uec/get/wechat-applet-session`,
|
|
data
|
|
},
|
|
{ hideLoading: true }
|
|
)
|
|
}
|
|
// wx登陆生成器缓存
|
|
let loginGenerator = {}
|
|
// wx会话缓存
|
|
let session = {}
|
|
/**
|
|
* 微信小程序登陆
|
|
* @param {object} data
|
|
* @returns {(login:Function,getSession:Function)}
|
|
*/
|
|
export function wxLoginGenerate() {
|
|
if (loginGenerator.login && loginGenerator.getSession) {
|
|
if (Date.now() > session.expireTime) {
|
|
loginGenerator.getSession()
|
|
}
|
|
return loginGenerator
|
|
}
|
|
let completed = false
|
|
function getSession() {
|
|
getUserAccountInfo()
|
|
.then(({ tmpAuthToken, openId, expireTime }) => {
|
|
expireTime = expireTime.replace(/-/g, '/')
|
|
store.commit('setOpenId', openId)
|
|
session = { tmpAuthToken, openId, expireTime: new Date(expireTime) }
|
|
completed = true
|
|
})
|
|
.catch((err) => {
|
|
console.log(err)
|
|
completed = false
|
|
})
|
|
}
|
|
getSession()
|
|
function login() {
|
|
return new Promise((resolve, reject) => {
|
|
if (!completed) {
|
|
reject('未获取到会话,请再次点击登陆')
|
|
return
|
|
}
|
|
if (Date.now() > session.expireTime) {
|
|
getSession()
|
|
reject('会话已失效,请再次点击登陆')
|
|
return
|
|
}
|
|
uni.getUserProfile({
|
|
desc: '获取你的昵称、头像',
|
|
success: (res) => {
|
|
let iv = res.iv
|
|
let encryptedData = res.encryptedData
|
|
uni.showLoading({
|
|
title: '加载中'
|
|
})
|
|
wxAuthorize({ iv, encryptedData, tmpAuthToken: session.tmpAuthToken })
|
|
.then((info) => {
|
|
let userInfo = {
|
|
name: res.userInfo.nickName,
|
|
userId: info.userId,
|
|
avatar: res.userInfo.avatarUrl,
|
|
mobile: ''
|
|
}
|
|
store.commit('setUserInfo', userInfo)
|
|
store.commit('setToken', info.token)
|
|
resolve(userInfo)
|
|
})
|
|
.catch(() => {
|
|
reject('获取用户信息异常,请联系客服')
|
|
})
|
|
.finally(() => {
|
|
uni.hideLoading()
|
|
})
|
|
},
|
|
fail: () => {
|
|
reject('请同意昵称和头像信息的授权')
|
|
}
|
|
})
|
|
})
|
|
}
|
|
loginGenerator = { login, getSession }
|
|
return loginGenerator
|
|
}
|
|
|
|
/**
|
|
* 获取当前账号的企业实名认证地址
|
|
* @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
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 获取快递列表
|
|
* @param {object} data
|
|
*/
|
|
export function getPostageList(data) {
|
|
return http.get({
|
|
url: '/wukong-fast-print/get/printing/express/type',
|
|
data: data
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 获取网盘链接地址
|
|
* @param {object} data
|
|
*/
|
|
export function getBandingLink(data) {
|
|
return http.get({
|
|
url: '/uec/user/get/baidu-pan/authorize-page',
|
|
data: 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 })
|
|
}
|
|
|
|
/**
|
|
* 推送客户绑定
|
|
*
|
|
*/
|
|
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 storeUserId
|
|
*/
|
|
export function bindingStore(data = {}) {
|
|
return http.post(
|
|
{
|
|
url: '/wukong-fast-print/user/create/distribution-relation',
|
|
data: data
|
|
},
|
|
{ hideLoading: true }
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 获取二维码绑定的userId
|
|
* @param {object} data host QrCodeRecordId
|
|
*/
|
|
export function getQrCodeRecordId(data = {}) {
|
|
return http.get(
|
|
{
|
|
url: '/uec/verify/qrcode',
|
|
data
|
|
},
|
|
{ hideLoading: true }
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 获取半天妖客户经理列表
|
|
* @param {object} data host QrCodeRecordId
|
|
*/
|
|
export function getBTAreaList() {
|
|
return http.get(
|
|
{
|
|
url: '/wukong-fast-print/get/ban/tian/yao/area/customer/manager/list'
|
|
},
|
|
{ hideLoading: true }
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 获取活动海报
|
|
*/
|
|
export function getPoster(data = {}) {
|
|
return http.get({
|
|
url: '/uec/fission/get/poster',
|
|
data
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 用户修改用户昵称和头像
|
|
* @param {*} data
|
|
* @returns
|
|
*/
|
|
export function changeUserInfo(data = {}) {
|
|
return http.post({
|
|
url: '/uec/user/update/user-info',
|
|
data: data
|
|
})
|
|
}
|
|
|
|
export function uploadAvatar(path) {
|
|
return http.uploadFile({ data: { filePath: path } })
|
|
}
|