Commit 2f7c6604 authored by 关振斌's avatar 关振斌

update

parent 874883c2
......@@ -47,6 +47,15 @@ class UserAPI {
// UserLoginResponseEntity.fromJson(response);
}
static Future<UserInfoEntity> getUserInfo() async {
var response = await HttpUtil().get(
'/user/info',
);
return UserInfoEntity.fromMap(response['data']);
// UserLoginResponseEntity.fromJson(response);
}
// /api/user/info
static Future<MsmEntity> sendSms(
Map<String, dynamic>? params,
) async {
......
......@@ -36,7 +36,7 @@ class HttpUtil {
connectTimeout: 10000,
// 响应流上前后两次接受到数据的间隔,单位为毫秒。
receiveTimeout: 45000,
receiveTimeout: 20000,
// Http请求头.
headers: {},
......
// baidu yapi
// const SERVER_API_URL = 'https://yapi.baidu.com/mock/41008';
// const SERVER_API_URL = 'https://yapi.ducafecat.tech/mock/11';
const SERVER_API_URL = 'http://101.34.153.228:8083/api';//线上
// const SERVER_API_URL = 'http://192.168.120.23:8083/api';
// const SERVER_API_URL = 'http://101.34.153.228:8083/api';//线上
// http://192.168.110.66:8083/api/doc.html
const SERVER_API_URL = 'http://192.168.110.66:8083/api';
// http://192.168.110.25:8083/
// const SERVER_API_URL = 'http://192.168.2.178:8083/api';
// const SERVER_API_URL = 'http://192.168.110.57:8083/api';
......
......@@ -264,3 +264,26 @@ class MsmEntity {
"timestamp": timestamp
};
}
class UserInfoEntity {
UserInfoEntity({required this.expireTime, required this.integral});
final dynamic expireTime;
final int integral;
// expireTime: res.expireTime,
// integral: res.integral
factory UserInfoEntity.fromJson(String str) =>
UserInfoEntity.fromMap(json.decode(str));
String toJson() => json.encode(toMap());
factory UserInfoEntity.fromMap(Map<String, dynamic> json) => UserInfoEntity(
integral: json['integral'],
expireTime: json["expireTime"] == null
? null
: DateTime.parse(json["expireTime"]));
Map<String, dynamic> toMap() =>
{"integral": integral, "expireTime": expireTime};
}
......@@ -6,6 +6,6 @@ class ChatBinding implements Bindings {
@override
void dependencies() {
// print('ChatPageControllerChatPageControllerChatPageController');
// Get.lazyPut<ChatPageController>(() => ChatPageController());
Get.lazyPut<ChatPageController>(() => ChatPageController());
}
}
......@@ -5,6 +5,7 @@ import 'package:alipay_kit/alipay_kit.dart';
import 'package:chart/common/apis/apis.dart';
import 'package:chart/common/entities/good.dart';
import 'package:chart/common/store/user.dart';
import 'package:chart/entity/user_entity.dart';
import 'package:chart/pages/frame/android_pay_list/unsafe_alipay_kit.dart';
// import 'package:chart/common/routers/routes.dart';
// import 'package:chart/common/store/store.dart';
......@@ -23,6 +24,7 @@ class AndroidPayListController extends GetxController {
final state = AndroidPayListState();
late final StreamSubscription<AlipayResp> _alipaySubs; //用于付
// Platform messages may fail, so we use a try/catch PlatformException.
// prepare
......@@ -55,8 +57,49 @@ class AndroidPayListController extends GetxController {
// 初始静态数据
}
void listenAlipayPay(AlipayResp resp) {
final String content = 'pay: ${resp.resultStatus} - ${resp.result}';
print(content);
// 9000——订单支付成功 下面的result有值 8000——正在处理中 4000——订单支付失败 5000——重复请求 6001——用户中途取消 6002——网络连接出错
switch (resp.resultStatus) {
case 9000:
EasyLoading.showToast("订单支付成功");
UserAPI.getUserInfo().then((value) async {
await UserStore.to.saveProfile(IntegralEntity(
id: UserStore.to.profile.id,
username: UserStore.to.profile.username,
token: UserStore.to.profile.token,
expireTime: value.expireTime,
integral: value.integral));
});
Get.back();
break;
case 8000:
EasyLoading.showToast("正在处理中");
break;
case 4000:
EasyLoading.showToast("订单支付失败");
break;
case 5000:
EasyLoading.showToast("5000");
break;
case 6001:
EasyLoading.showToast("用户中途取消");
break;
case 6002:
EasyLoading.showToast("网络连接出错");
break;
default:
break;
}
}
Future initializedPlugins() async {
await AlipayKitPlatform.instance.isInstalled();
_alipaySubs = AlipayKitPlatform.instance.payResp().listen(listenAlipayPay);
}
Future _getProduct() async {
......@@ -102,6 +145,7 @@ class AndroidPayListController extends GetxController {
});
AlipayKitPlatform.instance.pay(orderInfo: orderInfo);
EasyLoading.dismiss();
// actSelected
// selected
......@@ -145,6 +189,7 @@ class AndroidPayListController extends GetxController {
///将一些数据保存在磁盘上也可能很有用。
@override
void onClose() {
_alipaySubs.cancel();
super.onClose();
// 1 stop & close 关闭对象
// 2 save 持久化数据
......@@ -153,9 +198,7 @@ class AndroidPayListController extends GetxController {
///dispose 释放内存
@override
void dispose() {
// _purchaseUpdatedSubscription.cancel();
// _purchaseErrorSubscription.cancel();
// _conectionSubscription.cancel();
_alipaySubs.cancel();
super.dispose();
// dispose 释放对象
}
......
......@@ -295,7 +295,7 @@ class PayItemWidget extends GetView<AndroidPayListController> {
child: Container(
margin: EdgeInsets.only(top: 20),
child: GradientButton(
child: Text('订阅'),
child: Text('购买'),
increaseHeightBy: 15.00,
increaseWidthBy: 200.00,
callback: controller.requestPurchase,
......
import 'package:chart/common/apis/apis.dart';
import 'package:chart/common/store/store.dart';
import 'package:chart/entity/user_entity.dart';
import 'package:chart/package/chat_dash/dash_chat_2.dart' as Chat;
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_vibrate/flutter_vibrate.dart';
......@@ -95,6 +96,14 @@ class ChatNewController extends GetxController {
_addMessage(receiveMessage);
EasyLoading.dismiss();
Vibrate.feedback(FeedbackType.success);
UserAPI.getUserInfo().then((value) async {
await UserStore.to.saveProfile(IntegralEntity(
id: UserStore.to.profile.id,
username: UserStore.to.profile.username,
token: UserStore.to.profile.token,
expireTime: value.expireTime,
integral: value.integral));
});
} else {
final receiveErrorMessage = Chat.ChatMessage(
user: receiveUser,
......
......@@ -91,6 +91,15 @@ class PayListController extends GetxController {
EasyLoading.showSuccess('${res?.message}');
Vibrate.feedback(FeedbackType.success);
EasyLoading.dismiss();
UserAPI.getUserInfo().then((value) async {
await UserStore.to.saveProfile(IntegralEntity(
id: UserStore.to.profile.id,
username: UserStore.to.profile.username,
token: UserStore.to.profile.token,
expireTime: value.expireTime,
integral: value.integral));
});
Get.back();
// equired this.id,
// required this.username,
// required this.token,
......
......@@ -293,7 +293,7 @@ class PayItemWidget extends GetView<PayListController> {
child: Container(
margin: EdgeInsets.only(top: 20),
child: GradientButton(
child: Text('订阅'),
child: Text('购买'),
increaseHeightBy: 15.00,
increaseWidthBy: 200.00,
callback: controller.requestPurchase,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment