From 7ab40efae4dcf39ad1e8a659ad8783feb02b8245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=9D=B0?= Date: Wed, 10 Sep 2025 18:29:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mod_user/orderList/index.config.ts | 2 +- src/mod_user/orderList/index.module.scss | 33 +++++++++++ src/mod_user/orderList/index.scss | 1 - src/mod_user/orderList/index.tsx | 72 +++++++----------------- src/services/orderService.ts | 6 +- 5 files changed, 59 insertions(+), 55 deletions(-) create mode 100644 src/mod_user/orderList/index.module.scss delete mode 100644 src/mod_user/orderList/index.scss diff --git a/src/mod_user/orderList/index.config.ts b/src/mod_user/orderList/index.config.ts index e8419ed..7824187 100644 --- a/src/mod_user/orderList/index.config.ts +++ b/src/mod_user/orderList/index.config.ts @@ -1,4 +1,4 @@ export default definePageConfig({ - navigationBarTitleText: '订单确认', + navigationBarTitleText: '订单列表', navigationBarBackgroundColor: '#FAFAFA' }) \ No newline at end of file diff --git a/src/mod_user/orderList/index.module.scss b/src/mod_user/orderList/index.module.scss new file mode 100644 index 0000000..a41d76c --- /dev/null +++ b/src/mod_user/orderList/index.module.scss @@ -0,0 +1,33 @@ +@use '~@/scss/images.scss' as img; + +.container { + padding: 12px; + background-color: #fafafa; + min-height: 100vh; + + .orderItem { + width: 100%; + height: 222px; + background-color: #fff; + border-radius: 12px; + border: 1px solid rgba(0, 0, 0, 0.06); + box-shadow: 0 4px 36px 0 rgba(0, 0, 0, 0.06); + margin-bottom: 12px; + + .orderTitle { + height: 18px; + padding: 15px 15px 12px; + border-bottom: 1px solid rgba(0, 0, 0, 0.06); + } + + .gameInfo { + height: 122px; + } + + .orderActions { + height: 28px; + padding: 12px 12px 15px; + border-top: 1px solid rgba(0, 0, 0, 0.06); + } + } +} \ No newline at end of file diff --git a/src/mod_user/orderList/index.scss b/src/mod_user/orderList/index.scss deleted file mode 100644 index e9e7c6b..0000000 --- a/src/mod_user/orderList/index.scss +++ /dev/null @@ -1 +0,0 @@ -@use '~@/scss/images.scss' as img; \ No newline at end of file diff --git a/src/mod_user/orderList/index.tsx b/src/mod_user/orderList/index.tsx index 94c8903..51d1aab 100644 --- a/src/mod_user/orderList/index.tsx +++ b/src/mod_user/orderList/index.tsx @@ -1,71 +1,39 @@ import React, { useState } from 'react' import { View, Text, Button } from '@tarojs/components' -import Taro, { useDidShow, useRouter } from '@tarojs/taro' +import Taro, { useDidShow } from '@tarojs/taro' import { delay } from '@/utils' import orderService from '@/services/orderService' -import detailService, { GameDetail } from '@/services/detailService' import { withAuth } from '@/components' +import styles from './index.module.scss' -const OrderCheck = () => { - const { params } = useRouter() - const { id, gameId } = params - const [detail ,setDetail] = useState({}) +const OrderList = () => { + const [list, setList] = useState([]) useDidShow(async () => { - const res = await detailService.getDetail(Number(gameId)) + const res = await orderService.getOrderList() console.log(res) if (res.code === 0) { - setDetail(res.data) + setList(res.data.rows) } }) - //TODO: get order msg from id - const handlePay = async () => { - Taro.showLoading({ - title: '支付中...', - mask: true - }) - const res = await orderService.createOrder(Number(gameId)) - if (res.code === 0) { - const { payment_required, payment_params } = res.data - if (payment_required) { - const { timeStamp, nonceStr, package: package_, signType, paySign } = payment_params - await Taro.requestPayment({ - timeStamp, - nonceStr, - package: package_, - signType, - paySign, - success: async () => { - Taro.hideLoading() - Taro.showToast({ - title: '支付成功', - icon: 'success' - }) - await delay(1000) - Taro.navigateBack({ - delta: 1 - }) - }, - fail: () => { - Taro.hideLoading() - Taro.showToast({ - title: '支付失败', - icon: 'none' - }) - } + console.log(list, 'list') + + return ( + + { + list.map(item => { + return ( + + + {item?.game_info?.title} + + + ) }) } - } - } - return ( - - OrderCheck - 球局名称:{detail?.title || '-'} - 价格:¥{detail?.price || '-'} - ) } -export default withAuth(OrderCheck) \ No newline at end of file +export default withAuth(OrderList) \ No newline at end of file diff --git a/src/services/orderService.ts b/src/services/orderService.ts index 196e88f..76f3394 100644 --- a/src/services/orderService.ts +++ b/src/services/orderService.ts @@ -68,7 +68,11 @@ export interface GameOrderRes { // 发布球局类 class OrderService { - // 用户登录 + // 查询订单列表 + async getOrderList() { + return httpService.post('/user/orders', {}, { showLoading: true }) + } + // 创建订单 async createOrder(game_id: number): Promise> { return httpService.post('/payment/create_order', { game_id }, { showLoading: true,