1、支付联调

This commit is contained in:
cuiyouliang 2025-09-01 18:18:26 +08:00
parent ce0331e4c6
commit f0fd7fa2c2
3 changed files with 59 additions and 6 deletions

View File

@ -14,4 +14,11 @@ class ShopApi {
///---------------------get ///---------------------get
/// [url参数/id] /// [url参数/id]
static const String shopDetail = '/app/product'; // static const String shopDetail = '/app/product'; //
//
static const String createGoodsOrder = '/oms/order/add';
//
static const String goodsOrderDetail = '/oms/order';
} }

View File

@ -77,6 +77,33 @@ class _GoodsState extends State<Goods> {
} }
} }
///
createOrder(String goodsId) async {
var params ={
"type": 1, // 1->2->;3->
"distribution": 1, // 1->2->;3->;
"skuItemBOList": [
{
"skuId": goodsId,
"quantity": 1
}
]
};
print('下单请求参数---->${params}');
try {
final res = await Http.post('${ShopApi.createGoodsOrder}', data: params);
var resData = res['data'];
print('1111111111111111111111111---->${res}');
if(resData['id'].isNotEmpty){
return resData['id'];
}else{
return null;
}
} catch (e) {
logger.e(e);
return null;
}
}
void handleShareClick(int index) { void handleShareClick(int index) {
final description = shopObj['describe']; // final description = shopObj['describe']; //
if (index == 1) { if (index == 1) {
@ -621,10 +648,15 @@ class _GoodsState extends State<Goods> {
padding: const EdgeInsets.symmetric(horizontal: 20.0), padding: const EdgeInsets.symmetric(horizontal: 20.0),
color: Color(0xFFFF5000), color: Color(0xFFFF5000),
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () async {
// orderId // orderId
String orderId = '1958380183857659904'; // // String orderId = '1958380183857659904'; //
Get.toNamed('/order/detail', arguments: orderId); String orderId = await createOrder(shopObj['skuList'][0]['id']);
if(orderId.isNotEmpty){
Get.toNamed('/order/detail', arguments: orderId);
}else{
MyDialog.toast('生成订单失败', icon: const Icon(Icons.warning), style: ToastStyle(backgroundColor: Colors.red.withAlpha(200)));
}
}, },
child: Text( child: Text(
'立即购买', '立即购买',

View File

@ -2,8 +2,11 @@ library;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:loopin/service/http.dart';
import 'package:loopin/api/shop_api.dart';
import 'package:shirne_dialog/shirne_dialog.dart'; import 'package:shirne_dialog/shirne_dialog.dart';
import 'package:timer_count_down/timer_count_down.dart'; import 'package:timer_count_down/timer_count_down.dart';
import 'package:loopin/utils/wxsdk.dart';
import '../../behavior/custom_scroll_behavior.dart'; import '../../behavior/custom_scroll_behavior.dart';
@ -16,6 +19,7 @@ class OrderDetail extends StatefulWidget {
class _OrderDetailState extends State<OrderDetail> with SingleTickerProviderStateMixin { class _OrderDetailState extends State<OrderDetail> with SingleTickerProviderStateMixin {
late String _orderId; late String _orderId;
dynamic orderGoodsInfo;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -25,7 +29,15 @@ class _OrderDetailState extends State<OrderDetail> with SingleTickerProviderStat
// //
void getOrderDetail({required String orderId}) async { void getOrderDetail({required String orderId}) async {
// try {
final res = await Http.get('${ShopApi.goodsOrderDetail}/$orderId');
print('订单详情-------------->${res['data']}');
setState(() {
orderGoodsInfo = res['data']; // data
});
} catch (e) {
Get.back();
}
} }
// //
int handleTime() { int handleTime() {
@ -38,7 +50,6 @@ class _OrderDetailState extends State<OrderDetail> with SingleTickerProviderStat
if (remainSeconds < 0) remainSeconds = 0; if (remainSeconds < 0) remainSeconds = 0;
return remainSeconds; return remainSeconds;
} }
Widget emptyTip() { Widget emptyTip() {
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@ -323,7 +334,10 @@ class _OrderDetailState extends State<OrderDetail> with SingleTickerProviderStat
), ),
const SizedBox(width: 10.0), const SizedBox(width: 10.0),
ElevatedButton( ElevatedButton(
onPressed: () {}, onPressed: () {
//pages/index/index
Wxsdk.openMiniApp(orderId:_orderId);
},
style: ButtonStyle( style: ButtonStyle(
backgroundColor: WidgetStateProperty.all(Color(0xff07c160)), backgroundColor: WidgetStateProperty.all(Color(0xff07c160)),
foregroundColor: WidgetStateProperty.all(Colors.white), foregroundColor: WidgetStateProperty.all(Colors.white),