微信支付宝支付
This commit is contained in:
parent
6c5f3bfd47
commit
88bf23398b
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:circle_app/app/call_out/logic.dart';
|
|
||||||
import 'package:circle_app/app/circle/logic.dart';
|
import 'package:circle_app/app/circle/logic.dart';
|
||||||
import 'package:circle_app/app/circle/state.dart';
|
import 'package:circle_app/app/circle/state.dart';
|
||||||
import 'package:circle_app/app/circle/widgets/list_logic.dart';
|
import 'package:circle_app/app/circle/widgets/list_logic.dart';
|
||||||
@ -159,10 +158,12 @@ class _InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClie
|
|||||||
|
|
||||||
void pushMsgPage(Lists bean, String cicleId) async {
|
void pushMsgPage(Lists bean, String cicleId) async {
|
||||||
|
|
||||||
// if (widget.bean.is_limit) {
|
if (widget.bean.is_limit&&widget.bean.amount>0) {
|
||||||
// showJoinCiclePiker(cicleId,widget.bean.amount.toString(),widget.bean.oldAmount.toString(),2);
|
showJoinCiclePiker(cicleId,widget.bean.amount.toString(),widget.bean.oldAmount.toString(),2,(payResult){
|
||||||
// return;
|
widget.bean.is_limit = false;
|
||||||
// }
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var sp = await SharedPreferencesHelper.getInstance();
|
var sp = await SharedPreferencesHelper.getInstance();
|
||||||
String myUserId = sp.getMyUserId();
|
String myUserId = sp.getMyUserId();
|
||||||
@ -181,29 +182,8 @@ class _InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClie
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
TextSpan descSpan;
|
|
||||||
// widget.bean.intro = widget.bean.intro+widget.bean.intro+widget.bean.intro+widget.bean.intro+widget.bean.intro;
|
|
||||||
TextSpan span;
|
|
||||||
if (widget.bean.intro.length > 20) {
|
|
||||||
String truncatedText = widget.bean.intro.substring(0, 60)+"...";
|
|
||||||
descSpan = TextSpan(
|
|
||||||
text: truncatedText,
|
|
||||||
style: TextStyle(color: Colors.white, fontSize: 10.sp),
|
|
||||||
);
|
|
||||||
span = TextSpan(
|
|
||||||
text: '查看更多',
|
|
||||||
style: TextStyle(color: Color(0xFFFF4DF6), fontSize: 10.sp),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
descSpan = TextSpan(
|
|
||||||
text: widget.bean.intro,
|
|
||||||
style: TextStyle(color: Colors.white, fontSize: 10.sp),
|
|
||||||
);
|
|
||||||
span = TextSpan(
|
|
||||||
text: '',
|
|
||||||
style: TextStyle(color: Color(0xFFFF4DF6), fontSize: 10.sp),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<JoinUser> urlList = widget.bean.lastJoinUsers;
|
List<JoinUser> urlList = widget.bean.lastJoinUsers;
|
||||||
List<Widget> widgets = [];
|
List<Widget> widgets = [];
|
||||||
@ -272,7 +252,7 @@ class _InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClie
|
|||||||
margin: EdgeInsets.only(bottom: 7.sp),
|
margin: EdgeInsets.only(bottom: 7.sp),
|
||||||
width: Get.width,
|
width: Get.width,
|
||||||
height: 30.sp,
|
height: 30.sp,
|
||||||
child: HideText(text: widget.bean.intro,additionText: '查看更多',maxLines: 2,style: TextStyle(color: Colors.white, fontSize: 10.sp),additionStyle: TextStyle(color: Color(0xFFFF4DF6), fontSize: 10.sp),onTap: () {
|
child: HideText(text: widget.bean.intro,additionText: '查看更多',maxLines: 2,style: TextStyle(color: Colors.white, fontSize: 10.sp),additionStyle: TextStyle(color: const Color(0xFFFF4DF6), fontSize: 10.sp),onTap: () {
|
||||||
_showTextContentDialog(
|
_showTextContentDialog(
|
||||||
context, widget.bean.intro);
|
context, widget.bean.intro);
|
||||||
},),
|
},),
|
||||||
@ -538,11 +518,10 @@ class _InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClie
|
|||||||
|
|
||||||
double picHeight = 0.0;
|
double picHeight = 0.0;
|
||||||
|
|
||||||
int type = 0;
|
|
||||||
if (lists.album != null) {
|
if (lists.album != null) {
|
||||||
if (lists.album!.isNotEmpty) {
|
if (lists.album!.isNotEmpty) {
|
||||||
Album info = lists.album!.first!;
|
Album info = lists.album!.first;
|
||||||
type = info.type!;
|
|
||||||
|
|
||||||
if (info.type == 1) {
|
if (info.type == 1) {
|
||||||
if (lists.album!.length > 3) {
|
if (lists.album!.length > 3) {
|
||||||
@ -615,7 +594,7 @@ class _InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClie
|
|||||||
}
|
}
|
||||||
if (widget.bean.is_limit) {
|
if (widget.bean.is_limit) {
|
||||||
showJoinCiclePiker(widget.bean.id.toString(),widget.bean.amount.toString(),widget.bean.oldAmount.toString(),1,(payResult){
|
showJoinCiclePiker(widget.bean.id.toString(),widget.bean.amount.toString(),widget.bean.oldAmount.toString(),1,(payResult){
|
||||||
|
widget.bean.is_limit = false;
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -713,7 +692,7 @@ class _InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClie
|
|||||||
child: picHeight == 140.sp
|
child: picHeight == 140.sp
|
||||||
? ClipRRect(
|
? ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(6.sp),
|
borderRadius: BorderRadius.circular(6.sp),
|
||||||
child: VideoItemWidget(lists.album![0]!.url!))
|
child: VideoItemWidget(lists.album![0].url!))
|
||||||
: GridView.builder(
|
: GridView.builder(
|
||||||
itemCount: lists.album!.length,
|
itemCount: lists.album!.length,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
@ -822,12 +801,9 @@ class _InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClie
|
|||||||
);
|
);
|
||||||
|
|
||||||
double picHeight = 0.0;
|
double picHeight = 0.0;
|
||||||
|
|
||||||
int type = 0;
|
|
||||||
if (lists.album != null) {
|
if (lists.album != null) {
|
||||||
if (lists.album!.isNotEmpty) {
|
if (lists.album!.isNotEmpty) {
|
||||||
Album info = lists.album!.first!;
|
Album info = lists.album!.first;
|
||||||
type = info.type!;
|
|
||||||
|
|
||||||
if (info.type == 1) {
|
if (info.type == 1) {
|
||||||
if (lists.album!.length > 3) {
|
if (lists.album!.length > 3) {
|
||||||
@ -843,7 +819,7 @@ class _InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClie
|
|||||||
|
|
||||||
List<Widget> widgets = [];
|
List<Widget> widgets = [];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
lists!.chat!.users!.forEach((element) {
|
lists.chat!.users!.forEach((element) {
|
||||||
widgets.add(Positioned(
|
widgets.add(Positioned(
|
||||||
left: 12.sp * index,
|
left: 12.sp * index,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
@ -911,9 +887,9 @@ class _InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClie
|
|||||||
Get.toNamed(AppRoutes.UserInfoActivity, arguments: "");
|
Get.toNamed(AppRoutes.UserInfoActivity, arguments: "");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (widget.bean.is_limit) {
|
if (widget.bean.is_limit&&widget.bean.amount > 0) {
|
||||||
showJoinCiclePiker(widget.bean.id.toString(),widget.bean.amount.toString(),widget.bean.oldAmount.toString(),1,(payResult){
|
showJoinCiclePiker(widget.bean.id.toString(),widget.bean.amount.toString(),widget.bean.oldAmount.toString(),1,(payResult){
|
||||||
|
widget.bean.is_limit = false;
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -931,7 +907,7 @@ class _InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClie
|
|||||||
lists.user!.avatar!,
|
lists.user!.avatar!,
|
||||||
width: 40.sp,
|
width: 40.sp,
|
||||||
height: 40.sp,
|
height: 40.sp,
|
||||||
fit: BoxFit.fill,
|
fit: BoxFit.cover,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@ -946,7 +922,7 @@ class _InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClie
|
|||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
lists.user!.nickname! ?? '',
|
lists.user!.nickname!,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 18.sp,
|
fontSize: 18.sp,
|
||||||
|
|||||||
@ -117,7 +117,7 @@ class ReportPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
// right: 1.sp,
|
// right: 1.sp,
|
||||||
top: 160.sp,
|
top: 150.sp,
|
||||||
child: Text(
|
child: Text(
|
||||||
'${controller.textEditingController.text.length}/200',
|
'${controller.textEditingController.text.length}/200',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:alipay_kit/alipay_kit.dart';
|
|
||||||
import 'package:circle_app/util/util.dart';
|
import 'package:circle_app/util/util.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
@ -10,18 +10,19 @@ import '../../network/api.dart';
|
|||||||
import '../../network/dio_manager.dart';
|
import '../../network/dio_manager.dart';
|
||||||
import '../../util/PaymentUtils.dart';
|
import '../../util/PaymentUtils.dart';
|
||||||
import 'open_vip_tip/logic.dart';
|
import 'open_vip_tip/logic.dart';
|
||||||
|
|
||||||
bool isZfbPrice = true;
|
bool isZfbPrice = true;
|
||||||
joiinCircileTipWdiget(String cicleId,String pirce,String oldPrice,String title,MyCallback myCallback) {
|
|
||||||
return StatefulBuilder(
|
joiinCircileTipWdiget(String cicleId, String pirce, String oldPrice,
|
||||||
builder:(BuildContext context, StateSetter setState) {
|
String title, MyCallback myCallback) {
|
||||||
|
return StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
body: Container(
|
body: Container(
|
||||||
width: Get.width,
|
width: Get.width,
|
||||||
height: Get.height,
|
height: Get.height,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child:
|
child: Stack(
|
||||||
Stack(
|
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
@ -67,7 +68,9 @@ joiinCircileTipWdiget(String cicleId,String pirce,String oldPrice,String title,M
|
|||||||
color: Color.fromRGBO(247, 250, 250, 0.8),
|
color: Color.fromRGBO(247, 250, 250, 0.8),
|
||||||
fontSize: 12.sp)),
|
fontSize: 12.sp)),
|
||||||
)),
|
)),
|
||||||
Positioned(
|
Platform.isIOS
|
||||||
|
? Container()
|
||||||
|
: Positioned(
|
||||||
bottom: 108.sp,
|
bottom: 108.sp,
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: EdgeInsets.only(top: 24.0.sp),
|
margin: EdgeInsets.only(top: 24.0.sp),
|
||||||
@ -149,13 +152,15 @@ joiinCircileTipWdiget(String cicleId,String pirce,String oldPrice,String title,M
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 18.sp,
|
bottom: 18.sp,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: (){
|
onTap: () {
|
||||||
unlockingPayment(myCallback);
|
if (Platform.isIOS) {
|
||||||
|
} else {
|
||||||
|
unlockingPayment(cicleId, myCallback);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 168.sp,
|
width: 168.sp,
|
||||||
@ -204,48 +209,52 @@ joiinCircileTipWdiget(String cicleId,String pirce,String oldPrice,String title,M
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
unlockingPayment(MyCallback myCallback)async{
|
|
||||||
|
unlockingPayment(String cicleId, MyCallback myCallback) async {
|
||||||
if (isZfbPrice) {
|
if (isZfbPrice) {
|
||||||
var data = await DioManager.instance.post(url: Api.postAliPayOrder, params: {
|
var data = await DioManager.instance.post(
|
||||||
//"product_id": priceBean[index].id,
|
url: Api.postAliPayOrder, params: {"product_id": cicleId, "type": 1});
|
||||||
"type": 1});
|
var bean = BaseResponse<PayUrlBean>.fromJson(
|
||||||
var bean = BaseResponse<PayUrlBean>.fromJson(data, (data) => PayUrlBean.fromJson(data));
|
data, (data) => PayUrlBean.fromJson(data));
|
||||||
if(bean.isSuccess()){
|
if (bean.isSuccess()) {
|
||||||
var data = await AlipayKitPlatform.instance.pay(
|
openAliPay(bean.data.payUrl, (isSuccess, errorMsg) {
|
||||||
orderInfo: bean.data.payUrl,
|
if (isSuccess) {
|
||||||
isShowLoading :true
|
myCallback(true);
|
||||||
);
|
}
|
||||||
}else {
|
});
|
||||||
|
// showToast(data.toString());
|
||||||
|
} else {
|
||||||
showToast(bean.msg);
|
showToast(bean.msg);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
} else{
|
var data = await DioManager.instance
|
||||||
initWxApi();
|
.post(url: Api.postWxOrder, params: {"product_id": cicleId, "type": 1});
|
||||||
var data = await DioManager.instance.post(url: Api.postWxOrder, params: {
|
var bean = BaseResponse<PaymentData>.fromJson(
|
||||||
// "product_id": priceBean[index].id,
|
data, (data) => PaymentData.fromJson(data));
|
||||||
"type": 1});
|
if (bean.isSuccess()) {
|
||||||
var bean = BaseResponse<PaymentData>.fromJson(data, (data) => PaymentData.fromJson(data));
|
openWxPay(bean.data, (bool isSuccess, String? errorMessage) {
|
||||||
if(bean.isSuccess()){
|
if (isSuccess) {
|
||||||
openWxPay(bean.data);
|
myCallback(true);
|
||||||
}else {
|
} else {
|
||||||
|
// 处理支付失败,errorMessage 可能为 null
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
showToast(bean.msg);
|
showToast(bean.msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
typedef void MyCallback(bool payResult);
|
typedef void MyCallback(bool payResult);
|
||||||
|
|
||||||
showJoinCiclePiker(String cicleId,String pirce,String oldPrice,int type,MyCallback payResult) {
|
showJoinCiclePiker(String cicleId, String pirce, String oldPrice, int type,
|
||||||
|
MyCallback payResult) {
|
||||||
String title = ['解锁圈子才能发布喊话','解锁圈子才能查看主页','解锁圈子才能主动私聊'][type];
|
String title = ['解锁圈子才能发布喊话', '解锁圈子才能查看主页', '解锁圈子才能主动私聊'][type];
|
||||||
return Get.bottomSheet(
|
return Get.bottomSheet(
|
||||||
joiinCircileTipWdiget(cicleId,pirce,oldPrice,title,payResult),
|
joiinCircileTipWdiget(cicleId, pirce, oldPrice, title, payResult),
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
enableDrag: false
|
enableDrag: false);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@ -1,6 +1,4 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:alipay_kit/alipay_kit.dart';
|
|
||||||
import 'package:circle_app/util/util.dart';
|
import 'package:circle_app/util/util.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
@ -8,7 +6,6 @@ import '../../../network/api.dart';
|
|||||||
import '../../../network/dio_manager.dart';
|
import '../../../network/dio_manager.dart';
|
||||||
import '../../../util/PaymentUtils.dart';
|
import '../../../util/PaymentUtils.dart';
|
||||||
import 'state.dart';
|
import 'state.dart';
|
||||||
import 'package:fluwx/fluwx.dart' as fluwx;
|
|
||||||
|
|
||||||
class Open_vip_tipLogic extends GetxController {
|
class Open_vip_tipLogic extends GetxController {
|
||||||
List<PriceBean> priceBean = [];
|
List<PriceBean> priceBean = [];
|
||||||
@ -33,20 +30,28 @@ class Open_vip_tipLogic extends GetxController {
|
|||||||
var data = await DioManager.instance.post(url: Api.postAliPayOrder, params: {"product_id": priceBean[index].id, "type": 2});
|
var data = await DioManager.instance.post(url: Api.postAliPayOrder, params: {"product_id": priceBean[index].id, "type": 2});
|
||||||
var bean = BaseResponse<PayUrlBean>.fromJson(data, (data) => PayUrlBean.fromJson(data));
|
var bean = BaseResponse<PayUrlBean>.fromJson(data, (data) => PayUrlBean.fromJson(data));
|
||||||
if(bean.isSuccess()){
|
if(bean.isSuccess()){
|
||||||
AlipayKitPlatform.instance.pay(
|
openAliPay(bean.data.payUrl,(isSuccess,errorMsg){
|
||||||
orderInfo: bean.data.payUrl,
|
if (isSuccess) {
|
||||||
isShowLoading :true
|
// 处理支付成功
|
||||||
);
|
} else {
|
||||||
|
// 处理支付失败,errorMessage 可能为 null
|
||||||
|
}
|
||||||
|
});
|
||||||
}else {
|
}else {
|
||||||
showToast(bean.msg);
|
showToast(bean.msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else{
|
} else{
|
||||||
initWxApi();
|
|
||||||
var data = await DioManager.instance.post(url: Api.postWxOrder, params: {"product_id": priceBean[index].id, "type": 2});
|
var data = await DioManager.instance.post(url: Api.postWxOrder, params: {"product_id": priceBean[index].id, "type": 2});
|
||||||
var bean = BaseResponse<PaymentData>.fromJson(data, (data) => PaymentData.fromJson(data));
|
var bean = BaseResponse<PaymentData>.fromJson(data, (data) => PaymentData.fromJson(data));
|
||||||
if(bean.isSuccess()){
|
if(bean.isSuccess()){
|
||||||
openWxPay(bean.data);
|
openWxPay(bean.data,(bool isSuccess, String? errorMessage) {
|
||||||
|
if (isSuccess) {
|
||||||
|
// 处理支付成功
|
||||||
|
} else {
|
||||||
|
// 处理支付失败,errorMessage 可能为 null
|
||||||
|
}
|
||||||
|
});
|
||||||
}else {
|
}else {
|
||||||
showToast(bean.msg);
|
showToast(bean.msg);
|
||||||
}
|
}
|
||||||
@ -55,13 +60,6 @@ class Open_vip_tipLogic extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//注册微信
|
|
||||||
void initWxApi() {
|
|
||||||
fluwx.registerWxApi(
|
|
||||||
appId: "wx6c6f4c89465dac4b",
|
|
||||||
universalLink: "dcc5bd5012a417eb585684700fbd1307",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:circle_app/util/util.dart';
|
import 'package:circle_app/util/util.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
@ -117,7 +119,7 @@ class Open_vip_tipPage extends StatelessWidget {
|
|||||||
controller, controller.index == 2, 2),
|
controller, controller.index == 2, 2),
|
||||||
],
|
],
|
||||||
))),
|
))),
|
||||||
Positioned(
|
Platform.isIOS ? Container(): Positioned(
|
||||||
bottom: 108.sp,
|
bottom: 108.sp,
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: EdgeInsets.only(top: 24.0.sp),
|
margin: EdgeInsets.only(top: 24.0.sp),
|
||||||
@ -200,7 +202,12 @@ class Open_vip_tipPage extends StatelessWidget {
|
|||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: (){
|
onTap: (){
|
||||||
|
if( Platform.isIOS){
|
||||||
|
|
||||||
|
}else{
|
||||||
controller.startPayment();
|
controller.startPayment();
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 168.sp,
|
width: 168.sp,
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
import 'package:circle_app/app/splash/binding.dart';
|
import 'package:circle_app/app/splash/binding.dart';
|
||||||
import 'package:circle_app/router/app_pages.dart';
|
import 'package:circle_app/router/app_pages.dart';
|
||||||
import 'package:circle_app/router/app_routers.dart';
|
import 'package:circle_app/router/app_routers.dart';
|
||||||
|
import 'package:circle_app/util/PaymentUtils.dart';
|
||||||
import 'package:circle_app/util/util.dart';
|
import 'package:circle_app/util/util.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
@ -60,6 +61,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
initIM();
|
initIM();
|
||||||
|
initWxApi();
|
||||||
loadBgImage();
|
loadBgImage();
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,35 @@
|
|||||||
|
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:alipay_kit/alipay_kit.dart';
|
||||||
import 'package:circle_app/util/util.dart';
|
import 'package:circle_app/util/util.dart';
|
||||||
|
|
||||||
import '../common/Widgets/open_vip_tip/logic.dart';
|
import '../common/Widgets/open_vip_tip/logic.dart';
|
||||||
import 'package:fluwx/fluwx.dart' as fluwx;
|
import 'package:fluwx/fluwx.dart' as fluwx;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//注册微信
|
||||||
|
void initWxApi() {
|
||||||
|
fluwx.registerWxApi(
|
||||||
|
appId: "wx6c6f4c89465dac4b",
|
||||||
|
universalLink: "dcc5bd5012a417eb585684700fbd1307",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//微信支付
|
//微信支付
|
||||||
Future<void> openWxPay(PaymentData data) async {
|
typedef WxPayCallback = void Function(bool isSuccess, String? errorMessage);
|
||||||
//是否安装微信
|
|
||||||
|
Future<void> openWxPay(PaymentData data, WxPayCallback callback) async {
|
||||||
|
// 是否安装微信
|
||||||
bool isInstalled = await fluwx.isWeChatInstalled;
|
bool isInstalled = await fluwx.isWeChatInstalled;
|
||||||
if (!isInstalled) {
|
if (!isInstalled) {
|
||||||
showToast("请先安装微信");
|
showToast("请先安装微信");
|
||||||
|
callback(false, "请先安装微信");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//调起支付
|
|
||||||
|
// 调起支付
|
||||||
fluwx.payWithWeChat(
|
fluwx.payWithWeChat(
|
||||||
appId: data.appId,
|
appId: data.appId,
|
||||||
partnerId: data.mchId,
|
partnerId: data.mchId,
|
||||||
@ -21,12 +39,51 @@ Future<void> openWxPay(PaymentData data) async {
|
|||||||
timeStamp: int.parse(data.timestamp),
|
timeStamp: int.parse(data.timestamp),
|
||||||
sign: data.sign,
|
sign: data.sign,
|
||||||
);
|
);
|
||||||
//监听微信回调
|
|
||||||
|
// 监听微信回调
|
||||||
fluwx.weChatResponseEventHandler.listen((event) {
|
fluwx.weChatResponseEventHandler.listen((event) {
|
||||||
if(event.isSuccessful) {
|
if (event.isSuccessful) {
|
||||||
showToast("微信支付成功");
|
showToast("微信支付成功");
|
||||||
|
callback(true, null);
|
||||||
} else {
|
} else {
|
||||||
showToast(event.errStr??"微信支付成功");
|
showToast(event.errStr ?? "微信支付失败");
|
||||||
|
callback(false, event.errStr);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
late final StreamSubscription<AlipayResp> _paySubs;
|
||||||
|
/// 返回码,标识支付状态,含义如下:
|
||||||
|
/// 9000——订单支付成功 下面的result有值
|
||||||
|
/// 8000——正在处理中
|
||||||
|
/// 4000——订单支付失败
|
||||||
|
/// 5000——重复请求
|
||||||
|
/// 6001——用户中途取消
|
||||||
|
/// 6002——网络连接出错
|
||||||
|
void _listenPay(AlipayResp resp) {
|
||||||
|
final String content = 'pay: ${resp.resultStatus} - ${resp.result}';
|
||||||
|
if(resp.resultStatus == 9000){
|
||||||
|
callback(true,resp.result);
|
||||||
|
}else{
|
||||||
|
callback(false,resp.result);
|
||||||
|
}
|
||||||
|
|
||||||
|
print(content );
|
||||||
|
}
|
||||||
|
late WxPayCallback callback ;
|
||||||
|
openAliPay(String payUrl,WxPayCallback myCallback)async{
|
||||||
|
callback = myCallback;
|
||||||
|
bool isInstalled =await AlipayKitPlatform.instance.isInstalled();
|
||||||
|
if (!isInstalled) {
|
||||||
|
showToast("请先安装支付宝");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(null==_paySubs){
|
||||||
|
_paySubs = AlipayKitPlatform.instance.payResp().listen(_listenPay);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var data = await AlipayKitPlatform.instance.pay(
|
||||||
|
orderInfo: payUrl,
|
||||||
|
isShowLoading :true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user