Browse Source

活动支付

zyh
w-R 3 years ago
parent
commit
454a5be3be
  1. 126
      lib/settlement/settlement.dart
  2. 3
      lib/store/shopping/shopping_goods_details.dart

126
lib/settlement/settlement.dart

@ -117,9 +117,15 @@ class _Settlement extends State<Settlement> {
actProductSkuId ?? "",
);
} else
queryOrderInfo(null, selectedBtn, null, 0, null,
queryOrderInfo(
null,
selectedBtn,
null,
0,
null,
actProductId ?? "",
actProductSkuId ?? "",);
actProductSkuId ?? "",
);
});
weChatResponseEventHandler.listen((event) async {
@ -170,7 +176,7 @@ class _Settlement extends State<Settlement> {
setState(() {
minOrderInfo = baseData.data;
});
}else{
} else {
SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
}
}
@ -180,9 +186,15 @@ class _Settlement extends State<Settlement> {
this.selectedBtn = selectedBtn;
});
if (address != null) {
queryOrderInfo(address.id, selectedBtn, null, 0, null,
queryOrderInfo(
address.id,
selectedBtn,
null,
0,
null,
actProductId ?? "",
actProductSkuId ?? "",);
actProductSkuId ?? "",
);
return;
}
BaseData<List<Address>> baseDate =
@ -226,9 +238,15 @@ class _Settlement extends State<Settlement> {
}
}
queryOrderInfo(address.id, selectedBtn, null, 0, null,
queryOrderInfo(
address.id,
selectedBtn,
null,
0,
null,
actProductId ?? "",
actProductSkuId ?? "",);
actProductSkuId ?? "",
);
}
}
@ -244,9 +262,15 @@ class _Settlement extends State<Settlement> {
});
});
queryOrderInfo(address.id, selectedBtn, null, 0, null,
queryOrderInfo(
address.id,
selectedBtn,
null,
0,
null,
actProductId ?? "",
actProductSkuId ?? "",);
actProductSkuId ?? "",
);
}
}
@ -306,11 +330,12 @@ class _Settlement extends State<Settlement> {
if (baseData != null && baseData.isSuccess) {
placeOrder = true;
this.downOrder = baseData.data;
querySettlement();
pageType != null ? activityPay() : querySettlement();
} else {
baseData?.isSuccess ?? false ?
SmartDialog.showToast("下单失败:订单实付金额不能为0", alignment: Alignment.center) :
SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
baseData?.isSuccess ?? false
? SmartDialog.showToast("下单失败:订单实付金额不能为0",
alignment: Alignment.center)
: SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
}
} else {
///
@ -358,7 +383,7 @@ class _Settlement extends State<Settlement> {
? minOrderInfo.orderProductVOList
: downOrder.orderProductVOList;
if (placeOrderFirst.payChannel == 1) {
if(Platform.isAndroid){
if (Platform.isAndroid) {
if (!(await Min.isInitialize())) {
// app的充值支付使用同一个WXPayEntryActivity回调
// getPackage空指针
@ -408,6 +433,68 @@ class _Settlement extends State<Settlement> {
}
}
///
activityPay() async {
placeOrderFirst.id = widget.arguments["orderId"] != ""
? widget.arguments["orderId"]
: downOrder.id;
placeOrderFirst.orderProductVOList = downOrder == null
? minOrderInfo.orderProductVOList
: downOrder.orderProductVOList;
if (placeOrderFirst.payChannel == 1) {
if (Platform.isAndroid) {
if (!(await Min.isInitialize())) {
// app的充值支付使用同一个WXPayEntryActivity回调
// getPackage空指针
//
await Min.initialize();
}
}
BaseData<WxPay> baseData = await minService
.actPay({
"orderId": widget.arguments["orderId"],
"payChannel":placeOrderFirst.payChannel
}).catchError((error) {
print(error);
});
if (baseData != null && baseData.isSuccess) {
WxPay wxPay = baseData.data;
await registerWxApi(
appId: wxPay.appId,
doOnAndroid: true,
universalLink: "https://hx.lotus-wallet.com/app/",
);
payWithWeChat(
appId: wxPay.appId,
partnerId: wxPay.partnerId,
prepayId: wxPay.prepayId,
packageValue: wxPay.packageValue,
nonceStr: wxPay.nonceStr,
timeStamp: int.tryParse(wxPay.timeStamp),
sign: wxPay.sign,
);
}
} else {
BaseData baseData = await minService.actPay({
"orderId": widget.arguments["orderId"],
"payChannel":placeOrderFirst.payChannel
}).catchError((error) {
print(error);
});
if (baseData != null && baseData.isSuccess) {
toOrderDetails(placeOrderFirst.id);
} else {
SmartDialog.show(
widget: Tips(
() {
toOrderDetails(placeOrderFirst.id);
},
text: "${baseData.msg}",
));
}
}
}
toOrderDetails(String orderId) {
Navigator.of(context).popAndPushNamed(
'/router/order_details',
@ -460,10 +547,15 @@ class _Settlement extends State<Settlement> {
setState(() {
this.selectedBtn = 0;
});
queryOrderInfo(addressId, isTake,
memberCouponId, orderId, promotionId,
queryOrderInfo(
addressId,
isTake,
memberCouponId,
orderId,
promotionId,
actProductId ?? "",
actProductSkuId ?? "",);
actProductSkuId ?? "",
);
}, queryAddress, storeInfo, address,
selectedAddress, pageType),

3
lib/store/shopping/shopping_goods_details.dart

@ -5,8 +5,6 @@ import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_html/image_render.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:huixiang/generated/l10n.dart';
@ -15,7 +13,6 @@ import 'package:huixiang/retrofit/data/activity_details.dart';
import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/launch_join_act.dart';
import 'package:huixiang/retrofit/data/miNiDetail.dart';
import 'package:huixiang/retrofit/data/placeOrderFirst.dart';
import 'package:huixiang/retrofit/data/shoppingCart.dart';
import 'package:huixiang/retrofit/data/store_info.dart';
import 'package:huixiang/retrofit/min_api.dart';

Loading…
Cancel
Save