通过微信开发者工具 商城模板 创建新小程序
This commit is contained in:
20
mini-program/services/good/comments/fetchCommentDetail.js
Normal file
20
mini-program/services/good/comments/fetchCommentDetail.js
Normal file
@@ -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');
|
||||
});
|
||||
}
|
18
mini-program/services/good/fetchCategoryList.js
Normal file
18
mini-program/services/good/fetchCategoryList.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { config } from '../../config/index';
|
||||
|
||||
/** 获取商品列表 */
|
||||
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) => {
|
||||
resolve('real api');
|
||||
});
|
||||
}
|
18
mini-program/services/good/fetchGood.js
Normal file
18
mini-program/services/good/fetchGood.js
Normal file
@@ -0,0 +1,18 @@
|
||||
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 new Promise((resolve) => {
|
||||
resolve('real api');
|
||||
});
|
||||
}
|
29
mini-program/services/good/fetchGoods.js
Normal file
29
mini-program/services/good/fetchGoods.js
Normal file
@@ -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');
|
||||
});
|
||||
}
|
37
mini-program/services/good/fetchGoodsDetailsComments.js
Normal file
37
mini-program/services/good/fetchGoodsDetailsComments.js
Normal file
@@ -0,0 +1,37 @@
|
||||
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 new Promise((resolve) => {
|
||||
resolve('real api');
|
||||
});
|
||||
}
|
39
mini-program/services/good/fetchGoodsList.js
Normal file
39
mini-program/services/good/fetchGoodsList.js
Normal file
@@ -0,0 +1,39 @@
|
||||
/* eslint-disable no-param-reassign */
|
||||
import { config } from '../../config/index';
|
||||
|
||||
/** 获取商品列表 */
|
||||
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 new Promise((resolve) => {
|
||||
resolve('real api');
|
||||
});
|
||||
}
|
35
mini-program/services/good/fetchSearchHistory.js
Normal file
35
mini-program/services/good/fetchSearchHistory.js
Normal file
@@ -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');
|
||||
});
|
||||
}
|
38
mini-program/services/good/fetchSearchResult.js
Normal file
38
mini-program/services/good/fetchSearchResult.js
Normal file
@@ -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');
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user