Merge branch 'feat/liujie'
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
export default definePageConfig({
|
export default definePageConfig({
|
||||||
navigationBarTitleText: '订单确认',
|
navigationBarTitleText: '订单列表',
|
||||||
navigationBarBackgroundColor: '#FAFAFA'
|
navigationBarBackgroundColor: '#FAFAFA'
|
||||||
})
|
})
|
||||||
33
src/mod_user/orderList/index.module.scss
Normal file
33
src/mod_user/orderList/index.module.scss
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
@use '~@/scss/images.scss' as img;
|
|
||||||
@@ -1,71 +1,39 @@
|
|||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { View, Text, Button } from '@tarojs/components'
|
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 { delay } from '@/utils'
|
||||||
import orderService from '@/services/orderService'
|
import orderService from '@/services/orderService'
|
||||||
import detailService, { GameDetail } from '@/services/detailService'
|
|
||||||
import { withAuth } from '@/components'
|
import { withAuth } from '@/components'
|
||||||
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
const OrderCheck = () => {
|
const OrderList = () => {
|
||||||
const { params } = useRouter()
|
const [list, setList] = useState([])
|
||||||
const { id, gameId } = params
|
|
||||||
const [detail ,setDetail] = useState<GameDetail | {}>({})
|
|
||||||
|
|
||||||
useDidShow(async () => {
|
useDidShow(async () => {
|
||||||
const res = await detailService.getDetail(Number(gameId))
|
const res = await orderService.getOrderList()
|
||||||
console.log(res)
|
console.log(res)
|
||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
setDetail(res.data)
|
setList(res.data.rows)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
//TODO: get order msg from id
|
console.log(list, 'list')
|
||||||
const handlePay = async () => {
|
|
||||||
Taro.showLoading({
|
return (
|
||||||
title: '支付中...',
|
<View className={styles.container}>
|
||||||
mask: true
|
{
|
||||||
})
|
list.map(item => {
|
||||||
const res = await orderService.createOrder(Number(gameId))
|
return (
|
||||||
if (res.code === 0) {
|
<View key={item.id} className={styles.orderItem}>
|
||||||
const { payment_required, payment_params } = res.data
|
<View className={styles.orderTitle}></View>
|
||||||
if (payment_required) {
|
<View className={styles.gameInfo}>{item?.game_info?.title}</View>
|
||||||
const { timeStamp, nonceStr, package: package_, signType, paySign } = payment_params
|
<View className={styles.orderActions}></View>
|
||||||
await Taro.requestPayment({
|
</View>
|
||||||
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'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<View>
|
|
||||||
<Text>OrderCheck</Text>
|
|
||||||
<Text>球局名称:{detail?.title || '-'}</Text>
|
|
||||||
<Text>价格:¥{detail?.price || '-'}</Text>
|
|
||||||
<Button onClick={handlePay}>支付</Button>
|
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withAuth(OrderCheck)
|
export default withAuth(OrderList)
|
||||||
@@ -68,7 +68,11 @@ export interface GameOrderRes {
|
|||||||
|
|
||||||
// 发布球局类
|
// 发布球局类
|
||||||
class OrderService {
|
class OrderService {
|
||||||
// 用户登录
|
// 查询订单列表
|
||||||
|
async getOrderList() {
|
||||||
|
return httpService.post('/user/orders', {}, { showLoading: true })
|
||||||
|
}
|
||||||
|
// 创建订单
|
||||||
async createOrder(game_id: number): Promise<ApiResponse<OrderResponse>> {
|
async createOrder(game_id: number): Promise<ApiResponse<OrderResponse>> {
|
||||||
return httpService.post('/payment/create_order', { game_id }, {
|
return httpService.post('/payment/create_order', { game_id }, {
|
||||||
showLoading: true,
|
showLoading: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user