Showing
5 changed files
with
211 additions
and
2 deletions
lib/models/wx_send_sms_model.dart
0 → 100644
| 1 | +import 'package:json_annotation/json_annotation.dart'; | ||
| 2 | + | ||
| 3 | +part 'wx_send_sms_model.g.dart'; | ||
| 4 | + | ||
| 5 | +@JsonSerializable() | ||
| 6 | +class WxSendSmsModel extends Object { | ||
| 7 | + @JsonKey(name: 'ret') | ||
| 8 | + int ret; | ||
| 9 | + | ||
| 10 | + @JsonKey(name: 'data') | ||
| 11 | + WxSendSmsSunModel data; | ||
| 12 | + | ||
| 13 | + @JsonKey(name: 'msg') | ||
| 14 | + String msg; | ||
| 15 | + | ||
| 16 | + WxSendSmsModel( | ||
| 17 | + this.ret, | ||
| 18 | + this.data, | ||
| 19 | + this.msg, | ||
| 20 | + ); | ||
| 21 | + | ||
| 22 | + factory WxSendSmsModel.fromJson(Map<String, dynamic> srcJson) => | ||
| 23 | + _$WxSendSmsModelFromJson(srcJson); | ||
| 24 | + | ||
| 25 | + Map<String, dynamic> toJson() => _$WxSendSmsModelToJson(this); | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +@JsonSerializable() | ||
| 29 | +class WxSendSmsSunModel extends Object { | ||
| 30 | + @JsonKey(name: 'errcode') | ||
| 31 | + int errcode; | ||
| 32 | + | ||
| 33 | + @JsonKey(name: 'send_status_list') | ||
| 34 | + List<SendStatusList> sendStatusList; | ||
| 35 | + | ||
| 36 | + @JsonKey(name: 'query_id') | ||
| 37 | + String queryId; | ||
| 38 | + | ||
| 39 | + WxSendSmsSunModel( | ||
| 40 | + this.errcode, | ||
| 41 | + this.sendStatusList, | ||
| 42 | + this.queryId, | ||
| 43 | + ); | ||
| 44 | + | ||
| 45 | + factory WxSendSmsSunModel.fromJson(Map<String, dynamic> srcJson) => | ||
| 46 | + _$WxSendSmsSunModelFromJson(srcJson); | ||
| 47 | + | ||
| 48 | + Map<String, dynamic> toJson() => _$WxSendSmsSunModelToJson(this); | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +@JsonSerializable() | ||
| 52 | +class SendStatusList extends Object { | ||
| 53 | + @JsonKey(name: 'serial_no') | ||
| 54 | + String serialNo; | ||
| 55 | + | ||
| 56 | + @JsonKey(name: 'phone_number') | ||
| 57 | + String phoneNumber; | ||
| 58 | + | ||
| 59 | + @JsonKey(name: 'code') | ||
| 60 | + String code; | ||
| 61 | + | ||
| 62 | + @JsonKey(name: 'message') | ||
| 63 | + String message; | ||
| 64 | + | ||
| 65 | + @JsonKey(name: 'iso_code') | ||
| 66 | + String isoCode; | ||
| 67 | + | ||
| 68 | + SendStatusList( | ||
| 69 | + this.serialNo, | ||
| 70 | + this.phoneNumber, | ||
| 71 | + this.code, | ||
| 72 | + this.message, | ||
| 73 | + this.isoCode, | ||
| 74 | + ); | ||
| 75 | + | ||
| 76 | + factory SendStatusList.fromJson(Map<String, dynamic> srcJson) => | ||
| 77 | + _$SendStatusListFromJson(srcJson); | ||
| 78 | + | ||
| 79 | + Map<String, dynamic> toJson() => _$SendStatusListToJson(this); | ||
| 80 | +} |
lib/models/wx_send_sms_model.g.dart
0 → 100644
| 1 | +// GENERATED CODE - DO NOT MODIFY BY HAND | ||
| 2 | + | ||
| 3 | +part of 'wx_send_sms_model.dart'; | ||
| 4 | + | ||
| 5 | +// ************************************************************************** | ||
| 6 | +// JsonSerializableGenerator | ||
| 7 | +// ************************************************************************** | ||
| 8 | + | ||
| 9 | +WxSendSmsModel _$WxSendSmsModelFromJson(Map<String, dynamic> json) { | ||
| 10 | + return WxSendSmsModel( | ||
| 11 | + json['ret'] as int, | ||
| 12 | + json['data'] == null | ||
| 13 | + ? null | ||
| 14 | + : WxSendSmsSunModel.fromJson(json['data'] as Map<String, dynamic>), | ||
| 15 | + json['msg'] as String); | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +Map<String, dynamic> _$WxSendSmsModelToJson(WxSendSmsModel instance) => | ||
| 19 | + <String, dynamic>{ | ||
| 20 | + 'ret': instance.ret, | ||
| 21 | + 'data': instance.data, | ||
| 22 | + 'msg': instance.msg | ||
| 23 | + }; | ||
| 24 | + | ||
| 25 | +WxSendSmsSunModel _$WxSendSmsSunModelFromJson(Map<String, dynamic> json) { | ||
| 26 | + return WxSendSmsSunModel( | ||
| 27 | + json['errcode'] as int, | ||
| 28 | + (json['send_status_list'] as List) | ||
| 29 | + ?.map((e) => e == null | ||
| 30 | + ? null | ||
| 31 | + : SendStatusList.fromJson(e as Map<String, dynamic>)) | ||
| 32 | + ?.toList(), | ||
| 33 | + json['query_id'] as String); | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +Map<String, dynamic> _$WxSendSmsSunModelToJson(WxSendSmsSunModel instance) => | ||
| 37 | + <String, dynamic>{ | ||
| 38 | + 'errcode': instance.errcode, | ||
| 39 | + 'send_status_list': instance.sendStatusList, | ||
| 40 | + 'query_id': instance.queryId | ||
| 41 | + }; | ||
| 42 | + | ||
| 43 | +SendStatusList _$SendStatusListFromJson(Map<String, dynamic> json) { | ||
| 44 | + return SendStatusList( | ||
| 45 | + json['serial_no'] as String, | ||
| 46 | + json['phone_number'] as String, | ||
| 47 | + json['code'] as String, | ||
| 48 | + json['message'] as String, | ||
| 49 | + json['iso_code'] as String); | ||
| 50 | +} | ||
| 51 | + | ||
| 52 | +Map<String, dynamic> _$SendStatusListToJson(SendStatusList instance) => | ||
| 53 | + <String, dynamic>{ | ||
| 54 | + 'serial_no': instance.serialNo, | ||
| 55 | + 'phone_number': instance.phoneNumber, | ||
| 56 | + 'code': instance.code, | ||
| 57 | + 'message': instance.message, | ||
| 58 | + 'iso_code': instance.isoCode | ||
| 59 | + }; |
| @@ -87,5 +87,7 @@ class HttpUrl { | @@ -87,5 +87,7 @@ class HttpUrl { | ||
| 87 | "?service=App.Activity.GetCustomerActivityBaseinfo"; //客户经理获取基本信息 | 87 | "?service=App.Activity.GetCustomerActivityBaseinfo"; //客户经理获取基本信息 |
| 88 | static const String get_seller_photo_by_id = | 88 | static const String get_seller_photo_by_id = |
| 89 | "?service=App.Photo.getSellerPhotoById"; //查看商家图片 | 89 | "?service=App.Photo.getSellerPhotoById"; //查看商家图片 |
| 90 | + static const String app_sendsms_wxSendSms = | ||
| 91 | + "?service=App.SendSMS.WxSendSms"; //预订安排发短信 | ||
| 90 | 92 | ||
| 91 | } | 93 | } |
| @@ -61,6 +61,7 @@ class InvicationPageState extends State<InvicationPage> { | @@ -61,6 +61,7 @@ class InvicationPageState extends State<InvicationPage> { | ||
| 61 | super.initState(); | 61 | super.initState(); |
| 62 | 62 | ||
| 63 | WidgetsBinding.instance.addPostFrameCallback((_) { | 63 | WidgetsBinding.instance.addPostFrameCallback((_) { |
| 64 | + couponProvider.sendSMS = false; | ||
| 64 | _getActivityByRid(); | 65 | _getActivityByRid(); |
| 65 | _getCustomerActivityBaseinfo(); | 66 | _getCustomerActivityBaseinfo(); |
| 66 | _getSellerPhotoById(); | 67 | _getSellerPhotoById(); |
| @@ -744,12 +745,32 @@ class InvicationPageState extends State<InvicationPage> { | @@ -744,12 +745,32 @@ class InvicationPageState extends State<InvicationPage> { | ||
| 744 | child: Row( | 745 | child: Row( |
| 745 | children: <Widget>[ | 746 | children: <Widget>[ |
| 746 | GestureDetector( | 747 | GestureDetector( |
| 747 | - onTap: () { | 748 | + onTap: () async { |
| 748 | if (widget.phone.isEmpty) { | 749 | if (widget.phone.isEmpty) { |
| 749 | Utils.showToast("没有预订人电话信息"); | 750 | Utils.showToast("没有预订人电话信息"); |
| 750 | return; | 751 | return; |
| 751 | } | 752 | } |
| 752 | - NavigatorUtil.goSmsPage(context, widget.rid); | 753 | + if (!couponProvider.sendSMS) { |
| 754 | + Map<String, String> params = { | ||
| 755 | + "phone": widget.phone, | ||
| 756 | + "Strtext": user.sellername + | ||
| 757 | + _baseIndoProvider | ||
| 758 | + .baseInfoSunModel.position + | ||
| 759 | + _baseIndoProvider.baseInfoSunModel.name | ||
| 760 | + }; | ||
| 761 | + bool success = await couponProvider | ||
| 762 | + .sendSMSWxSendSms(context, params); | ||
| 763 | + print(success); | ||
| 764 | + if (success) { | ||
| 765 | + Utils.showToast('短信已经发送成功!'); | ||
| 766 | + } else { | ||
| 767 | + Utils.showToast('发送次数太频繁!'); | ||
| 768 | + } | ||
| 769 | + } else { | ||
| 770 | + Utils.showToast('短信已经发送成功!'); | ||
| 771 | + } | ||
| 772 | + | ||
| 773 | + // NavigatorUtil.goSmsPage(context, widget.rid); | ||
| 753 | }, | 774 | }, |
| 754 | child: Container( | 775 | child: Container( |
| 755 | width: ScreenUtil().setWidth(135 * 2), | 776 | width: ScreenUtil().setWidth(135 * 2), |
| @@ -3,6 +3,7 @@ import 'package:one_key/constant/constant.dart'; | @@ -3,6 +3,7 @@ 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/constant/state.dart'; | 4 | import 'package:one_key/constant/state.dart'; |
| 5 | import 'package:one_key/models/coupon_model.dart'; | 5 | import 'package:one_key/models/coupon_model.dart'; |
| 6 | +import 'package:one_key/models/wx_send_sms_model.dart'; | ||
| 6 | import 'package:one_key/net/dio_util.dart'; | 7 | import 'package:one_key/net/dio_util.dart'; |
| 7 | import 'package:one_key/net/http_url.dart'; | 8 | import 'package:one_key/net/http_url.dart'; |
| 8 | import 'package:one_key/net/base_resp.dart'; | 9 | import 'package:one_key/net/base_resp.dart'; |
| @@ -16,6 +17,7 @@ class CouponProvider with ChangeNotifier { | @@ -16,6 +17,7 @@ class CouponProvider with ChangeNotifier { | ||
| 16 | PageState pageStateHistory = PageState.Loading; | 17 | PageState pageStateHistory = PageState.Loading; |
| 17 | PageState pageStateSelect = PageState.Loading; | 18 | PageState pageStateSelect = PageState.Loading; |
| 18 | bool hasModify = false; | 19 | bool hasModify = false; |
| 20 | + bool sendSMS = false; | ||
| 19 | 21 | ||
| 20 | bool checkValue = true; //优惠券页面“全选”按钮状态 ----- 数据状态全部选中为true | 22 | bool checkValue = true; //优惠券页面“全选”按钮状态 ----- 数据状态全部选中为true |
| 21 | // List<Map<String, dynamic>> listData = []; //优惠券页面数据 | 23 | // List<Map<String, dynamic>> listData = []; //优惠券页面数据 |
| @@ -391,4 +393,49 @@ class CouponProvider with ChangeNotifier { | @@ -391,4 +393,49 @@ class CouponProvider with ChangeNotifier { | ||
| 391 | return false; | 393 | return false; |
| 392 | } | 394 | } |
| 393 | } | 395 | } |
| 396 | + | ||
| 397 | + ///预定安排微信发短信 | ||
| 398 | + Future<bool> sendSMSWxSendSms( | ||
| 399 | + BuildContext context, Map<String, String> params, | ||
| 400 | + {isShowLoading = true}) async { | ||
| 401 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 402 | + .request<dynamic>(context, Method.get, HttpUrl.app_sendsms_wxSendSms, | ||
| 403 | + data: params, showLoading: isShowLoading) | ||
| 404 | + .catchError((error) { | ||
| 405 | + print(error.toString()); | ||
| 406 | + if (error is MyError) {} | ||
| 407 | + }); | ||
| 408 | + if (baseResp.code == Constant.status_success) { | ||
| 409 | + if (baseResp.data == null) { | ||
| 410 | + return false; | ||
| 411 | + } else { | ||
| 412 | + if (WxSendSmsModel.fromJson(baseResp.responseData) | ||
| 413 | + .data | ||
| 414 | + .sendStatusList | ||
| 415 | + .length > | ||
| 416 | + 0) { | ||
| 417 | + String code = WxSendSmsModel.fromJson(baseResp.responseData) | ||
| 418 | + .data | ||
| 419 | + .sendStatusList[0] | ||
| 420 | + .code; | ||
| 421 | + if (code == 'Ok') { | ||
| 422 | + sendSMS = true; | ||
| 423 | + | ||
| 424 | + return true; | ||
| 425 | + } else if (code == 'LimitExceeded.PhoneNumberSameContentDailyLimit') { | ||
| 426 | + return false; | ||
| 427 | + } else { | ||
| 428 | + return false; | ||
| 429 | + } | ||
| 430 | + } else { | ||
| 431 | + return false; | ||
| 432 | + } | ||
| 433 | + } | ||
| 434 | + } else { | ||
| 435 | + if (baseResp != null) { | ||
| 436 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 437 | + } | ||
| 438 | + return false; | ||
| 439 | + } | ||
| 440 | + } | ||
| 394 | } | 441 | } |
-
Please register or login to post a comment