feat: 订单列表

This commit is contained in:
2025-09-10 18:29:03 +08:00
parent d60445b850
commit 7ab40efae4
5 changed files with 59 additions and 55 deletions

View File

@@ -1,4 +1,4 @@
export default definePageConfig({
navigationBarTitleText: '订单确认',
navigationBarTitleText: '订单列表',
navigationBarBackgroundColor: '#FAFAFA'
})

View File

@@ -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);
}
}
}

View File

@@ -1 +0,0 @@
@use '~@/scss/images.scss' as img;

View File

@@ -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<GameDetail | {}>({})
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 (
<View className={styles.container}>
{
list.map(item => {
return (
<View key={item.id} className={styles.orderItem}>
<View className={styles.orderTitle}></View>
<View className={styles.gameInfo}>{item?.game_info?.title}</View>
<View className={styles.orderActions}></View>
</View>
)
})
}
}
}
return (
<View>
<Text>OrderCheck</Text>
<Text>{detail?.title || '-'}</Text>
<Text>¥{detail?.price || '-'}</Text>
<Button onClick={handlePay}></Button>
</View>
)
}
export default withAuth(OrderCheck)
export default withAuth(OrderList)

View File

@@ -68,7 +68,11 @@ export interface GameOrderRes {
// 发布球局类
class OrderService {
// 用户登录
// 查询订单列表
async getOrderList() {
return httpService.post('/user/orders', {}, { showLoading: true })
}
// 创建订单
async createOrder(game_id: number): Promise<ApiResponse<OrderResponse>> {
return httpService.post('/payment/create_order', { game_id }, {
showLoading: true,