Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
f1469b77
提交
f1469b77
authored
1月 31, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
刷新token
上级
08fb8659
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
70 行增加
和
20 行删除
+70
-20
account.dart
lib/pages/mine/widgets/account.dart
+3
-0
index.dart
lib/pages/user_coin/index.dart
+7
-0
view.dart
lib/pages/user_coin/view.dart
+1
-0
controller.dart
lib/pages/user_coin_recharge/controller.dart
+40
-14
index.dart
lib/pages/user_coin_recharge/index.dart
+3
-0
view.dart
lib/pages/user_coin_recharge/view.dart
+5
-1
http.dart
lib/services/http.dart
+11
-5
没有找到文件。
lib/pages/mine/widgets/account.dart
浏览文件 @
f1469b77
...
...
@@ -45,6 +45,8 @@ class BuildAccount extends StatelessWidget {
if
(
onTap
!=
null
)
onTap
;
}
},
child:
Container
(
color:
Colors
.
white
,
child:
Column
(
children:
[
SizedBox
(
...
...
@@ -65,6 +67,7 @@ class BuildAccount extends StatelessWidget {
],
),
),
),
);
}
).
toList
(),
),
...
...
lib/pages/user_coin/index.dart
浏览文件 @
f1469b77
library
user_coin
;
import
'dart:core'
;
import
'dart:io'
;
import
'package:easy_refresh/easy_refresh.dart'
;
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:flutter_screenutil/flutter_screenutil.dart'
;
import
'package:fluwx/fluwx.dart'
;
import
'package:get/get.dart'
;
import
'package:tobias/tobias.dart'
;
import
'../../apis/index.dart'
;
import
'../../models/index.dart'
;
import
'../../services/index.dart'
;
import
'../user_coin_recharge/index.dart'
;
part
'view.dart'
;
...
...
lib/pages/user_coin/view.dart
浏览文件 @
f1469b77
...
...
@@ -28,6 +28,7 @@ class _UserCoinPageState extends State<UserCoinPage> {
},
).
then
((
value
)
{
print
(
'================================================================'
);
// Navigator.of(context).removeRoute(ModalRoute.of(context)!);
});
},
child:
Text
(
'充值'
,
style:
TextStyle
(
color:
Colours
.
c3
,
fontSize:
14
.
w
,
height:
1.5
,
fontWeight:
Fonts
.
medium
),)
...
...
lib/pages/user_coin_recharge/controller.dart
浏览文件 @
f1469b77
...
...
@@ -2,11 +2,10 @@ part of recharge;
class
CoinRechargeController
extends
GetxController
{
late
dynamic
_purchaseUpdatedSubscription
;
late
dynamic
_purchaseErrorSubscription
;
late
dynamic
_connectionSubscription
;
late
int
_buyIndex
;
late
PurchasedItem
_resultItem
;
dynamic
_purchaseUpdatedSubscription
;
dynamic
_purchaseErrorSubscription
;
dynamic
_connectionSubscription
;
PurchasedItem
?
_resultItem
;
List
<
IAPItem
>
_items
=
[];
List
<
PurchasedItem
>
_purchases
=
[];
...
...
@@ -55,6 +54,15 @@ class CoinRechargeController extends GetxController {
_connectionSubscription
.
cancel
();
_connectionSubscription
=
null
;
}
if
(
_purchaseUpdatedSubscription
!=
null
)
{
_purchaseUpdatedSubscription
.
cancel
();
_purchaseUpdatedSubscription
=
null
;
}
if
(
_purchaseErrorSubscription
!=
null
)
{
_purchaseErrorSubscription
.
cancel
();
_purchaseErrorSubscription
=
null
;
}
super
.
onClose
();
}
...
...
@@ -76,8 +84,6 @@ class CoinRechargeController extends GetxController {
model
.
selected
=
(
model
==
coinModel
);
}
rechargeModel
=
coinModel
;
_buyIndex
=
data
.
indexOf
(
coinModel
);
update
();
}
...
...
@@ -94,7 +100,9 @@ class CoinRechargeController extends GetxController {
final
result
=
await
MineAPI
.
coinsRechargeList
(
type:
type
);
data
=
result
;
if
(
Platform
.
isIOS
){
_getProduct
();
}
update
();
}
...
...
@@ -102,6 +110,7 @@ class CoinRechargeController extends GetxController {
var
result
=
await
FlutterInappPurchase
.
instance
.
initialize
();
print
(
'--------------initPlatformState-------------------------
$result
'
);
_connectionSubscription
=
FlutterInappPurchase
.
connectionUpdated
.
listen
((
connected
)
{
print
(
'connected:
$connected
'
);
});
...
...
@@ -129,7 +138,7 @@ class CoinRechargeController extends GetxController {
.
toList
();
print
(
'-------------productList-------------------
$productList
'
);
List
<
IAPItem
>
items
=
await
FlutterInappPurchase
.
instance
.
getProducts
(
[
'com.zijing.book.flutterBook'
]
);
List
<
IAPItem
>
items
=
await
FlutterInappPurchase
.
instance
.
getProducts
(
productList
);
for
(
var
item
in
items
)
{
_items
.
add
(
item
);
}
...
...
@@ -143,7 +152,14 @@ class CoinRechargeController extends GetxController {
/// 创建订单
void
createRechargeOrder
()
async
{
final
result
=
await
MineAPI
.
createRechargeOrder
(
identifying:
rechargeModel
.
identifying
??
''
,
type:
payModel
.
type
.
toString
());
String
type
=
''
;
if
(
Platform
.
isIOS
){
type
=
'3'
;
}
else
{
type
=
payModel
.
type
.
toString
();
}
final
result
=
await
MineAPI
.
createRechargeOrder
(
identifying:
rechargeModel
.
identifying
??
''
,
type:
type
);
print
(
'-----------------------------------
${result.ordersnum}
--------------------------------
${result.msg}
'
);
payOrderModel
=
result
;
...
...
@@ -153,10 +169,20 @@ class CoinRechargeController extends GetxController {
// 苹果
if
(
Platform
.
isIOS
){
// 发起苹果支付
_requestPurchase
(
_items
[
_buyIndex
]);
IAPItem
targetItem
=
_items
.
firstWhere
(
(
item
)
=>
item
.
productId
==
rechargeModel
.
identifying
,
);
_requestPurchase
(
targetItem
);
}
// 安卓
else
if
(
Platform
.
isAndroid
){
// 发起支付宝支付
if
(
payModel
.
type
==
2
){
requestAliPay
();
}
else
if
(
payModel
.
type
==
1
){
requestWechat
();
}
}
}
...
...
@@ -165,7 +191,7 @@ class CoinRechargeController extends GetxController {
}
/// 获取后台关于当前单号的结算结果
void
_requestOrderStatus
()
async
{
final
result
=
await
ShopAPI
.
orderStatus
(
orderNumber:
payOrderModel
.
ordersnum
??
''
,
receipt:
_resultItem
.
transactionReceipt
.
toString
()
);
final
result
=
await
ShopAPI
.
orderStatus
(
orderNumber:
payOrderModel
.
ordersnum
??
''
,
receipt:
_resultItem
!=
null
?
_resultItem
!.
transactionReceipt
.
toString
():
''
);
// 查询订单支付成功
if
(
result
.
paySuccess
==
1
){
...
...
@@ -183,7 +209,7 @@ class CoinRechargeController extends GetxController {
}
StorageService
.
to
.
setObject
(
kFailOrder
,
temp
);
}
FlutterInappPurchase
.
instance
.
finishTransactionIOS
(
_resultItem
.
transactionId
!);
FlutterInappPurchase
.
instance
.
finishTransactionIOS
(
_resultItem
!
.
transactionId
!);
}
}
// 查询订单支付失败
...
...
@@ -193,8 +219,8 @@ class CoinRechargeController extends GetxController {
// 保存未支付的订单
Map
<
String
,
String
>
failOrder
=
{
'orderNum'
:
payOrderModel
.
ordersnum
??
''
,
'transactionReceipt'
:
_resultItem
.
transactionReceipt
.
toString
(),
'transactionId'
:
_resultItem
.
transactionId
.
toString
()
'transactionReceipt'
:
_resultItem
!
.
transactionReceipt
.
toString
(),
'transactionId'
:
_resultItem
!
.
transactionId
.
toString
()
};
List
<
Map
>
failOrderList
=
[];
failOrderList
.
add
(
failOrder
);
...
...
lib/pages/user_coin_recharge/index.dart
浏览文件 @
f1469b77
...
...
@@ -22,6 +22,8 @@ import '../../widgets/index.dart';
import
'../book_pay/index.dart'
;
import
'dart:io'
;
import
'../user_coin/index.dart'
;
part
'view.dart'
;
part
'controller.dart'
;
\ No newline at end of file
lib/pages/user_coin_recharge/view.dart
浏览文件 @
f1469b77
...
...
@@ -9,7 +9,7 @@ class CoinRechargePage extends StatefulWidget {
State
<
CoinRechargePage
>
createState
()
=>
_CoinRechargePageState
();
}
class
_CoinRechargePageState
extends
State
<
CoinRechargePage
>
{
class
_CoinRechargePageState
extends
State
<
CoinRechargePage
>
with
AutomaticKeepAliveClientMixin
{
@override
Widget
build
(
BuildContext
context
)
{
return
GetBuilder
<
CoinRechargeController
>(
...
...
@@ -133,4 +133,8 @@ class _CoinRechargePageState extends State<CoinRechargePage> {
itemCount:
controller
.
pays
.
length
,
);
}
@override
// TODO: implement wantKeepAlive
bool
get
wantKeepAlive
=>
true
;
}
lib/services/http.dart
浏览文件 @
f1469b77
...
...
@@ -166,7 +166,7 @@ class HttpService extends GetxService {
class
_RequestInterceptor
extends
Interceptor
{
@override
void
onResponse
(
Response
response
,
ResponseInterceptorHandler
handler
)
{
void
onResponse
(
Response
response
,
ResponseInterceptorHandler
handler
)
async
{
if
(
response
.
data
[
'code'
]
!=
200
)
{
handler
.
reject
(
DioException
(
...
...
@@ -176,7 +176,7 @@ class _RequestInterceptor extends Interceptor {
),
true
,
);
}
else
{
}
else
{
super
.
onResponse
(
response
,
handler
);
}
}
...
...
@@ -202,7 +202,6 @@ class _RequestInterceptor extends Interceptor {
final
statusCode
=
response
?.
statusCode
;
print
(
'*************
${response?.data}
'
);
// Console.log(response?.data);
final
code
=
int
.
tryParse
(
response
?.
data
[
'code'
]?.
toString
()
??
''
);
var
msg
=
'服务器错误'
;
switch
(
statusCode
)
{
case
401
:
...
...
@@ -237,20 +236,23 @@ class _RequestInterceptor extends Interceptor {
break
;
case
404
:
msg
=
'
$statusCode
- Server not found'
;
CustomToast
.
fail
(
msg
);
break
;
case
500
:
msg
=
'
$statusCode
- Server error'
;
CustomToast
.
fail
(
msg
);
break
;
case
502
:
msg
=
'
$statusCode
- Bad gateway'
;
CustomToast
.
fail
(
msg
);
break
;
default
:
// if (code == 901) UserStore.to.logout();
// msg = response?.data?['msg']?.toString() ?? msg;
msg
=
response
?.
data
?[
'message'
]?.
toString
()
??
msg
;
CustomToast
.
fail
(
msg
);
break
;
}
CustomToast
.
fail
(
msg
);
break
;
case
DioExceptionType
.
cancel
:
Console
.
log
(
'请求取消'
);
...
...
@@ -266,10 +268,14 @@ class _RequestInterceptor extends Interceptor {
}
Future
<
String
?>
refreshToken
()
async
{
final
result
=
await
HttpService
.
to
.
post
(
'/v1/members/login/getToken'
,
params:
{
'access_token'
:
UserStore
.
to
.
accessToken
}
);
if
(
result
.
data
is
!
Map
)
{
if
(
result
.
data
is
Map
)
{
await
Future
.
wait
([
UserStore
.
to
.
setToken
(
result
.
data
[
'token'
]),
UserStore
.
to
.
setAccessToken
(
result
.
data
[
'access_token'
]),
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论