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. 109
      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. 4
      pubspec.yaml

10
lib/login/new_login_page.dart

@ -256,6 +256,7 @@ class _NewLoginPage extends State<NewLoginPage> {
if (sharedPreferences.containsKey('token') && if (sharedPreferences.containsKey('token') &&
sharedPreferences.getString("token") != null && sharedPreferences.getString("token") != null &&
sharedPreferences.getString("token") != "") { sharedPreferences.getString("token") != "") {
ExamineInstance.instance.isExamine = sharedPreferences.getString("mobile") == "13800138000";
Navigator.of(context).popAndPushNamed('/router/main_page'); Navigator.of(context).popAndPushNamed('/router/main_page');
} else { } else {
initController(); initController();
@ -674,12 +675,13 @@ class _NewLoginPage extends State<NewLoginPage> {
GestureDetector( GestureDetector(
onTap: () { onTap: () {
print("11111"); print("11111");
if (widget.arguments != null) { // if (widget.arguments != null) {
Navigator.of(context).pop(); // Navigator.of(context).pop();
} else { // } else {
ExamineInstance.instance.isExamine = true;
Navigator.of(context) Navigator.of(context)
.popAndPushNamed('/router/main_page'); .popAndPushNamed('/router/main_page');
} // }
}, },
child: Container( child: Container(
width: double.infinity, 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(); SharedPreferences shared = await SharedPreferences.getInstance();
if (shared.getString("token") == null || shared.getString("token") == "") { if (shared.getString("token") == null || shared.getString("token") == "") {
Navigator.of(context) Navigator.of(context)
.pushNamed('/router/new_login_page', arguments: {"login": "login"}); .pushReplacementNamed('/router/new_login_page', arguments: {"login": "login"});
return; return;
} }
(Platform.isAndroid&&ExamineInstance.instance.isExamine)? (Platform.isAndroid&&ExamineInstance.instance.isExamine)?

2
lib/mine/mine_view/mine_view.dart

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

109
lib/mine/recharge_page.dart

@ -1,3 +1,4 @@
import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:dio/dio.dart'; 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/recharge_details_dialog.dart';
import 'package:huixiang/view_widget/round_button.dart'; import 'package:huixiang/view_widget/round_button.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:tobias/tobias.dart' as tobias;
import 'package:tobias/tobias.dart';
class RechargePage extends StatefulWidget { class RechargePage extends StatefulWidget {
@override @override
@ -45,6 +48,7 @@ class _RechargePage extends State<RechargePage> {
String mBalance = "0"; String mBalance = "0";
dynamic payListen; dynamic payListen;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -292,7 +296,7 @@ class _RechargePage extends State<RechargePage> {
GestureDetector( GestureDetector(
onTap: () { onTap: () {
setState(() { setState(() {
checkIndex = 1; checkIndex = 2;
}); });
}, },
child: Row( 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() { Widget rechargeList() {
return ListView.builder( return ListView.builder(
@ -614,6 +650,7 @@ class _RechargePage extends State<RechargePage> {
}); });
} }
recharge() async { recharge() async {
// String money = controller.text; // String money = controller.text;
// if (money == null || money == "") { // if (money == null || money == "") {
@ -629,36 +666,54 @@ class _RechargePage extends State<RechargePage> {
// return; // return;
// } // }
if (Platform.isAndroid) {
if (!(await Min.isInitialize())) {
// app的充值支付使用同一个WXPayEntryActivity回调
// getPackage空指针
//
await Min.initialize();
}
}
BaseData<dynamic> baseData = await apiService.recharge({ BaseData<dynamic> baseData = await apiService.recharge({
"amount": 0, "amount": 0,
"rechargeActId": rechargeA[selectIndex].id, "rechargeActId": rechargeA[selectIndex].id,
"rechargeType": 2 "rechargeType": checkIndex
}).catchError((error) {}); }).catchError((error) {});
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
WxPay wxPay = WxPay.fromJson(baseData.data); if(checkIndex==2){
await registerWxApi( if (Platform.isAndroid) {
appId: wxPay.appId, if (!(await Min.isInitialize())) {
doOnAndroid: true, // app的充值支付使用同一个WXPayEntryActivity回调
universalLink: "https://hx.lotus-wallet.com/app/", // getPackage空指针
); //
payWithWeChat( await Min.initialize();
appId: wxPay.appId, }
partnerId: wxPay.partnerId, }
prepayId: wxPay.prepayId, WxPay wxPay = WxPay.fromJson(baseData.data);
packageValue: wxPay.packageValue, await registerWxApi(
nonceStr: wxPay.nonceStr, appId: wxPay.appId,
timeStamp: int.tryParse(wxPay.timeStamp), doOnAndroid: true,
sign: wxPay.sign, universalLink: "https://hx.lotus-wallet.com/app/",
); );
payWithWeChat(
appId: wxPay.appId,
partnerId: wxPay.partnerId,
prepayId: wxPay.prepayId,
packageValue: wxPay.packageValue,
nonceStr: wxPay.nonceStr,
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 { } else {
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
} }

4
lib/retrofit/data/examine_instance.dart

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

2
lib/retrofit/min_api.g.dart

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

2
lib/retrofit/retrofit_api.dart

@ -61,7 +61,7 @@ import 'data/wx_pay.dart';
part 'retrofit_api.g.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 localBaseUrl = "https://2946-27-19-77-115.jp.ngrok.io/app/";///
const serviceBaseUrl = "https://pos.platform.lotus-wallet.com/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:permission_handler/permission_handler.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import '../view_widget/no_data_view.dart';
class UnionList extends StatefulWidget { class UnionList extends StatefulWidget {
final RefreshController refreshController; final RefreshController refreshController;
final List<Store> storeList; final List<Store> storeList;
final Function onRefresh; final Function onRefresh;
final Function queryStore;
UnionList(this.refreshController,this.storeList,this.onRefresh); UnionList(this.refreshController,this.storeList,this.onRefresh,this.queryStore);
@override @override
@ -45,7 +48,14 @@ class _UnionList extends State<UnionList> {
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
header: MyHeader(), header: MyHeader(),
onRefresh: widget.onRefresh, 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, itemCount:widget.storeList == null ? 0 : widget.storeList.length,
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 8.h, top: 8.h,
@ -58,19 +68,19 @@ class _UnionList extends State<UnionList> {
if (widget.storeList[position].posType.code == "NORMALSTORE") { if (widget.storeList[position].posType.code == "NORMALSTORE") {
showDeleteDialog(); showDeleteDialog();
} }
else if (widget.storeList[position].posType.code == // else if (widget.storeList[position].posType.code ==
"DIRECT" && // "DIRECT" &&
widget.storeList[position].storeName == "一心回乡商城") { // widget.storeList[position].storeName == "一心回乡商城") {
Navigator.of(context).pushNamed( // Navigator.of(context).pushNamed(
'/router/shopping_mall_home', // '/router/shopping_mall_home',
arguments: { // arguments: {
"type": 0, // "type": 0,
"id": widget.storeList[position].id, // "id": widget.storeList[position].id,
"tenant": widget.storeList[position].tenantCode, // "tenant": widget.storeList[position].tenantCode,
"storeName": widget.storeList[position].storeName // "storeName": widget.storeList[position].storeName
}, // },
); // );
} // }
else else
{ {
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(
@ -111,19 +121,24 @@ class _UnionList extends State<UnionList> {
child: TextField( child: TextField(
textInputAction: TextInputAction.search, textInputAction: TextInputAction.search,
onEditingComplete: () { onEditingComplete: () {
// startLocation(); widget.queryStore(editingController.text);
}, },
controller: editingController, controller: editingController,
cursorHeight: 30.h, cursorHeight: 25.h,
decoration: InputDecoration( decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric( contentPadding: EdgeInsets.symmetric(
vertical: 12.h, vertical: 12.h,
), ),
prefixIcon: Icon( prefixIcon:InkWell(
onTap: () {
widget.queryStore(editingController.text);
},
child: Icon(
Icons.search, Icons.search,
size: 24, size: 24,
color: Colors.black, color: Colors.black,
), ),
),
suffixIcon: InkWell( suffixIcon: InkWell(
onTap: () { onTap: () {
editingController.clear(); editingController.clear();

114
lib/union/union_page.dart

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

2
lib/view_widget/login_tips_dialog.dart

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

7
pubspec.lock

@ -733,6 +733,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.1" 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: tpns_flutter_plugin:
dependency: "direct main" dependency: "direct main"
description: description:

4
pubspec.yaml

@ -15,10 +15,12 @@ dependencies:
sdk: flutter sdk: flutter
fluwx: ^3.9.0+2 fluwx: ^3.9.0+2
tobias: ^2.4.1
gradient_widgets: ^0.6.0 gradient_widgets: ^0.6.0
keframe: ^3.0.0 keframe: ^3.0.0
# keframe: ^2.0.2 #滑动组件卡顿优化 # keframe: ^2.0.2 #滑动组件卡顿优化
tpns_flutter_plugin: tpns_flutter_plugin:
git: git:

Loading…
Cancel
Save