Commit 006468e4 by 姜雷

修改我的订单样式

parent 0f69b4fe
page {
padding-top: 80px;
background-color: #eee;
}
.OrderList { .OrderList {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 100%; width: 100%;
height: 100%; // height: 100%;
overflow: hidden; // overflow: hidden;
.Tab { .Tab {
position: absolute; position: fixed;
top: 0; top: 0;
display: flex; display: flex;
background-color: #fff; background-color: #fff;
...@@ -14,6 +18,7 @@ ...@@ -14,6 +18,7 @@
line-height: 80px; line-height: 80px;
text-align: center; text-align: center;
font-size: 30px; font-size: 30px;
z-index: 1;
.Tab-item { .Tab-item {
width: 50%; width: 50%;
color: #999; color: #999;
...@@ -28,6 +33,10 @@ ...@@ -28,6 +33,10 @@
margin-top: 80px; margin-top: 80px;
background-color: #eee; background-color: #eee;
} }
.OrderList-Wrap {
padding-top: 22px;
background-color: #eee;
}
.OrderList-Group { .OrderList-Group {
margin-bottom: 22px; margin-bottom: 22px;
.OrderList-GroupTitle { .OrderList-GroupTitle {
......
...@@ -11,16 +11,20 @@ import { ...@@ -11,16 +11,20 @@ import {
} from './actions'; } from './actions';
import { RechargeOrderItem } from '@/api/order'; import { RechargeOrderItem } from '@/api/order';
export type ConsumeOrderInfo = {
consumeOrders: AllOrderItem[];
lastOrderId: number;
};
export type RechargeOrderInfo = {
rechargeOrders: RechargeOrderItem[];
lastOrderId: number;
};
export interface OrderStoreState { export interface OrderStoreState {
selectedOrder: Order; selectedOrder: Order;
consume: { consume: ConsumeOrderInfo;
consumeOrders: AllOrderItem[]; recharge: RechargeOrderInfo;
lastOrderId: number;
};
recharge: {
rechargeOrders: RechargeOrderItem[];
lastOrderId: number;
};
} }
const initOrder = () => ({ const initOrder = () => ({
actualMoney: 0, actualMoney: 0,
...@@ -64,6 +68,18 @@ const INITIAL_STATE = { ...@@ -64,6 +68,18 @@ const INITIAL_STATE = {
}, },
}; };
const getLastId = (arr): number => {
const itemIdx = arr.length - 1;
if (itemIdx >= 0) {
const orderIdx = arr[itemIdx].data.length - 1;
if (orderIdx >= 0) {
let lastOrderId = arr[itemIdx].data[orderIdx].id;
return lastOrderId;
}
}
return 0;
};
export default function OrderList( export default function OrderList(
state: OrderStoreState = INITIAL_STATE, state: OrderStoreState = INITIAL_STATE,
actions: Actions, actions: Actions,
...@@ -75,6 +91,17 @@ export default function OrderList( ...@@ -75,6 +91,17 @@ export default function OrderList(
selectedOrder: actions.payload, selectedOrder: actions.payload,
}; };
case UPDATE_CONSUME_ORDERS: case UPDATE_CONSUME_ORDERS:
if (actions.payload.length) {
let arr = actions.payload;
let lastOrderId = getLastId(arr);
return {
...state,
consume: {
lastOrderId: lastOrderId,
consumeOrders: actions.payload,
},
};
}
return { return {
...state, ...state,
consume: { consume: {
...@@ -83,6 +110,17 @@ export default function OrderList( ...@@ -83,6 +110,17 @@ export default function OrderList(
}, },
}; };
case APPEND_CONSUME_ORDERS: case APPEND_CONSUME_ORDERS:
if (actions.payload.length) {
let arr = actions.payload;
let lastOrderId = getLastId(arr);
return {
...state,
consume: {
lastOrderId: lastOrderId,
consumeOrders: [...state.consume.consumeOrders, ...actions.payload],
},
};
}
return { return {
...state, ...state,
consume: { consume: {
...@@ -99,6 +137,17 @@ export default function OrderList( ...@@ -99,6 +137,17 @@ export default function OrderList(
}, },
}; };
case UPDATE_RECHARGE_ORDERS: case UPDATE_RECHARGE_ORDERS:
if (actions.payload.length) {
let arr = actions.payload;
let lastOrderId = getLastId(arr);
return {
...state,
recharge: {
lastOrderId: lastOrderId,
rechargeOrders: actions.payload,
},
};
}
return { return {
...state, ...state,
recharge: { recharge: {
...@@ -107,6 +156,20 @@ export default function OrderList( ...@@ -107,6 +156,20 @@ export default function OrderList(
}, },
}; };
case APPEND_RECHARGE_ORDERS: case APPEND_RECHARGE_ORDERS:
if (actions.payload.length) {
let arr = actions.payload;
let lastOrderId = getLastId(arr);
return {
...state,
recharge: {
lastOrderId: lastOrderId,
rechargeOrders: [
...state.recharge.rechargeOrders,
...actions.payload,
],
},
};
}
return { return {
...state, ...state,
recharge: { recharge: {
......
...@@ -34,16 +34,6 @@ const useConsumeOrders = ( ...@@ -34,16 +34,6 @@ const useConsumeOrders = (
console.log(err); console.log(err);
}); });
const fetchMore = () => { const fetchMore = () => {
let arr = state.consumeOrders;
const itemIdx = arr.length - 1;
if (itemIdx >= 0) {
const orderIdx = arr[itemIdx].data.length - 1;
if (orderIdx >= 0) {
dispatch(updateConsumeLastId(arr[itemIdx].data[orderIdx].id));
return fetchData(customerId, pageSize);
}
}
dispatch(updateConsumeLastId(0));
return fetchData(customerId, pageSize); return fetchData(customerId, pageSize);
}; };
const resetOrders = () => { const resetOrders = () => {
......
...@@ -32,16 +32,6 @@ const useRechargeOrders = ( ...@@ -32,16 +32,6 @@ const useRechargeOrders = (
console.log(err); console.log(err);
}); });
const fetchMore = () => { const fetchMore = () => {
let arr = state.rechargeOrders;
const itemIdx = arr.length - 1;
if (itemIdx >= 0) {
const orderIdx = arr[itemIdx].data.length - 1;
if (orderIdx >= 0) {
dispatch(updateRechargeLastId(arr[itemIdx].data[orderIdx].id));
return fetchData(customerId, pageSize);
}
}
dispatch(updateRechargeLastId(0));
return fetchData(customerId, pageSize); return fetchData(customerId, pageSize);
}; };
const resetOrders = () => { const resetOrders = () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment