Initial commit

This commit is contained in:
Dev
2026-09-17 16:25:31 +08:00
commit 382a3069b9
1268 changed files with 266342 additions and 0 deletions
@@ -0,0 +1,20 @@
import { config } from '../../../config/index';
import { queryCommentDetail } from '../../../model/comments/queryDetail';
/** 获取商品评价数据 */
function mockQueryCommentDetail(params) {
const { delay } = require('../../_utils/delay');
const data = queryCommentDetail(params);
return delay().then(() => {
return data;
});
}
/** 获取评价详情 */
export function getCommentDetail(params) {
if (config.useMock) {
return mockQueryCommentDetail(params);
}
return new Promise((resolve) => {
resolve('real api');
});
}
@@ -0,0 +1,32 @@
import { config } from '../../config/index';
import { CatalogList } from '../../config/api';
/** 获取商品列表 */
function mockFetchGoodCategory() {
const { delay } = require('../_utils/delay');
const { getCategoryList } = require('../../model/category');
return delay().then(() => getCategoryList());
}
/** 获取商品列表 */
export function getCategoryList() {
if (config.useMock) {
return mockFetchGoodCategory();
}
return new Promise((resolve, reject) => {
wx.request({
url: CatalogList,
method: 'GET',
success: (res) => {
if (res.statusCode === 200) {
resolve(res.data.data);
} else {
reject(new Error('获取分类列表失败'));
}
},
fail: (err) => {
reject(err);
}
});
});
}
@@ -0,0 +1,16 @@
import { config } from '../../config/index';
/** 获取商品列表 */
function mockFetchGood(ID = 0) {
const { delay } = require('../_utils/delay');
const { genGood } = require('../../model/good');
return delay().then(() => genGood(ID));
}
/** 获取商品列表 */
export function fetchGood(ID = 0) {
if (config.useMock) {
return mockFetchGood(ID);
}
return wx.$util.request(wx.$api.GoodsDetail, { id: ID }, 'GET');
}
@@ -0,0 +1,29 @@
import { config } from '../../config/index';
/** 获取商品列表 */
function mockFetchGoodsList(pageIndex = 1, pageSize = 20) {
const { delay } = require('../_utils/delay');
const { getGoodsList } = require('../../model/goods');
return delay().then(() =>
getGoodsList(pageIndex, pageSize).map((item) => {
return {
spuId: item.spuId,
thumb: item.primaryImage,
title: item.title,
price: item.minSalePrice,
originPrice: item.maxLinePrice,
tags: item.spuTagList.map((tag) => tag.title),
};
}),
);
}
/** 获取商品列表 */
export function fetchGoodsList(pageIndex = 1, pageSize = 20) {
if (config.useMock) {
return mockFetchGoodsList(pageIndex, pageSize);
}
return new Promise((resolve) => {
resolve('real api');
});
}
@@ -0,0 +1,35 @@
import { config } from '../../config/index';
/** 获取商品详情页评论数 */
function mockFetchGoodDetailsCommentsCount(spuId = 0) {
const { delay } = require('../_utils/delay');
const {
getGoodsDetailsCommentsCount,
} = require('../../model/detailsComments');
return delay().then(() => getGoodsDetailsCommentsCount(spuId));
}
/** 获取商品详情页评论数 */
export function getGoodsDetailsCommentsCount(spuId = 0) {
if (config.useMock) {
return mockFetchGoodDetailsCommentsCount(spuId);
}
return new Promise((resolve) => {
resolve('real api');
});
}
/** 获取商品详情页评论 */
function mockFetchGoodDetailsCommentList(spuId = 0) {
const { delay } = require('../_utils/delay');
const { getGoodsDetailsComments } = require('../../model/detailsComments');
return delay().then(() => getGoodsDetailsComments(spuId));
}
/** 获取商品详情页评论 */
export function getGoodsDetailsCommentList(spuId = 0) {
if (config.useMock) {
return mockFetchGoodDetailsCommentList(spuId);
}
return {homePageComments: []}
}
@@ -0,0 +1,38 @@
/* eslint-disable no-param-reassign */
import { config } from '../../config/index';
import { GoodsList } from '../../config/api';
/** 获取商品列表 */
function mockFetchGoodsList(params) {
const { delay } = require('../_utils/delay');
const { getSearchResult } = require('../../model/search');
const data = getSearchResult(params);
if (data.spuList.length) {
data.spuList.forEach((item) => {
item.spuId = item.spuId;
item.thumb = item.primaryImage;
item.title = item.title;
item.price = item.minSalePrice;
item.originPrice = item.maxLinePrice;
item.desc = '';
if (item.spuTagList) {
item.tags = item.spuTagList.map((tag) => tag.title);
} else {
item.tags = [];
}
});
}
return delay().then(() => {
return data;
});
}
/** 获取商品列表 */
export function fetchGoodsList(params) {
if (config.useMock) {
return mockFetchGoodsList(params);
}
return wx.$util.request(wx.$api.GoodsList, params, 'GET');
}
@@ -0,0 +1,35 @@
import { config } from '../../config/index';
/** 获取搜索历史 */
function mockSearchHistory() {
const { delay } = require('../_utils/delay');
const { getSearchHistory } = require('../../model/search');
return delay().then(() => getSearchHistory());
}
/** 获取搜索历史 */
export function getSearchHistory() {
if (config.useMock) {
return mockSearchHistory();
}
return new Promise((resolve) => {
resolve('real api');
});
}
/** 获取搜索历史 */
function mockSearchPopular() {
const { delay } = require('../_utils/delay');
const { getSearchPopular } = require('../../model/search');
return delay().then(() => getSearchPopular());
}
/** 获取搜索历史 */
export function getSearchPopular() {
if (config.useMock) {
return mockSearchPopular();
}
return new Promise((resolve) => {
resolve('real api');
});
}
@@ -0,0 +1,38 @@
/* eslint-disable no-param-reassign */
import { config } from '../../config/index';
/** 获取搜索历史 */
function mockSearchResult(params) {
const { delay } = require('../_utils/delay');
const { getSearchResult } = require('../../model/search');
const data = getSearchResult(params);
if (data.spuList.length) {
data.spuList.forEach((item) => {
item.spuId = item.spuId;
item.thumb = item.primaryImage;
item.title = item.title;
item.price = item.minSalePrice;
item.originPrice = item.maxLinePrice;
if (item.spuTagList) {
item.tags = item.spuTagList.map((tag) => ({ title: tag.title }));
} else {
item.tags = [];
}
});
}
return delay().then(() => {
return data;
});
}
/** 获取搜索历史 */
export function getSearchResult(params) {
if (config.useMock) {
return mockSearchResult(params);
}
return new Promise((resolve) => {
resolve('real api');
});
}