Merge branch 'feat/liujie'
This commit is contained in:
@@ -7,6 +7,7 @@ import DetailService from "@/services/detailService";
|
|||||||
import * as LoginService from "@/services/loginService";
|
import * as LoginService from "@/services/loginService";
|
||||||
import { getCurrentLocation } from "@/utils/locationUtils";
|
import { getCurrentLocation } from "@/utils/locationUtils";
|
||||||
import { useUserInfo, useUserActions } from "@/store/userStore";
|
import { useUserInfo, useUserActions } from "@/store/userStore";
|
||||||
|
import { useGlobalState } from "@/store/global";
|
||||||
import GameTags from "./components/GameTags";
|
import GameTags from "./components/GameTags";
|
||||||
import Carousel from "./components/Carousel";
|
import Carousel from "./components/Carousel";
|
||||||
import StickyBottom from "./components/StickyBottom";
|
import StickyBottom from "./components/StickyBottom";
|
||||||
@@ -33,6 +34,9 @@ function Index() {
|
|||||||
const { fetchUserInfo } = useUserActions(); // 获取登录用户的userInfo
|
const { fetchUserInfo } = useUserActions(); // 获取登录用户的userInfo
|
||||||
const myInfo = useUserInfo();
|
const myInfo = useUserInfo();
|
||||||
|
|
||||||
|
const { statusNavbarHeightInfo } = useGlobalState();
|
||||||
|
const { statusBarHeight, navBarHeight } = statusNavbarHeightInfo;
|
||||||
|
|
||||||
useSceneRedirect("game_pages/detail/index");
|
useSceneRedirect("game_pages/detail/index");
|
||||||
|
|
||||||
const isMyOwn = userInfo.id === myInfo.id;
|
const isMyOwn = userInfo.id === myInfo.id;
|
||||||
@@ -151,7 +155,13 @@ function Index() {
|
|||||||
return (
|
return (
|
||||||
<View className={styles["detail-page"]}>
|
<View className={styles["detail-page"]}>
|
||||||
{/* custom navbar */}
|
{/* custom navbar */}
|
||||||
<view className={styles["custom-navbar"]}>
|
<view
|
||||||
|
className={styles["custom-navbar"]}
|
||||||
|
style={{
|
||||||
|
height: `${statusBarHeight}px`,
|
||||||
|
paddingTop: `${navBarHeight}px`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<View className={styles["detail-navigator"]}>
|
<View className={styles["detail-navigator"]}>
|
||||||
<View
|
<View
|
||||||
className={styles["detail-navigator-back"]}
|
className={styles["detail-navigator-back"]}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export default definePageConfig({
|
export default definePageConfig({
|
||||||
navigationBarTitleText: "订单详情",
|
navigationBarTitleText: "订单详情",
|
||||||
|
navigationStyle: 'custom',
|
||||||
navigationBarBackgroundColor: "#FAFAFA",
|
navigationBarBackgroundColor: "#FAFAFA",
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,6 +11,15 @@
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.navbar {
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
& > view > view:nth-child(2) {
|
||||||
|
justify-content: flex-start;
|
||||||
|
margin-left: -30px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|||||||
@@ -20,8 +20,10 @@ import {
|
|||||||
generateOrderActions,
|
generateOrderActions,
|
||||||
} from "@/utils";
|
} from "@/utils";
|
||||||
import { getStorage, setStorage } from "@/store/storage";
|
import { getStorage, setStorage } from "@/store/storage";
|
||||||
|
import { useGlobalStore } from "@/store/global";
|
||||||
|
import { useOrder } from "@/store/orderStore";
|
||||||
import detailService, { GameData } from "@/services/detailService";
|
import detailService, { GameData } from "@/services/detailService";
|
||||||
import { withAuth, RefundPopup } from "@/components";
|
import { withAuth, RefundPopup, GeneralNavbar } from "@/components";
|
||||||
import img from "@/config/images";
|
import img from "@/config/images";
|
||||||
import CustomerIcon from "@/static/order/customer.svg";
|
import CustomerIcon from "@/static/order/customer.svg";
|
||||||
import { handleCustomerService } from "@/services/userService";
|
import { handleCustomerService } from "@/services/userService";
|
||||||
@@ -49,6 +51,9 @@ const gameNoticeMap = new Map([
|
|||||||
function genGameNotice(order_status, start_time) {
|
function genGameNotice(order_status, start_time) {
|
||||||
const startTime = dayjs(start_time);
|
const startTime = dayjs(start_time);
|
||||||
let key = "";
|
let key = "";
|
||||||
|
if (order_status === OrderStatus.PENDING) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
if (order_status === OrderStatus.FINISHED) {
|
if (order_status === OrderStatus.FINISHED) {
|
||||||
key = "finish";
|
key = "finish";
|
||||||
}
|
}
|
||||||
@@ -235,12 +240,13 @@ function GameInfo(props) {
|
|||||||
{refundTextMap.get(refund_status)} ¥ {amount}
|
{refundTextMap.get(refund_status)} ¥ {amount}
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
{["progress", "expired"].includes(orderStatus) && (
|
{["progress", "expired"].includes(orderStatus) &&
|
||||||
<View className={styles.gameStatus}>
|
order_status !== OrderStatus.PENDING && (
|
||||||
<Text className={styles.statusText}>{gameNotice.title}</Text>
|
<View className={styles.gameStatus}>
|
||||||
{gameNotice.content && <Text>{gameNotice.content}</Text>}
|
<Text className={styles.statusText}>{gameNotice.title}</Text>
|
||||||
</View>
|
{gameNotice.content && <Text>{gameNotice.content}</Text>}
|
||||||
)}
|
</View>
|
||||||
|
)}
|
||||||
<View className={styles.gameInfo}>
|
<View className={styles.gameInfo}>
|
||||||
{/* Date and Weather */}
|
{/* Date and Weather */}
|
||||||
<View className={styles.gameInfoDateWeather}>
|
<View className={styles.gameInfoDateWeather}>
|
||||||
@@ -505,7 +511,7 @@ const OrderCheck = () => {
|
|||||||
const [location, setLocation] = useState<number[]>([0, 0]);
|
const [location, setLocation] = useState<number[]>([0, 0]);
|
||||||
const [checkOrderInfo, setCheckOrderInfo] = useState<GameOrderRes | {}>({});
|
const [checkOrderInfo, setCheckOrderInfo] = useState<GameOrderRes | {}>({});
|
||||||
const [orderDetail, setOrderDetail] = useState({});
|
const [orderDetail, setOrderDetail] = useState({});
|
||||||
const [paying, setPaying] = useState(false);
|
const { paying, setPaying } = useOrder();
|
||||||
|
|
||||||
useDidShow(() => {
|
useDidShow(() => {
|
||||||
init();
|
init();
|
||||||
@@ -615,8 +621,19 @@ const OrderCheck = () => {
|
|||||||
|
|
||||||
const { order_status, cancel_type } = orderDetail;
|
const { order_status, cancel_type } = orderDetail;
|
||||||
|
|
||||||
|
const { statusNavbarHeightInfo } = useGlobalStore();
|
||||||
|
const { totalHeight } = statusNavbarHeightInfo;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className={styles.container}>
|
<View
|
||||||
|
className={styles.container}
|
||||||
|
style={{ paddingTop: `${totalHeight + 8}px` }}
|
||||||
|
>
|
||||||
|
<GeneralNavbar
|
||||||
|
title={id ? "订单详情" : "加入活动"}
|
||||||
|
titleClassName={styles.titleClassName}
|
||||||
|
className={styles.navbar}
|
||||||
|
/>
|
||||||
{/* Game Date and Address */}
|
{/* Game Date and Address */}
|
||||||
<GameInfo
|
<GameInfo
|
||||||
detail={detail}
|
detail={detail}
|
||||||
@@ -636,16 +653,17 @@ const OrderCheck = () => {
|
|||||||
<Disclaimer />
|
<Disclaimer />
|
||||||
{(!id ||
|
{(!id ||
|
||||||
(order_status === OrderStatus.PENDING &&
|
(order_status === OrderStatus.PENDING &&
|
||||||
cancel_type === CancelType.NONE)) && (
|
cancel_type === CancelType.NONE)) &&
|
||||||
<Button
|
!paying && (
|
||||||
className={styles.payButton}
|
<Button
|
||||||
disabled={paying}
|
className={styles.payButton}
|
||||||
onClick={handlePay}
|
disabled={paying}
|
||||||
>
|
onClick={handlePay}
|
||||||
{order_status === OrderStatus.PENDING ? "继续" : "确认"}
|
>
|
||||||
支付
|
{order_status === OrderStatus.PENDING ? "继续" : "确认"}
|
||||||
</Button>
|
支付
|
||||||
)}
|
</Button>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import orderService, {
|
|||||||
refundTextMap,
|
refundTextMap,
|
||||||
} from "@/services/orderService";
|
} from "@/services/orderService";
|
||||||
import { getStorage, removeStorage, setStorage } from "@/store/storage";
|
import { getStorage, removeStorage, setStorage } from "@/store/storage";
|
||||||
|
import { useGlobalStore } from "@/store/global";
|
||||||
import { handleCustomerService } from "@/services/userService";
|
import { handleCustomerService } from "@/services/userService";
|
||||||
import { withAuth, RefundPopup, GeneralNavbar } from "@/components";
|
import { withAuth, RefundPopup, GeneralNavbar } from "@/components";
|
||||||
import { payOrder, generateOrderActions } from "@/utils";
|
import { payOrder, generateOrderActions } from "@/utils";
|
||||||
@@ -256,8 +257,14 @@ const OrderList = () => {
|
|||||||
|
|
||||||
const flatList = list.flat();
|
const flatList = list.flat();
|
||||||
|
|
||||||
|
const { statusNavbarHeightInfo } = useGlobalStore();
|
||||||
|
const { totalHeight } = statusNavbarHeightInfo;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className={styles.container}>
|
<View
|
||||||
|
className={styles.container}
|
||||||
|
style={{ paddingTop: `${totalHeight + 8}px` }}
|
||||||
|
>
|
||||||
<GeneralNavbar
|
<GeneralNavbar
|
||||||
title="订单列表"
|
title="订单列表"
|
||||||
backgroundColor="transparent"
|
backgroundColor="transparent"
|
||||||
@@ -278,7 +285,9 @@ const OrderList = () => {
|
|||||||
const unPay =
|
const unPay =
|
||||||
item.order_status === OrderStatus.PENDING &&
|
item.order_status === OrderStatus.PENDING &&
|
||||||
item.cancel_type === CancelType.NONE;
|
item.cancel_type === CancelType.NONE;
|
||||||
const timeout = item.cancel_type === CancelType.TIMEOUT;
|
const canceled = [CancelType.USER, CancelType.TIMEOUT].includes(
|
||||||
|
item.cancel_type
|
||||||
|
);
|
||||||
const { game_info } = item;
|
const { game_info } = item;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -300,7 +309,7 @@ const OrderList = () => {
|
|||||||
>
|
>
|
||||||
<View className={styles.gameTitle}>
|
<View className={styles.gameTitle}>
|
||||||
<View className={styles.title}>{item?.game_info?.title}</View>
|
<View className={styles.title}>{item?.game_info?.title}</View>
|
||||||
{!timeout && (
|
{!canceled && (
|
||||||
<View
|
<View
|
||||||
className={classnames(
|
className={classnames(
|
||||||
styles.payNum,
|
styles.payNum,
|
||||||
|
|||||||
16
src/store/orderStore.ts
Normal file
16
src/store/orderStore.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { create } from "zustand";
|
||||||
|
|
||||||
|
export interface OrderStore {
|
||||||
|
paying: boolean;
|
||||||
|
setPaying: (paying: boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useOrderStore = create<OrderStore>()((set) => ({
|
||||||
|
paying: false,
|
||||||
|
setPaying: (paying: boolean) => set({ paying }),
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const useOrder = () => useOrderStore(({ paying, setPaying }) => ({
|
||||||
|
paying,
|
||||||
|
setPaying,
|
||||||
|
}))
|
||||||
@@ -8,10 +8,11 @@ export function getOrderStatus(orderData) {
|
|||||||
const unPay = order_status === OrderStatus.PENDING && ([CancelType.NONE].includes(cancel_type));
|
const unPay = order_status === OrderStatus.PENDING && ([CancelType.NONE].includes(cancel_type));
|
||||||
const refund = [RefundStatus.PENDING, RefundStatus.SUCCESS].includes(refund_status);
|
const refund = [RefundStatus.PENDING, RefundStatus.SUCCESS].includes(refund_status);
|
||||||
const expired =
|
const expired =
|
||||||
order_status === OrderStatus.FINISHED ||
|
order_status === OrderStatus.FINISHED;
|
||||||
[CancelType.TIMEOUT, CancelType.USER].includes(cancel_type);
|
|
||||||
|
|
||||||
return unPay ? 'unpay' : refund ? 'refund' : expired ? cancel_type === CancelType.TIMEOUT ? 'timeout' : 'expired' : 'progress'
|
const canceled = [CancelType.TIMEOUT, CancelType.USER].includes(cancel_type);
|
||||||
|
|
||||||
|
return unPay ? 'unpay' : refund ? 'refund' : canceled ? 'canceled' : expired ? 'expired' : 'progress'
|
||||||
}
|
}
|
||||||
|
|
||||||
// scene: list、detail
|
// scene: list、detail
|
||||||
@@ -54,7 +55,7 @@ export function generateOrderActions(orderData, actions, scene) {
|
|||||||
|
|
||||||
if (scene === 'list') {
|
if (scene === 'list') {
|
||||||
const actionMap = new Map([
|
const actionMap = new Map([
|
||||||
['timeout', [deleteOrder, gameDetail]],
|
['canceled', [deleteOrder, gameDetail]],
|
||||||
['expired', [deleteOrder, gameDetail]],
|
['expired', [deleteOrder, gameDetail]],
|
||||||
['progress', [quitGame, gameDetail]],
|
['progress', [quitGame, gameDetail]],
|
||||||
['refund', [deleteOrder, gameDetail]],
|
['refund', [deleteOrder, gameDetail]],
|
||||||
@@ -65,7 +66,7 @@ export function generateOrderActions(orderData, actions, scene) {
|
|||||||
|
|
||||||
if (scene === 'detail') {
|
if (scene === 'detail') {
|
||||||
const actionMap = new Map([
|
const actionMap = new Map([
|
||||||
['timeout', [deleteOrder, gameDetail]],
|
['canceled', [deleteOrder, gameDetail]],
|
||||||
['expired', [gameDetail, deleteOrder]],
|
['expired', [gameDetail, deleteOrder]],
|
||||||
['progress', [gameDetail, quitGame]],
|
['progress', [gameDetail, quitGame]],
|
||||||
['refund', [deleteOrder, gameDetail]],
|
['refund', [deleteOrder, gameDetail]],
|
||||||
|
|||||||
Reference in New Issue
Block a user