Merge branch 'main' of http://192.168.195.14:3000/shang/guyu
This commit is contained in:
commit
e0fdca0197
30
common/env.js
Normal file
30
common/env.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* 项目环境配置文件
|
||||
* 集中管理所有环境相关的配置参数
|
||||
*/
|
||||
|
||||
// 开发环境配置
|
||||
const development = {
|
||||
// API基础URL
|
||||
// baseUrl: 'https://ydsapi.zpc-xy.com',
|
||||
baseUrl: 'https://guyu.zpc-xy.com',
|
||||
imageUrl: 'https://guyu-1308826010.cos.ap-shanghai.myqcloud.com',
|
||||
|
||||
};
|
||||
|
||||
// 生产环境配置
|
||||
const production = {
|
||||
baseUrl: 'https://guyu.zpc-xy.com/',
|
||||
imageUrl: 'https://guyu-1308826010.cos.ap-shanghai.myqcloud.com',
|
||||
|
||||
};
|
||||
|
||||
// 根据环境变量选择对应配置
|
||||
let currentEnv = development;//production;//testing;
|
||||
// 衍生配置
|
||||
const config = {
|
||||
...currentEnv,
|
||||
apiBaseUrl: currentEnv.baseUrl + '/api/',
|
||||
};
|
||||
|
||||
export default config;
|
||||
11
common/gy.js
Normal file
11
common/gy.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import * as utils1 from './utils';
|
||||
import * as utils2 from './system/cacheService';
|
||||
import * as utils3 from './system/router';
|
||||
import * as utils4 from './system/request';
|
||||
// 动态合并所有导出到 yds 对象
|
||||
export const gy = {
|
||||
...utils1,
|
||||
...utils2,
|
||||
...utils3,
|
||||
...utils4,
|
||||
};
|
||||
18
common/server/config.js
Normal file
18
common/server/config.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
export const getConfig = async () => {
|
||||
let res = await request.get('Common/GetConfigV3', {});
|
||||
return res.data;
|
||||
}
|
||||
|
||||
export class Config {
|
||||
constructor() {
|
||||
this.config = null;
|
||||
}
|
||||
|
||||
async getConfig() {
|
||||
if (this.config == null) {
|
||||
this.config = await getConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
23
common/server/home.js
Normal file
23
common/server/home.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
import { getAdvertList } from '@/common/server/interface/advert'
|
||||
import { noticeInfo as getNoticeInfo } from '@/common/server/interface/notice'
|
||||
|
||||
/**
|
||||
* 获取首页关键数据
|
||||
* @returns 首页数据
|
||||
*/
|
||||
export const getHomePage = async () => {
|
||||
// 获取首页banner位
|
||||
const advertTask = getAdvertList("TplIndexBanner1");
|
||||
// 获取首页滚动文字
|
||||
const noticeInfoTask = getNoticeInfo(9);
|
||||
|
||||
const results = await Promise.allSettled([advertTask, noticeInfoTask]);
|
||||
const [advertList, noticeInfo] = results.map(result =>
|
||||
result.status === 'fulfilled' ? result.value : null
|
||||
);
|
||||
return {
|
||||
advertList,
|
||||
noticeInfo
|
||||
};
|
||||
}
|
||||
27
common/server/interface/advert.js
Normal file
27
common/server/interface/advert.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 获取滚动条
|
||||
* @param {String} code 编码 TplIndexBanner1:首页轮播图
|
||||
* @returns
|
||||
*/
|
||||
export const getAdvertList = async (code) => {
|
||||
if (code == null || code == "") {
|
||||
return [];
|
||||
}
|
||||
const res = await request.getOrCache("advert/GetAdvertList", { code: code });
|
||||
return res.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取广告位置信息
|
||||
* @param {Object} data 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getPositionList = async (data) => {
|
||||
const res = await request.post("Advert/GetPositionList", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
115
common/server/interface/agent.js
Normal file
115
common/server/interface/agent.js
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 申请成为代理商接口
|
||||
* @param {Object} data 代理商申请数据
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const applyAgent = async (data) => {
|
||||
const res = await request.post("Agent/ApplyAgent", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取代理商排行
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getAgentRanking = async (params) => {
|
||||
const res = await request.post("Agent/GetAgentRanking", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据查询条件获取分页数据
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getGoodsPageList = async (params) => {
|
||||
const res = await request.post("Agent/GetGoodsPageList", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的订单统计
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getOrderSum = async () => {
|
||||
const res = await request.post("Agent/GetOrderSum");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺信息
|
||||
* @param {number} id 店铺ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getStoreInfo = async (id) => {
|
||||
const res = await request.post("Agent/GetStoreInfo", { id });
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的下级用户数量
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getTeamSum = async () => {
|
||||
const res = await request.post("Agent/GetTeamSum");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户是否可以成为代理商
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const info = async () => {
|
||||
const res = await request.post("Agent/Info");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 我推广的订单
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const myOrder = async (params) => {
|
||||
const res = await request.post("Agent/MyOrder", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺设置
|
||||
* @param {Object} data 店铺设置数据
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const setStore = async (data) => {
|
||||
const res = await request.post("Agent/SetStore", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
40
common/server/interface/article.js
Normal file
40
common/server/interface/article.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 获取文章列表
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getArticleList = async (params) => {
|
||||
const res = await request.post("Article/GetArticleList", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个文章内容
|
||||
* @param {number} id 文章ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getArticleDetail = async (id) => {
|
||||
const res = await request.post("Article/GetArticleDetail", { id });
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取通知列表
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const noticeList = async (params) => {
|
||||
const res = await request.post("Article/NoticeList", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
66
common/server/interface/cart.js
Normal file
66
common/server/interface/cart.js
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 添加单个货品到购物车
|
||||
* @param {Object} data 包含商品信息的数据
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const addCart = async (data) => {
|
||||
const res = await request.post("Cart/AddCart", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除购物车商品
|
||||
* @param {number} id 购物车ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const doDelete = async (id) => {
|
||||
const res = await request.post("Cart/DoDelete", { id });
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取购物车列表
|
||||
* @param {Object} params 参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getList = async (params) => {
|
||||
const res = await request.post("Cart/GetList", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置购物车商品数量
|
||||
* @param {Object} data 设置数量参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const setCartNum = async (data) => {
|
||||
const res = await request.post("Cart/SetCartNum", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据提交的数据判断哪些购物券可以使用
|
||||
* @param {Object} data 优惠券判断参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getCartAvailableCoupon = async (data) => {
|
||||
const res = await request.post("Cart/GetCartAvailableCoupon", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
74
common/server/interface/common.js
Normal file
74
common/server/interface/common.js
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 获取层级分配后的区域信息
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getAreas = async () => {
|
||||
const res = await request.post("Common/GetAreas");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回配置数据文件V2.0
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getConfigV2 = async () => {
|
||||
const res = await request.post("Common/GetConfigV2");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回配置数据文件V3.0
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getConfigV3 = async () => {
|
||||
const res = await request.get("Common/GetConfigV3");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商城关键词说明列表
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getServiceDescription = async () => {
|
||||
const res = await request.post("Common/GetServiceDescription");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口测试反馈
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const interFaceTest = async () => {
|
||||
const res = await request.post("Common/InterFaceTest");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传附件通用接口
|
||||
* @param {FormData} formData 上传的表单数据
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const uploadImages = async (formData) => {
|
||||
const res = await request.post("Common/UploadImages", formData);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
66
common/server/interface/coupon.js
Normal file
66
common/server/interface/coupon.js
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 获取可领取的优惠券
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const couponList = async (params) => {
|
||||
const res = await request.post("Coupon/CouponList", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取优惠券详情
|
||||
* @param {number} id 优惠券ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const couponDetail = async (id) => {
|
||||
const res = await request.post("Coupon/CouponDetail", { id });
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户领取优惠券
|
||||
* @param {number} id 优惠券ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getCoupon = async (id) => {
|
||||
const res = await request.post("Coupon/GetCoupon", { id });
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户输入code领取优惠券
|
||||
* @param {Object} data 包含code的数据
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getCouponKey = async (data) => {
|
||||
const res = await request.post("Coupon/GetCouponKey", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户已领取的优惠券
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const userCoupon = async (params) => {
|
||||
const res = await request.post("Coupon/UserCoupon", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
102
common/server/interface/distribution.js
Normal file
102
common/server/interface/distribution.js
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 申请成为分销商接口
|
||||
* @param {Object} data 分销商申请数据
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const applyDistribution = async (data) => {
|
||||
const res = await request.post("Distribution/ApplyDistribution", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商排行
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getDistributionRanking = async (params) => {
|
||||
const res = await request.post("Distribution/GetDistributionRanking", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的订单统计
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getOrderSum = async () => {
|
||||
const res = await request.post("Distribution/GetOrderSum");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺信息
|
||||
* @param {number} id 店铺ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getStoreInfo = async (id) => {
|
||||
const res = await request.post("Distribution/GetStoreInfo", { id });
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的下级用户数量
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getTeamSum = async () => {
|
||||
const res = await request.post("Distribution/GetTeamSum");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户是否可以成为分销商
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const info = async () => {
|
||||
const res = await request.post("Distribution/Info");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 我推广的订单
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const myOrder = async (params) => {
|
||||
const res = await request.post("Distribution/MyOrder", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺设置
|
||||
* @param {Object} data 设置数据
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const setStore = async (data) => {
|
||||
const res = await request.post("Distribution/SetStore", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
27
common/server/interface/form.js
Normal file
27
common/server/interface/form.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 万能表单/提交表单
|
||||
* @param {Object} data 表单数据
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const addSubmit = async (data) => {
|
||||
const res = await request.post("Form/AddSubmit", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 万能表单/获取活动商品详情
|
||||
* @param {Object} data 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getFormDetial = async (data) => {
|
||||
const res = await request.post("Form/GetFormDetial", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
141
common/server/interface/good.js
Normal file
141
common/server/interface/good.js
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 获取所有分类
|
||||
* @returns
|
||||
*/
|
||||
export const getAllCategories = async () => {
|
||||
const res = await request.get("Good/GetAllCategories");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取商品评价列表分页数据
|
||||
* @returns {}
|
||||
*/
|
||||
export const getGoodsComment = async (otherData, id, page, limit, order, where) => {
|
||||
const res = await request.post("Good/GetGoodsComment", {
|
||||
"otherData": otherData,
|
||||
"id": id,
|
||||
"page": page,
|
||||
"limit": limit,
|
||||
"order": order,
|
||||
"where": where
|
||||
});
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品详情
|
||||
* @param {number} id 商品ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getDetial = async (id) => {
|
||||
const res = await request.get("Good/GetDetial", { params: { id } });
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据Token获取商品详情
|
||||
* @param {number} id 商品ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getDetialByToken = async (id) => {
|
||||
const res = await request.post("Good/GetDetialByToken", { id });
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据查询条件获取分页数据
|
||||
* @param {number} page 页码
|
||||
* @param {number} limit 每页数量
|
||||
* @param {string} order 排序
|
||||
* @param {string} where 条件
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getGoodsPageList = async (page, limit, order, where) => {
|
||||
const res = await request.get("Good/GetGoodsPageList", {
|
||||
params: {
|
||||
page,
|
||||
limit,
|
||||
order,
|
||||
where
|
||||
}
|
||||
});
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个商品参数
|
||||
* @param {number} id 商品ID
|
||||
* @param {Object} data 附加数据
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getGoodsParams = async (id, data = {}) => {
|
||||
const res = await request.get("Good/GetGoodsParams", {
|
||||
params: {
|
||||
id,
|
||||
data
|
||||
}
|
||||
});
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取随机推荐商品
|
||||
* @param {number} id 商品ID
|
||||
* @param {Object} data 附加数据
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getGoodsRecommendList = async (id, data = {}) => {
|
||||
const res = await request.get("Good/GetGoodsRecommendList", {
|
||||
params: {
|
||||
id,
|
||||
data
|
||||
}
|
||||
});
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个货品信息
|
||||
* @param {number} id 货品ID
|
||||
* @param {string} type 类型
|
||||
* @param {number} groupId 分组ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getProductInfo = async (id, type, groupId) => {
|
||||
const res = await request.get("Good/GetProductInfo", {
|
||||
params: {
|
||||
id,
|
||||
type,
|
||||
groupId
|
||||
}
|
||||
});
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
27
common/server/interface/group.js
Normal file
27
common/server/interface/group.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 获取秒杀团购详情
|
||||
* @param {Object} data 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getGoodsDetial = async (data) => {
|
||||
const res = await request.post("Group/GetGoodsDetial", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取秒杀团购列表
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getList = async (params) => {
|
||||
const res = await request.post("Group/GetList", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
27
common/server/interface/notice.js
Normal file
27
common/server/interface/notice.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 获取单个公告内容
|
||||
* @param {number} id 公告ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const noticeInfo = async (id) => {
|
||||
const res = await request.getOrCache("Notice/NoticeInfo", { id });
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公告列表
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const noticeList = async (params) => {
|
||||
const res = await request.post("Notice/NoticeList", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
131
common/server/interface/order.js
Normal file
131
common/server/interface/order.js
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
* @param {Object} data 订单数据
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const createOrder = async (data) => {
|
||||
const res = await request.post("Order/CreateOrder", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取个人订单列表
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getOrderList = async (params) => {
|
||||
const res = await request.post("Order/GetOrderList", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单不同状态的数量
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getOrderStatusNum = async (params) => {
|
||||
const res = await request.post("Order/GetOrderStatusNum", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
* @param {string} id 订单ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const orderDetails = async (id) => {
|
||||
const res = await request.post("Order/OrderDetails", { id });
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订单
|
||||
* @param {string} id 订单ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const cancelOrder = async (id) => {
|
||||
const res = await request.post("Order/CancelOrder", { id });
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除订单
|
||||
* @param {string} id 订单ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const deleteOrder = async (id) => {
|
||||
const res = await request.post("Order/DeleteOrder", { id });
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认签收订单
|
||||
* @param {string} id 订单ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const orderConfirm = async (id) => {
|
||||
const res = await request.post("Order/OrderConfirm", { id });
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加售后单
|
||||
* @param {Object} data 售后单数据
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const addAftersales = async (data) => {
|
||||
const res = await request.post("Order/AddAftersales", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取售后单列表
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const aftersalesList = async (params) => {
|
||||
const res = await request.post("Order/AftersalesList", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取售后单详情
|
||||
* @param {string} id 售后单ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const aftersalesinfo = async (id) => {
|
||||
const res = await request.post("Order/Aftersalesinfo", { id });
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
27
common/server/interface/page.js
Normal file
27
common/server/interface/page.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 获取页面布局数据
|
||||
* @param {Object} data 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getPageConfig = async (data) => {
|
||||
const res = await request.post("Page/GetPageConfig", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户购买记录
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getRecod = async (params) => {
|
||||
const res = await request.post("Page/GetRecod", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
27
common/server/interface/payments.js
Normal file
27
common/server/interface/payments.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 支付确认页面取信息
|
||||
* @param {Object} params 支付参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const checkPay = async (params) => {
|
||||
const res = await request.post("Payments/CheckPay", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付单详情
|
||||
* @param {string} id 支付单ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getInfo = async (id) => {
|
||||
const res = await request.post("Payments/GetInfo", { id });
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
53
common/server/interface/pintuan.js
Normal file
53
common/server/interface/pintuan.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 获取拼团商品信息
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getGoodsInfo = async (params) => {
|
||||
const res = await request.post("PinTuan/GetGoodsInfo", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团列表
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getList = async (params) => {
|
||||
const res = await request.post("PinTuan/GetList", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团团队
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getPinTuanTeam = async (params) => {
|
||||
const res = await request.post("PinTuan/GetPinTuanTeam", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团产品信息
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getProductInfo = async (params) => {
|
||||
const res = await request.post("PinTuan/GetProductInfo", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
92
common/server/interface/service.js
Normal file
92
common/server/interface/service.js
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 添加服务订单
|
||||
* @param {Object} data 服务订单数据
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const addServiceOrder = async (data) => {
|
||||
const res = await request.post("Service/AddServiceOrder", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务详情
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getDetails = async (params) => {
|
||||
const res = await request.post("Service/GetDetails", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务分页列表
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getPageList = async (params) => {
|
||||
const res = await request.post("Service/GetPageList", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取票务信息
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getTicketInfo = async (params) => {
|
||||
const res = await request.post("Service/GetTicketInfo", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除日志
|
||||
* @param {Object} params 删除参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const logDelete = async (params) => {
|
||||
const res = await request.post("Service/LogDelete", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取验证分页列表
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const verificationPageList = async (params) => {
|
||||
const res = await request.post("Service/VerificationPageList", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证票据
|
||||
* @param {Object} params 验证参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const verificationTicket = async (params) => {
|
||||
const res = await request.post("Service/VerificationTicket", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
166
common/server/interface/store.js
Normal file
166
common/server/interface/store.js
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 获取默认商店
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getDefaultStore = async () => {
|
||||
const res = await request.post("Store/GetDefaultStore");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商家订单分页
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getOrderPageByMerchant = async (params) => {
|
||||
const res = await request.post("Store/GetOrderPageByMerchant", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商家订单搜索分页
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getOrderPageByMerchantSearch = async (params) => {
|
||||
const res = await request.post("Store/GetOrderPageByMerchantSearch", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取推荐关键词
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getRecommendKeys = async () => {
|
||||
const res = await request.post("Store/GetRecommendKeys");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID获取商店
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getStoreById = async (params) => {
|
||||
const res = await request.post("Store/GetStoreById", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID获取商店
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getStoreByUserId = async (params) => {
|
||||
const res = await request.post("Store/GetStoreByUserId", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商店列表
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getStoreList = async (params) => {
|
||||
const res = await request.post("Store/GetStoreList", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商店开关
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getStoreSwitch = async () => {
|
||||
const res = await request.post("Store/GetStoreSwitch");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否店员
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const isClerk = async () => {
|
||||
const res = await request.post("Store/IsClerk");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 装载
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const lading = async (params) => {
|
||||
const res = await request.post("Store/Lading", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除装载
|
||||
* @param {Object} params 删除参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const ladingDelete = async (params) => {
|
||||
const res = await request.post("Store/LadingDelete", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取装载信息
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const ladingInfo = async (params) => {
|
||||
const res = await request.post("Store/LadingInfo", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商店装载列表
|
||||
* @param {Object} params 查询参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const storeLadingList = async (params) => {
|
||||
const res = await request.post("Store/StoreLadingList", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
63
common/server/interface/user.js
Normal file
63
common/server/interface/user.js
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
import request from '@/common/system/request';
|
||||
|
||||
/**
|
||||
* 查询用户是否可以成为分销商
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getDistributionInfo = async () => {
|
||||
const res = await request.post("Distribution/Info");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请成为分销商接口
|
||||
* @param {Object} data 分销商申请数据
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const applyDistribution = async (data) => {
|
||||
const res = await request.post("Distribution/ApplyDistribution", data);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商排行
|
||||
* @param {Object} params 分页参数
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getDistributionRanking = async (params) => {
|
||||
const res = await request.post("Distribution/GetDistributionRanking", params);
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的订单统计
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getOrderSum = async () => {
|
||||
const res = await request.post("Distribution/GetOrderSum");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的下级用户数量
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export const getTeamSum = async () => {
|
||||
const res = await request.post("Distribution/GetTeamSum");
|
||||
if (res.code == 0) {
|
||||
return res.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
9855
common/server/swagger.json
Normal file
9855
common/server/swagger.json
Normal file
File diff suppressed because it is too large
Load Diff
66
common/system/cacheService.js
Normal file
66
common/system/cacheService.js
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* 设置缓存,持久化到本地
|
||||
* @param {String} key 缓存key
|
||||
* @param {Object} value 缓存数据
|
||||
*/
|
||||
export const setCache = (key, value) => {
|
||||
uni.setStorageSync(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存
|
||||
* @param {String} key 缓存key
|
||||
* @returns {Object} 缓存数据
|
||||
*/
|
||||
export const getCache = (key) => {
|
||||
return uni.getStorageSync(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
* @param {String} key 缓存key
|
||||
*/
|
||||
export const removeCache = (key) => {
|
||||
uni.removeStorageSync(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地缓存
|
||||
*/
|
||||
let localCache = {};
|
||||
|
||||
/**
|
||||
* 设置缓存,非持久化
|
||||
* @param {String} key 缓存key
|
||||
* @param {Object} value 缓存数据
|
||||
* @param {Number} time 缓存时间,秒
|
||||
*/
|
||||
export const setLocalStorage = (key, value, time = 0) => {
|
||||
localCache[key] = {
|
||||
value: value,
|
||||
expireTime: time > 0 ? Date.now() + time * 1000 : 0,
|
||||
createTime: Date.now()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存,非持久化
|
||||
* @param {String} key 缓存key
|
||||
* @returns {Object} 缓存数据
|
||||
*/
|
||||
export const getLocalStorage = (key) => {
|
||||
if (localCache[key]) {
|
||||
if (localCache[key].expireTime > 0 && localCache[key].expireTime > Date.now()) {
|
||||
return localCache[key].value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除缓存,非持久化
|
||||
* @param {String} key 缓存key
|
||||
*/
|
||||
export const removeLocalStorage = (key) => {
|
||||
delete localCache[key];
|
||||
}
|
||||
204
common/system/request.js
Normal file
204
common/system/request.js
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
/**
|
||||
* 网络请求工具类
|
||||
* 封装统一的网络请求方法
|
||||
*/
|
||||
|
||||
import EnvConfig from '@/common/env.js';
|
||||
import md5 from 'js-md5';
|
||||
import { getLocalStorage, setLocalStorage } from './cacheService';
|
||||
import qs from 'qs';
|
||||
class request {
|
||||
/**
|
||||
* 生成唯一的nonce值
|
||||
* @returns {String} nonce值
|
||||
*/
|
||||
static generateNonce() {
|
||||
return md5(Date.now() + Math.random().toString(36).substring(2, 15));
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建签名
|
||||
* @param {Object} data 请求数据
|
||||
* @param {String} host 主机名
|
||||
* @returns {Object} 带签名的数据和参数字符串
|
||||
* @private
|
||||
*/
|
||||
static _createSignature(data, host) {
|
||||
// 添加时间戳
|
||||
data.timestamp = Math.floor(Date.now() / 1000);
|
||||
// 添加nonce随机字符串
|
||||
data.nonce = request.generateNonce();
|
||||
|
||||
// 按照键名对参数进行排序
|
||||
const sortedParams = {};
|
||||
Object.keys(data).sort().forEach(key => {
|
||||
sortedParams[key] = data[key];
|
||||
});
|
||||
|
||||
// 组合参数为字符串
|
||||
let signStr = '';
|
||||
for (const key in sortedParams) {
|
||||
if (typeof sortedParams[key] === 'object') {
|
||||
signStr += key + '=' + JSON.stringify(sortedParams[key]) + '&';
|
||||
} else {
|
||||
signStr += key + '=' + sortedParams[key] + '&';
|
||||
}
|
||||
}
|
||||
|
||||
// 获取时间戳,组合为密钥
|
||||
const timestamp = data.timestamp;
|
||||
const appSecret = host + timestamp;
|
||||
|
||||
// 添加密钥并去除最后的&
|
||||
signStr = signStr.substring(0, signStr.length - 1) + appSecret;
|
||||
|
||||
// 使用MD5生成签名
|
||||
const sign = md5(signStr);
|
||||
data.sign = sign;
|
||||
|
||||
return { data, signStr };
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建请求URL
|
||||
* @param {String} url 请求路径
|
||||
* @returns {Object} 包含请求URL和主机名的对象
|
||||
* @private
|
||||
*/
|
||||
static _buildRequestUrl(url) {
|
||||
let requestUrl = '';
|
||||
|
||||
if (url.startsWith('http://') || url.startsWith('https://')) {
|
||||
// 如果是完整的URL,直接使用
|
||||
requestUrl = url;
|
||||
} else {
|
||||
// 否则拼接基础URL和相对路径
|
||||
// 确保基础URL以/结尾,而请求路径不以/开头
|
||||
const apiBaseUrl = EnvConfig.apiBaseUrl;
|
||||
const baseUrlWithSlash = apiBaseUrl.endsWith('/') ? apiBaseUrl : apiBaseUrl + '/';
|
||||
let routeMap = url;
|
||||
const path = routeMap.startsWith('/') ? routeMap.substring(1) : routeMap;
|
||||
requestUrl = baseUrlWithSlash + path;
|
||||
}
|
||||
|
||||
// 使用正则表达式从URL中提取主机名
|
||||
const hostRegex = /^(?:https?:\/\/)?([^\/]+)/i;
|
||||
const matches = requestUrl.match(hostRegex);
|
||||
const host = matches && matches[1] ? matches[1] : 'localhost';
|
||||
|
||||
return { requestUrl, host };
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送请求
|
||||
* @param {String} url 请求地址
|
||||
* @param {Object} fromData 请求数据
|
||||
* @param {String} method 请求方式
|
||||
* @param {Boolean} showLoading 是否显示加载提示
|
||||
* @returns {Promise} 返回请求Promise
|
||||
*/
|
||||
static request(url, fromData = {}, method = 'POST', showLoading = false) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 使用传入的method而不是重新声明
|
||||
const requestMethod = method.toUpperCase();
|
||||
const token = uni.getStorageSync('token');
|
||||
let data = { ...fromData }; // 创建数据的深拷贝,避免修改原数据
|
||||
|
||||
// 构建请求URL和提取主机名
|
||||
const { requestUrl, host } = request._buildRequestUrl(url);
|
||||
|
||||
// 显示加载提示
|
||||
if (showLoading) {
|
||||
uni.showLoading({
|
||||
title: '正在加载中...',
|
||||
mask: true
|
||||
});
|
||||
}
|
||||
|
||||
// 创建签名并准备请求数据和头信息
|
||||
const { data: signedData } = request._createSignature(data, host);
|
||||
data = signedData;
|
||||
// 根据请求方法设置不同的headers
|
||||
const header = {
|
||||
Authorization: 'Bearer ' + token,
|
||||
'content-type': 'application/json'
|
||||
};
|
||||
|
||||
const startDate = Date.now();
|
||||
|
||||
// 发起网络请求
|
||||
uni.request({
|
||||
url: requestUrl,
|
||||
method: requestMethod,
|
||||
header: header,
|
||||
data: data,
|
||||
timeout: 30000, // 设置30秒超时
|
||||
success: res => {
|
||||
const endDate = Date.now();
|
||||
console.log(requestUrl, "请求消耗时间", endDate - startDate);
|
||||
resolve(res);
|
||||
},
|
||||
fail: e => {
|
||||
console.error('网络请求失败:', e);
|
||||
uni.showToast({
|
||||
title: e.errMsg || '发送请求失败,请稍后再试!',
|
||||
icon: 'none'
|
||||
});
|
||||
reject(e);
|
||||
},
|
||||
complete: () => {
|
||||
if (showLoading) {
|
||||
uni.hideLoading();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送GET请求
|
||||
* @param {String} url 请求地址
|
||||
* @param {Object} data 请求参数
|
||||
* @param {Boolean} showLoading 是否显示加载提示
|
||||
* @returns {Promise} 返回请求Promise
|
||||
*/
|
||||
static get(url, data = {}, showLoading = false) {
|
||||
return request.request(url, data, 'GET', showLoading);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送POST请求
|
||||
* @param {String} url 请求地址
|
||||
* @param {Object} data 请求参数
|
||||
* @param {Boolean} showLoading 是否显示加载提示
|
||||
* @returns {Promise} 返回请求Promise
|
||||
*/
|
||||
static post(url, data = {}, showLoading = false) {
|
||||
return request.request(url, data, 'POST', showLoading);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送get请求,如果缓存存在,则返回缓存数据,否则发送请求,并缓存数据
|
||||
* @param {String} url 请求地址
|
||||
* @param {Object} data 请求参数
|
||||
* @param {Number} time 缓存时间,秒
|
||||
* @param {Boolean} showLoading 是否显示加载提示
|
||||
* @returns {Promise} 返回请求Promise
|
||||
*/
|
||||
static async getOrCache(url, data = {}, time = 300, showLoading = false) {
|
||||
const cacheKey = 'cache_' + url + '_' + qs.stringify(data);
|
||||
// console.log('getOrCache', cacheKey, '查询缓存');
|
||||
const cacheData = getLocalStorage(cacheKey);
|
||||
if (cacheData) {
|
||||
console.log('getOrCache', cacheKey, '缓存命中');
|
||||
return cacheData;
|
||||
}
|
||||
|
||||
const res = await request.request(url, data, 'GET', showLoading);
|
||||
setLocalStorage(cacheKey, res, time);
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default request;
|
||||
33
common/system/router.js
Normal file
33
common/system/router.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
export const navigateTo = (url) => {
|
||||
uni.navigateTo({
|
||||
url: url,
|
||||
fail: (err) => {
|
||||
console.log('err', err);
|
||||
|
||||
uni.switchTab({
|
||||
url: url
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转登录页面
|
||||
* @param {String} page 跳转页面
|
||||
*/
|
||||
export const navigateToAccountLogin = (page = "") => {
|
||||
if (page == "") {
|
||||
const _page = getCurrentPages()[0];
|
||||
page = _page.route;
|
||||
}
|
||||
// navigateTo(`/pages/me/account-login?page=${encodeURIComponent(page)}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转协议页面
|
||||
* @param {String} type 协议类型
|
||||
*/
|
||||
export const navigateToAgreement = (type) => {
|
||||
// navigateTo(`/pages/other/agreement?type=${type}`);
|
||||
};
|
||||
38
common/system/system.js
Normal file
38
common/system/system.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import { getHomePage } from '@/common/server/home'
|
||||
import { getConfig } from '@/common/server/config';
|
||||
/**
|
||||
* 应用初始化函数,带有超时控制
|
||||
* @param {number} timeoutMs - 超时时间(毫秒)
|
||||
* @returns {Promise<boolean>} - 返回Promise,true表示初始化成功,false表示失败
|
||||
*/
|
||||
export const appInit = async (timeoutMs = 5000) => {
|
||||
try {
|
||||
//获取系统配置
|
||||
const getConfigTask = getConfig();
|
||||
//获取首页关键数据
|
||||
const homeTask = getHomePage();
|
||||
|
||||
// 2. 创建一个会在指定时间后拒绝的Promise用于超时控制
|
||||
const timeoutPromise = new Promise((_, reject) =>
|
||||
setTimeout(() =>
|
||||
// 当超时触发时,拒绝Promise并返回超时错误
|
||||
reject(new Error(`初始化获取超时 (${timeoutMs}ms)`)),
|
||||
timeoutMs
|
||||
)
|
||||
);
|
||||
// 3. 使用Promise.race让首页获取数据和超时Promise"赛跑"
|
||||
// 哪个先完成(成功或失败)就采用哪个的结果
|
||||
await Promise.race([
|
||||
// 使用Promise.all包装是为了保持一致性
|
||||
Promise.all([getConfigTask, homeTask]),
|
||||
timeoutPromise
|
||||
]);
|
||||
// 4. 如果没有超时全部获取成功,返回true
|
||||
return true;
|
||||
} catch (error) {
|
||||
// 5. 错误处理(可能是超时错误或首页获取失败)
|
||||
console.error('初始化任务失败:', error);
|
||||
// 6. 返回false表示初始化失败
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -109,3 +109,20 @@ export function hideLoading() {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
let os = '';
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export function getOS() {
|
||||
if (os != '') {
|
||||
return os;
|
||||
}
|
||||
// #ifdef APP-PLUS
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
return systemInfo.platform === 'ios' ? 'ios' : 'android';
|
||||
// #endif
|
||||
|
||||
return 'mp';
|
||||
}
|
||||
7
package-lock.json
generated
7
package-lock.json
generated
|
|
@ -8,6 +8,7 @@
|
|||
"@dcloudio/uni-ui": "^1.5.7",
|
||||
"crypto-js": "^4.2.0",
|
||||
"js-md5": "^0.8.3",
|
||||
"lodash": "^4.17.21",
|
||||
"qs": "^6.14.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
@ -685,6 +686,12 @@
|
|||
"url": "https://github.com/sponsors/antfu"
|
||||
}
|
||||
},
|
||||
"node_modules/lodash": {
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/magic-string": {
|
||||
"version": "0.30.17",
|
||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz",
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
"@dcloudio/uni-ui": "^1.5.7",
|
||||
"crypto-js": "^4.2.0",
|
||||
"js-md5": "^0.8.3",
|
||||
"lodash": "^4.17.21",
|
||||
"qs": "^6.14.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
|||
14
pages.json
14
pages.json
|
|
@ -1,18 +1,17 @@
|
|||
{
|
||||
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
||||
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/home/home-page",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
}, {
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/bags/bags-page",
|
||||
|
|
@ -78,7 +77,6 @@
|
|||
"backgroundColor": "#F8F8F8"
|
||||
},
|
||||
"uniIdRouter": {},
|
||||
|
||||
"tabBar": {
|
||||
"color": "#FFFDF1",
|
||||
"selectedColor": "#333333",
|
||||
|
|
|
|||
|
|
@ -1,32 +1,49 @@
|
|||
<template>
|
||||
<view class="content">
|
||||
|
||||
<image src="/static/bg.png" style="width: 100vw; height: 100vh"></image>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
|
||||
}
|
||||
<script setup>
|
||||
import { appInit } from "@/common/system/system";
|
||||
onLoad(async () => {
|
||||
// 检查网络状态
|
||||
const network = await uni.getNetworkType();
|
||||
if (network.networkType === "none") {
|
||||
tips_text.value = "请检查网络连接";
|
||||
// 监听网络状态变化
|
||||
uni.onNetworkStatusChange(checkNetwork);
|
||||
return;
|
||||
}
|
||||
// 记录开始时间
|
||||
const startTime = Date.now();
|
||||
let res = await appInit();
|
||||
|
||||
// 计算总耗时
|
||||
const endTime = Date.now();
|
||||
const duration = endTime - startTime;
|
||||
console.log(`应用初始化成功,耗时: ${duration}ms`);
|
||||
gy.navigateTo("/pages/home/home-page");
|
||||
});
|
||||
/**
|
||||
* 检查网络状态
|
||||
* @param {Object} res 网络状态
|
||||
*/
|
||||
function checkNetwork(res) {
|
||||
console.log("网络状态变化:", res.isConnected, res.networkType);
|
||||
if (res.isConnected) {
|
||||
// #ifdef APP
|
||||
plus.runtime.restart();
|
||||
// #endif
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
BIN
static/bg.png
Normal file
BIN
static/bg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 257 KiB |
175
vite.config.js
175
vite.config.js
|
|
@ -1,101 +1,92 @@
|
|||
import {
|
||||
defineConfig
|
||||
defineConfig
|
||||
} from 'vite';
|
||||
import uni from "@dcloudio/vite-plugin-uni";
|
||||
import AutoImport from 'unplugin-auto-import/vite';
|
||||
import Components from 'unplugin-vue-components/vite';
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
minify: 'terser',
|
||||
// assetsInlineLimit: 0, // 禁止将图片转成 import
|
||||
terserOptions: {
|
||||
compress: {
|
||||
drop_console: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
uni(),
|
||||
{
|
||||
name: 'transform-assets',
|
||||
enforce: 'pre', // 在 Vue 插件之前执行
|
||||
transform(code, id) {
|
||||
build: {
|
||||
minify: 'terser',
|
||||
// assetsInlineLimit: 0, // 禁止将图片转成 import
|
||||
terserOptions: {
|
||||
compress: {
|
||||
drop_console: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
uni(),
|
||||
{
|
||||
name: 'transform-assets',
|
||||
enforce: 'pre', // 在 Vue 插件之前执行
|
||||
transform(code, id) {
|
||||
|
||||
if (/\.(vue|js|ts|css|scss|json)$/.test(id)) {
|
||||
let count = 0
|
||||
const replacedCode = code.replace(
|
||||
/@@:([^\s"'()<>]+?\.(png|jpe?g|gif|svg|webp))/g,
|
||||
(match, path) => {
|
||||
count++
|
||||
return `https://guyu-1308826010.cos.ap-shanghai.myqcloud.com/${path}`
|
||||
}
|
||||
);
|
||||
// code.replace(
|
||||
// /@\/?([^\s"'()]+)/g,
|
||||
// (match) => {
|
||||
// count++
|
||||
// return 'https://guyu-1308826010.cos.ap-shanghai.myqcloud.com/' + match
|
||||
// .replace(/^http:\/\/@\/?/, '')
|
||||
// }
|
||||
// )
|
||||
if (count > 0) {
|
||||
console.log(id, `本次替换了 ${count} 个图片地址`)
|
||||
}
|
||||
// console.log(id, fcode)
|
||||
return {
|
||||
code: replacedCode,
|
||||
map: null
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
// 自动导入 Vue 相关 API(如 ref, reactive)
|
||||
AutoImport({
|
||||
imports: ['vue',
|
||||
{
|
||||
'@dcloudio/uni-app': [
|
||||
'onLoad', // 页面加载时触发
|
||||
'onShow', // 页面显示时触发
|
||||
'onHide', // 页面隐藏时触发
|
||||
'onUnload', // 页面卸载时触发
|
||||
],
|
||||
},
|
||||
{
|
||||
'@/common/utils': [
|
||||
'showToast', // 明确列出方法名(推荐)
|
||||
'sleep',
|
||||
],
|
||||
}
|
||||
// ,
|
||||
// {
|
||||
// '@/common/yds': [
|
||||
// ['yds'], // 从 '@/common/index' 导入 yds 对象
|
||||
// ],
|
||||
// }
|
||||
],
|
||||
}),
|
||||
// 自动导入组件
|
||||
Components({
|
||||
dirs: [
|
||||
// 'components/guyu-container',
|
||||
// 'components/uni-nav-bar',
|
||||
// 'components/uni-popup',
|
||||
// 'components/uni-transition'
|
||||
], // 指定组件目录
|
||||
extensions: ['vue'],
|
||||
dts: true, // 生成类型声明文件(可选)
|
||||
// resolvers: [
|
||||
// (name) => {
|
||||
// if (name === 'uni-popup') { // 匹配 kebab-case 名称
|
||||
// return {
|
||||
// importName: 'uni-popup', // 组件文件实际导出的名称
|
||||
// path: '@/components/uni-popup/components/uni-popup/uni-popup.vue', // 文件路径
|
||||
// kebabCase: true
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
}),
|
||||
]
|
||||
if (/\.(vue|js|ts|css|scss|json)$/.test(id)) {
|
||||
let count = 0
|
||||
const replacedCode = code.replace(
|
||||
/@@:([^\s"'()<>]+?\.(png|jpe?g|gif|svg|webp))/g,
|
||||
(match, path) => {
|
||||
count++
|
||||
return `https://guyu-1308826010.cos.ap-shanghai.myqcloud.com/${path}`
|
||||
}
|
||||
);
|
||||
if (count > 0) {
|
||||
console.log(id, `本次替换了 ${count} 个图片地址`)
|
||||
}
|
||||
// console.log(id)
|
||||
return {
|
||||
code: replacedCode,
|
||||
map: null
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
// 自动导入 Vue 相关 API(如 ref, reactive)
|
||||
AutoImport({
|
||||
imports: ['vue',
|
||||
{
|
||||
'@dcloudio/uni-app': [
|
||||
'onLoad', // 页面加载时触发
|
||||
'onShow', // 页面显示时触发
|
||||
'onHide', // 页面隐藏时触发
|
||||
'onUnload', // 页面卸载时触发
|
||||
],
|
||||
},
|
||||
{
|
||||
'@/common/utils': [
|
||||
'showToast', // 明确列出方法名(推荐)
|
||||
'sleep',
|
||||
],
|
||||
},
|
||||
{
|
||||
'@/common/gy': [
|
||||
['gy'], // 从 '@/common/index' 导入 yds 对象
|
||||
],
|
||||
}
|
||||
],
|
||||
}),
|
||||
// 自动导入组件
|
||||
Components({
|
||||
dirs: [
|
||||
// 'components/guyu-container',
|
||||
// 'components/uni-nav-bar',
|
||||
// 'components/uni-popup',
|
||||
// 'components/uni-transition'
|
||||
], // 指定组件目录
|
||||
extensions: ['vue'],
|
||||
dts: true, // 生成类型声明文件(可选)
|
||||
// resolvers: [
|
||||
// (name) => {
|
||||
// if (name === 'uni-popup') { // 匹配 kebab-case 名称
|
||||
// return {
|
||||
// importName: 'uni-popup', // 组件文件实际导出的名称
|
||||
// path: '@/components/uni-popup/components/uni-popup/uni-popup.vue', // 文件路径
|
||||
// kebabCase: true
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
}),
|
||||
]
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user