初始化万家商超用户端仓库

This commit is contained in:
wangxiaowei
2025-04-30 14:04:34 +08:00
commit 022c640d89
425 changed files with 160005 additions and 0 deletions

33
common/api/index.js Normal file
View 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.user_token || '',
'user-group': 1,
'Accept-Language': global.locale,
'Accept-Platform': ACCEPT_PLATFORM,
'Accept-Serial': SERIAL,
//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
View 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;
}
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)
}
}

150
common/api/url.js Normal file
View File

@ -0,0 +1,150 @@
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/63be0e760981e`, // 获取oss配置接口
UPLOAD_IMAGE_URL: `/${API_VERSION}/62ddf0e4eadde`, // 本地图片上传接口
// UPLOAD_FILE_URL: `/${API_VERSION}/5d5fa8984f0c2`, // 文件上传接口
GetVerifyCode: `/${API_VERSION}/5b5bdc44796e8`, // 发送验证码
Get5d8b062aefc08: `/${API_VERSION}/5d8b062aefc08`, // 更新用户设备的client_id
post5c78c4772da97: `/${API_VERSION}/5c78c4772da97`, //获取会员详细信息
post636d04052bb00: `/${API_VERSION}/636d04052bb00`, //钱包-1
post5cb54af125f1c: `/${API_VERSION}/5cb54af125f1c`, //个人资料修改
post636f7683cf195: `/${API_VERSION}/636f7683cf195`, //收货地址列表
post5cadd0d3a0c93: `/${API_VERSION}/636f773e8d763`, //删除收货地址
post6389ad65f28d9: `/${API_VERSION}/6389ad65f28d9`, //设置默认地址-1
post637defdbd53ef: `/${API_VERSION}/637defdbd53ef`, //添加地址 -01-3-1
post636fd7826b3ee: `/${API_VERSION}/636fd7826b3ee`, // 地址管理-获取地址信息-1
post637df1ea39d16: `/${API_VERSION}/637df1ea39d16`, //编辑地址 -01-3-1
postRegister: `/${API_VERSION}/5cad9f63e4f94`, // 注册
postPasswordLogin: `/${API_VERSION}/5c78dbfd977cf`, // 密码登录
postCodeLogin: `/${API_VERSION}/5c78dca45ebc1`, // 验证码登录
postForgotPass: `/${API_VERSION}/5caeeba9866aa`, // 验证码登录
getSwiperList: `/${API_VERSION}/636e02b419726`, // 获取轮播图 2=首页 3=分类
getCateList: `/${API_VERSION}/64895b9fd996b`, // 获取首页分类
getSecondCateList: `/${API_VERSION}/64895bd999e93`, // 获取二级分类
getShopList: `/${API_VERSION}/64895cd1c3d04`, // 获取店铺列表
getShopDetail: `/${API_VERSION}/6489628bdf8da`, // 获取店铺详情
getGoodsCate: `/${API_VERSION}/6489684eab924`, // 获取商品分类
getGoodsDetail: `/${API_VERSION}/6486cd1135581`, // 获取商品详情
getShopCommentNums: `/${API_VERSION}/648c38061c2db`, // 获取店铺评论数量
getShopCommentList: `/${API_VERSION}/648c3585e8af8`, // 获取店铺评论
getGoodsDetailGoodsList: `/${API_VERSION}/64896912c1d22`, // 获取商品详情商品列表
getAddressLabelList: `/${API_VERSION}/5ff6859e3c4fd`, // 获取地址标签
postAddAddressLabel: `/${API_VERSION}/641846b264ece`, // 添加地址标签
postEditAddressLabel: `/${API_VERSION}/5ff6859e3c4fd`, // 编辑地址标签
feedbackTypes: `/${API_VERSION}/636dbfbfd7b81`, // 获取意见反馈类型
feedbackAdd: `/${API_VERSION}/636dc0bcb5991`, // 提交意见反馈
reportTypes: `/${API_VERSION}/649f88bd22592`, // 获取举报类型
reportAdd: `/${API_VERSION}/649f89a752ad5`, // 提交举报
myFeedback: `/${API_VERSION}/636dc7436d54d`, // 获取 意见反馈
editUserinfo: `/${API_VERSION}/5cb54af125f1c`, // 修改个人信息
postAddCart: `/${API_VERSION}/648aac5e094b8`, // 添加购物车
postMinusCart: `/${API_VERSION}/648aad454d5a6`, // 减少购物车
postDelCart: `/${API_VERSION}/648aae903cbcb`, // 删除购物车
getCartList: `/${API_VERSION}/648aaee3b3ee5`, // 获取购物车列表
getSettleInfo: `/${API_VERSION}/648ab46e107ad`, // 获取结算信息
postCreateOrder: `/${API_VERSION}/648aba3bde8cb`, // 创建订单
postPayOrder: `/${API_VERSION}/63feb2ce76ac6`, // 余额支付订单
getXieyi: `/${API_VERSION}/636c78ae2216b`, // 获取协议
getOrderList: `/${API_VERSION}/648ac3f7e946f`, // 获取订单列表
getOrderDetail: `/${API_VERSION}/648ac83704d15`, // 获取订单详情
postCancelOrder: `/${API_VERSION}/648ad6ebd84be`, // 取消订单
postDelOrder: `/${API_VERSION}/648ae27931659`, // 删除订单
postAddOrderComment: `/${API_VERSION}/648c268310fae`, // 提交评价
getCommentList: `/${API_VERSION}/648d71bd4b5ff`, // 取消订单
get64a530ab891d9: `/${API_VERSION}/64a530ab891d9`, // 获取下单时积分
get64a533a675a0a: `/${API_VERSION}/64a533a675a0a`, // 下单时备注
get64a62b3d77830: `/${API_VERSION}/64a62b3d77830`, // 获取支付信息
get64a633e0099ce: `/${API_VERSION}/64a633e0099ce`, // 抵用券抵扣
getHotSearch: `/${API_VERSION}/648d6c026d7b9`, // 获取热门搜索记录
postDelSearch: `/${API_VERSION}/648d6e1945d16`, // 删除搜索记录
getSearchHistory: `/${API_VERSION}/648d6db56078d`, // 获取搜索历史
getPromotionList: `/${API_VERSION}/648bb98977746`, // 获取促销列表
getPromotionDetail: `/${API_VERSION}/648bbb939cfbd`, // 获取促销详情
getFooterList: `/${API_VERSION}/636cabd662b22`, // 获取足迹/收藏
getScoreList: `/${API_VERSION}/649165fd2d3a7`,
getContributionList: `/${API_VERSION}/64916225e43d9`, // 获取积分列表
post64916daebef0c: `/${API_VERSION}/64916daebef0c`, // 获取抵用券详情
post648fb89315da5: `/${API_VERSION}/648fb89315da5`,
post648fb49f85c1c: `/${API_VERSION}/648fb49f85c1c`,
Get636c78ae2216b: `/${API_VERSION}/636c78ae2216b`,
post649175157d9de: `/${API_VERSION}/649175157d9de`,
post649b9700c9ff1: `/${API_VERSION}/649b9700c9ff1`,
post5f6db4db8abcf: `/${API_VERSION}/5f6db4db8abcf`,
post5f6c915d69d1f: `/${API_VERSION}/5f6c915d69d1f`,
post648bc370be940: `/${API_VERSION}/648bc370be940`,
post636caf10164ce: `/${API_VERSION}/636caf10164ce`,
post6483f11510991: `/${API_VERSION}/6483f11510991`,
post649baca5b33e8: `/${API_VERSION}/649baca5b33e8`,
post649a5059d4e18: `/${API_VERSION}/649a5059d4e18`,
post649e2989f16bd: `/${API_VERSION}/649e2989f16bd`, // 删除评价
shopCategorys: `/${API_VERSION}/6484441b0a326`,
authInfoSubmit: `/${API_VERSION}/648445ffb4866`, //提交审核
getAllCate: `/${API_VERSION}/649fc8e9a8127`, // 获取全部分类
getSendTime: `/${API_VERSION}/649bd02180fce`, // 获取配送时间
scanPay: `/${API_VERSION}/649f8f5546102`, // 扫码支付
wxPay: `/${API_VERSION}/62e335233b477`,
// wxPay: `/${API_VERSION}/670cf72bd30c1`,
aliPay: `/${API_VERSION}/62e342a23919c`,
getShopStatus: `/${API_VERSION}/648450b13a386`,
authInfoCheck: `/${API_VERSION}/648450b13a386`,
getDistanceList: `/${API_VERSION}/64a298d3c38f1`,
get6437c0cb9d5b4: `/${API_VERSION}/6437c0cb9d5b4`,
post5f6010f4df24a: `/${API_VERSION}/5f6010f4df24a`,
get6437c28c6c105: `/${API_VERSION}/6437c28c6c105`,
get6437c2a476843: `/${API_VERSION}/6437c2a476843`,
get6437c2dc0386c: `/${API_VERSION}/6437c2dc0386c`,
IMAuthenticate: `/${API_VERSION}/5fbb84a54d991`,
postForgetPassword: `/${API_VERSION}/5caeeba9866aa`,
post5f5ee8e86c27b: `/${API_VERSION}/5f5ee8e86c27b`,
post5f601350edaa4: `/${API_VERSION}/5f601350edaa4`,
postBuyAgain: `/${API_VERSION}/64a8d14ccbbea`,
postUserSocialLogin: `/${API_VERSION}/5d7660a421e69`,
postLoginByWechat: `/${API_VERSION}/5d7757d28d076`,
getLevel: `/${API_VERSION}/650a64a2b2c85`,
getIsSupportSend: `/${API_VERSION}/650a4737366d0`,
getPayCode: `/${API_VERSION}/66f1200287aaa`,
post6710d191613f2: `/${API_VERSION}/6710d191613f2`,
post67306fc87dbd7: `/${API_VERSION}/67306fc87dbd7`,
post67306ffb6ec75: `/${API_VERSION}/67306ffb6ec75`,
post673572b0bebd7: `/${API_VERSION}/673572b0bebd7`,
post6735bb9284e19: `/${API_VERSION}/6735bb9284e19`,
post6747c61bebd27: `/${API_VERSION}/6747c61bebd27`,
post637c458b131e3: `/${API_VERSION}/637c458b131e3`,
post636c78ae2216b: `/${API_VERSION}/636c78ae2216b`,
post637c4d70d3aa8: `/${API_VERSION}/637c4d70d3aa8`,
getRiderInfo: `/${API_VERSION}/674d6a65730f3`,
post6757f462c15d3: `/${API_VERSION}/6757f462c15d3`,
post674d6a65730f3: `/${API_VERSION}/674d6a65730f3`,
post67ac5d9302006: `/${API_VERSION}/67ac5d9302006`,
post67ac3a198d7bd: `/${API_VERSION}/67ac3a198d7bd`,
post67fe2ff7032c4: `/${API_VERSION}/67fe2ff7032c4`
}
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 = {}