fixed 完善购物车列表展示
This commit is contained in:
parent
a22aa80b8a
commit
fa015b5cd4
@ -19,7 +19,8 @@ Page({
|
|||||||
refreshData() {
|
refreshData() {
|
||||||
this.getCartGroupData().then((res) => {
|
this.getCartGroupData().then((res) => {
|
||||||
let isEmpty = true;
|
let isEmpty = true;
|
||||||
const cartGroupData = res.data;
|
const cartGroupData = res;
|
||||||
|
console.log(cartGroupData,'1231232');
|
||||||
// 一些组件中需要的字段可能接口并没有返回,或者返回的数据结构与预期不一致,需要在此先对数据做一些处理
|
// 一些组件中需要的字段可能接口并没有返回,或者返回的数据结构与预期不一致,需要在此先对数据做一些处理
|
||||||
// 统计门店下加购的商品是否全选、是否存在缺货/无货
|
// 统计门店下加购的商品是否全选、是否存在缺货/无货
|
||||||
for (const store of cartGroupData.storeGoods) {
|
for (const store of cartGroupData.storeGoods) {
|
||||||
@ -56,10 +57,10 @@ Page({
|
|||||||
isEmpty = false;
|
isEmpty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cartGroupData.invalidGoodItems = cartGroupData.invalidGoodItems.map((goods) => {
|
// cartGroupData.invalidGoodItems = cartGroupData.invalidGoodItems.map((goods) => {
|
||||||
goods.originPrice = undefined;
|
// goods.originPrice = undefined;
|
||||||
return goods;
|
// return goods;
|
||||||
});
|
// });
|
||||||
cartGroupData.isNotEmpty = !isEmpty;
|
cartGroupData.isNotEmpty = !isEmpty;
|
||||||
this.setData({ cartGroupData });
|
this.setData({ cartGroupData });
|
||||||
});
|
});
|
||||||
|
@ -1,20 +1,21 @@
|
|||||||
import { config } from '../../config/index';
|
import {
|
||||||
|
request
|
||||||
/** 获取购物车mock数据 */
|
} from '../_utils/request';
|
||||||
function mockFetchCartGroupData(params) {
|
|
||||||
const { delay } = require('../_utils/delay');
|
|
||||||
const { genCartGroupData } = require('../../model/cart');
|
|
||||||
|
|
||||||
return delay().then(() => genCartGroupData(params));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 获取购物车数据 */
|
/** 获取购物车数据 */
|
||||||
export function fetchCartGroupData(params) {
|
export function fetchCartGroupData() {
|
||||||
if (config.useMock) {
|
return new Promise((resolve, reject) => {
|
||||||
return mockFetchCartGroupData(params);
|
request({
|
||||||
}
|
url: `CartApi/getCartList`,
|
||||||
|
method: 'GET',
|
||||||
return new Promise((resolve) => {
|
success: function (res) {
|
||||||
resolve('real api');
|
let list = res.data;
|
||||||
|
|
||||||
|
resolve(list);
|
||||||
|
},
|
||||||
|
fail: function (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user