Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
2bd1e215
提交
2bd1e215
authored
3月 05, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1、添加紫荆币 已取消和已完成详情
2、消息跳转订单详情
上级
78e8b484
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
1057 行增加
和
0 行删除
+1057
-0
coin.dart
lib/pages/user_order/widgets/coin.dart
+14
-0
controller.dart
lib/pages/user_order_coin_cancel/controller.dart
+290
-0
index.dart
lib/pages/user_order_coin_cancel/index.dart
+26
-0
view.dart
lib/pages/user_order_coin_cancel/view.dart
+193
-0
controller.dart
lib/pages/user_order_coin_completed/controller.dart
+291
-0
index.dart
lib/pages/user_order_coin_completed/index.dart
+26
-0
view.dart
lib/pages/user_order_coin_completed/view.dart
+193
-0
index.dart
lib/routes/index.dart
+2
-0
routes.dart
lib/routes/routes.dart
+22
-0
没有找到文件。
lib/pages/user_order/widgets/coin.dart
浏览文件 @
2bd1e215
...
@@ -24,6 +24,20 @@ class BuiltCoin extends StatelessWidget {
...
@@ -24,6 +24,20 @@ class BuiltCoin extends StatelessWidget {
controller
.
onRefresh
();
controller
.
onRefresh
();
}
}
}
}
else
if
(
model
.
status
==
2
){
final
result
=
await
context
.
pushNamed
(
Routes
.
orderCoinCancel
,
queryParameters:
{
'orderNum'
:
model
.
ordersnum
});
if
(
result
==
true
){
controller
.
onRefresh
();
}
}
else
if
(
model
.
status
==
3
){
final
result
=
await
context
.
pushNamed
(
Routes
.
orderCoinCompleted
,
queryParameters:
{
'orderNum'
:
model
.
ordersnum
});
if
(
result
==
true
){
controller
.
onRefresh
();
}
}
},
},
child:
Container
(
child:
Container
(
margin:
EdgeInsets
.
only
(
left:
10
.
w
,
right:
10
.
w
,
top:
10
.
w
),
margin:
EdgeInsets
.
only
(
left:
10
.
w
,
right:
10
.
w
,
top:
10
.
w
),
...
...
lib/pages/user_order_coin_cancel/controller.dart
0 → 100644
浏览文件 @
2bd1e215
part of
user_order_coin_cancel
;
/// 紫荆币等待付款订单
class
UserOrderCoinCancelController
extends
GetxController
{
late
String
_orderNum
;
final
BuildContext
context
;
String
get
orderNum
=>
_orderNum
;
// 获取订单编号的方法
UserOrderCoinCancelController
(
this
.
context
);
// 更新订单编号的方法
void
updateOrderNum
(
String
newOrderNum
)
{
_orderNum
=
newOrderNum
;
}
late
OrderInfoModel
model
;
// 应付款、订单编号等
List
<
OrderCompletedModel
>
orderAwaitings
=
[];
// 支付宝
Tobias
tobias
=
Tobias
();
// 微信
Fluwx
fluwx
=
Fluwx
();
late
PayOrderModel
payOrderModel
;
dynamic
_purchaseUpdatedSubscription
;
dynamic
_purchaseErrorSubscription
;
dynamic
_connectionSubscription
;
PurchasedItem
?
_resultItem
;
List
<
IAPItem
>
_items
=
[];
List
<
PurchasedItem
>
_purchases
=
[];
///未完成的订单
List
<
PurchasedItem
>
_pendingPurchases
=
[];
List
<
CoinModel
>
data
=
[];
@override
void
onInit
()
{
if
(
Platform
.
isIOS
){
_getProduct
();
initPlatformState
();
_getPendingPurchase
();
}
super
.
onInit
();
}
@override
void
onReady
()
{
getOrderInfo
();
super
.
onReady
();
}
@override
void
onClose
()
{
// controller.onRefresh();
if
(
_connectionSubscription
!=
null
)
{
_connectionSubscription
.
cancel
();
_connectionSubscription
=
null
;
}
if
(
_purchaseUpdatedSubscription
!=
null
)
{
_purchaseUpdatedSubscription
.
cancel
();
_purchaseUpdatedSubscription
=
null
;
}
if
(
_purchaseErrorSubscription
!=
null
)
{
_purchaseErrorSubscription
.
cancel
();
_purchaseErrorSubscription
=
null
;
}
super
.
onClose
();
}
Future
<
void
>
initPlatformState
()
async
{
var
result
=
await
FlutterInappPurchase
.
instance
.
initialize
();
print
(
'--------------initPlatformState-------------------------
$result
'
);
_connectionSubscription
=
FlutterInappPurchase
.
connectionUpdated
.
listen
((
connected
)
{
print
(
'connected:
$connected
'
);
});
_purchaseUpdatedSubscription
=
FlutterInappPurchase
.
purchaseUpdated
.
listen
((
productItem
)
{
CustomToast
.
dismiss
();
if
(
productItem
!=
null
){
_resultItem
=
productItem
;
requestOrderStatus
();
}
});
_purchaseErrorSubscription
=
FlutterInappPurchase
.
purchaseError
.
listen
((
purchaseError
)
{
CustomToast
.
dismiss
();
Toast
.
show
(
purchaseError
!.
message
.
toString
());
});
}
/// 取消订单
Future
<
bool
>
cancelPay
()
async
{
final
result
=
await
MineAPI
.
cancelPay
(
ordersnum:
orderNum
);
if
(
result
)
{
Toast
.
show
(
'取消成功'
);
}
return
result
;
}
/// 获取订单信息
Future
<
void
>
getOrderInfo
()
async
{
data
.
clear
();
model
=
await
MineAPI
.
getOrderInfo
(
orderNum:
orderNum
);
String
payWay
=
''
;
if
(
model
.
payType
==
1
){
payWay
=
'微信'
;
}
else
if
(
model
.
payType
==
2
){
payWay
=
'支付宝'
;
}
else
if
(
model
.
payType
==
3
){
payWay
=
'紫荆币'
;
}
orderAwaitings
=
[
OrderCompletedModel
(
name:
'订单编号'
,
value:
model
.
ordersnum
.
toString
()),
OrderCompletedModel
(
name:
'支付方式'
,
value:
payWay
),
OrderCompletedModel
(
name:
'下单时间'
,
value:
model
.
createTime
.
toString
()),
];
data
.
add
(
CoinModel
(
identifying:
model
.
goodsId
));
update
();
}
/// 获取商品列表
Future
_getProduct
()
async
{
List
<
String
>
productList
=
data
.
where
((
coinModel
)
=>
coinModel
.
identifying
!=
null
)
.
map
((
coinModel
)
=>
coinModel
.
identifying
!)
.
toList
();
print
(
'-------------productList-------------------
$productList
'
);
List
<
IAPItem
>
items
=
await
FlutterInappPurchase
.
instance
.
getProducts
(
productList
);
for
(
var
item
in
items
)
{
_items
.
add
(
item
);
}
print
(
'-------------_items-------------------
$items
'
);
_items
=
items
;
_purchases
=
[];
// update();
}
Future
<
void
>
payOrder
()
async
{
// 苹果支付
if
(
model
.
payType
==
3
){
// 发起苹果支付
IAPItem
targetItem
=
_items
.
firstWhere
(
(
item
)
=>
item
.
productId
==
model
.
goodsId
,
);
_requestPurchase
(
targetItem
);
}
else
{
payOrderModel
=
await
MineAPI
.
getPayInfo
(
ordersNum:
orderNum
);
// 支付宝
if
(
model
.
payType
==
2
){
final
result
=
await
tobias
.
isAliPayInstalled
;
if
(!
result
){
Toast
.
show
(
'请先安装支付宝'
);
}
else
{
requestAliPay
();
}
}
// 微信
else
if
(
model
.
payType
==
1
){
final
result
=
await
fluwx
.
isWeChatInstalled
;
if
(!
result
){
Toast
.
show
(
'请先安装微信'
);
}
else
{
requestWechat
();
}
}
}
}
// 苹果支付
void
_requestPurchase
(
IAPItem
item
)
{
CustomToast
.
loading
();
FlutterInappPurchase
.
instance
.
requestPurchase
(
item
.
productId
!);
}
// 支付宝支付
void
requestAliPay
(){
Console
.
log
(
'================================================================
${payOrderModel.encryptionOrder!}
'
);
tobias
.
pay
(
payOrderModel
.
encryptionOrder
!).
then
((
payResult
){
if
(
payResult
[
'resultStatus'
]
==
'9000'
)
{
requestOrderStatus
();
}
else
{
Toast
.
show
(
payResult
[
'memo'
].
toString
());
}
});
}
// 微信支付
void
requestWechat
(){
Payment
payment
=
Payment
(
appId:
payOrderModel
.
appid
??
''
,
partnerId:
payOrderModel
.
partnerid
??
''
,
prepayId:
payOrderModel
.
prepayid
??
''
,
packageValue:
payOrderModel
.
package
??
''
,
nonceStr:
payOrderModel
.
noncestr
??
''
,
timestamp:
payOrderModel
.
timestamp
!.
toInt
(),
sign:
payOrderModel
.
sign
??
''
);
fluwx
.
pay
(
which:
payment
);
fluwx
.
addSubscriber
((
response
)
{
if
(
response
.
errCode
==
0
)
{
requestOrderStatus
();
}
else
{
Toast
.
show
(
'
${response.errStr}
'
);
}
});
}
void
requestOrderStatus
()
async
{
final
result
=
await
ShopAPI
.
orderStatus
(
orderNumber:
model
.
ordersnum
??
''
,
receipt:
_resultItem
!=
null
?
_resultItem
!.
transactionReceipt
.
toString
():
''
);
if
(
result
.
paySuccess
==
1
){
Toast
.
show
(
'订单支付完成'
);
if
(
context
.
mounted
){
context
.
pop
(
true
);
}
if
(
model
.
payType
==
3
){
// 清除
if
(
StorageService
.
to
.
getObject
(
kFailOrder
)
!=
null
){
List
<
Map
<
String
,
String
>>
failOrderList
=
StorageService
.
to
.
getObject
(
kFailOrder
)
as
List
<
Map
<
String
,
String
>>;
List
<
Map
<
String
,
String
>>
temp
=
[];
temp
.
addAll
(
failOrderList
);
for
(
var
element
in
failOrderList
)
{
if
(
element
[
'orderNum'
]
==
result
.
ordersnum
){
temp
.
remove
(
element
);
}
}
StorageService
.
to
.
setObject
(
kFailOrder
,
temp
);
}
FlutterInappPurchase
.
instance
.
finishTransactionIOS
(
_resultItem
!.
transactionId
!);
}
}
else
{
Toast
.
show
(
'支付失败'
);
if
(
model
.
payType
==
3
){
// 保存未支付的订单
Map
<
String
,
String
>
failOrder
=
{
'orderNum'
:
payOrderModel
.
ordersnum
??
''
,
'transactionReceipt'
:
_resultItem
!.
transactionReceipt
.
toString
(),
'transactionId'
:
_resultItem
!.
transactionId
.
toString
()
};
List
<
Map
>
failOrderList
=
[];
failOrderList
.
add
(
failOrder
);
StorageService
.
to
.
setObject
(
kFailOrder
,
failOrderList
);
}
}
}
///获取未完成的购买
Future
_getPendingPurchase
()
async
{
List
<
PurchasedItem
>?
items
=
await
FlutterInappPurchase
.
instance
.
getPurchaseHistory
();
for
(
var
item
in
items
!)
{
_pendingPurchases
.
add
(
item
);
}
if
(
StorageService
.
to
.
getObject
(
kFailOrder
)
!=
null
){
List
<
Map
<
String
,
String
>>
failOrderList
=
StorageService
.
to
.
getObject
(
kFailOrder
)
as
List
<
Map
<
String
,
String
>>;
for
(
var
item
in
_pendingPurchases
)
{
for
(
var
element
in
failOrderList
)
{
if
(
element
[
'transactionId'
]
==
item
.
transactionId
){
requestOrderStatus
();
}
}
}
}
}
}
lib/pages/user_order_coin_cancel/index.dart
0 → 100644
浏览文件 @
2bd1e215
library
user_order_coin_cancel
;
import
'dart:io'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_book/theme.dart'
;
import
'package:flutter_book/utils/index.dart'
;
import
'package:flutter_book/widgets/index.dart'
;
import
'package:flutter_inapp_purchase/flutter_inapp_purchase.dart'
;
import
'package:flutter_inapp_purchase/modules.dart'
;
import
'package:fluwx/fluwx.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get_state_manager/src/simple/get_controllers.dart'
;
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
import
'package:get/get_state_manager/src/simple/get_state.dart'
;
import
'package:go_router/go_router.dart'
;
import
'package:tobias/tobias.dart'
;
import
'../../apis/index.dart'
;
import
'../../models/index.dart'
;
import
'../../services/index.dart'
;
import
'../user_order/index.dart'
;
part
'view.dart'
;
part
'controller.dart'
;
\ No newline at end of file
lib/pages/user_order_coin_cancel/view.dart
0 → 100644
浏览文件 @
2bd1e215
part of
user_order_coin_cancel
;
/// 紫荆币待支付
class
UserOrderCoinCancelPage
extends
StatefulWidget
{
final
String
orderNum
;
// 订单编号
const
UserOrderCoinCancelPage
({
Key
?
key
,
required
this
.
orderNum
})
:
super
(
key:
key
);
@override
State
<
UserOrderCoinCancelPage
>
createState
()
=>
_UserOrderCoinAwaitingState
();
}
class
_UserOrderCoinAwaitingState
extends
State
<
UserOrderCoinCancelPage
>
{
late
UserOrderCoinCancelController
myController
;
@override
void
initState
()
{
myController
=
Get
.
put
(
UserOrderCoinCancelController
(
context
));
myController
.
updateOrderNum
(
widget
.
orderNum
);
super
.
initState
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
WillPopScope
(
onWillPop:
()
async
{
context
.
pop
(
true
);
return
false
;
},
child:
FutureBuilder
(
future:
myController
.
getOrderInfo
(),
builder:
(
context
,
snapshot
)
{
if
(
snapshot
.
connectionState
==
ConnectionState
.
waiting
)
{
return
Scaffold
(
appBar:
AppBar
(
centerTitle:
true
,
title:
const
Text
(
'已取消'
),
),
);
}
else
{
return
WillPopScope
(
onWillPop:
()
async
{
context
.
pop
(
true
);
return
false
;
},
child:
Scaffold
(
appBar:
CustomAppBar
(
title:
const
Text
(
'已取消'
),
actions:
[],
),
body:
Column
(
children:
[
Container
(
margin:
EdgeInsets
.
symmetric
(
horizontal:
AppTheme
.
margin
,
vertical:
AppTheme
.
margin
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
8
.
w
),
color:
Colors
.
white
,
boxShadow:
[
BoxShadow
(
color:
Colours
.
cC7
.
withOpacity
(
0.5
),
offset:
Offset
(
3
.
w
,
0
),
blurRadius:
10
.
w
,
spreadRadius:
0
.
w
,
),
],
),
child:
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
8
.
w
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
mainAxisSize:
MainAxisSize
.
min
,
children:
[
Padding
(
padding:
EdgeInsets
.
only
(
left:
12.0
.
w
,
top:
17.5
.
w
,
bottom:
12.0
.
w
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Image
.
asset
(
'assets/images/coin.png'
,
// fit: BoxFit.cover, // 设置适应方式为充满
width:
42.0
.
w
,
height:
42.0
.
w
,
),
Expanded
(
child:
Padding
(
padding:
EdgeInsets
.
only
(
right:
16.5
.
w
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
crossAxisAlignment:
CrossAxisAlignment
.
end
,
// 下面的Text靠左
children:
[
Text
(
'充值
${myController.model.bean}
紫荆币'
,
style:
TextStyle
(
color:
Colours
.
c3
,
fontWeight:
Fonts
.
bold
,
fontSize:
13
.
w
,
),
maxLines:
2
,
overflow:
TextOverflow
.
ellipsis
,
// 超过部分显示省略号
),
SizedBox
(
height:
9
.
w
),
// Text(
// "需付款 ¥${myController.model.finalTotalPrice}",
// style: TextStyle(
// color: Colours.cAB1941,
// fontWeight: Fonts.bold,
// fontSize: 14.w,
// ),
// ),
],
),
),
),
],
),
),
Container
(
color:
Colours
.
cLine
,
margin:
EdgeInsets
.
only
(
left:
10
.
w
,
right:
10
.
w
,
bottom:
12
.
w
),
height:
1
.
w
,
),
Container
(
padding:
EdgeInsets
.
only
(
left:
11.5
.
w
,
bottom:
8
.
w
,
right:
23.5
.
w
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
children:
myController
.
orderAwaitings
.
map
((
model
)
{
return
Padding
(
padding:
EdgeInsets
.
only
(
top:
12
.
w
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Text
(
model
.
name
,
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.6
.
w
,
color:
Colours
.
c9
),
),
Text
(
model
.
value
.
toString
(),
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.6
.
w
,
color:
Colours
.
c3
),
),
],
),
);
}).
toList
(),
),
),
SizedBox
(
height:
13.5
.
w
,
),
],
),
),
),
SizedBox
(
height:
11.5
.
w
,
),
],
),
),
);
}
},
),
);
}
}
lib/pages/user_order_coin_completed/controller.dart
0 → 100644
浏览文件 @
2bd1e215
part of
user_order_coin_completed
;
/// 紫荆币等待付款订单
class
UserOrderCoinCompletedController
extends
GetxController
{
late
String
_orderNum
;
final
BuildContext
context
;
String
get
orderNum
=>
_orderNum
;
// 获取订单编号的方法
UserOrderCoinCompletedController
(
this
.
context
);
// 更新订单编号的方法
void
updateOrderNum
(
String
newOrderNum
)
{
_orderNum
=
newOrderNum
;
}
late
OrderInfoModel
model
;
// 应付款、订单编号等
List
<
OrderCompletedModel
>
orderAwaitings
=
[];
// 支付宝
Tobias
tobias
=
Tobias
();
// 微信
Fluwx
fluwx
=
Fluwx
();
late
PayOrderModel
payOrderModel
;
dynamic
_purchaseUpdatedSubscription
;
dynamic
_purchaseErrorSubscription
;
dynamic
_connectionSubscription
;
PurchasedItem
?
_resultItem
;
List
<
IAPItem
>
_items
=
[];
List
<
PurchasedItem
>
_purchases
=
[];
///未完成的订单
List
<
PurchasedItem
>
_pendingPurchases
=
[];
List
<
CoinModel
>
data
=
[];
@override
void
onInit
()
{
if
(
Platform
.
isIOS
){
_getProduct
();
initPlatformState
();
_getPendingPurchase
();
}
super
.
onInit
();
}
@override
void
onReady
()
{
getOrderInfo
();
super
.
onReady
();
}
@override
void
onClose
()
{
// controller.onRefresh();
if
(
_connectionSubscription
!=
null
)
{
_connectionSubscription
.
cancel
();
_connectionSubscription
=
null
;
}
if
(
_purchaseUpdatedSubscription
!=
null
)
{
_purchaseUpdatedSubscription
.
cancel
();
_purchaseUpdatedSubscription
=
null
;
}
if
(
_purchaseErrorSubscription
!=
null
)
{
_purchaseErrorSubscription
.
cancel
();
_purchaseErrorSubscription
=
null
;
}
super
.
onClose
();
}
Future
<
void
>
initPlatformState
()
async
{
var
result
=
await
FlutterInappPurchase
.
instance
.
initialize
();
print
(
'--------------initPlatformState-------------------------
$result
'
);
_connectionSubscription
=
FlutterInappPurchase
.
connectionUpdated
.
listen
((
connected
)
{
print
(
'connected:
$connected
'
);
});
_purchaseUpdatedSubscription
=
FlutterInappPurchase
.
purchaseUpdated
.
listen
((
productItem
)
{
CustomToast
.
dismiss
();
if
(
productItem
!=
null
){
_resultItem
=
productItem
;
requestOrderStatus
();
}
});
_purchaseErrorSubscription
=
FlutterInappPurchase
.
purchaseError
.
listen
((
purchaseError
)
{
CustomToast
.
dismiss
();
Toast
.
show
(
purchaseError
!.
message
.
toString
());
});
}
/// 取消订单
Future
<
bool
>
cancelPay
()
async
{
final
result
=
await
MineAPI
.
cancelPay
(
ordersnum:
orderNum
);
if
(
result
)
{
Toast
.
show
(
'取消成功'
);
}
return
result
;
}
/// 获取订单信息
Future
<
void
>
getOrderInfo
()
async
{
data
.
clear
();
model
=
await
MineAPI
.
getOrderInfo
(
orderNum:
orderNum
);
String
payWay
=
''
;
if
(
model
.
payType
==
1
){
payWay
=
'微信'
;
}
else
if
(
model
.
payType
==
2
){
payWay
=
'支付宝'
;
}
else
if
(
model
.
payType
==
3
){
payWay
=
'紫荆币'
;
}
orderAwaitings
=
[
OrderCompletedModel
(
name:
'订单编号'
,
value:
model
.
ordersnum
.
toString
()),
OrderCompletedModel
(
name:
'支付方式'
,
value:
payWay
),
OrderCompletedModel
(
name:
'支付时间'
,
value:
model
.
payTime
.
toString
()),
OrderCompletedModel
(
name:
'下单时间'
,
value:
model
.
createTime
.
toString
()),
];
data
.
add
(
CoinModel
(
identifying:
model
.
goodsId
));
update
();
}
/// 获取商品列表
Future
_getProduct
()
async
{
List
<
String
>
productList
=
data
.
where
((
coinModel
)
=>
coinModel
.
identifying
!=
null
)
.
map
((
coinModel
)
=>
coinModel
.
identifying
!)
.
toList
();
print
(
'-------------productList-------------------
$productList
'
);
List
<
IAPItem
>
items
=
await
FlutterInappPurchase
.
instance
.
getProducts
(
productList
);
for
(
var
item
in
items
)
{
_items
.
add
(
item
);
}
print
(
'-------------_items-------------------
$items
'
);
_items
=
items
;
_purchases
=
[];
// update();
}
Future
<
void
>
payOrder
()
async
{
// 苹果支付
if
(
model
.
payType
==
3
){
// 发起苹果支付
IAPItem
targetItem
=
_items
.
firstWhere
(
(
item
)
=>
item
.
productId
==
model
.
goodsId
,
);
_requestPurchase
(
targetItem
);
}
else
{
payOrderModel
=
await
MineAPI
.
getPayInfo
(
ordersNum:
orderNum
);
// 支付宝
if
(
model
.
payType
==
2
){
final
result
=
await
tobias
.
isAliPayInstalled
;
if
(!
result
){
Toast
.
show
(
'请先安装支付宝'
);
}
else
{
requestAliPay
();
}
}
// 微信
else
if
(
model
.
payType
==
1
){
final
result
=
await
fluwx
.
isWeChatInstalled
;
if
(!
result
){
Toast
.
show
(
'请先安装微信'
);
}
else
{
requestWechat
();
}
}
}
}
// 苹果支付
void
_requestPurchase
(
IAPItem
item
)
{
CustomToast
.
loading
();
FlutterInappPurchase
.
instance
.
requestPurchase
(
item
.
productId
!);
}
// 支付宝支付
void
requestAliPay
(){
Console
.
log
(
'================================================================
${payOrderModel.encryptionOrder!}
'
);
tobias
.
pay
(
payOrderModel
.
encryptionOrder
!).
then
((
payResult
){
if
(
payResult
[
'resultStatus'
]
==
'9000'
)
{
requestOrderStatus
();
}
else
{
Toast
.
show
(
payResult
[
'memo'
].
toString
());
}
});
}
// 微信支付
void
requestWechat
(){
Payment
payment
=
Payment
(
appId:
payOrderModel
.
appid
??
''
,
partnerId:
payOrderModel
.
partnerid
??
''
,
prepayId:
payOrderModel
.
prepayid
??
''
,
packageValue:
payOrderModel
.
package
??
''
,
nonceStr:
payOrderModel
.
noncestr
??
''
,
timestamp:
payOrderModel
.
timestamp
!.
toInt
(),
sign:
payOrderModel
.
sign
??
''
);
fluwx
.
pay
(
which:
payment
);
fluwx
.
addSubscriber
((
response
)
{
if
(
response
.
errCode
==
0
)
{
requestOrderStatus
();
}
else
{
Toast
.
show
(
'
${response.errStr}
'
);
}
});
}
void
requestOrderStatus
()
async
{
final
result
=
await
ShopAPI
.
orderStatus
(
orderNumber:
model
.
ordersnum
??
''
,
receipt:
_resultItem
!=
null
?
_resultItem
!.
transactionReceipt
.
toString
():
''
);
if
(
result
.
paySuccess
==
1
){
Toast
.
show
(
'订单支付完成'
);
if
(
context
.
mounted
){
context
.
pop
(
true
);
}
if
(
model
.
payType
==
3
){
// 清除
if
(
StorageService
.
to
.
getObject
(
kFailOrder
)
!=
null
){
List
<
Map
<
String
,
String
>>
failOrderList
=
StorageService
.
to
.
getObject
(
kFailOrder
)
as
List
<
Map
<
String
,
String
>>;
List
<
Map
<
String
,
String
>>
temp
=
[];
temp
.
addAll
(
failOrderList
);
for
(
var
element
in
failOrderList
)
{
if
(
element
[
'orderNum'
]
==
result
.
ordersnum
){
temp
.
remove
(
element
);
}
}
StorageService
.
to
.
setObject
(
kFailOrder
,
temp
);
}
FlutterInappPurchase
.
instance
.
finishTransactionIOS
(
_resultItem
!.
transactionId
!);
}
}
else
{
Toast
.
show
(
'支付失败'
);
if
(
model
.
payType
==
3
){
// 保存未支付的订单
Map
<
String
,
String
>
failOrder
=
{
'orderNum'
:
payOrderModel
.
ordersnum
??
''
,
'transactionReceipt'
:
_resultItem
!.
transactionReceipt
.
toString
(),
'transactionId'
:
_resultItem
!.
transactionId
.
toString
()
};
List
<
Map
>
failOrderList
=
[];
failOrderList
.
add
(
failOrder
);
StorageService
.
to
.
setObject
(
kFailOrder
,
failOrderList
);
}
}
}
///获取未完成的购买
Future
_getPendingPurchase
()
async
{
List
<
PurchasedItem
>?
items
=
await
FlutterInappPurchase
.
instance
.
getPurchaseHistory
();
for
(
var
item
in
items
!)
{
_pendingPurchases
.
add
(
item
);
}
if
(
StorageService
.
to
.
getObject
(
kFailOrder
)
!=
null
){
List
<
Map
<
String
,
String
>>
failOrderList
=
StorageService
.
to
.
getObject
(
kFailOrder
)
as
List
<
Map
<
String
,
String
>>;
for
(
var
item
in
_pendingPurchases
)
{
for
(
var
element
in
failOrderList
)
{
if
(
element
[
'transactionId'
]
==
item
.
transactionId
){
requestOrderStatus
();
}
}
}
}
}
}
lib/pages/user_order_coin_completed/index.dart
0 → 100644
浏览文件 @
2bd1e215
library
user_order_coin_completed
;
import
'dart:io'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_book/theme.dart'
;
import
'package:flutter_book/utils/index.dart'
;
import
'package:flutter_book/widgets/index.dart'
;
import
'package:flutter_inapp_purchase/flutter_inapp_purchase.dart'
;
import
'package:flutter_inapp_purchase/modules.dart'
;
import
'package:fluwx/fluwx.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get_state_manager/src/simple/get_controllers.dart'
;
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
import
'package:get/get_state_manager/src/simple/get_state.dart'
;
import
'package:go_router/go_router.dart'
;
import
'package:tobias/tobias.dart'
;
import
'../../apis/index.dart'
;
import
'../../models/index.dart'
;
import
'../../services/index.dart'
;
import
'../user_order/index.dart'
;
part
'view.dart'
;
part
'controller.dart'
;
\ No newline at end of file
lib/pages/user_order_coin_completed/view.dart
0 → 100644
浏览文件 @
2bd1e215
part of
user_order_coin_completed
;
/// 紫荆币待支付
class
UserOrderCoinCompletedPage
extends
StatefulWidget
{
final
String
orderNum
;
// 订单编号
const
UserOrderCoinCompletedPage
({
Key
?
key
,
required
this
.
orderNum
})
:
super
(
key:
key
);
@override
State
<
UserOrderCoinCompletedPage
>
createState
()
=>
_UserOrderCoinAwaitingState
();
}
class
_UserOrderCoinAwaitingState
extends
State
<
UserOrderCoinCompletedPage
>
{
late
UserOrderCoinCompletedController
myController
;
@override
void
initState
()
{
myController
=
Get
.
put
(
UserOrderCoinCompletedController
(
context
));
myController
.
updateOrderNum
(
widget
.
orderNum
);
super
.
initState
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
WillPopScope
(
onWillPop:
()
async
{
context
.
pop
(
true
);
return
false
;
},
child:
FutureBuilder
(
future:
myController
.
getOrderInfo
(),
builder:
(
context
,
snapshot
)
{
if
(
snapshot
.
connectionState
==
ConnectionState
.
waiting
)
{
return
Scaffold
(
appBar:
AppBar
(
centerTitle:
true
,
title:
const
Text
(
'已完成'
),
),
);
}
else
{
return
WillPopScope
(
onWillPop:
()
async
{
context
.
pop
(
true
);
return
false
;
},
child:
Scaffold
(
appBar:
CustomAppBar
(
title:
const
Text
(
'已完成'
),
actions:
[],
),
body:
Column
(
children:
[
Container
(
margin:
EdgeInsets
.
symmetric
(
horizontal:
AppTheme
.
margin
,
vertical:
AppTheme
.
margin
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
8
.
w
),
color:
Colors
.
white
,
boxShadow:
[
BoxShadow
(
color:
Colours
.
cC7
.
withOpacity
(
0.5
),
offset:
Offset
(
3
.
w
,
0
),
blurRadius:
10
.
w
,
spreadRadius:
0
.
w
,
),
],
),
child:
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
8
.
w
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
mainAxisSize:
MainAxisSize
.
min
,
children:
[
Padding
(
padding:
EdgeInsets
.
only
(
left:
12.0
.
w
,
top:
17.5
.
w
,
bottom:
12.0
.
w
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Image
.
asset
(
'assets/images/coin.png'
,
// fit: BoxFit.cover, // 设置适应方式为充满
width:
42.0
.
w
,
height:
42.0
.
w
,
),
Expanded
(
child:
Padding
(
padding:
EdgeInsets
.
only
(
right:
16.5
.
w
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
crossAxisAlignment:
CrossAxisAlignment
.
end
,
// 下面的Text靠左
children:
[
Text
(
'充值
${myController.model.bean}
紫荆币'
,
style:
TextStyle
(
color:
Colours
.
c3
,
fontWeight:
Fonts
.
bold
,
fontSize:
13
.
w
,
),
maxLines:
2
,
overflow:
TextOverflow
.
ellipsis
,
// 超过部分显示省略号
),
SizedBox
(
height:
9
.
w
),
// Text(
// "需付款 ¥${myController.model.finalTotalPrice}",
// style: TextStyle(
// color: Colours.cAB1941,
// fontWeight: Fonts.bold,
// fontSize: 14.w,
// ),
// ),
],
),
),
),
],
),
),
Container
(
color:
Colours
.
cLine
,
margin:
EdgeInsets
.
only
(
left:
10
.
w
,
right:
10
.
w
,
bottom:
12
.
w
),
height:
1
.
w
,
),
Container
(
padding:
EdgeInsets
.
only
(
left:
11.5
.
w
,
bottom:
8
.
w
,
right:
23.5
.
w
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
children:
myController
.
orderAwaitings
.
map
((
model
)
{
return
Padding
(
padding:
EdgeInsets
.
only
(
top:
12
.
w
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Text
(
model
.
name
,
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.6
.
w
,
color:
Colours
.
c9
),
),
Text
(
model
.
value
.
toString
(),
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.6
.
w
,
color:
Colours
.
c3
),
),
],
),
);
}).
toList
(),
),
),
SizedBox
(
height:
13.5
.
w
,
),
],
),
),
),
SizedBox
(
height:
11.5
.
w
,
),
],
),
),
);
}
},
),
);
}
}
lib/routes/index.dart
浏览文件 @
2bd1e215
...
@@ -36,6 +36,8 @@ import 'package:flutter_book/pages/user_notes/index.dart';
...
@@ -36,6 +36,8 @@ import 'package:flutter_book/pages/user_notes/index.dart';
import
'package:flutter_book/pages/user_notes_des/index.dart'
;
import
'package:flutter_book/pages/user_notes_des/index.dart'
;
import
'package:flutter_book/pages/user_order_awaiting/index.dart'
;
import
'package:flutter_book/pages/user_order_awaiting/index.dart'
;
import
'package:flutter_book/pages/user_order_coin_awaiting/index.dart'
;
import
'package:flutter_book/pages/user_order_coin_awaiting/index.dart'
;
import
'package:flutter_book/pages/user_order_coin_cancel/index.dart'
;
import
'package:flutter_book/pages/user_order_coin_completed/index.dart'
;
import
'package:flutter_book/pages/user_order_completed/index.dart'
;
import
'package:flutter_book/pages/user_order_completed/index.dart'
;
import
'package:flutter_book/pages/user_order_refunded/index.dart'
;
import
'package:flutter_book/pages/user_order_refunded/index.dart'
;
import
'package:flutter_book/pages/user_point/index.dart'
;
import
'package:flutter_book/pages/user_point/index.dart'
;
...
...
lib/routes/routes.dart
浏览文件 @
2bd1e215
...
@@ -122,6 +122,10 @@ abstract class Routes {
...
@@ -122,6 +122,10 @@ abstract class Routes {
static
const
orderCancel
=
'order_cancel'
;
static
const
orderCancel
=
'order_cancel'
;
// 紫荆币待付款订单
// 紫荆币待付款订单
static
const
orderCoinAwaiting
=
'order_coin_awaiting'
;
static
const
orderCoinAwaiting
=
'order_coin_awaiting'
;
// 紫荆币已取消订单
static
const
orderCoinCancel
=
'order_coin_cancel'
;
// 紫荆币已完成订单
static
const
orderCoinCompleted
=
'order_coin_completed'
;
// 已退款订单
// 已退款订单
static
const
orderRefunded
=
'order_refunded'
;
static
const
orderRefunded
=
'order_refunded'
;
// 搜索订单
// 搜索订单
...
@@ -587,6 +591,24 @@ abstract class Routes {
...
@@ -587,6 +591,24 @@ abstract class Routes {
child:
UserOrderCoinAwaitingPage
(
orderNum:
state
.
uri
.
queryParameters
[
'orderNum'
].
toString
())
child:
UserOrderCoinAwaitingPage
(
orderNum:
state
.
uri
.
queryParameters
[
'orderNum'
].
toString
())
)
)
),
),
GoRoute
(
// 紫荆币已取消订单
path:
'/
$orderCoinCancel
'
,
name:
orderCoinCancel
,
pageBuilder:
(
context
,
state
)
=>
CupertinoPage
(
name:
state
.
uri
.
toString
(),
key:
state
.
pageKey
,
child:
UserOrderCoinCancelPage
(
orderNum:
state
.
uri
.
queryParameters
[
'orderNum'
].
toString
())
)
),
GoRoute
(
// 紫荆币已完成订单
path:
'/
$orderCoinCompleted
'
,
name:
orderCoinCompleted
,
pageBuilder:
(
context
,
state
)
=>
CupertinoPage
(
name:
state
.
uri
.
toString
(),
key:
state
.
pageKey
,
child:
UserOrderCoinCompletedPage
(
orderNum:
state
.
uri
.
queryParameters
[
'orderNum'
].
toString
())
)
),
GoRoute
(
// 已退款订单
GoRoute
(
// 已退款订单
path:
'/
$orderRefunded
'
,
path:
'/
$orderRefunded
'
,
name:
orderRefunded
,
name:
orderRefunded
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论