diff --git a/lib/login/new_login_page.dart b/lib/login/new_login_page.dart index 66d4bcea..60b9c2f4 100644 --- a/lib/login/new_login_page.dart +++ b/lib/login/new_login_page.dart @@ -256,6 +256,7 @@ class _NewLoginPage extends State { 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 { 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, diff --git a/lib/mine/mine_page.dart b/lib/mine/mine_page.dart index 897c0be8..6ba1ec69 100644 --- a/lib/mine/mine_page.dart +++ b/lib/mine/mine_page.dart @@ -49,7 +49,7 @@ class MinePageState extends State 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)? diff --git a/lib/mine/mine_view/mine_view.dart b/lib/mine/mine_view/mine_view.dart index f8248f56..a94f68f1 100644 --- a/lib/mine/mine_view/mine_view.dart +++ b/lib/mine/mine_view/mine_view.dart @@ -300,7 +300,7 @@ class _MineView extends State { child: Text( widget.userInfo == null ? S.of(context).denglu - : "${widget.userInfo.nickname}", + : "${widget.userInfo.nickname??""}", style: TextStyle( fontSize: 16.sp, fontWeight: FontWeight.bold, diff --git a/lib/mine/recharge_page.dart b/lib/mine/recharge_page.dart index 5de0b37d..848d0bb6 100644 --- a/lib/mine/recharge_page.dart +++ b/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 { String mBalance = "0"; dynamic payListen; + @override void initState() { super.initState(); @@ -292,7 +296,7 @@ class _RechargePage extends State { GestureDetector( onTap: () { setState(() { - checkIndex = 1; + checkIndex = 2; }); }, child: Row( @@ -316,7 +320,39 @@ class _RechargePage extends State { ), ), ), - 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 { ); } - var checkIndex = 1; + var checkIndex = 2; Widget rechargeList() { return ListView.builder( @@ -614,6 +650,7 @@ class _RechargePage extends State { }); } + recharge() async { // String money = controller.text; // if (money == null || money == "") { @@ -629,36 +666,54 @@ class _RechargePage extends State { // return; // } - if (Platform.isAndroid) { - if (!(await Min.isInitialize())) { - // 小程序的微信支付和app的充值支付使用同一个WXPayEntryActivity回调, - // 然而充值时小程序未初始化会导致回调内部代码调用getPackage空指针, - // 故而在此初始化一下 - await Min.initialize(); - } - } + BaseData baseData = await apiService.recharge({ "amount": 0, "rechargeActId": rechargeA[selectIndex].id, - "rechargeType": 2 + "rechargeType": checkIndex }).catchError((error) {}); if (baseData != null && baseData.isSuccess) { - WxPay wxPay = WxPay.fromJson(baseData.data); - await registerWxApi( - appId: wxPay.appId, - doOnAndroid: true, - 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, - ); + if(checkIndex==2){ + if (Platform.isAndroid) { + if (!(await Min.isInitialize())) { + // 小程序的微信支付和app的充值支付使用同一个WXPayEntryActivity回调, + // 然而充值时小程序未初始化会导致回调内部代码调用getPackage空指针, + // 故而在此初始化一下 + await Min.initialize(); + } + } + WxPay wxPay = WxPay.fromJson(baseData.data); + await registerWxApi( + appId: wxPay.appId, + doOnAndroid: true, + 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 { SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } diff --git a/lib/retrofit/data/examine_instance.dart b/lib/retrofit/data/examine_instance.dart index a5cd7287..63954b33 100644 --- a/lib/retrofit/data/examine_instance.dart +++ b/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(){ diff --git a/lib/retrofit/min_api.g.dart b/lib/retrofit/min_api.g.dart index 563bfbf2..643b10a8 100644 --- a/lib/retrofit/min_api.g.dart +++ b/lib/retrofit/min_api.g.dart @@ -100,7 +100,7 @@ class _MinApiService implements MinApiService { data: _data); final value = BaseData>.fromJson( _result.data, - (json) => json==null?null:(json as List) + (json) => ((json??"") == "")?null:(json as List) .map( (i) => ShoppingCart.fromJson(i as Map)) .toList()); diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index b55cfa21..3b6f86e7 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/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/";///线上 diff --git a/lib/union/union_list.dart b/lib/union/union_list.dart index bda2240f..73d69d9e 100644 --- a/lib/union/union_list.dart +++ b/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 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 { 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 { 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 { 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(); diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index d6360820..44caea6b 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -161,7 +161,7 @@ class UnionPageState extends State event["province"], event["city"], event["district"], - editingController.text, + "", -1); if (_mapController != null) _mapController.updateMapOptions(BMFMapOptions( @@ -214,7 +214,7 @@ class UnionPageState extends State value.getString("province"), value.getString("city"), value.getString("district"), - editingController.text, + "", -1), setState(() { if (_mapController != null) { @@ -227,7 +227,7 @@ class UnionPageState extends State } else { - queryStore("", "", "", "", "", editingController.text, -1), + queryStore("", "", "", "", "", "", -1), } }, ); @@ -254,6 +254,7 @@ class UnionPageState extends State // "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 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 ) { return Column( children: [ - buildSearchItem(), + // buildSearchItem(), Container( height: MediaQuery.of(context).size.height - 103.h - @@ -509,60 +518,59 @@ class UnionPageState extends State } 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( diff --git a/lib/view_widget/login_tips_dialog.dart b/lib/view_widget/login_tips_dialog.dart index ec56f4b5..2dde3f6a 100644 --- a/lib/view_widget/login_tips_dialog.dart +++ b/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"}, ); diff --git a/pubspec.lock b/pubspec.lock index 9cb8532b..ea333bca 100644 --- a/pubspec.lock +++ b/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: diff --git a/pubspec.yaml b/pubspec.yaml index d6ad3878..1b13ed61 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,10 +15,12 @@ dependencies: sdk: flutter fluwx: ^3.9.0+2 + tobias: ^2.4.1 + gradient_widgets: ^0.6.0 keframe: ^3.0.0 -# keframe: ^2.0.2 #滑动组件卡顿优化 + # keframe: ^2.0.2 #滑动组件卡顿优化 tpns_flutter_plugin: git: