Browse Source

充值支付宝支付

dart3_last
wurong 2 years ago
parent
commit
1d0a51687c
  1. 10
      lib/login/new_login_page.dart
  2. 2
      lib/mine/mine_page.dart
  3. 2
      lib/mine/mine_view/mine_view.dart
  4. 75
      lib/mine/recharge_page.dart
  5. 4
      lib/retrofit/data/examine_instance.dart
  6. 2
      lib/retrofit/min_api.g.dart
  7. 2
      lib/retrofit/retrofit_api.dart
  8. 51
      lib/union/union_list.dart
  9. 114
      lib/union/union_page.dart
  10. 2
      lib/view_widget/login_tips_dialog.dart
  11. 7
      pubspec.lock
  12. 2
      pubspec.yaml

10
lib/login/new_login_page.dart

@ -256,6 +256,7 @@ class _NewLoginPage extends State<NewLoginPage> {
if (sharedPreferences.containsKey('token') &&
sharedPreferences.getString("token") != null &&
sharedPreferences.getString("token") != "") {
ExamineInstance.instance.isExamine = sharedPreferences.getString("mobile") == "13800138000";
Navigator.of(context).popAndPushNamed('/router/main_page');
} else {
initController();
@ -674,12 +675,13 @@ class _NewLoginPage extends State<NewLoginPage> {
GestureDetector(
onTap: () {
print("11111");
if (widget.arguments != null) {
Navigator.of(context).pop();
} else {
// if (widget.arguments != null) {
// Navigator.of(context).pop();
// } else {
ExamineInstance.instance.isExamine = true;
Navigator.of(context)
.popAndPushNamed('/router/main_page');
}
// }
},
child: Container(
width: double.infinity,

2
lib/mine/mine_page.dart

@ -49,7 +49,7 @@ class MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin {
SharedPreferences shared = await SharedPreferences.getInstance();
if (shared.getString("token") == null || shared.getString("token") == "") {
Navigator.of(context)
.pushNamed('/router/new_login_page', arguments: {"login": "login"});
.pushReplacementNamed('/router/new_login_page', arguments: {"login": "login"});
return;
}
(Platform.isAndroid&&ExamineInstance.instance.isExamine)?

2
lib/mine/mine_view/mine_view.dart

@ -300,7 +300,7 @@ class _MineView extends State<MineView> {
child: Text(
widget.userInfo == null
? S.of(context).denglu
: "${widget.userInfo.nickname}",
: "${widget.userInfo.nickname??""}",
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.bold,

75
lib/mine/recharge_page.dart

@ -1,3 +1,4 @@
import 'dart:convert';
import 'dart:io';
import 'package:dio/dio.dart';
@ -24,6 +25,8 @@ import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:huixiang/view_widget/recharge_details_dialog.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tobias/tobias.dart' as tobias;
import 'package:tobias/tobias.dart';
class RechargePage extends StatefulWidget {
@override
@ -45,6 +48,7 @@ class _RechargePage extends State<RechargePage> {
String mBalance = "0";
dynamic payListen;
@override
void initState() {
super.initState();
@ -292,7 +296,7 @@ class _RechargePage extends State<RechargePage> {
GestureDetector(
onTap: () {
setState(() {
checkIndex = 1;
checkIndex = 2;
});
},
child: Row(
@ -316,7 +320,39 @@ class _RechargePage extends State<RechargePage> {
),
),
),
checkView(1),
checkView(2),
],
),
),
SizedBox(height:10.h),
GestureDetector(
onTap: () {
setState(() {
checkIndex = 3;
});
},
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Image.asset(
"assets/image/icon_alipay.webp"),
Expanded(
flex: 1,
child: Padding(
padding: EdgeInsets.only(left: 8.w),
child: Text(
S.of(context).zhifubao,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xff353535),
),
),
),
),
checkView(3),
],
),
),
@ -463,7 +499,7 @@ class _RechargePage extends State<RechargePage> {
);
}
var checkIndex = 1;
var checkIndex = 2;
Widget rechargeList() {
return ListView.builder(
@ -614,6 +650,7 @@ class _RechargePage extends State<RechargePage> {
});
}
recharge() async {
// String money = controller.text;
// if (money == null || money == "") {
@ -629,6 +666,15 @@ class _RechargePage extends State<RechargePage> {
// return;
// }
BaseData<dynamic> baseData = await apiService.recharge({
"amount": 0,
"rechargeActId": rechargeA[selectIndex].id,
"rechargeType": checkIndex
}).catchError((error) {});
if (baseData != null && baseData.isSuccess) {
if(checkIndex==2){
if (Platform.isAndroid) {
if (!(await Min.isInitialize())) {
// app的充值支付使用同一个WXPayEntryActivity回调
@ -637,13 +683,6 @@ class _RechargePage extends State<RechargePage> {
await Min.initialize();
}
}
BaseData<dynamic> baseData = await apiService.recharge({
"amount": 0,
"rechargeActId": rechargeA[selectIndex].id,
"rechargeType": 2
}).catchError((error) {});
if (baseData != null && baseData.isSuccess) {
WxPay wxPay = WxPay.fromJson(baseData.data);
await registerWxApi(
appId: wxPay.appId,
@ -659,6 +698,22 @@ class _RechargePage extends State<RechargePage> {
timeStamp: int.tryParse(wxPay.timeStamp),
sign: wxPay.sign,
);
}else{
tobias.isAliPayInstalled().then((value) => { //
if (!value) {
SmartDialog.showToast("请安装支付宝", alignment: Alignment.center)
}else{
tobias.aliPay(baseData.data["body"],evn: AliPayEvn.SANDBOX).then((payRes) {
if (payRes['resultStatus'] == 9000 ||
payRes['resultStatus'] == '9000') {
Navigator.of(context).pop();
} else {
SmartDialog.showToast(payRes['memo'], alignment: Alignment.center);
}
})
}
});
}
} else {
SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
}

4
lib/retrofit/data/examine_instance.dart

@ -7,7 +7,7 @@ class ExamineInstance{
static ExamineInstance _instance;
bool _isExamine = true;
bool _isExamine;
bool get isExamine =>
_isExamine;
@ -18,7 +18,7 @@ class ExamineInstance{
ExamineInstance._internal(){
//
_isExamine = true;
}
static ExamineInstance _getInstance(){

2
lib/retrofit/min_api.g.dart

@ -100,7 +100,7 @@ class _MinApiService implements MinApiService {
data: _data);
final value = BaseData<List<ShoppingCart>>.fromJson(
_result.data,
(json) => json==null?null:(json as List<dynamic>)
(json) => ((json??"") == "")?null:(json as List<dynamic>)
.map<ShoppingCart>(
(i) => ShoppingCart.fromJson(i as Map<String, dynamic>))
.toList());

2
lib/retrofit/retrofit_api.dart

@ -61,7 +61,7 @@ import 'data/wx_pay.dart';
part 'retrofit_api.g.dart';
const localBaseUrl = "http://192.168.10.78:8766/app/";///
const localBaseUrl = "http://192.168.10.129:8766/app/";///
// const localBaseUrl = "https://2946-27-19-77-115.jp.ngrok.io/app/";///
const serviceBaseUrl = "https://pos.platform.lotus-wallet.com/app/";///线

51
lib/union/union_list.dart

@ -12,12 +12,15 @@ import 'package:huixiang/view_widget/round_button.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import '../view_widget/no_data_view.dart';
class UnionList extends StatefulWidget {
final RefreshController refreshController;
final List<Store> storeList;
final Function onRefresh;
final Function queryStore;
UnionList(this.refreshController,this.storeList,this.onRefresh);
UnionList(this.refreshController,this.storeList,this.onRefresh,this.queryStore);
@override
@ -45,7 +48,14 @@ class _UnionList extends State<UnionList> {
physics: BouncingScrollPhysics(),
header: MyHeader(),
onRefresh: widget.onRefresh,
child: ListView.builder(
child: (widget.storeList == null || widget.storeList.length == 0)
? NoDataView(
src:"assets/image/di_zhi.webp",
isShowBtn: false,
text: "暂无店铺列表~",
fontSize: 16.sp,
margin: EdgeInsets.only(top: 120.h),
):ListView.builder(
itemCount:widget.storeList == null ? 0 : widget.storeList.length,
padding: EdgeInsets.only(
top: 8.h,
@ -58,19 +68,19 @@ class _UnionList extends State<UnionList> {
if (widget.storeList[position].posType.code == "NORMALSTORE") {
showDeleteDialog();
}
else if (widget.storeList[position].posType.code ==
"DIRECT" &&
widget.storeList[position].storeName == "一心回乡商城") {
Navigator.of(context).pushNamed(
'/router/shopping_mall_home',
arguments: {
"type": 0,
"id": widget.storeList[position].id,
"tenant": widget.storeList[position].tenantCode,
"storeName": widget.storeList[position].storeName
},
);
}
// else if (widget.storeList[position].posType.code ==
// "DIRECT" &&
// widget.storeList[position].storeName == "一心回乡商城") {
// Navigator.of(context).pushNamed(
// '/router/shopping_mall_home',
// arguments: {
// "type": 0,
// "id": widget.storeList[position].id,
// "tenant": widget.storeList[position].tenantCode,
// "storeName": widget.storeList[position].storeName
// },
// );
// }
else
{
Navigator.of(context).pushNamed(
@ -111,19 +121,24 @@ class _UnionList extends State<UnionList> {
child: TextField(
textInputAction: TextInputAction.search,
onEditingComplete: () {
// startLocation();
widget.queryStore(editingController.text);
},
controller: editingController,
cursorHeight: 30.h,
cursorHeight: 25.h,
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(
vertical: 12.h,
),
prefixIcon: Icon(
prefixIcon:InkWell(
onTap: () {
widget.queryStore(editingController.text);
},
child: Icon(
Icons.search,
size: 24,
color: Colors.black,
),
),
suffixIcon: InkWell(
onTap: () {
editingController.clear();

114
lib/union/union_page.dart

@ -161,7 +161,7 @@ class UnionPageState extends State<UnionPage>
event["province"],
event["city"],
event["district"],
editingController.text,
"",
-1);
if (_mapController != null)
_mapController.updateMapOptions(BMFMapOptions(
@ -214,7 +214,7 @@ class UnionPageState extends State<UnionPage>
value.getString("province"),
value.getString("city"),
value.getString("district"),
editingController.text,
"",
-1),
setState(() {
if (_mapController != null) {
@ -227,7 +227,7 @@ class UnionPageState extends State<UnionPage>
}
else
{
queryStore("", "", "", "", "", editingController.text, -1),
queryStore("", "", "", "", "", "", -1),
}
},
);
@ -254,6 +254,7 @@ class UnionPageState extends State<UnionPage>
// "province": province,
"latitude": latitude,
"longitude": longitude,
if(searchKey != "")
"searchKey": searchKey,
"serviceType": (tabController.index == 0 && index == -1) || index == 0
? ""
@ -351,15 +352,23 @@ class UnionPageState extends State<UnionPage>
children: [
UnionList(refreshController, storeList, () {
startLocation(true);
},(txt){
queryStore("","","","","",txt,0);
}),
UnionList(refreshController1, storeList1, () {
startLocation(true);
},(txt){
queryStore("","","","","",txt,0);
}),
UnionList(refreshController2, storeList2, () {
startLocation(true);
},(txt){
queryStore("","","","","",txt,0);
}),
UnionList(refreshController3, storeList3, () {
startLocation(true);
},(txt){
queryStore("","","","","",txt,0);
}),
],
),
@ -451,7 +460,7 @@ class UnionPageState extends State<UnionPage>
) {
return Column(
children: [
buildSearchItem(),
// buildSearchItem(),
Container(
height: MediaQuery.of(context).size.height -
103.h -
@ -509,60 +518,59 @@ class UnionPageState extends State<UnionPage>
}
BMFMapController _mapController;
final TextEditingController editingController = TextEditingController();
void onMapCreated(BMFMapController controller) {
_mapController = controller;
}
Widget buildSearchItem() {
return Container(
height: 36.h,
margin: EdgeInsets.fromLTRB(6.w, 0, 14.w, 0),
padding: EdgeInsets.fromLTRB(0, 6.h, 0, 6.h),
decoration: BoxDecoration(
color: Color(0xFFF5FAF7),
borderRadius: BorderRadius.circular(4),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
),
child: TextField(
textInputAction: TextInputAction.search,
onEditingComplete: () {
startLocation(false);
},
controller: editingController,
cursorHeight: 30.h,
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(
vertical: 12.h,
),
prefixIcon: Icon(
Icons.search,
size: 24,
color: Colors.black,
),
suffixIcon: InkWell(
onTap: () {
editingController.clear();
},
child: Icon(
Icons.close,
size: 19,
color: Colors.grey,
),
),
border: InputBorder.none,
),
),
);
}
// Widget buildSearchItem() {
// return Container(
// height: 36.h,
// margin: EdgeInsets.fromLTRB(6.w, 0, 14.w, 0),
// padding: EdgeInsets.fromLTRB(0, 6.h, 0, 6.h),
// decoration: BoxDecoration(
// color: Color(0xFFF5FAF7),
// borderRadius: BorderRadius.circular(4),
// boxShadow: [
// BoxShadow(
// color: Colors.black.withAlpha(12),
// offset: Offset(0, 3),
// blurRadius: 14,
// spreadRadius: 0,
// ),
// ],
// ),
// child: TextField(
// textInputAction: TextInputAction.search,
// onEditingComplete: () {
// startLocation(false);
// },
// controller: editingController,
// cursorHeight: 30.h,
// decoration: InputDecoration(
// contentPadding: EdgeInsets.symmetric(
// vertical: 12.h,
// ),
// prefixIcon: Icon(
// Icons.search,
// size: 24,
// color: Colors.black,
// ),
// suffixIcon: InkWell(
// onTap: () {
// editingController.clear();
// },
// child: Icon(
// Icons.close,
// size: 19,
// color: Colors.grey,
// ),
// ),
// border: InputBorder.none,
// ),
// ),
// );
// }
// Widget buildSliverAppBar(BMFMapWidget map) {
// return SliverAppBar(

2
lib/view_widget/login_tips_dialog.dart

@ -32,7 +32,7 @@ class LoginTipsDialog {
value.setString("mobile", "");
value.setString("nick", "");
});
Navigator.of(context).pushNamed(
Navigator.of(context).pushReplacementNamed(
'/router/new_login_page',
arguments: {"login": "login"},
);

7
pubspec.lock

@ -733,6 +733,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.1"
tobias:
dependency: "direct main"
description:
name: tobias
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.4.1"
tpns_flutter_plugin:
dependency: "direct main"
description:

2
pubspec.yaml

@ -15,6 +15,8 @@ dependencies:
sdk: flutter
fluwx: ^3.9.0+2
tobias: ^2.4.1
gradient_widgets: ^0.6.0
keframe: ^3.0.0

Loading…
Cancel
Save