1、支付联调
This commit is contained in:
parent
ce0331e4c6
commit
f0fd7fa2c2
@ -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';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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'; //测试数据
|
||||||
|
String orderId = await createOrder(shopObj['skuList'][0]['id']);
|
||||||
|
if(orderId.isNotEmpty){
|
||||||
Get.toNamed('/order/detail', arguments: orderId);
|
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(
|
||||||
'立即购买',
|
'立即购买',
|
||||||
|
@ -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),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user