Commit 4acb1e4ea6a01951b88b13a2f5e328ad167ae6c8

Authored by wdn127929
1 parent 303bed5d

短信购买ok

@@ -479,10 +479,10 @@ @@ -479,10 +479,10 @@
479 CODE_SIGN_IDENTITY = "iPhone Developer"; 479 CODE_SIGN_IDENTITY = "iPhone Developer";
480 "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 480 "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
481 CODE_SIGN_STYLE = Automatic; 481 CODE_SIGN_STYLE = Automatic;
482 - CURRENT_PROJECT_VERSION = 260; 482 + CURRENT_PROJECT_VERSION = 290;
483 DEVELOPMENT_TEAM = 8J59HM8B82; 483 DEVELOPMENT_TEAM = 8J59HM8B82;
484 ENABLE_BITCODE = NO; 484 ENABLE_BITCODE = NO;
485 - FLUTTER_BUILD_MODE = debug; 485 + FLUTTER_BUILD_MODE = release;
486 FRAMEWORK_SEARCH_PATHS = ( 486 FRAMEWORK_SEARCH_PATHS = (
487 "$(inherited)", 487 "$(inherited)",
488 "$(PROJECT_DIR)/Flutter", 488 "$(PROJECT_DIR)/Flutter",
@@ -494,7 +494,7 @@ @@ -494,7 +494,7 @@
494 "$(inherited)", 494 "$(inherited)",
495 "$(PROJECT_DIR)/Flutter", 495 "$(PROJECT_DIR)/Flutter",
496 ); 496 );
497 - MARKETING_VERSION = 2.6.6; 497 + MARKETING_VERSION = 2.9.6;
498 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; 498 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine;
499 PRODUCT_NAME = Runner; 499 PRODUCT_NAME = Runner;
500 PROVISIONING_PROFILE_SPECIFIER = ""; 500 PROVISIONING_PROFILE_SPECIFIER = "";
@@ -624,10 +624,10 @@ @@ -624,10 +624,10 @@
624 CODE_SIGN_ENTITLEMENTS = "Runner/一键订Debug.entitlements"; 624 CODE_SIGN_ENTITLEMENTS = "Runner/一键订Debug.entitlements";
625 CODE_SIGN_IDENTITY = "iPhone Developer"; 625 CODE_SIGN_IDENTITY = "iPhone Developer";
626 CODE_SIGN_STYLE = Automatic; 626 CODE_SIGN_STYLE = Automatic;
627 - CURRENT_PROJECT_VERSION = 260; 627 + CURRENT_PROJECT_VERSION = 290;
628 DEVELOPMENT_TEAM = 8J59HM8B82; 628 DEVELOPMENT_TEAM = 8J59HM8B82;
629 ENABLE_BITCODE = NO; 629 ENABLE_BITCODE = NO;
630 - FLUTTER_BUILD_MODE = debug; 630 + FLUTTER_BUILD_MODE = release;
631 FRAMEWORK_SEARCH_PATHS = ( 631 FRAMEWORK_SEARCH_PATHS = (
632 "$(inherited)", 632 "$(inherited)",
633 "$(PROJECT_DIR)/Flutter", 633 "$(PROJECT_DIR)/Flutter",
@@ -639,7 +639,7 @@ @@ -639,7 +639,7 @@
639 "$(inherited)", 639 "$(inherited)",
640 "$(PROJECT_DIR)/Flutter", 640 "$(PROJECT_DIR)/Flutter",
641 ); 641 );
642 - MARKETING_VERSION = 2.6.6; 642 + MARKETING_VERSION = 2.9.6;
643 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; 643 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine;
644 PRODUCT_NAME = Runner; 644 PRODUCT_NAME = Runner;
645 PROVISIONING_PROFILE_SPECIFIER = ""; 645 PROVISIONING_PROFILE_SPECIFIER = "";
@@ -659,7 +659,7 @@ @@ -659,7 +659,7 @@
659 CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; 659 CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
660 CODE_SIGN_IDENTITY = "iPhone Developer"; 660 CODE_SIGN_IDENTITY = "iPhone Developer";
661 CODE_SIGN_STYLE = Automatic; 661 CODE_SIGN_STYLE = Automatic;
662 - CURRENT_PROJECT_VERSION = 260; 662 + CURRENT_PROJECT_VERSION = 290;
663 DEVELOPMENT_TEAM = 8J59HM8B82; 663 DEVELOPMENT_TEAM = 8J59HM8B82;
664 ENABLE_BITCODE = NO; 664 ENABLE_BITCODE = NO;
665 FLUTTER_BUILD_MODE = release; 665 FLUTTER_BUILD_MODE = release;
@@ -674,7 +674,7 @@ @@ -674,7 +674,7 @@
674 "$(inherited)", 674 "$(inherited)",
675 "$(PROJECT_DIR)/Flutter", 675 "$(PROJECT_DIR)/Flutter",
676 ); 676 );
677 - MARKETING_VERSION = 2.6.6; 677 + MARKETING_VERSION = 2.9.6;
678 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; 678 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine;
679 PRODUCT_NAME = Runner; 679 PRODUCT_NAME = Runner;
680 PROVISIONING_PROFILE_SPECIFIER = ""; 680 PROVISIONING_PROFILE_SPECIFIER = "";
  1 +import 'package:json_annotation/json_annotation.dart';
  2 +
  3 +part 'wechat_pay_model.g.dart';
  4 +
  5 +@JsonSerializable()
  6 +class WechatPayModel extends Object {
  7 + @JsonKey(name: 'ret')
  8 + int ret;
  9 +
  10 + @JsonKey(name: 'data')
  11 + WechatPaySunModel data;
  12 +
  13 + @JsonKey(name: 'msg')
  14 + String msg;
  15 +
  16 + WechatPayModel(
  17 + this.ret,
  18 + this.data,
  19 + this.msg,
  20 + );
  21 +
  22 + factory WechatPayModel.fromJson(Map<String, dynamic> srcJson) =>
  23 + _$WechatPayModelFromJson(srcJson);
  24 +
  25 + Map<String, dynamic> toJson() => _$WechatPayModelToJson(this);
  26 +}
  27 +
  28 +@JsonSerializable()
  29 +class WechatPaySunModel extends Object {
  30 + @JsonKey(name: 'appId')
  31 + String appId;
  32 +
  33 + @JsonKey(name: 'timeStamp')
  34 + String timeStamp;
  35 +
  36 + @JsonKey(name: 'nonceStr')
  37 + String nonceStr;
  38 +
  39 + @JsonKey(name: 'package')
  40 + String package;
  41 +
  42 + @JsonKey(name: 'signType')
  43 + String signType;
  44 +
  45 + @JsonKey(name: 'paySign')
  46 + String paySign;
  47 +
  48 + WechatPaySunModel(
  49 + this.appId,
  50 + this.timeStamp,
  51 + this.nonceStr,
  52 + this.package,
  53 + this.signType,
  54 + this.paySign,
  55 + );
  56 +
  57 + factory WechatPaySunModel.fromJson(Map<String, dynamic> srcJson) =>
  58 + _$WechatPaySunModelFromJson(srcJson);
  59 +
  60 + Map<String, dynamic> toJson() => _$WechatPaySunModelToJson(this);
  61 +}
  1 +// GENERATED CODE - DO NOT MODIFY BY HAND
  2 +
  3 +part of 'wechat_pay_model.dart';
  4 +
  5 +// **************************************************************************
  6 +// JsonSerializableGenerator
  7 +// **************************************************************************
  8 +
  9 +WechatPayModel _$WechatPayModelFromJson(Map<String, dynamic> json) {
  10 + return WechatPayModel(
  11 + json['ret'] as int,
  12 + json['data'] == null
  13 + ? null
  14 + : WechatPaySunModel.fromJson(json['data'] as Map<String, dynamic>),
  15 + json['msg'] as String,
  16 + );
  17 +}
  18 +
  19 +Map<String, dynamic> _$WechatPayModelToJson(WechatPayModel instance) =>
  20 + <String, dynamic>{
  21 + 'ret': instance.ret,
  22 + 'data': instance.data,
  23 + 'msg': instance.msg,
  24 + };
  25 +
  26 +WechatPaySunModel _$WechatPaySunModelFromJson(Map<String, dynamic> json) {
  27 + return WechatPaySunModel(
  28 + json['appId'] as String,
  29 + json['timeStamp'] as String,
  30 + json['nonceStr'] as String,
  31 + json['package'] as String,
  32 + json['signType'] as String,
  33 + json['paySign'] as String,
  34 + );
  35 +}
  36 +
  37 +Map<String, dynamic> _$WechatPaySunModelToJson(WechatPaySunModel instance) =>
  38 + <String, dynamic>{
  39 + 'appId': instance.appId,
  40 + 'timeStamp': instance.timeStamp,
  41 + 'nonceStr': instance.nonceStr,
  42 + 'package': instance.package,
  43 + 'signType': instance.signType,
  44 + 'paySign': instance.paySign,
  45 + };
@@ -132,4 +132,7 @@ class HttpUrl { @@ -132,4 +132,7 @@ class HttpUrl {
132 static const String get_table_fill_update = 132 static const String get_table_fill_update =
133 "?service=App.Customer.GetTableFillUpDate"; // 根据指定日期,返回当前商家包间类型置满情况的日期 133 "?service=App.Customer.GetTableFillUpDate"; // 根据指定日期,返回当前商家包间类型置满情况的日期
134 134
  135 + static const String app_pay_sub =
  136 + "?service=App.Pay.AppPaySub"; // 根据指定日期,返回当前商家包间类型置满情况的日期
  137 +
135 } 138 }
@@ -14,7 +14,7 @@ import 'package:one_key/widgets/v_empty_view.dart'; @@ -14,7 +14,7 @@ import 'package:one_key/widgets/v_empty_view.dart';
14 import 'package:provider/provider.dart'; 14 import 'package:provider/provider.dart';
15 15
16 class SmsManagerPage extends StatefulWidget { 16 class SmsManagerPage extends StatefulWidget {
17 - final SmsInfoData infoData; 17 + SmsInfoData infoData;
18 SmsManagerPage({Key key, this.infoData}) : super(key: key); 18 SmsManagerPage({Key key, this.infoData}) : super(key: key);
19 19
20 @override 20 @override
@@ -22,11 +22,37 @@ class SmsManagerPage extends StatefulWidget { @@ -22,11 +22,37 @@ class SmsManagerPage extends StatefulWidget {
22 } 22 }
23 23
24 class _SmsManagerPageState extends State<SmsManagerPage> { 24 class _SmsManagerPageState extends State<SmsManagerPage> {
  25 + bool isShow = false;
25 @override 26 @override
26 void initState() { 27 void initState() {
27 // TODO: implement initState 28 // TODO: implement initState
28 super.initState(); 29 super.initState();
  30 +
  31 + isShow = widget.infoData.meals.any((element) => element.discount != '0');
29 Utils.changeStatusColor(color: MyColours.color_199095); 32 Utils.changeStatusColor(color: MyColours.color_199095);
  33 + EventBus().on('refreshSmsNum', (arg) {
  34 + _getSmsInfo(context);
  35 + });
  36 + }
  37 +
  38 + @override
  39 + void dispose() {
  40 + // TODO: implement dispose
  41 + super.dispose();
  42 + EventBus().off('refreshSmsNum');
  43 + }
  44 +
  45 + _getSmsInfo(context) async {
  46 + MyModel myModel = Provider.of<MyModel>(context, listen: false);
  47 + widget.infoData = await myModel.getSmsInfo(context);
  48 + isShow = widget.infoData.meals.any((element) => element.discount != '0');
  49 +
  50 + setState(() {});
  51 + // setState(() {
  52 + // if (smsInfoData != null) {
  53 + // smsInfo = smsInfoData?.lastNum;
  54 + // }
  55 + // });
30 } 56 }
31 57
32 @override 58 @override
@@ -118,32 +144,35 @@ class _SmsManagerPageState extends State<SmsManagerPage> { @@ -118,32 +144,35 @@ class _SmsManagerPageState extends State<SmsManagerPage> {
118 smsInfoData: widget.infoData); 144 smsInfoData: widget.infoData);
119 }, 145 },
120 ), 146 ),
121 - Positioned(  
122 - top: 0,  
123 - right: 0,  
124 - child: Container(  
125 - // padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(16),vertical: ScreenUtil().setWidth(4)),  
126 - padding: EdgeInsets.only(  
127 - left: ScreenUtil().setWidth(6)),  
128 - alignment: Alignment.center,  
129 - width: ScreenUtil().setWidth(34 * 2),  
130 - height: ScreenUtil().setWidth(30),  
131 - decoration: BoxDecoration(  
132 - // color: Colors.red,  
133 - image: DecorationImage(  
134 - image: ExactAssetImage(  
135 - Utils.getImgPath('sms_manager'),  
136 - ),  
137 - fit: BoxFit.cover,  
138 - ),  
139 - ),  
140 - child: Text(  
141 - '特惠',  
142 - style: TextStyle(  
143 - color: MyColours.color_fefefe,  
144 - fontSize: ScreenUtil().setSp(24)),  
145 - )),  
146 - ) 147 + isShow
  148 + ? Positioned(
  149 + top: 0,
  150 + right: 0,
  151 + child: Container(
  152 + // padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(16),vertical: ScreenUtil().setWidth(4)),
  153 + padding: EdgeInsets.only(
  154 + left: ScreenUtil().setWidth(6)),
  155 + alignment: Alignment.center,
  156 + width: ScreenUtil().setWidth(34 * 2),
  157 + height: ScreenUtil().setWidth(30),
  158 + decoration: BoxDecoration(
  159 + // color: Colors.red,
  160 + image: DecorationImage(
  161 + image: ExactAssetImage(
  162 + Utils.getImgPath('sms_manager'),
  163 + ),
  164 + fit: BoxFit.cover,
  165 + ),
  166 + ),
  167 + child: Text(
  168 + '特惠',
  169 + style: TextStyle(
  170 + color: MyColours.color_fefefe,
  171 + fontSize:
  172 + ScreenUtil().setSp(24)),
  173 + )),
  174 + )
  175 + : SizedBox()
147 ]) 176 ])
148 ], 177 ],
149 )), 178 )),
@@ -3,8 +3,10 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -3,8 +3,10 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
3 import 'package:one_key/models/sms_info.dart'; 3 import 'package:one_key/models/sms_info.dart';
4 import 'package:one_key/pages/my/sms_recharge_item_page.dart'; 4 import 'package:one_key/pages/my/sms_recharge_item_page.dart';
5 import 'package:one_key/provider/sms_recharge_provider.dart'; 5 import 'package:one_key/provider/sms_recharge_provider.dart';
  6 +import 'package:one_key/provider/user_model.dart';
6 import 'package:one_key/res/colors.dart'; 7 import 'package:one_key/res/colors.dart';
7 import 'package:one_key/utils/event_bus.dart'; 8 import 'package:one_key/utils/event_bus.dart';
  9 +import 'package:one_key/utils/utils.dart';
8 import 'package:one_key/widgets/h_empty_view.dart'; 10 import 'package:one_key/widgets/h_empty_view.dart';
9 import 'package:one_key/widgets/round_button.dart'; 11 import 'package:one_key/widgets/round_button.dart';
10 import 'package:one_key/widgets/system_app_bar.dart'; 12 import 'package:one_key/widgets/system_app_bar.dart';
@@ -24,6 +26,25 @@ class _SmsRechargePageState extends State<SmsRechargePage> { @@ -24,6 +26,25 @@ class _SmsRechargePageState extends State<SmsRechargePage> {
24 ScrollController controller = ScrollController(); 26 ScrollController controller = ScrollController();
25 Meals mealsSelected; 27 Meals mealsSelected;
26 SmsRechargeModel rechargeModel; 28 SmsRechargeModel rechargeModel;
  29 + @override
  30 + void initState() {
  31 + super.initState();
  32 + fluwx.weChatResponseEventHandler.listen((res) {
  33 + if (res is fluwx.WeChatPaymentResponse) {
  34 + print("pay :${res.isSuccessful}");
  35 + if (res.errCode == 0) {
  36 + // Utils.showToast('购买成功');
  37 + bus.emit('refreshSmsNum');
  38 + EventBus().emit('changeStatusColor');
  39 + Navigator.pop(context);
  40 + } else if (res.errCode == -1) {
  41 + Utils.showToast('支付错误');
  42 + } else if (res.errCode == -2) {
  43 + Utils.showToast('您已取消支付');
  44 + }
  45 + }
  46 + });
  47 + }
27 48
28 @override 49 @override
29 Widget build(BuildContext context) { 50 Widget build(BuildContext context) {
@@ -129,26 +150,45 @@ class _SmsRechargePageState extends State<SmsRechargePage> { @@ -129,26 +150,45 @@ class _SmsRechargePageState extends State<SmsRechargePage> {
129 height: ScreenUtil().setWidth(70), 150 height: ScreenUtil().setWidth(70),
130 textColor: MyColours.color_F0F0F0, 151 textColor: MyColours.color_F0F0F0,
131 onPressed: () async { 152 onPressed: () async {
  153 + if (mealsSelected == null) {
  154 + Utils.showToast('请选择您要购买的短信套餐');
  155 + return;
  156 + }
132 //1.接口请求微信支付所需参数 157 //1.接口请求微信支付所需参数
133 //2.成功后掉起微信支付 158 //2.成功后掉起微信支付
134 - Map<String, String> params; 159 + Map<String, String> params = {
  160 + 'sellerid':
  161 + Provider.of<UserModel>(context, listen: false)
  162 + .user
  163 + .sellerid,
  164 + 'meal_id': mealsSelected.id,
  165 + // 'price': '0.01'
  166 + 'price': mealsSelected.price
  167 + };
135 bool success = await rechargeModel.getWechatPayInfo( 168 bool success = await rechargeModel.getWechatPayInfo(
136 context, params); 169 context, params);
137 if (success) { 170 if (success) {
  171 + print(rechargeModel.sunModel.package.substring(10));
138 //掉起微信支付 172 //掉起微信支付
139 - // fluwx  
140 - // .payWithWeChat(  
141 - // appId: result['appid'].toString(),  
142 - // partnerId: result['partnerid'].toString(),  
143 - // prepayId: result['prepayid'].toString(),  
144 - // packageValue: result['package'].toString(),  
145 - // nonceStr: result['noncestr'].toString(),  
146 - // timeStamp: result['timestamp'],  
147 - // sign: result['sign'].toString(),  
148 - // )  
149 - // .then((data) {  
150 - // print("---》$data");  
151 - // }); 173 + fluwx
  174 + .payWithWeChat(
  175 + // appId: 'wx85aa3cdd0f791e65',
  176 + // appId: 'wx71921f840e8f1c34',
  177 + appId: rechargeModel.sunModel.appId,
  178 + partnerId: '1489405762',
  179 + prepayId: rechargeModel.sunModel.package
  180 + .substring(10),
  181 + packageValue: 'Sign=WXPay',
  182 + nonceStr: rechargeModel.sunModel.nonceStr,
  183 + timeStamp: int.parse(
  184 + rechargeModel.sunModel.timeStamp),
  185 + // sign: rechargeModel.sunModel.paySign,
  186 + sign: 'MD5')
  187 + .then((data) {
  188 + print("---》$data");
  189 + }).catchError((error) {
  190 + print(error.toString());
  191 + });
152 } else { 192 } else {
153 //给用户提示错误 193 //给用户提示错误
154 } 194 }
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:one_key/constant/constant.dart'; 2 import 'package:one_key/constant/constant.dart';
3 import 'package:one_key/constant/error.dart'; 3 import 'package:one_key/constant/error.dart';
  4 +import 'package:one_key/models/wechat_pay_model.dart';
4 import 'package:one_key/net/base_resp.dart'; 5 import 'package:one_key/net/base_resp.dart';
5 import 'package:one_key/net/dio_util.dart'; 6 import 'package:one_key/net/dio_util.dart';
6 import 'package:one_key/net/http_url.dart'; 7 import 'package:one_key/net/http_url.dart';
@@ -10,20 +11,26 @@ import 'package:one_key/utils/utils.dart'; @@ -10,20 +11,26 @@ import 'package:one_key/utils/utils.dart';
10 * 短信充值 11 * 短信充值
11 */ 12 */
12 class SmsRechargeModel extends ChangeNotifier { 13 class SmsRechargeModel extends ChangeNotifier {
  14 + WechatPaySunModel sunModel;
13 //获取微信支付所需参数 15 //获取微信支付所需参数
14 - getWechatPayInfo(BuildContext context, Map<String, String> params, 16 + Future<bool> getWechatPayInfo(
  17 + BuildContext context, Map<String, String> params,
15 {bool showPageLoading = false}) async { 18 {bool showPageLoading = false}) async {
16 - BaseResp<List> baseResp = await DioUtil()  
17 - .request<List>(context, Method.get, HttpUrl.get_custom_remark, 19 + BaseResp<dynamic> baseResp = await DioUtil()
  20 + .request<dynamic>(context, Method.get, HttpUrl.app_pay_sub,
18 data: params, showLoading: showPageLoading ? false : true) 21 data: params, showLoading: showPageLoading ? false : true)
19 .catchError((error) { 22 .catchError((error) {
20 print(error.toString()); 23 print(error.toString());
21 if (error is MyError) {} 24 if (error is MyError) {}
22 }); 25 });
23 if (baseResp != null && baseResp.code == Constant.status_success) { 26 if (baseResp != null && baseResp.code == Constant.status_success) {
  27 + sunModel = WechatPayModel.fromJson(baseResp.responseData).data;
  28 + if (sunModel != null) {
  29 + return true;
  30 + }
24 } else { 31 } else {
25 Utils.showToast(baseResp.msg ?? ""); 32 Utils.showToast(baseResp.msg ?? "");
26 } 33 }
27 - notifyListeners(); 34 + return false;
28 } 35 }
29 } 36 }