Showing
8 changed files
with
372 additions
and
105 deletions
lib/models/consume_qrcode_model.dart
0 → 100644
| 1 | +import 'package:flutter/cupertino.dart'; | ||
| 2 | + | ||
| 3 | +class ConsumeQrcodeModel { | ||
| 4 | + int? ret; | ||
| 5 | + List<ConsumeQrcodeSunModel>? data; | ||
| 6 | + String? msg; | ||
| 7 | + | ||
| 8 | + ConsumeQrcodeModel({this.ret, this.data, this.msg}); | ||
| 9 | + | ||
| 10 | + ConsumeQrcodeModel.fromJson(Map<dynamic, dynamic> json) { | ||
| 11 | + ret = json['ret']; | ||
| 12 | + if (json['data'] != null) { | ||
| 13 | + data = <ConsumeQrcodeSunModel>[]; | ||
| 14 | + json['data'].forEach((v) { | ||
| 15 | + data!.add(new ConsumeQrcodeSunModel.fromJson(v)); | ||
| 16 | + }); | ||
| 17 | + } | ||
| 18 | + msg = json['msg']; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + Map<String, dynamic> toJson() { | ||
| 22 | + final Map<String, dynamic> data = new Map<String, dynamic>(); | ||
| 23 | + data['ret'] = this.ret; | ||
| 24 | + if (this.data != null) { | ||
| 25 | + data['data'] = this.data!.map((v) => v.toJson()).toList(); | ||
| 26 | + } | ||
| 27 | + data['msg'] = this.msg; | ||
| 28 | + return data; | ||
| 29 | + } | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +class ConsumeQrcodeSunModel { | ||
| 33 | + String? id; | ||
| 34 | + String? sellerid; | ||
| 35 | + String? qrcode; | ||
| 36 | + String? amount; | ||
| 37 | + String? cdate; | ||
| 38 | + TextEditingController amountC = TextEditingController(); | ||
| 39 | + | ||
| 40 | + ConsumeQrcodeSunModel( | ||
| 41 | + {this.id, this.sellerid, this.qrcode, this.amount, this.cdate}); | ||
| 42 | + | ||
| 43 | + ConsumeQrcodeSunModel.fromJson(Map<String, dynamic> json) { | ||
| 44 | + id = json['id']; | ||
| 45 | + sellerid = json['sellerid']; | ||
| 46 | + qrcode = json['qrcode']; | ||
| 47 | + amount = json['amount']; | ||
| 48 | + cdate = json['cdate']; | ||
| 49 | + amountC.text = amount ?? ''; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + Map<String, dynamic> toJson() { | ||
| 53 | + final Map<String, dynamic> data = new Map<String, dynamic>(); | ||
| 54 | + data['id'] = this.id; | ||
| 55 | + data['sellerid'] = this.sellerid; | ||
| 56 | + data['qrcode'] = this.qrcode; | ||
| 57 | + data['amount'] = this.amount; | ||
| 58 | + data['cdate'] = this.cdate; | ||
| 59 | + return data; | ||
| 60 | + } | ||
| 61 | +} |
| @@ -646,4 +646,13 @@ class HttpUrl { | @@ -646,4 +646,13 @@ class HttpUrl { | ||
| 646 | 646 | ||
| 647 | static const get_consume_config = | 647 | static const get_consume_config = |
| 648 | "?service=App.Activity.GetConsumeConfig"; // 获取商家消费金规则 | 648 | "?service=App.Activity.GetConsumeConfig"; // 获取商家消费金规则 |
| 649 | + | ||
| 650 | + static const create_consume_qrcode = | ||
| 651 | + "?service=App.Activity.CreateConsumeQrcode"; // 创建消费金二维码 | ||
| 652 | + | ||
| 653 | + static const get_consume_qrcode = | ||
| 654 | + "?service=App.Activity.GetConsumeQrcode"; // 获取商家消费金二维码 | ||
| 655 | + | ||
| 656 | + static const del_consume_qrcode = | ||
| 657 | + "?service=App.Activity.DelConsumeQrcode"; // 获取商家消费金二维码 | ||
| 649 | } | 658 | } |
| @@ -60,7 +60,7 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver { | @@ -60,7 +60,7 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver { | ||
| 60 | late CreateStoreModel createStoreModel; | 60 | late CreateStoreModel createStoreModel; |
| 61 | Fluwx fluwx = Fluwx(); | 61 | Fluwx fluwx = Fluwx(); |
| 62 | 62 | ||
| 63 | - Function(WeChatResponse)? responseListener; | 63 | + Function(WeChatResponse)? responseListener; |
| 64 | 64 | ||
| 65 | @override | 65 | @override |
| 66 | void initState() { | 66 | void initState() { |
| @@ -88,10 +88,9 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver { | @@ -88,10 +88,9 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver { | ||
| 88 | @override | 88 | @override |
| 89 | void dispose() { | 89 | void dispose() { |
| 90 | super.dispose(); | 90 | super.dispose(); |
| 91 | - if(responseListener != null){ | ||
| 92 | - fluwx.removeSubscriber(responseListener!); | 91 | + if (responseListener != null) { |
| 92 | + fluwx.removeSubscriber(responseListener!); | ||
| 93 | } | 93 | } |
| 94 | - | ||
| 95 | 94 | ||
| 96 | WidgetsBinding.instance.removeObserver(this); | 95 | WidgetsBinding.instance.removeObserver(this); |
| 97 | } | 96 | } |
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:flutter/services.dart'; | 2 | import 'package:flutter/services.dart'; |
| 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 4 | +import 'package:one_key/models/consume_qrcode_model.dart'; | ||
| 5 | +import 'package:one_key/provider/finance_provider.dart'; | ||
| 6 | +import 'package:one_key/provider/user_model.dart'; | ||
| 4 | import 'package:one_key/res/colors.dart'; | 7 | import 'package:one_key/res/colors.dart'; |
| 5 | import 'package:one_key/route/navigator_util.dart'; | 8 | import 'package:one_key/route/navigator_util.dart'; |
| 9 | +import 'package:one_key/utils/dialog_util.dart'; | ||
| 6 | import 'package:one_key/utils/screen_util.dart'; | 10 | import 'package:one_key/utils/screen_util.dart'; |
| 11 | +import 'package:one_key/utils/utils.dart'; | ||
| 7 | import 'package:one_key/widgets/h_empty_view.dart'; | 12 | import 'package:one_key/widgets/h_empty_view.dart'; |
| 8 | import 'package:one_key/widgets/round_button.dart'; | 13 | import 'package:one_key/widgets/round_button.dart'; |
| 9 | import 'package:one_key/widgets/system_app_bar.dart'; | 14 | import 'package:one_key/widgets/system_app_bar.dart'; |
| 15 | +import 'package:provider/provider.dart'; | ||
| 10 | 16 | ||
| 11 | /** | 17 | /** |
| 12 | * 发放消费金 | 18 | * 发放消费金 |
| @@ -21,18 +27,46 @@ class GrantPage extends StatefulWidget { | @@ -21,18 +27,46 @@ class GrantPage extends StatefulWidget { | ||
| 21 | 27 | ||
| 22 | class _GrantPageState extends State<GrantPage> { | 28 | class _GrantPageState extends State<GrantPage> { |
| 23 | ScrollController controller = ScrollController(); | 29 | ScrollController controller = ScrollController(); |
| 24 | - List ladderSelectFree = []; | 30 | + List<ConsumeQrcodeSunModel> ladderSelectFree = []; |
| 31 | + FinanceProvider? financeProvider; | ||
| 25 | 32 | ||
| 26 | @override | 33 | @override |
| 27 | void initState() { | 34 | void initState() { |
| 28 | super.initState(); | 35 | super.initState(); |
| 29 | - ladderSelectFree.add('1'); | 36 | + ConsumeQrcodeSunModel model = ConsumeQrcodeSunModel(); |
| 37 | + ladderSelectFree.add(model); | ||
| 30 | 38 | ||
| 31 | WidgetsBinding.instance.addPostFrameCallback((_) { | 39 | WidgetsBinding.instance.addPostFrameCallback((_) { |
| 32 | - // _getConsumeConfig(); | 40 | + _geConsumeQrcode(); |
| 33 | }); | 41 | }); |
| 34 | } | 42 | } |
| 35 | 43 | ||
| 44 | + _geConsumeQrcode() async { | ||
| 45 | + Map<String, String> pramas = { | ||
| 46 | + 'sellerid': | ||
| 47 | + Provider.of<UserModel>(context, listen: false).user!.sellerid!, | ||
| 48 | + }; | ||
| 49 | + await financeProvider!.geConsumeQrcode(context, pramas); | ||
| 50 | + if (financeProvider!.consumeQrcodeData != null) { | ||
| 51 | + //有数据 | ||
| 52 | + ladderSelectFree = []; | ||
| 53 | + ladderSelectFree.addAll(financeProvider!.consumeQrcodeData!); | ||
| 54 | + setState(() {}); | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + _createConsumeQrcode(String amounts) async { | ||
| 59 | + Map<String, String> pramas = { | ||
| 60 | + 'sellerid': | ||
| 61 | + Provider.of<UserModel>(context, listen: false).user!.sellerid!, | ||
| 62 | + 'amount': amounts | ||
| 63 | + }; | ||
| 64 | + bool success = await financeProvider!.createConsumeQrcode(context, pramas); | ||
| 65 | + if (success) { | ||
| 66 | + Navigator.pop(context); | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + | ||
| 36 | ///发放阶梯 | 70 | ///发放阶梯 |
| 37 | Widget _ladderWidget() { | 71 | Widget _ladderWidget() { |
| 38 | return ListView.builder( | 72 | return ListView.builder( |
| @@ -40,7 +74,7 @@ class _GrantPageState extends State<GrantPage> { | @@ -40,7 +74,7 @@ class _GrantPageState extends State<GrantPage> { | ||
| 40 | shrinkWrap: true, | 74 | shrinkWrap: true, |
| 41 | itemCount: ladderSelectFree.length, | 75 | itemCount: ladderSelectFree.length, |
| 42 | itemBuilder: (context, index) { | 76 | itemBuilder: (context, index) { |
| 43 | - dynamic data = ladderSelectFree[index]; | 77 | + ConsumeQrcodeSunModel data = ladderSelectFree[index]; |
| 44 | return Container( | 78 | return Container( |
| 45 | padding: EdgeInsets.only( | 79 | padding: EdgeInsets.only( |
| 46 | left: w(16), | 80 | left: w(16), |
| @@ -67,8 +101,28 @@ class _GrantPageState extends State<GrantPage> { | @@ -67,8 +101,28 @@ class _GrantPageState extends State<GrantPage> { | ||
| 67 | InkWell( | 101 | InkWell( |
| 68 | onTap: () { | 102 | onTap: () { |
| 69 | //删除媒体 | 103 | //删除媒体 |
| 70 | - ladderSelectFree.remove(data); | ||
| 71 | - setState(() {}); | 104 | + |
| 105 | + // 确认是否删除 | ||
| 106 | + | ||
| 107 | + //弹框确认是否删除 | ||
| 108 | + DialogUtil.cupertinoAlertDialog(context, | ||
| 109 | + title: "", | ||
| 110 | + content: "确定要将该发放金删除吗?", | ||
| 111 | + rTitle: "确定", rCallback: () async { | ||
| 112 | + Map<String, String?> pramas = { | ||
| 113 | + 'id': data.id, | ||
| 114 | + }; | ||
| 115 | + | ||
| 116 | + bool success = await financeProvider! | ||
| 117 | + .delConsumeQrcode(context, pramas); | ||
| 118 | + if (success) { | ||
| 119 | + //删除成功,刷新页面 | ||
| 120 | + | ||
| 121 | + setState(() { | ||
| 122 | + ladderSelectFree.removeAt(index); | ||
| 123 | + }); | ||
| 124 | + } | ||
| 125 | + }); | ||
| 72 | }, | 126 | }, |
| 73 | child: Padding( | 127 | child: Padding( |
| 74 | padding: EdgeInsets.only(top: w(8), bottom: w(8)), | 128 | padding: EdgeInsets.only(top: w(8), bottom: w(8)), |
| @@ -82,8 +136,7 @@ class _GrantPageState extends State<GrantPage> { | @@ -82,8 +136,7 @@ class _GrantPageState extends State<GrantPage> { | ||
| 82 | ], | 136 | ], |
| 83 | ), | 137 | ), |
| 84 | ), | 138 | ), |
| 85 | - _ladderPriceWidget(TextEditingController(), FocusNode(), | ||
| 86 | - width: 50), | 139 | + _ladderPriceWidget(data, FocusNode(), width: 50), |
| 87 | ], | 140 | ], |
| 88 | ), | 141 | ), |
| 89 | ); | 142 | ); |
| @@ -91,8 +144,7 @@ class _GrantPageState extends State<GrantPage> { | @@ -91,8 +144,7 @@ class _GrantPageState extends State<GrantPage> { | ||
| 91 | } | 144 | } |
| 92 | 145 | ||
| 93 | //阶梯返还金额widget | 146 | //阶梯返还金额widget |
| 94 | - Widget _ladderPriceWidget( | ||
| 95 | - TextEditingController controllerGive, FocusNode focusNodeGive, | 147 | + Widget _ladderPriceWidget(ConsumeQrcodeSunModel data, FocusNode focusNodeGive, |
| 96 | {num width = 40}) { | 148 | {num width = 40}) { |
| 97 | return Container( | 149 | return Container( |
| 98 | height: w(40), | 150 | height: w(40), |
| @@ -117,7 +169,7 @@ class _GrantPageState extends State<GrantPage> { | @@ -117,7 +169,7 @@ class _GrantPageState extends State<GrantPage> { | ||
| 117 | decoration: BoxDecoration( | 169 | decoration: BoxDecoration( |
| 118 | border: Border.all(color: MyColours.color_999999, width: w(1))), | 170 | border: Border.all(color: MyColours.color_999999, width: w(1))), |
| 119 | child: TextField( | 171 | child: TextField( |
| 120 | - controller: controllerGive, | 172 | + controller: data.amountC, |
| 121 | textAlign: TextAlign.center, | 173 | textAlign: TextAlign.center, |
| 122 | textAlignVertical: TextAlignVertical.center, | 174 | textAlignVertical: TextAlignVertical.center, |
| 123 | maxLines: 1, | 175 | maxLines: 1, |
| @@ -161,21 +213,24 @@ class _GrantPageState extends State<GrantPage> { | @@ -161,21 +213,24 @@ class _GrantPageState extends State<GrantPage> { | ||
| 161 | ), | 213 | ), |
| 162 | HEmptyView(10), | 214 | HEmptyView(10), |
| 163 | Spacer(), | 215 | Spacer(), |
| 164 | - RoundButton( | ||
| 165 | - text: '查看二维码', | ||
| 166 | - width: w(86), | ||
| 167 | - height: w(24), | ||
| 168 | - fontSize: 28, | ||
| 169 | - gradientStart: MyColours.color_438E93, | ||
| 170 | - gradientEnd: MyColours.color_438E93, | ||
| 171 | - textColor: MyColours.color_ffffff, | ||
| 172 | - isBold: false, | ||
| 173 | - radius: 5, | ||
| 174 | - onPressed: () { | ||
| 175 | - //跳转到二维码展示页面 | ||
| 176 | - NavigatorUtil.goGrantWechatPage(context); | ||
| 177 | - }, | ||
| 178 | - ), | 216 | + if (data.qrcode != null) |
| 217 | + RoundButton( | ||
| 218 | + text: '查看二维码', | ||
| 219 | + width: w(86), | ||
| 220 | + height: w(24), | ||
| 221 | + fontSize: 28, | ||
| 222 | + gradientStart: MyColours.color_438E93, | ||
| 223 | + gradientEnd: MyColours.color_438E93, | ||
| 224 | + textColor: MyColours.color_ffffff, | ||
| 225 | + isBold: false, | ||
| 226 | + radius: 5, | ||
| 227 | + onPressed: () { | ||
| 228 | + //跳转到二维码展示页面 | ||
| 229 | + // String qrcode = data.qrcode ?? ''; | ||
| 230 | + // String account = data.amount ?? ''; | ||
| 231 | + NavigatorUtil.goGrantWechatPage(context, data); | ||
| 232 | + }, | ||
| 233 | + ), | ||
| 179 | HEmptyView(32), | 234 | HEmptyView(32), |
| 180 | ], | 235 | ], |
| 181 | ), | 236 | ), |
| @@ -184,28 +239,85 @@ class _GrantPageState extends State<GrantPage> { | @@ -184,28 +239,85 @@ class _GrantPageState extends State<GrantPage> { | ||
| 184 | 239 | ||
| 185 | @override | 240 | @override |
| 186 | Widget build(BuildContext context) { | 241 | Widget build(BuildContext context) { |
| 242 | + financeProvider = Provider.of<FinanceProvider>(context, listen: true); | ||
| 187 | return Scaffold( | 243 | return Scaffold( |
| 188 | backgroundColor: MyColours.color_ffffff, | 244 | backgroundColor: MyColours.color_ffffff, |
| 189 | appBar: SystemAppBar('发放消费金'), | 245 | appBar: SystemAppBar('发放消费金'), |
| 190 | body: Column( | 246 | body: Column( |
| 191 | children: [ | 247 | children: [ |
| 192 | - _ladderWidget(), | ||
| 193 | - InkWell( | ||
| 194 | - onTap: () { | ||
| 195 | - // LadderData data = LadderData(); | ||
| 196 | - ladderSelectFree.add('1'); | ||
| 197 | - setState(() {}); | 248 | + Expanded( |
| 249 | + child: SingleChildScrollView( | ||
| 250 | + child: Column( | ||
| 251 | + children: [ | ||
| 252 | + _ladderWidget(), | ||
| 253 | + InkWell( | ||
| 254 | + onTap: () { | ||
| 255 | + ConsumeQrcodeSunModel model = ConsumeQrcodeSunModel(); | ||
| 256 | + ladderSelectFree.add(model); | ||
| 257 | + setState(() {}); | ||
| 258 | + }, | ||
| 259 | + child: Container( | ||
| 260 | + height: w(30), | ||
| 261 | + margin: EdgeInsets.only(left: w(60), right: w(16)), | ||
| 262 | + alignment: Alignment.centerLeft, | ||
| 263 | + child: Text( | ||
| 264 | + '+增加阶梯', | ||
| 265 | + style: TextStyle( | ||
| 266 | + color: MyColours.color_438E93, fontSize: font(12)), | ||
| 267 | + ), | ||
| 268 | + )), | ||
| 269 | + ], | ||
| 270 | + ), | ||
| 271 | + )), | ||
| 272 | + Container( | ||
| 273 | + padding: EdgeInsets.only( | ||
| 274 | + top: w(13), left: w(45), right: w(45), bottom: w(26)), | ||
| 275 | + child: RoundButton( | ||
| 276 | + text: '保存', | ||
| 277 | + height: w(43), | ||
| 278 | + radius: r(5), | ||
| 279 | + gradientStart: MyColours.color_438E93, | ||
| 280 | + gradientEnd: MyColours.color_438E93, | ||
| 281 | + borderColor: MyColours.color_438E93, | ||
| 282 | + textColor: MyColours.color_ffffff, | ||
| 283 | + isBold: true, | ||
| 284 | + fontSize: 32, | ||
| 285 | + onPressed: () { | ||
| 286 | + // 调用接口 | ||
| 287 | + // 组装amount数据 | ||
| 288 | + | ||
| 289 | + if (ladderSelectFree.length == 0) { | ||
| 290 | + //请点击增加阶梯按钮设置发放消费金金额 | ||
| 291 | + Utils.showToast('请点击【增加阶梯】按钮设置发放消费金金额'); | ||
| 292 | + return; | ||
| 293 | + } | ||
| 294 | + | ||
| 295 | + //判断阶梯里面的数据 实际支付金额是否输入 | ||
| 296 | + | ||
| 297 | + bool canPrice = ladderSelectFree | ||
| 298 | + .any((e) => e.amountC.text.trim().length == 0); | ||
| 299 | + if (canPrice) { | ||
| 300 | + int index = ladderSelectFree | ||
| 301 | + .indexWhere((e) => e.amountC.text.trim().length == 0); | ||
| 302 | + | ||
| 303 | + Utils.showToast('请输入发放(${index + 1})的发放消费金金额!'); | ||
| 304 | + return; | ||
| 305 | + } | ||
| 306 | + | ||
| 307 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 308 | + String amounts = ''; | ||
| 309 | + | ||
| 310 | + ladderSelectFree.forEach((e) { | ||
| 311 | + amounts += (e.amountC.text + ','); | ||
| 312 | + }); | ||
| 313 | + if (amounts.endsWith(',')) { | ||
| 314 | + amounts = amounts.substring(0, amounts.length - 1); | ||
| 315 | + } | ||
| 316 | + | ||
| 317 | + _createConsumeQrcode(amounts); | ||
| 198 | }, | 318 | }, |
| 199 | - child: Container( | ||
| 200 | - height: w(30), | ||
| 201 | - margin: EdgeInsets.only(left: w(60), right: w(16)), | ||
| 202 | - alignment: Alignment.centerLeft, | ||
| 203 | - child: Text( | ||
| 204 | - '+增加阶梯', | ||
| 205 | - style: TextStyle( | ||
| 206 | - color: MyColours.color_438E93, fontSize: font(12)), | ||
| 207 | - ), | ||
| 208 | - )), | 319 | + ), |
| 320 | + ) | ||
| 209 | ], | 321 | ], |
| 210 | ), | 322 | ), |
| 211 | ); | 323 | ); |
| @@ -8,6 +8,7 @@ import 'package:flutter/material.dart'; | @@ -8,6 +8,7 @@ import 'package:flutter/material.dart'; | ||
| 8 | import 'package:flutter/rendering.dart'; | 8 | import 'package:flutter/rendering.dart'; |
| 9 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 9 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 10 | import 'package:image_gallery_saver/image_gallery_saver.dart'; | 10 | import 'package:image_gallery_saver/image_gallery_saver.dart'; |
| 11 | +import 'package:one_key/models/consume_qrcode_model.dart'; | ||
| 11 | import 'package:one_key/provider/user_model.dart'; | 12 | import 'package:one_key/provider/user_model.dart'; |
| 12 | import 'package:one_key/widgets/round_button.dart'; | 13 | import 'package:one_key/widgets/round_button.dart'; |
| 13 | import 'package:one_key/widgets/system_app_bar.dart'; | 14 | import 'package:one_key/widgets/system_app_bar.dart'; |
| @@ -29,7 +30,8 @@ import 'dart:ui' as ui; | @@ -29,7 +30,8 @@ import 'dart:ui' as ui; | ||
| 29 | */ | 30 | */ |
| 30 | 31 | ||
| 31 | class GrantWechatPage extends StatefulWidget { | 32 | class GrantWechatPage extends StatefulWidget { |
| 32 | - const GrantWechatPage({super.key}); | 33 | + final ConsumeQrcodeSunModel data; |
| 34 | + const GrantWechatPage({super.key, required this.data}); | ||
| 33 | 35 | ||
| 34 | @override | 36 | @override |
| 35 | State<GrantWechatPage> createState() => _GrantWechatPageState(); | 37 | State<GrantWechatPage> createState() => _GrantWechatPageState(); |
| @@ -45,13 +47,13 @@ class _GrantWechatPageState extends State<GrantWechatPage> { | @@ -45,13 +47,13 @@ class _GrantWechatPageState extends State<GrantWechatPage> { | ||
| 45 | super.initState(); | 47 | super.initState(); |
| 46 | 48 | ||
| 47 | WidgetsBinding.instance.addPostFrameCallback((_) async { | 49 | WidgetsBinding.instance.addPostFrameCallback((_) async { |
| 48 | - _createPayQrcode(); | 50 | + // _createPayQrcode(); |
| 49 | }); | 51 | }); |
| 50 | } | 52 | } |
| 51 | 53 | ||
| 52 | - _createPayQrcode() { | ||
| 53 | - financeProvider!.createPayQrcode(context); | ||
| 54 | - } | 54 | + // _createPayQrcode() { |
| 55 | + // financeProvider!.createPayQrcode(context); | ||
| 56 | + // } | ||
| 55 | 57 | ||
| 56 | /// 截图 | 58 | /// 截图 |
| 57 | Future<Uint8List?> _capturePng( | 59 | Future<Uint8List?> _capturePng( |
| @@ -110,57 +112,35 @@ class _GrantWechatPageState extends State<GrantWechatPage> { | @@ -110,57 +112,35 @@ class _GrantWechatPageState extends State<GrantWechatPage> { | ||
| 110 | fontWeight: FontWeight.bold), | 112 | fontWeight: FontWeight.bold), |
| 111 | ), | 113 | ), |
| 112 | VEmptyView(20), | 114 | VEmptyView(20), |
| 113 | - Consumer<FinanceProvider>( | ||
| 114 | - builder: (context, model, _) { | ||
| 115 | - if (model.pageState != PageState.Success) { | ||
| 116 | - return Container( | ||
| 117 | - height: w(210), | ||
| 118 | - child: Center( | ||
| 119 | - child: SizedBox( | ||
| 120 | - width: | ||
| 121 | - ScreenUtil().setWidth(40), | ||
| 122 | - height: | ||
| 123 | - ScreenUtil().setWidth(40), | ||
| 124 | - child: | ||
| 125 | - CupertinoActivityIndicator( | ||
| 126 | - color: MyColours.color_ffffff, | ||
| 127 | - ))), | ||
| 128 | - ); | ||
| 129 | - } else { | ||
| 130 | - return Container( | ||
| 131 | - padding: EdgeInsets.symmetric( | ||
| 132 | - horizontal: w(21), | ||
| 133 | - vertical: w(16)), | ||
| 134 | - color: MyColours.color_ffffff, | ||
| 135 | - child: Column( | ||
| 136 | - children: [ | ||
| 137 | - CachedNetworkImage( | ||
| 138 | - imageUrl: financeProvider! | ||
| 139 | - .paymentCodeUrl), | ||
| 140 | - // VEmptyView(28), | ||
| 141 | - Text( | ||
| 142 | - '${Provider.of<UserModel>(context).user!.sellername}', | ||
| 143 | - maxLines: 3, | ||
| 144 | - overflow: TextOverflow.ellipsis, | ||
| 145 | - style: TextStyle( | ||
| 146 | - color: | ||
| 147 | - MyColours.color_000000, | ||
| 148 | - fontSize: font(14)), | ||
| 149 | - ), | ||
| 150 | - VEmptyView(28), | ||
| 151 | - Text( | ||
| 152 | - '消费金:¥50.00', | ||
| 153 | - maxLines: 3, | ||
| 154 | - overflow: TextOverflow.ellipsis, | ||
| 155 | - style: TextStyle( | ||
| 156 | - color: | ||
| 157 | - MyColours.color_000000, | ||
| 158 | - fontSize: font(14)), | ||
| 159 | - ), | ||
| 160 | - ], | ||
| 161 | - )); | ||
| 162 | - } | ||
| 163 | - }) | 115 | + Container( |
| 116 | + padding: EdgeInsets.symmetric( | ||
| 117 | + horizontal: w(21), vertical: w(16)), | ||
| 118 | + color: MyColours.color_ffffff, | ||
| 119 | + child: Column( | ||
| 120 | + children: [ | ||
| 121 | + CachedNetworkImage( | ||
| 122 | + imageUrl: | ||
| 123 | + widget.data.qrcode ?? ''), | ||
| 124 | + // VEmptyView(28), | ||
| 125 | + Text( | ||
| 126 | + '${Provider.of<UserModel>(context).user!.sellername}', | ||
| 127 | + maxLines: 3, | ||
| 128 | + overflow: TextOverflow.ellipsis, | ||
| 129 | + style: TextStyle( | ||
| 130 | + color: MyColours.color_000000, | ||
| 131 | + fontSize: font(14)), | ||
| 132 | + ), | ||
| 133 | + VEmptyView(28), | ||
| 134 | + Text( | ||
| 135 | + '消费金:¥${widget.data.amount}', | ||
| 136 | + maxLines: 3, | ||
| 137 | + overflow: TextOverflow.ellipsis, | ||
| 138 | + style: TextStyle( | ||
| 139 | + color: MyColours.color_000000, | ||
| 140 | + fontSize: font(14)), | ||
| 141 | + ), | ||
| 142 | + ], | ||
| 143 | + )) | ||
| 164 | ], | 144 | ], |
| 165 | ), | 145 | ), |
| 166 | ), | 146 | ), |
| @@ -3,6 +3,7 @@ import 'dart:io'; | @@ -3,6 +3,7 @@ import 'dart:io'; | ||
| 3 | 3 | ||
| 4 | import 'package:dio/dio.dart'; | 4 | import 'package:dio/dio.dart'; |
| 5 | import 'package:flutter/material.dart'; | 5 | import 'package:flutter/material.dart'; |
| 6 | +import 'package:one_key/models/consume_qrcode_model.dart'; | ||
| 6 | import 'package:one_key/models/deposit_record_detail_model.dart'; | 7 | import 'package:one_key/models/deposit_record_detail_model.dart'; |
| 7 | import 'package:one_key/models/deposit_record_model.dart'; | 8 | import 'package:one_key/models/deposit_record_model.dart'; |
| 8 | import 'package:one_key/models/ladder_coupons_model.dart'; | 9 | import 'package:one_key/models/ladder_coupons_model.dart'; |
| @@ -48,6 +49,8 @@ class FinanceProvider extends ChangeNotifier { | @@ -48,6 +49,8 @@ class FinanceProvider extends ChangeNotifier { | ||
| 48 | 49 | ||
| 49 | ReturnMoneySunModel? returnMoneySunModel; | 50 | ReturnMoneySunModel? returnMoneySunModel; |
| 50 | 51 | ||
| 52 | + List<ConsumeQrcodeSunModel>? consumeQrcodeData; | ||
| 53 | + | ||
| 51 | ///客户经理获取所创建活动列表 | 54 | ///客户经理获取所创建活动列表 |
| 52 | Future createPayQrcode(BuildContext context, {isShowLoading = true}) async { | 55 | Future createPayQrcode(BuildContext context, {isShowLoading = true}) async { |
| 53 | try { | 56 | try { |
| @@ -230,6 +233,41 @@ class FinanceProvider extends ChangeNotifier { | @@ -230,6 +233,41 @@ class FinanceProvider extends ChangeNotifier { | ||
| 230 | } | 233 | } |
| 231 | } | 234 | } |
| 232 | 235 | ||
| 236 | + // 创建消费金二维码 | ||
| 237 | + Future<bool> createConsumeQrcode( | ||
| 238 | + BuildContext context, Map<String, String?> params, | ||
| 239 | + {bool showLoading = true, bool needToast = true}) async { | ||
| 240 | + try { | ||
| 241 | + BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>( | ||
| 242 | + context, Method.post, HttpUrl.create_consume_qrcode, | ||
| 243 | + data: params, showLoading: showLoading); | ||
| 244 | + if (baseResp.code == Constant.status_success) { | ||
| 245 | + if (baseResp.data is String) { | ||
| 246 | + if (needToast) { | ||
| 247 | + Utils.showToast('创建成功'); | ||
| 248 | + } | ||
| 249 | + return true; | ||
| 250 | + } else { | ||
| 251 | + if (needToast) { | ||
| 252 | + Utils.showToast('创建失败,请重试'); | ||
| 253 | + } | ||
| 254 | + } | ||
| 255 | + } else { | ||
| 256 | + if (needToast) { | ||
| 257 | + Utils.showToast(baseResp.msg ?? '创建失败,请重试'); | ||
| 258 | + } | ||
| 259 | + } | ||
| 260 | + return false; | ||
| 261 | + } catch (error) { | ||
| 262 | + print(error.toString()); | ||
| 263 | + if (needToast) { | ||
| 264 | + Utils.showToast('设置失败,请重试'); | ||
| 265 | + } | ||
| 266 | + | ||
| 267 | + return false; | ||
| 268 | + } | ||
| 269 | + } | ||
| 270 | + | ||
| 233 | // 设置商家消费金规则 | 271 | // 设置商家消费金规则 |
| 234 | Future<bool> setConsumeConfig( | 272 | Future<bool> setConsumeConfig( |
| 235 | BuildContext context, Map<String, String?> params, | 273 | BuildContext context, Map<String, String?> params, |
| @@ -267,6 +305,43 @@ class FinanceProvider extends ChangeNotifier { | @@ -267,6 +305,43 @@ class FinanceProvider extends ChangeNotifier { | ||
| 267 | } | 305 | } |
| 268 | } | 306 | } |
| 269 | 307 | ||
| 308 | + // 删除商家消费金二维码 | ||
| 309 | + Future<bool> delConsumeQrcode( | ||
| 310 | + BuildContext context, Map<String, String?> params, | ||
| 311 | + {bool showLoading = true, bool needToast = true}) async { | ||
| 312 | + try { | ||
| 313 | + BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>( | ||
| 314 | + context, Method.post, HttpUrl.del_consume_qrcode, | ||
| 315 | + data: params, showLoading: showLoading); | ||
| 316 | + if (baseResp.code == Constant.status_success) { | ||
| 317 | + if (baseResp.data == 0 || | ||
| 318 | + baseResp.data == 1 || | ||
| 319 | + (baseResp.data is Map)) { | ||
| 320 | + if (needToast) { | ||
| 321 | + Utils.showToast('删除成功'); | ||
| 322 | + } | ||
| 323 | + return true; | ||
| 324 | + } else { | ||
| 325 | + if (needToast) { | ||
| 326 | + Utils.showToast('删除失败,请重试'); | ||
| 327 | + } | ||
| 328 | + } | ||
| 329 | + } else { | ||
| 330 | + if (needToast) { | ||
| 331 | + Utils.showToast(baseResp.msg ?? '删除失败,请重试'); | ||
| 332 | + } | ||
| 333 | + } | ||
| 334 | + return false; | ||
| 335 | + } catch (error) { | ||
| 336 | + print(error.toString()); | ||
| 337 | + if (needToast) { | ||
| 338 | + Utils.showToast('删除失败,请重试'); | ||
| 339 | + } | ||
| 340 | + | ||
| 341 | + return false; | ||
| 342 | + } | ||
| 343 | + } | ||
| 344 | + | ||
| 270 | ///获取商家券赠送规则配置 还没做--------待使用---------- | 345 | ///获取商家券赠送规则配置 还没做--------待使用---------- |
| 271 | Future getActivityConfig(BuildContext context, Map<String, String?> params, | 346 | Future getActivityConfig(BuildContext context, Map<String, String?> params, |
| 272 | {isShowLoading = true}) async { | 347 | {isShowLoading = true}) async { |
| @@ -617,6 +692,31 @@ class FinanceProvider extends ChangeNotifier { | @@ -617,6 +692,31 @@ class FinanceProvider extends ChangeNotifier { | ||
| 617 | } | 692 | } |
| 618 | } | 693 | } |
| 619 | 694 | ||
| 695 | + /// 获取商家消费金二维码 | ||
| 696 | + Future geConsumeQrcode(BuildContext context, Map<String, String?> params, | ||
| 697 | + {isShowLoading = true}) async { | ||
| 698 | + try { | ||
| 699 | + BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>( | ||
| 700 | + context, Method.post, HttpUrl.get_consume_qrcode, | ||
| 701 | + data: params, showLoading: false); | ||
| 702 | + if (baseResp.code == Constant.status_success) { | ||
| 703 | + consumeQrcodeData = | ||
| 704 | + ConsumeQrcodeModel.fromJson(baseResp.responseData!).data; | ||
| 705 | + } else { | ||
| 706 | + if (baseResp != null) { | ||
| 707 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 708 | + } | ||
| 709 | + } | ||
| 710 | + | ||
| 711 | + notifyListeners(); | ||
| 712 | + } catch (error) { | ||
| 713 | + print(error.toString()); | ||
| 714 | + | ||
| 715 | + if (error is MyError) {} | ||
| 716 | + notifyListeners(); | ||
| 717 | + } | ||
| 718 | + } | ||
| 719 | + | ||
| 620 | /// 通过支付订单号或退款订单号获取会员充值订单 | 720 | /// 通过支付订单号或退款订单号获取会员充值订单 |
| 621 | Future getOrderRechargeOrderInfo( | 721 | Future getOrderRechargeOrderInfo( |
| 622 | BuildContext context, Map<String, String?> params, | 722 | BuildContext context, Map<String, String?> params, |
| @@ -4,6 +4,7 @@ import 'package:fluro/fluro.dart'; | @@ -4,6 +4,7 @@ import 'package:fluro/fluro.dart'; | ||
| 4 | import 'package:flutter/material.dart'; | 4 | import 'package:flutter/material.dart'; |
| 5 | import 'package:one_key/constant/state.dart'; | 5 | import 'package:one_key/constant/state.dart'; |
| 6 | import 'package:one_key/models/check_seller_acc_model.dart'; | 6 | import 'package:one_key/models/check_seller_acc_model.dart'; |
| 7 | +import 'package:one_key/models/consume_qrcode_model.dart'; | ||
| 7 | import 'package:one_key/models/cookbook_model.dart'; | 8 | import 'package:one_key/models/cookbook_model.dart'; |
| 8 | import 'package:one_key/models/coupon_model.dart'; | 9 | import 'package:one_key/models/coupon_model.dart'; |
| 9 | import 'package:one_key/models/customer_by_seller_model.dart'; | 10 | import 'package:one_key/models/customer_by_seller_model.dart'; |
| @@ -2452,10 +2453,12 @@ class NavigatorUtil { | @@ -2452,10 +2453,12 @@ class NavigatorUtil { | ||
| 2452 | 2453 | ||
| 2453 | ///发放消费金 | 2454 | ///发放消费金 |
| 2454 | static Future<dynamic> goGrantWechatPage( | 2455 | static Future<dynamic> goGrantWechatPage( |
| 2455 | - BuildContext context, { | 2456 | + BuildContext context, |
| 2457 | + ConsumeQrcodeSunModel data, { | ||
| 2456 | replace = false, | 2458 | replace = false, |
| 2457 | }) { | 2459 | }) { |
| 2458 | - return _navigateTo(context, "${Routes.grant_wechat_page}", | 2460 | + return _navigateTo(context, |
| 2461 | + "${Routes.grant_wechat_page}?data=${FluroConvertUtils.object2string(data)}", | ||
| 2459 | replace: replace); | 2462 | replace: replace); |
| 2460 | } | 2463 | } |
| 2461 | 2464 |
| @@ -4,6 +4,7 @@ import 'package:fluro/fluro.dart'; | @@ -4,6 +4,7 @@ import 'package:fluro/fluro.dart'; | ||
| 4 | import 'package:flutter/material.dart'; | 4 | import 'package:flutter/material.dart'; |
| 5 | import 'package:one_key/constant/state.dart'; | 5 | import 'package:one_key/constant/state.dart'; |
| 6 | import 'package:one_key/models/check_seller_acc_model.dart'; | 6 | import 'package:one_key/models/check_seller_acc_model.dart'; |
| 7 | +import 'package:one_key/models/consume_qrcode_model.dart'; | ||
| 7 | import 'package:one_key/models/cookbook_model.dart'; | 8 | import 'package:one_key/models/cookbook_model.dart'; |
| 8 | import 'package:one_key/models/coupon_model.dart'; | 9 | import 'package:one_key/models/coupon_model.dart'; |
| 9 | import 'package:one_key/models/customer_by_seller_model.dart'; | 10 | import 'package:one_key/models/customer_by_seller_model.dart'; |
| @@ -4327,8 +4328,10 @@ var grantPageHandle = new Handler( | @@ -4327,8 +4328,10 @@ var grantPageHandle = new Handler( | ||
| 4327 | ///扫码领消费金 | 4328 | ///扫码领消费金 |
| 4328 | var grantWechatPageHandle = new Handler( | 4329 | var grantWechatPageHandle = new Handler( |
| 4329 | handlerFunc: (BuildContext? context, Map<String, List<Object>> params) { | 4330 | handlerFunc: (BuildContext? context, Map<String, List<Object>> params) { |
| 4331 | + ConsumeQrcodeSunModel data = ConsumeQrcodeSunModel.fromJson(json.decode( | ||
| 4332 | + FluroConvertUtils.fluroCnParamsDecode(params["data"]!.first as String))); | ||
| 4330 | return ChangeNotifierProvider<FinanceProvider>( | 4333 | return ChangeNotifierProvider<FinanceProvider>( |
| 4331 | - create: (_) => FinanceProvider(), child: GrantWechatPage()); | 4334 | + create: (_) => FinanceProvider(), child: GrantWechatPage(data: data)); |
| 4332 | }); | 4335 | }); |
| 4333 | 4336 | ||
| 4334 | // /选择优惠券 | 4337 | // /选择优惠券 |
-
Please register or login to post a comment