初始化商家端
This commit is contained in:
33
common/api/index.js
Normal file
33
common/api/index.js
Normal file
@ -0,0 +1,33 @@
|
||||
import Request from './request';
|
||||
import { API_BASE_URL, SERIAL, IS_DEV, ACCEPT_PLATFORM } from '../config.js';
|
||||
const http = new Request();
|
||||
http.setConfig((config) => {
|
||||
config.baseUrl = API_BASE_URL;
|
||||
return config
|
||||
})
|
||||
http.interceptor.request((config, cancel) => {
|
||||
config.header = {
|
||||
...config.header,
|
||||
'user-token': global.token || global.tokenres || '',
|
||||
'Accept-Language': global.locale,
|
||||
'Accept-Platform': ACCEPT_PLATFORM,
|
||||
'Accept-Serial': SERIAL,
|
||||
'user-group':2
|
||||
//CUSTOM_HEADER
|
||||
}
|
||||
if (IS_DEV == 2) {
|
||||
config.data = {
|
||||
...config.data,
|
||||
ismock: 0,
|
||||
}
|
||||
}
|
||||
return config;
|
||||
})
|
||||
|
||||
http.interceptor.response((response) => {
|
||||
return response;
|
||||
})
|
||||
|
||||
export {
|
||||
http
|
||||
};
|
||||
171
common/api/request.js
Normal file
171
common/api/request.js
Normal file
@ -0,0 +1,171 @@
|
||||
import { navigateToLogin } from '@/common/utils/utils.js';
|
||||
import store from '@/store/index';
|
||||
import { dev_host, mock_host, product_host, needProductUrl } from '../config.js';
|
||||
export default class Request {
|
||||
config = {
|
||||
baseUrl: '',
|
||||
header: {
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
},
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
responseType: 'text',
|
||||
success() { },
|
||||
fail() { },
|
||||
complete() { }
|
||||
}
|
||||
static posUrl(url) { /* 判断url是否为绝对路径 */
|
||||
return /(http|https):\/\/([\w.]+\/?)\S*/.test(url)
|
||||
}
|
||||
interceptor = {
|
||||
request: (f) => {
|
||||
if (f) {
|
||||
this.requestBeforeFun = f
|
||||
}
|
||||
},
|
||||
response: (f) => {
|
||||
if (f) {
|
||||
this.requestComFun = f
|
||||
}
|
||||
}
|
||||
}
|
||||
static requestBeforeFun(config) {
|
||||
return config
|
||||
}
|
||||
static requestComFun(response) {
|
||||
return response
|
||||
}
|
||||
|
||||
setConfig(f) {
|
||||
this.config = f(this.config)
|
||||
return this
|
||||
}
|
||||
testNeedProductUrl(url) {
|
||||
return needProductUrl.findIndex(ele => ele == url) != -1;
|
||||
}
|
||||
request(options = {}) {
|
||||
if (this.testNeedProductUrl(options.url)) {
|
||||
options.baseUrl = product_host + '/api';
|
||||
} else {
|
||||
options.baseUrl = options.baseUrl || this.config.baseUrl;
|
||||
}
|
||||
console.log('options.url=', options.baseUrl)
|
||||
options.dataType = options.dataType || this.config.dataType;
|
||||
if (options.url == undefined) return Promise.reject();
|
||||
options.url = Request.posUrl(options.url) ? options.url : (options.baseUrl + options.url);
|
||||
options.data = options.data || {};
|
||||
options.header = options.header || this.config.header;
|
||||
options.method = options.method || this.config.method;
|
||||
if (options['Content-Type']) options.header['Content-Type'] = options['Content-Type'];
|
||||
return new Promise((resolve, reject) => {
|
||||
let next = true
|
||||
let _config = null
|
||||
options.complete = (response) => {
|
||||
let statusCode = response.statusCode
|
||||
response.config = _config
|
||||
response = this.requestComFun(response)
|
||||
if (statusCode != 200) {
|
||||
let errMessage = '';
|
||||
switch (statusCode) {
|
||||
case 400:
|
||||
errMessage = global.i18n.t('请求错误(400)');
|
||||
break;
|
||||
case 401:
|
||||
errMessage = global.i18n.t('未授权,请重新登录(401)');
|
||||
uni.showToast({
|
||||
title: global.i18n.t('登录失效'),
|
||||
icon: 'none',
|
||||
position: 'bottom',
|
||||
duration: 1500
|
||||
})
|
||||
store.commit('logout');
|
||||
break;
|
||||
case 403:
|
||||
errMessage = global.i18n.t('拒绝访问(403)');
|
||||
break;
|
||||
case 404:
|
||||
errMessage = global.i18n.t('请求出错(404)');
|
||||
break;
|
||||
case 408:
|
||||
errMessage = global.i18n.t('请求超时(408)');
|
||||
break;
|
||||
case 500:
|
||||
errMessage = global.i18n.t('服务器错误(500)');
|
||||
break;
|
||||
case 501:
|
||||
errMessage = global.i18n.t('服务未实现(501)');
|
||||
break;
|
||||
case 502:
|
||||
errMessage = global.i18n.t('网络错误(502)');
|
||||
break;
|
||||
case 503:
|
||||
errMessage = global.i18n.t('服务不可用(503)');
|
||||
break;
|
||||
case 504:
|
||||
errMessage = global.i18n.t('网络超时(504)');
|
||||
break;
|
||||
case 505:
|
||||
errMessage = global.i18n.t('HTTP版本不受支持(505)');
|
||||
break;
|
||||
default:
|
||||
// errMessage = global.i18n.t("服务器错误!");
|
||||
errMessage = '';
|
||||
break;
|
||||
}
|
||||
|
||||
if (statusCode != 401) {
|
||||
if (errMessage) {
|
||||
uni.showToast({
|
||||
title: errMessage,
|
||||
icon: 'none',
|
||||
position: 'bottom',
|
||||
duration: 1500
|
||||
})
|
||||
}
|
||||
uni.$emit('netWorkError', { msg: global.i18n.t('服务器太拥挤了~请您稍后重试') })
|
||||
}
|
||||
reject({ statusCode, errMessage })
|
||||
} else {
|
||||
let _code = response.data.code;
|
||||
if (_code == '-201' || _code == '-202' || _code == '-203') {
|
||||
uni.showToast({
|
||||
title: global.i18n.t('登录失效,请重新登录'),
|
||||
icon: 'none',
|
||||
})
|
||||
store.commit("logout");
|
||||
navigateToLogin();
|
||||
} else {
|
||||
resolve(response)
|
||||
}
|
||||
}
|
||||
uni.stopPullDownRefresh();
|
||||
}
|
||||
let cancel = (t = 'handle cancel') => {
|
||||
let err = {
|
||||
errMsg: t,
|
||||
config: afC
|
||||
}
|
||||
reject(err)
|
||||
next = false
|
||||
}
|
||||
let afC = { ...this.config, ...options }
|
||||
_config = { ...afC, ...this.requestBeforeFun(afC, cancel) }
|
||||
if (!next) return
|
||||
uni.request(_config)
|
||||
})
|
||||
}
|
||||
|
||||
get(url, data, options = {}) {
|
||||
options.url = url
|
||||
options.data = data
|
||||
options.method = 'GET'
|
||||
return this.request(options)
|
||||
}
|
||||
|
||||
post(url, data, options = {}) {
|
||||
options.url = url
|
||||
options.data = data
|
||||
options.method = 'POST'
|
||||
return this.request(options)
|
||||
}
|
||||
}
|
||||
188
common/api/url.js
Normal file
188
common/api/url.js
Normal file
@ -0,0 +1,188 @@
|
||||
import {
|
||||
API_VERSION,
|
||||
PAAS_URL
|
||||
} from '@/common/config.js';
|
||||
const publicApi = {
|
||||
postRecommentGoods: `/${API_VERSION}/5fd9a32379116`, //智能推荐
|
||||
numberOfShoppingCart: ``, //获取购物车数量
|
||||
publicUpdateAPP: `/${API_VERSION}/5b5bdc44796e8`, // 静默更新
|
||||
publicUpdateAPP1: `/${API_VERSION}/6728701f5e8bc`,
|
||||
queryAutograph: `/v1/6454d9663e508`, // 获取oss配置接口
|
||||
UPLOAD_IMAGE_URL: `/${API_VERSION}/62ddf0e4eadde`, // 本地图片上传接口
|
||||
// UPLOAD_FILE_URL: `/${API_VERSION}/5d5fa8984f0c2`, // 文件上传接口
|
||||
GetVerifyCode: `/${API_VERSION}/5b5bdc44796e8`, // 发送验证码
|
||||
Get636c78ae2216b: `/${API_VERSION}/636c78ae2216b`, // 协议
|
||||
Get6483f11510991: `/${API_VERSION}/6483f11510991`, // 获取公共信息
|
||||
Get5d8b062aefc08: `/${API_VERSION}/5d8b062aefc08`, // 更新用户设备的client_id(
|
||||
|
||||
postloginByAccount: `/${API_VERSION}/5c78dbfd977cf`, // 账号密码登录
|
||||
postUserSocialLogin: `/${API_VERSION}/5d7660a421e69`, //第三方登录
|
||||
userRegister:`/${API_VERSION}/5cad9f63e4f94`,//会员注册
|
||||
inviteCodeVerification: `/${API_VERSION}/60fb7b6712d79`, //验证邀请码是否正确
|
||||
postForgetPassword: `/${API_VERSION}/5caeeba9866aa`, // 忘记密码
|
||||
postUserMobileLogin: `/${API_VERSION}/5c78dca45ebc1`, //手机号加验证码登录注册
|
||||
post61501de16b9ff: `/${API_VERSION}/61501de16b9ff`, //联系我们
|
||||
post5f6db4db8abcf: `/${API_VERSION}/5f6db4db8abcf`, //校验验证码
|
||||
post5f6c915d69d1f: `/${API_VERSION}/5f6c915d69d1f`, //修改手机号
|
||||
|
||||
postGetUserInfo: `/${API_VERSION}/5c78c4772da97`, //获取会员详细信息
|
||||
post648fb49f85c1c: `/${API_VERSION}/648fb49f85c1c`, //获取粉丝邀请数据
|
||||
post648fb89315da5: `/${API_VERSION}/648fb89315da5`, //获取粉丝列表
|
||||
post64916225e43d9: `/${API_VERSION}/64916225e43d9`, //查询积分记录
|
||||
post649165fd2d3a7: `/${API_VERSION}/649165fd2d3a7`, //查询抵用券记录
|
||||
post64916daebef0c: `/${API_VERSION}/64916daebef0c`, //查询抵用券记录详情
|
||||
post649175157d9de: `/${API_VERSION}/649175157d9de`, //查询收益明细
|
||||
post649b9700c9ff1: `/${API_VERSION}/649b9700c9ff1`, //获取推广订单
|
||||
|
||||
|
||||
|
||||
|
||||
post636dbfbfd7b81: `/${API_VERSION}/636dbfbfd7b81`, //查询投诉建议类型
|
||||
post636dc0bcb5991: `/${API_VERSION}/636dc0bcb5991`, //提交意见反馈
|
||||
post636dc7436d54d: `/${API_VERSION}/636dc7436d54d`, //会员投诉建议,意见反馈
|
||||
|
||||
// 打印机
|
||||
post6486853cd3104: `/${API_VERSION}/6486853cd3104`, //查询打印机
|
||||
post648684c90ec38: `/${API_VERSION}/648684c90ec38`, //添加打印机
|
||||
post6486856ed0d81: `/${API_VERSION}/6486856ed0d81`, //解绑打印机
|
||||
|
||||
// 商品
|
||||
post6486d3d711b65: `/${API_VERSION}/6486d3d711b65`, //获取商品列表
|
||||
post6486d565ebaf7: `/${API_VERSION}/6486d565ebaf7`, //商家端-获取商品详情
|
||||
post6486d8abe5e20: `/${API_VERSION}/6486d8abe5e20`, //添加/编辑商品
|
||||
post6486d6892d380: `/${API_VERSION}/6486d6892d380`, //修改商品上下架
|
||||
post6486d6daa3505: `/${API_VERSION}/6486d6daa3505`, //批量上下架
|
||||
post6486d74a10d1c: `/${API_VERSION}/6486d74a10d1c`, //删除商品
|
||||
post6486d7cae40ad: `/${API_VERSION}/6486d7cae40ad`, //批量删除商品
|
||||
post6486bc83caec2: `/${API_VERSION}/6486bc83caec2`, //添加商家分类
|
||||
post6486c879ba7f3: `/${API_VERSION}/6486c879ba7f3`, //修改商品分类
|
||||
post6486c9004af38: `/${API_VERSION}/6486c9004af38`, //删除商品分类
|
||||
post6487d63dc3e21: `/${API_VERSION}/6487d63dc3e21`, //商品分类列表
|
||||
|
||||
getTypeId: `/${API_VERSION}/6004ff1455b20`, //添加规格-第一步:通过商品名称获取规格类型
|
||||
skuManagerAddSpec: `/${API_VERSION}/6004ffea8f4a2`, //添加规格-第二步:添加商品规格
|
||||
get60052c4e191c8: `/${API_VERSION}/60052c4e191c8`, //删除规格
|
||||
deleteItem: `/${API_VERSION}/60052d6002ee7`, //删除属性
|
||||
|
||||
post648826ea7189c: `/${API_VERSION}/648826ea7189c`, //图库上传照片
|
||||
post6488278581ec3: `/${API_VERSION}/6488278581ec3`, //查询图库列表
|
||||
|
||||
post64893775ce02c: `/${API_VERSION}/64893775ce02c`, //账户余额信息
|
||||
post6486e03b64354: `/${API_VERSION}/6486e03b64354`, //资金统计
|
||||
authInfoCheck: `/${API_VERSION}/648450b13a386`, // 获取商家信息
|
||||
shopCategorys: `/${API_VERSION}/6484441b0a326`, //获取商家分类
|
||||
shopCategorys1: `/${API_VERSION}/6484441b0a326`, //获取商家分类
|
||||
authInfoSubmit: `/${API_VERSION}/648445ffb4866`, //提交审核
|
||||
Get64868bb21965a: `/${API_VERSION}/64868bb21965a`, //修改店铺资料
|
||||
post648687ea70bc9: `/${API_VERSION}/648687ea70bc9`, //查询营业时间
|
||||
post6486873b6ee87: `/${API_VERSION}/6486873b6ee87`, //添加时间
|
||||
post648687a2c8509: `/${API_VERSION}/648687a2c8509`, //删除营业时间
|
||||
post648d0d73c1d23: `/${API_VERSION}/648d0d73c1d23`, //修改营业时间
|
||||
post650a64a2b2c85: `/${API_VERSION}/650a64a2b2c85`, //抽佣的档次
|
||||
post649baca5b33e8: `/${API_VERSION}/649baca5b33e8`, //查询排行榜
|
||||
|
||||
|
||||
|
||||
statistics: `/${API_VERSION}/600a2577b1e77`, //资金记录
|
||||
editShopMode: `/${API_VERSION}/648c17f53b93e`, //修改配送方式
|
||||
editShopStatus: `/${API_VERSION}/6728838e33512`, //修改开闭店
|
||||
post648c1964854c9: `/${API_VERSION}/648c1964854c9`, //查询配送方式审核记录
|
||||
postGetShopInfo: `/${API_VERSION}/648450b13a386`, //获取商家信息
|
||||
getCommentNum: `/${API_VERSION}/648c38061c2db`, //获取评论数量
|
||||
|
||||
|
||||
getShopSwiper: `/${API_VERSION}/648689bdd34be`, //获取轮播图
|
||||
getAddShopSwiper: `/${API_VERSION}/648688fbb5faf`, //添加/编辑轮播图
|
||||
getDelShopSwiper: `/${API_VERSION}/648689fda3847`, //删除轮播图
|
||||
get6486897b20c58: `/${API_VERSION}/6486897b20c58`, //设置跳转商品
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
getMoneyDetail: `/${API_VERSION}/636dfee37deef`, //金额流水明细
|
||||
// getMyMoney: `/${API_VERSION}/5cc45274d6be9`, //获取金额信息
|
||||
getMyCashMoney: `/${API_VERSION}/64893775ce02c`, //获取金额信息
|
||||
getmyMoneyText: `/${API_VERSION}/614c2b726ef99`, //我的钱包金额信息
|
||||
get649bdc9a8a38f: `/${API_VERSION}/649bdc9a8a38f`, //财务报表
|
||||
|
||||
|
||||
isSetPay: `/${API_VERSION}/5f64a4d364b44`, //判断用户是否设置支付密码
|
||||
getWithdrawAccount: `/${API_VERSION}/636cbb376d5d8`, //获取绑定的提现账号
|
||||
withdraw: `/${API_VERSION}/636e4ff0626ef`, //提现申请
|
||||
postLimitWithdraw: `/${API_VERSION}/6483f11510991`, //最小提现金额
|
||||
getWithdrawRule: `/${API_VERSION}/6036098f4807f`, //提现规则
|
||||
|
||||
postBindWithdrawAccount: `/${API_VERSION}/636cc0cc8d6cc`, //绑定提现账号
|
||||
getWithdrawDetail: `/${API_VERSION}/6461a2c3ba564`, //提现明细
|
||||
get636e3e94b5605: `/${API_VERSION}/636e3e94b5605`, //待结算明细
|
||||
|
||||
appealTypes: `/${API_VERSION}/648d0c6894179`, //获取投诉类型
|
||||
appealAdd: `/${API_VERSION}/648d0eaa86c1a`, //提交投诉
|
||||
appealAddReply: `/${API_VERSION}/648c3b2d6788c`, //评论回复
|
||||
|
||||
getCommentList: `/${API_VERSION}/648c3585e8af8`, //获取评论数据
|
||||
getHistoryOrder: `/${API_VERSION}/648ae402c26e1`, //获取历史订单
|
||||
delOrder: `/${API_VERSION}/648ae27931659`, //删除订单
|
||||
|
||||
orderDetails: `/${API_VERSION}/648aeb7f076fc`, //订单详情
|
||||
getOrderNumber: `/${API_VERSION}/6490016caede8`, //订单数量
|
||||
|
||||
Get648aeed87f7e3: `/${API_VERSION}/648aeed87f7e3`, //确认接单
|
||||
cancelOrder: `/${API_VERSION}/648ad6ebd84be`, //取消订单
|
||||
sureTakeGoods: `/${API_VERSION}/648aef77cefe4`, //备货完成
|
||||
confirmDelivery: `/${API_VERSION}/649ab7653c7a3`, //自提订单确认完成
|
||||
Get649ba7b664ecd: `/${API_VERSION}/649ba7b664ecd`, //打印小票
|
||||
|
||||
|
||||
// : '/v1/6008dbb12366a', // 确认送达
|
||||
|
||||
|
||||
// startDelivery: '/v1/600e208cddba9', // 开始配送
|
||||
// writeOffOrder: '/v1/600927868177a', // 核销订单
|
||||
// confirmDelivery: '/v1/600e20ba2c490', // 确认送达
|
||||
// postRefundPass: '/v1/6120ad445d8cb', // 同意退款
|
||||
// postRefundRefuse: '/v1/6120acadd7e7b', // 拒绝退款
|
||||
// postRefundRefund: '/v1/61766adc40e31', // 商家端发起退款
|
||||
|
||||
getMessageNum: `/${API_VERSION}/6437c3691ab60`, //未读消息数量
|
||||
get6437c0cb9d5b4: `/${API_VERSION}/6437c0cb9d5b4`, //获取站内信类型列表
|
||||
get6437c2dc0386c: `/${API_VERSION}/6437c2dc0386c`, //获取消息列表
|
||||
get6437c28c6c105: `/${API_VERSION}/6437c28c6c105`, //获取公告列表
|
||||
get6437c2a476843: `/${API_VERSION}/6437c2a476843`, //获取公告详情
|
||||
|
||||
|
||||
post5f601350edaa4: `/${API_VERSION}/5f601350edaa4`, // 聊天能力-获得两人的聊天记录
|
||||
post5f5ee8e86c27b: `/${API_VERSION}/5f5ee8e86c27b`, //发送消息
|
||||
post5f6010f4df24a: `/${API_VERSION}/5f6010f4df24a`, //获得我的会话列表
|
||||
post5fbb84a54d991: `/${API_VERSION}/5fbb84a54d991`, //聊天能力-注册并生成IM登录所用的票据
|
||||
|
||||
post671360dab5ddf: `/${API_VERSION}/671360dab5ddf`, // 获取城市编码
|
||||
post66ee7c8134ec4: `/${API_VERSION}/66ee7c8134ec4`, // 文件上传
|
||||
post66ed3644454b6: `/${API_VERSION}/66ed3644454b6`, // 分账认证
|
||||
post671358ea7dda0: `/${API_VERSION}/671358ea7dda0`, // 银行列表
|
||||
post6716176fcb1ff: `/${API_VERSION}/6716176fcb1ff`, // 获取分账认证信息
|
||||
|
||||
post67306fc87dbd7: `/${API_VERSION}/67306fc87dbd7`,
|
||||
post67306ffb6ec75: `/${API_VERSION}/67306ffb6ec75`,
|
||||
post6747c61bebd27: `/${API_VERSION}/6747c61bebd27`,
|
||||
post673572b0bebd7: `/${API_VERSION}/673572b0bebd7`,
|
||||
|
||||
post637c458b131e3: `/${API_VERSION}/637c458b131e3`,
|
||||
post636c78ae2216b: `/${API_VERSION}/636c78ae2216b`,
|
||||
post637c4d70d3aa8: `/${API_VERSION}/637c4d70d3aa8`,
|
||||
}
|
||||
const modulesFiles = require.context('../../pages/', true, /\api.js$/);
|
||||
const modules = modulesFiles.keys().reduce((modules, modulePath) => {
|
||||
const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1');
|
||||
const value = modulesFiles(modulePath);
|
||||
Object.assign(modules, value.default);
|
||||
return modules;
|
||||
}, publicApi);
|
||||
export default modules;
|
||||
/**
|
||||
* 如果是第一套代码,删掉下面的对象即可
|
||||
* 如果不是第一套代码,导出下面的对象即可
|
||||
* 如果哪一套的代码都有,下面的对象合并到上面的对象即可
|
||||
* */
|
||||
const del = {}
|
||||
Reference in New Issue
Block a user