From 0a5577b8576fb51f7746b4c2795b8c23e15d0c85 Mon Sep 17 00:00:00 2001 From: joeyzzeng Date: Mon, 14 Oct 2024 16:05:51 +0800 Subject: [PATCH] fix: add mock data to tcb shop --- miniprogram/tcb-shop/app.json | 10 +- .../cloud-template-checker/index.js | 33 --- .../cloud-template-checker/index.wxml | 21 -- .../cloud-template-checker/index.wxss | 37 ---- .../components/cloud-template-guide/index.js | 41 ++++ .../index.json | 5 +- .../cloud-template-guide/index.wxml | 18 ++ .../cloud-template-guide/index.wxss | 57 ++++++ miniprogram/tcb-shop/config/index.js | 6 + miniprogram/tcb-shop/pages/cart/index.wxml | 1 + .../tcb-shop/pages/goods/category/index.wxml | 1 + miniprogram/tcb-shop/pages/home/home.js | 13 +- miniprogram/tcb-shop/pages/home/home.json | 3 +- miniprogram/tcb-shop/pages/home/home.wxml | 35 ++-- .../tcb-shop/pages/usercenter/index.wxml | 1 + miniprogram/tcb-shop/services/cart/cart.js | 5 + miniprogram/tcb-shop/services/cate/cate.js | 6 +- .../tcb-shop/services/cloudbaseMock/index.js | 189 ++++++++++++++++++ miniprogram/tcb-shop/services/good/spu.js | 17 ++ miniprogram/tcb-shop/services/home/home.js | 6 + miniprogram/tcb-shop/services/order/order.js | 5 + 21 files changed, 379 insertions(+), 131 deletions(-) delete mode 100644 miniprogram/tcb-shop/components/cloud-template-checker/index.js delete mode 100644 miniprogram/tcb-shop/components/cloud-template-checker/index.wxml delete mode 100644 miniprogram/tcb-shop/components/cloud-template-checker/index.wxss create mode 100644 miniprogram/tcb-shop/components/cloud-template-guide/index.js rename miniprogram/tcb-shop/components/{cloud-template-checker => cloud-template-guide}/index.json (56%) create mode 100644 miniprogram/tcb-shop/components/cloud-template-guide/index.wxml create mode 100644 miniprogram/tcb-shop/components/cloud-template-guide/index.wxss create mode 100644 miniprogram/tcb-shop/services/cloudbaseMock/index.js diff --git a/miniprogram/tcb-shop/app.json b/miniprogram/tcb-shop/app.json index b4cea02..c04f483 100644 --- a/miniprogram/tcb-shop/app.json +++ b/miniprogram/tcb-shop/app.json @@ -56,11 +56,11 @@ } ] }, - "requiredPrivateInfos": [ - "chooseAddress" - ], + "requiredPrivateInfos": ["chooseAddress"], "lazyCodeLoading": "requiredComponents", - "usingComponents": {}, + "usingComponents": { + "cloud-template-guide": "/components/cloud-template-guide/index" + }, "window": { "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#fff", @@ -73,4 +73,4 @@ "desc": "你的位置信息将用于小程序位置接口的效果展示" } } -} \ No newline at end of file +} diff --git a/miniprogram/tcb-shop/components/cloud-template-checker/index.js b/miniprogram/tcb-shop/components/cloud-template-checker/index.js deleted file mode 100644 index 8ec8e78..0000000 --- a/miniprogram/tcb-shop/components/cloud-template-checker/index.js +++ /dev/null @@ -1,33 +0,0 @@ -Component({ - properties: { - show: { - type: Boolean, - value: false, - }, - text: { - type: String, - value: "" - }, - url: { - type: String, - value: "" - } - }, - - methods: { - check() { - this.triggerEvent("check"); - }, - copy() { - wx.setClipboardData({ - data: this.data.url, - }); - }, - }, - - lifetimes: { - attached: function () { - this.check(); - }, - }, -}); diff --git a/miniprogram/tcb-shop/components/cloud-template-checker/index.wxml b/miniprogram/tcb-shop/components/cloud-template-checker/index.wxml deleted file mode 100644 index 3952bb0..0000000 --- a/miniprogram/tcb-shop/components/cloud-template-checker/index.wxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - 加载数据失败 - - - {{text}} - - - {{url}} - - 复制链接 - 再试一次 - - - - - - - \ No newline at end of file diff --git a/miniprogram/tcb-shop/components/cloud-template-checker/index.wxss b/miniprogram/tcb-shop/components/cloud-template-checker/index.wxss deleted file mode 100644 index 8ff282f..0000000 --- a/miniprogram/tcb-shop/components/cloud-template-checker/index.wxss +++ /dev/null @@ -1,37 +0,0 @@ -.cloud-checker-container { - display: flex; - justify-content: center; - align-items: center; -} - -.cloud-checker-container .card { - padding: 60rpx; -} - -.cloud-checker-container .text { - text-align: center; - margin: 20rpx; -} -.cloud-checker-container .url { - word-break: break-all; - font-size: small; - color: #3f3f3f; -} - -.cloud-checker-container .icon-text { - display: flex; - justify-content: center; - align-items: center; -} - -.cloud-checker-container .t-icon { - color: red; - margin-right: 5rpx; -} - -.cloud-checker-container .btns { - margin-top: 40rpx; - display: flex; - justify-content: center; - align-items: center; -} \ No newline at end of file diff --git a/miniprogram/tcb-shop/components/cloud-template-guide/index.js b/miniprogram/tcb-shop/components/cloud-template-guide/index.js new file mode 100644 index 0000000..dfb1a61 --- /dev/null +++ b/miniprogram/tcb-shop/components/cloud-template-guide/index.js @@ -0,0 +1,41 @@ +import { cloudbaseTemplateConfig } from '../../config/index'; + +Component({ + properties: { + show: { + type: Boolean, + value: cloudbaseTemplateConfig.useMock, + }, + title: { + type: String, + value: '替换为真实数据', + }, + text: { + type: String, + value: '当前为体验数据,切换为真实数据请复制下方链接并在浏览器中打开,通过指引帮您快速替换', + }, + url: { + type: String, + value: + 'https://tcb.cloud.tencent.com/cloud-admin?_jump_source=wxide_tcb_shop#/cloud-template/detail?tplId=tpl-1sm7qkwQcbBUpZ&appName=electronic-business', + }, + }, + + data: { + dialogShow: false, + }, + + methods: { + open() { + this.setData({ dialogShow: true }); + }, + close() { + this.setData({ dialogShow: false }); + }, + copy() { + wx.setClipboardData({ + data: this.data.url, + }); + }, + }, +}); diff --git a/miniprogram/tcb-shop/components/cloud-template-checker/index.json b/miniprogram/tcb-shop/components/cloud-template-guide/index.json similarity index 56% rename from miniprogram/tcb-shop/components/cloud-template-checker/index.json rename to miniprogram/tcb-shop/components/cloud-template-guide/index.json index 0de7767..d6370d0 100644 --- a/miniprogram/tcb-shop/components/cloud-template-checker/index.json +++ b/miniprogram/tcb-shop/components/cloud-template-guide/index.json @@ -3,6 +3,7 @@ "styleIsolation": "shared", "usingComponents": { "t-button": "tdesign-miniprogram/button/button", - "t-icon": "tdesign-miniprogram/icon/icon" + "t-icon": "tdesign-miniprogram/icon/icon", + "t-dialog": "tdesign-miniprogram/dialog/dialog" } -} \ No newline at end of file +} diff --git a/miniprogram/tcb-shop/components/cloud-template-guide/index.wxml b/miniprogram/tcb-shop/components/cloud-template-guide/index.wxml new file mode 100644 index 0000000..ff0e2ec --- /dev/null +++ b/miniprogram/tcb-shop/components/cloud-template-guide/index.wxml @@ -0,0 +1,18 @@ + + + + 当前为体验数据,可替换为真实数据 + + 去替换> + + + + {{title}} + {{text}} + {{url}} + + 复制地址 + 暂不打开 + + + \ No newline at end of file diff --git a/miniprogram/tcb-shop/components/cloud-template-guide/index.wxss b/miniprogram/tcb-shop/components/cloud-template-guide/index.wxss new file mode 100644 index 0000000..ccae5cb --- /dev/null +++ b/miniprogram/tcb-shop/components/cloud-template-guide/index.wxss @@ -0,0 +1,57 @@ +.cloud-template-guide { + display: flex; + align-items: center; + justify-content: space-between; + background-color: #f2f3ff; + margin: 20rpx; + padding: 20rpx; + border-radius: 10rpx; + font-size: small; +} + +.cloud-template-guide .left { + gap: 10rpx; + display: flex; + align-items: center; +} + +.cloud-template-guide .right { + align-items: center; + color: #0052d9; +} + +.cloud-template-guide-dialog { + display: flex; + flex-direction: column; + gap: 30rpx; +} + +.cloud-template-guide-dialog .title { + font-size: large; + text-align: center; +} + +.cloud-template-guide-dialog .btns { + display: flex; + justify-content: space-between; + gap: 30rpx; +} + +.cloud-template-guide-dialog .close { + color: #0052d9; + border-color: #0052d9; + border: solid 1rpx #0052d9; +} + +.cloud-template-guide-dialog .text { + color: rgba(0, 0, 0, 0.5); + font-size: small; +} + +.cloud-template-guide-dialog .btns button { + flex: 1; +} + +.cloud-template-guide-dialog .url { + word-break: break-all; +} diff --git a/miniprogram/tcb-shop/config/index.js b/miniprogram/tcb-shop/config/index.js index 26ca6ee..b032b09 100644 --- a/miniprogram/tcb-shop/config/index.js +++ b/miniprogram/tcb-shop/config/index.js @@ -1,6 +1,12 @@ +/** TDesign 使用 */ export const config = { /** 是否使用mock代替api返回 */ useMock: true, }; +/** 云开发使用 */ +export const cloudbaseTemplateConfig = { + useMock: true, +}; + export const cdnBase = 'https://we-retail-static-1300977798.cos.ap-guangzhou.myqcloud.com/retail-mp'; diff --git a/miniprogram/tcb-shop/pages/cart/index.wxml b/miniprogram/tcb-shop/pages/cart/index.wxml index affa744..8f1bd6f 100644 --- a/miniprogram/tcb-shop/pages/cart/index.wxml +++ b/miniprogram/tcb-shop/pages/cart/index.wxml @@ -1,3 +1,4 @@ + diff --git a/miniprogram/tcb-shop/pages/goods/category/index.wxml b/miniprogram/tcb-shop/pages/goods/category/index.wxml index cdfd458..806b099 100644 --- a/miniprogram/tcb-shop/pages/goods/category/index.wxml +++ b/miniprogram/tcb-shop/pages/goods/category/index.wxml @@ -1,3 +1,4 @@ + diff --git a/miniprogram/tcb-shop/pages/home/home.js b/miniprogram/tcb-shop/pages/home/home.js index ac463d0..258687f 100644 --- a/miniprogram/tcb-shop/pages/home/home.js +++ b/miniprogram/tcb-shop/pages/home/home.js @@ -16,18 +16,7 @@ Page({ duration: '500', interval: 5000, navigation: { type: 'dots' }, - swiperImageProps: { mode: 'scaleToFill' }, - cloudCheckerShow: false - }, - - async onCloudCheck() { - try { - await getHomeSwiper(); - this.setData({ cloudCheckerShow: false }) - } catch (e) { - console.log(e); - this.setData({ cloudCheckerShow: true }) - } + swiperImageProps: { mode: 'scaleToFill' } }, goodListPagination: { diff --git a/miniprogram/tcb-shop/pages/home/home.json b/miniprogram/tcb-shop/pages/home/home.json index fae6a81..e722c9a 100644 --- a/miniprogram/tcb-shop/pages/home/home.json +++ b/miniprogram/tcb-shop/pages/home/home.json @@ -14,7 +14,6 @@ "t-tabs": "tdesign-miniprogram/tabs/tabs", "t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel", "goods-list": "/components/goods-list/index", - "load-more": "/components/load-more/index", - "cloud-template-checker": "/components/cloud-template-checker/index" + "load-more": "/components/load-more/index" } } \ No newline at end of file diff --git a/miniprogram/tcb-shop/pages/home/home.wxml b/miniprogram/tcb-shop/pages/home/home.wxml index a4051d6..0f05421 100644 --- a/miniprogram/tcb-shop/pages/home/home.wxml +++ b/miniprogram/tcb-shop/pages/home/home.wxml @@ -1,20 +1,19 @@ - - - + + + + + + + + + - - - - - - - - - + + - - - - - - \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/miniprogram/tcb-shop/pages/usercenter/index.wxml b/miniprogram/tcb-shop/pages/usercenter/index.wxml index e42a865..9ed6c3e 100644 --- a/miniprogram/tcb-shop/pages/usercenter/index.wxml +++ b/miniprogram/tcb-shop/pages/usercenter/index.wxml @@ -1,6 +1,7 @@ + diff --git a/miniprogram/tcb-shop/services/cart/cart.js b/miniprogram/tcb-shop/services/cart/cart.js index fb69231..8815eb5 100644 --- a/miniprogram/tcb-shop/services/cart/cart.js +++ b/miniprogram/tcb-shop/services/cart/cart.js @@ -1,6 +1,7 @@ import { model, getAll } from '../../services/_utils/model'; import { config } from '../../config/index'; import { DATA_MODEL_KEY } from '../../config/model'; +import { cloudbaseTemplateConfig } from '../../config/index'; const CATE_ITEM_MODEL_KEY = DATA_MODEL_KEY.CART_ITEM; @@ -39,6 +40,10 @@ export async function getCartItem({ id }) { } export async function fetchCartItems() { + if (cloudbaseTemplateConfig.useMock) { + return []; + } + return getAll({ name: CATE_ITEM_MODEL_KEY, select: { diff --git a/miniprogram/tcb-shop/services/cate/cate.js b/miniprogram/tcb-shop/services/cate/cate.js index 331e1c9..03d5620 100644 --- a/miniprogram/tcb-shop/services/cate/cate.js +++ b/miniprogram/tcb-shop/services/cate/cate.js @@ -3,6 +3,8 @@ import { model, getAll } from '../_utils/model'; import { getCloudImageTempUrl } from '../../utils/cloudImageHandler'; import { SPU_SELLING_STATUS } from '../../utils/spuStatus'; import { DATA_MODEL_KEY } from '../../config/model'; +import { cloudbaseTemplateConfig } from '../../config/index'; +import { CATEGORY } from '../cloudbaseMock/index'; const CATE_MODEL_KEY = DATA_MODEL_KEY.CATE; @@ -36,6 +38,9 @@ export async function getAllSpuOfCate(cateId) { } export async function getCates() { + if (cloudbaseTemplateConfig.useMock) { + return CATEGORY; + } const cateSelect = { _id: true, name: true, @@ -55,6 +60,5 @@ export async function getCates() { const childCates = allCates.flatMap((c) => c.child_cate); const res = await getCloudImageTempUrl(childCates.map((x) => x.image)); res.forEach((image, index) => (childCates[index].image = image)); - return allCates; } diff --git a/miniprogram/tcb-shop/services/cloudbaseMock/index.js b/miniprogram/tcb-shop/services/cloudbaseMock/index.js new file mode 100644 index 0000000..45b9d89 --- /dev/null +++ b/miniprogram/tcb-shop/services/cloudbaseMock/index.js @@ -0,0 +1,189 @@ +export const SPU = [ + { + swiper_images: ['https://qcloudimg.tencent-cloud.cn/raw/c63c16644e5e961c5d3a4669ae9c2031.png'], + createdAt: 1727664442792, + createBy: 'administrator', + updateBy: '1788891669799862274', + name: '冰冻鲜荔枝5斤新鲜水果当季现摘爆甜桂花荔枝香老树大果整箱包邮', + detail: + '

冰冻鲜荔枝

', + cover_image: 'https://qcloudimg.tencent-cloud.cn/raw/c63c16644e5e961c5d3a4669ae9c2031.png', + _id: 'A3QFLVAF2Y', + priority: 2, + updatedAt: 1728886008869, + status: 'ENABLED', + }, + { + swiper_images: ['https://qcloudimg.tencent-cloud.cn/raw/9f718f547304d4fabe267d3b42076a54.png'], + createdAt: 1727664442868, + createBy: 'administrator', + updateBy: '1788891669799862274', + name: '山系焦糖咖色优质90白鸭绒加厚羽绒马甲男士冬季保暖工装背心外套', + detail: + '

保暖工装背心外套

🎽

暖!

', + cover_image: 'https://qcloudimg.tencent-cloud.cn/raw/9f718f547304d4fabe267d3b42076a54.png', + _id: 'A3QFLVHSDN', + priority: 1, + updatedAt: 1728885989601, + status: 'ENABLED', + }, + { + swiper_images: ['https://qcloudimg.tencent-cloud.cn/raw/512ef5ccf0c6d2895456097646a9defc.png'], + createdAt: 1727664442706, + createBy: 'administrator', + updateBy: '1788891669799862274', + name: '现摘现发江西赣南寻乌蜜桔当季青皮无籽橘子蜜橘孕妇新鲜水果酸甜', + detail: + '

现摘现发江西赣南寻乌蜜桔

好吃哈,多的不说了。

', + cover_image: 'https://qcloudimg.tencent-cloud.cn/raw/512ef5ccf0c6d2895456097646a9defc.png', + _id: 'A3QFLV1E3S', + priority: 1, + updatedAt: 1728886017368, + status: 'ENABLED', + }, + { + swiper_images: ['https://qcloudimg.tencent-cloud.cn/raw/c8b249e12a41f3df127a007ebca23615.png'], + createdAt: 1727664442614, + createBy: 'administrator', + updateBy: '1788891669799862274', + name: '2024新鲜现磨玉米面纯玉米粉200g5斤特细农家特产无添加面粉杂粮', + detail: + '

无添加面粉

吃到退休都可以。

', + cover_image: 'https://qcloudimg.tencent-cloud.cn/raw/c8b249e12a41f3df127a007ebca23615.png', + _id: 'A3QFLUSAK2', + priority: 1, + updatedAt: 1728886026215, + status: 'ENABLED', + }, +]; + +export const SKU = [ + { + image: 'https://qcloudimg.tencent-cloud.cn/raw/9f718f547304d4fabe267d3b42076a54.png', + createdAt: 1727664441729, + createBy: 'administrator', + updateBy: '1788891669799862274', + price: 200, + count: 100, + description: '厚马甲', + spu: { + _id: 'A3QFLVHSDN', + }, + _id: 'A3QFLS1D92', + updatedAt: 1728886147209, + }, + { + image: 'https://qcloudimg.tencent-cloud.cn/raw/9f718f547304d4fabe267d3b42076a54.png', + createdAt: 1727664441622, + createBy: 'administrator', + updateBy: '1788891669799862274', + price: 100, + count: 100, + description: '薄马甲', + spu: { + _id: 'A3QFLVHSDN', + }, + _id: 'A3QFLRPP4L', + updatedAt: 1728886165775, + }, + { + image: 'https://qcloudimg.tencent-cloud.cn/raw/c63c16644e5e961c5d3a4669ae9c2031.png', + createdAt: 1727664441962, + createBy: 'administrator', + updateBy: '1788891669799862274', + price: 100, + count: 100, + description: '普通荔枝', + spu: { + _id: 'A3QFLVAF2Y', + }, + _id: 'A3QFLSRKA8', + updatedAt: 1727675194609, + }, + { + image: 'https://qcloudimg.tencent-cloud.cn/raw/c8b249e12a41f3df127a007ebca23615.png', + createdAt: 1727664441849, + createBy: 'administrator', + updateBy: 'administrator', + price: 100, + count: 100, + description: '普通面粉', + spu: { + _id: 'A3QFLUSAK2', + }, + _id: 'A3QFLSDV5S', + updatedAt: 1727664441849, + }, + { + image: 'https://qcloudimg.tencent-cloud.cn/raw/512ef5ccf0c6d2895456097646a9defc.png', + createdAt: 1727664441518, + createBy: 'administrator', + updateBy: '1788891669799862274', + price: 10, + count: 100, + description: '1 个橘子', + spu: { + _id: 'A3QFLV1E3S', + }, + _id: 'A3QFLRCZFW', + updatedAt: 1728886173454, + }, + { + image: 'https://qcloudimg.tencent-cloud.cn/raw/512ef5ccf0c6d2895456097646a9defc.png', + createdAt: 1727664441409, + createBy: 'administrator', + updateBy: '1788891669799862274', + price: 90, + count: 100, + description: '10 个橘子', + spu: { + _id: 'A3QFLV1E3S', + }, + _id: 'A3QFLR1PHA', + updatedAt: 1728886237158, + }, +]; + +export const HOME_SWIPER = [ + { + images: [ + 'https://qcloudimg.tencent-cloud.cn/raw/f1639ac8e846a521d080ebc42aad32f5.png', + 'https://qcloudimg.tencent-cloud.cn/raw/fd6116161224708715024029fe0d7015.png', + 'https://qcloudimg.tencent-cloud.cn/raw/39e27bedac34c6b656132ac4cb850150.png', + 'https://qcloudimg.tencent-cloud.cn/raw/3279d6a8b69672d7aece04da5a1cc0ff.png', + 'https://qcloudimg.tencent-cloud.cn/raw/c98ae1da9ce69c4112b48137e42ad511.png', + ], + _id: 'A3QFLT6UVN', + }, +]; + +export const CATEGORY = [ + { + name: '衣物', + _id: 'A3QFLU3ME8', + child_cate: [ + { + image: 'https://qcloudimg.tencent-cloud.cn/raw/9f718f547304d4fabe267d3b42076a54.png', + name: '上衣', + _id: 'A3QFLUAFZJ', + }, + ], + }, + { + name: '美食', + image: '', + _id: 'A3QFLTJS32', + child_cate: [ + { + image: 'https://qcloudimg.tencent-cloud.cn/raw/c63c16644e5e961c5d3a4669ae9c2031.png', + name: '水果', + _id: 'A3QFLTVZG4', + }, + { + image: 'https://qcloudimg.tencent-cloud.cn/raw/c8b249e12a41f3df127a007ebca23615.png', + name: '面点', + _id: 'A3QFLUHL7A', + }, + ], + }, +]; diff --git a/miniprogram/tcb-shop/services/good/spu.js b/miniprogram/tcb-shop/services/good/spu.js index 05ae792..8c0b64c 100644 --- a/miniprogram/tcb-shop/services/good/spu.js +++ b/miniprogram/tcb-shop/services/good/spu.js @@ -2,6 +2,8 @@ import { model } from '../_utils/model'; import { getCloudImageTempUrl } from '../../utils/cloudImageHandler'; import { SPU_SELLING_STATUS } from '../../utils/spuStatus'; import { DATA_MODEL_KEY } from '../../config/model'; +import { cloudbaseTemplateConfig } from '../../config/index'; +import { SPU, SKU } from '../cloudbaseMock/index'; const SPU_MODEL_KEY = DATA_MODEL_KEY.SPU; const SKU_MODEL_KEY = DATA_MODEL_KEY.SKU; @@ -17,6 +19,12 @@ const SKU_MODEL_KEY = DATA_MODEL_KEY.SKU; * @returns */ export async function listGood({ pageSize, pageNumber, search }) { + if (cloudbaseTemplateConfig.useMock) { + return { + records: SPU, + total: SPU.length, + }; + } const filter = { where: { status: { $eq: SPU_SELLING_STATUS }, @@ -38,6 +46,9 @@ export async function listGood({ pageSize, pageNumber, search }) { } export async function getPrice(spuId) { + if (cloudbaseTemplateConfig.useMock) { + return SKU.find((x) => x.spu._id === spuId).price; + } const { data: { records }, } = await model()[SKU_MODEL_KEY].list({ @@ -48,6 +59,12 @@ export async function getPrice(spuId) { }, }, }, + select: { + $master: true, + spu: { + _id: true, + }, + }, }); return records[0].price; } diff --git a/miniprogram/tcb-shop/services/home/home.js b/miniprogram/tcb-shop/services/home/home.js index ac3483d..eabeb79 100644 --- a/miniprogram/tcb-shop/services/home/home.js +++ b/miniprogram/tcb-shop/services/home/home.js @@ -1,8 +1,14 @@ import { model } from '../_utils/model'; import { DATA_MODEL_KEY } from '../../config/model'; +import { cloudbaseTemplateConfig } from '../../config/index'; +import { HOME_SWIPER } from '../cloudbaseMock/index'; const HOME_SWIPER_MODEL_KEY = DATA_MODEL_KEY.HOME_SWIPER; export async function getHomeSwiper() { + if (cloudbaseTemplateConfig.useMock) { + return HOME_SWIPER[0]; + } + return (await model()[HOME_SWIPER_MODEL_KEY].list({ select: { images: true } })).data.records[0]; } diff --git a/miniprogram/tcb-shop/services/order/order.js b/miniprogram/tcb-shop/services/order/order.js index 265d882..38ec9d4 100644 --- a/miniprogram/tcb-shop/services/order/order.js +++ b/miniprogram/tcb-shop/services/order/order.js @@ -1,5 +1,6 @@ import { model, getAll } from '../../services/_utils/model'; import { DATA_MODEL_KEY } from '../../config/model'; +import { cloudbaseTemplateConfig } from "../../config/index" const ORDER_MODEL_KEY = DATA_MODEL_KEY.ORDER; @@ -87,6 +88,10 @@ export async function listOrder({ pageSize, pageNumber, status }) { } async function getOrderCountOfStatus(status) { + if (cloudbaseTemplateConfig.useMock) { + return 0; + } + return ( await model()[ORDER_MODEL_KEY].list({ filter: { where: { status: { $eq: status } } },