Commit 524556de03e77672ea8fada4bc7ff3501904b3b0

Authored by “gaiyaguang”
1 parent 591b9691

短信部分

1 -397933a8f93ced880f583fe557299f5c  
  1 +7babc7873f8d177769b987ba4c6c2911
@@ -146,4 +146,4 @@ SPEC CHECKSUMS: @@ -146,4 +146,4 @@ SPEC CHECKSUMS:
146 146
147 PODFILE CHECKSUM: a75497545d4391e2d394c3668e20cfb1c2bbd4aa 147 PODFILE CHECKSUM: a75497545d4391e2d394c3668e20cfb1c2bbd4aa
148 148
149 -COCOAPODS: 1.9.1 149 +COCOAPODS: 1.9.3
  1 +import 'package:json_annotation/json_annotation.dart';
  2 +
  3 +part 'sms_info.g.dart';
  4 +
  5 +@JsonSerializable()
  6 +class SmsInfo extends Object {
  7 + @JsonKey(name: 'ret')
  8 + int ret;
  9 +
  10 + @JsonKey(name: 'data')
  11 + SmsInfoData data;
  12 +
  13 + @JsonKey(name: 'msg')
  14 + String msg;
  15 +
  16 + SmsInfo(
  17 + this.ret,
  18 + this.data,
  19 + this.msg,
  20 + );
  21 +
  22 + factory SmsInfo.fromJson(Map<String, dynamic> srcJson) =>
  23 + _$sms_infoFromJson(srcJson);
  24 +
  25 + Map<String, dynamic> toJson() => _$sms_infoToJson(this);
  26 +}
  27 +
  28 +@JsonSerializable()
  29 +class SmsInfoData extends Object {
  30 + @JsonKey(name: 'last_num')
  31 + String lastNum;
  32 +
  33 + @JsonKey(name: 'meals')
  34 + List<Meals> meals;
  35 +
  36 + SmsInfoData(
  37 + this.lastNum,
  38 + this.meals,
  39 + );
  40 +
  41 + factory SmsInfoData.fromJson(Map<String, dynamic> srcJson) =>
  42 + _$DataFromJson(srcJson);
  43 +
  44 + Map<String, dynamic> toJson() => _$DataToJson(this);
  45 +}
  46 +
  47 +@JsonSerializable()
  48 +class Meals extends Object {
  49 + @JsonKey(name: 'id')
  50 + String id;
  51 +
  52 + @JsonKey(name: 'package_name')
  53 + String packageName;
  54 +
  55 + @JsonKey(name: 'total')
  56 + String total;
  57 +
  58 + @JsonKey(name: 'price_ave')
  59 + String priceAve;
  60 +
  61 + @JsonKey(name: 'price_old')
  62 + String priceOld;
  63 +
  64 + @JsonKey(name: 'price')
  65 + String price;
  66 +
  67 + @JsonKey(name: 'discount')
  68 + String discount;
  69 +
  70 + Meals(
  71 + this.id,
  72 + this.packageName,
  73 + this.total,
  74 + this.priceAve,
  75 + this.priceOld,
  76 + this.price,
  77 + this.discount,
  78 + );
  79 +
  80 + factory Meals.fromJson(Map<String, dynamic> srcJson) =>
  81 + _$MealsFromJson(srcJson);
  82 +
  83 + Map<String, dynamic> toJson() => _$MealsToJson(this);
  84 +}
  1 +// GENERATED CODE - DO NOT MODIFY BY HAND
  2 +
  3 +part of 'sms_info.dart';
  4 +
  5 +// **************************************************************************
  6 +// JsonSerializableGenerator
  7 +// **************************************************************************
  8 +
  9 +SmsInfo _$sms_infoFromJson(Map<String, dynamic> json) {
  10 + return SmsInfo(
  11 + json['ret'] as int,
  12 + json['data'] == null
  13 + ? null
  14 + : SmsInfoData.fromJson(json['data'] as Map<String, dynamic>),
  15 + json['msg'] as String);
  16 +}
  17 +
  18 +Map<String, dynamic> _$sms_infoToJson(SmsInfo instance) => <String, dynamic>{
  19 + 'ret': instance.ret,
  20 + 'data': instance.data,
  21 + 'msg': instance.msg
  22 + };
  23 +
  24 +SmsInfoData _$DataFromJson(Map<String, dynamic> json) {
  25 + return SmsInfoData(
  26 + json['last_num'] as String,
  27 + (json['meals'] as List)
  28 + ?.map((e) =>
  29 + e == null ? null : Meals.fromJson(e as Map<String, dynamic>))
  30 + ?.toList());
  31 +}
  32 +
  33 +Map<String, dynamic> _$DataToJson(SmsInfoData instance) =>
  34 + <String, dynamic>{'last_num': instance.lastNum, 'meals': instance.meals};
  35 +
  36 +Meals _$MealsFromJson(Map<String, dynamic> json) {
  37 + return Meals(
  38 + json['id'] as String,
  39 + json['package_name'] as String,
  40 + json['total'] as String,
  41 + json['price_ave'] as String,
  42 + json['price_old'] as String,
  43 + json['price'] as String,
  44 + json['discount'] as String);
  45 +}
  46 +
  47 +Map<String, dynamic> _$MealsToJson(Meals instance) => <String, dynamic>{
  48 + 'id': instance.id,
  49 + 'package_name': instance.packageName,
  50 + 'total': instance.total,
  51 + 'price_ave': instance.priceAve,
  52 + 'price_old': instance.priceOld,
  53 + 'price': instance.price,
  54 + 'discount': instance.discount
  55 + };
@@ -37,4 +37,5 @@ class HttpUrl { @@ -37,4 +37,5 @@ class HttpUrl {
37 "?service=Android.Customer.SetReserveInfo"; //更改在线预订 37 "?service=Android.Customer.SetReserveInfo"; //更改在线预订
38 static const String set_switch_status = 38 static const String set_switch_status =
39 "?service=App.Reserve.SetSwitchStatus"; //启用/停用桌位 39 "?service=App.Reserve.SetSwitchStatus"; //启用/停用桌位
  40 + static const String sms_info = "?service=App.SendSMS.SmsInfo"; //短信余量查询及套餐查询接口
40 } 41 }
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:flutter_screenutil/flutter_screenutil.dart'; 2 import 'package:flutter_screenutil/flutter_screenutil.dart';
3 import 'package:fluwx/fluwx.dart'; 3 import 'package:fluwx/fluwx.dart';
  4 +import 'package:one_key/models/sms_info.dart';
  5 +import 'package:one_key/provider/my_model.dart';
4 import 'package:one_key/provider/update_model.dart'; 6 import 'package:one_key/provider/update_model.dart';
5 import 'package:one_key/provider/user_model.dart'; 7 import 'package:one_key/provider/user_model.dart';
6 import 'package:one_key/res/colors.dart'; 8 import 'package:one_key/res/colors.dart';
@@ -25,6 +27,7 @@ class MyPage extends StatefulWidget { @@ -25,6 +27,7 @@ class MyPage extends StatefulWidget {
25 class MyPageState extends State<MyPage> { 27 class MyPageState extends State<MyPage> {
26 String cur_version = ""; 28 String cur_version = "";
27 bool newVersion = false; 29 bool newVersion = false;
  30 + String smsInfo = "";
28 31
29 @override 32 @override
30 void initState() { 33 void initState() {
@@ -35,6 +38,18 @@ class MyPageState extends State<MyPage> { @@ -35,6 +38,18 @@ class MyPageState extends State<MyPage> {
35 cur_version = "v" + version; 38 cur_version = "v" + version;
36 }); 39 });
37 }); 40 });
  41 +
  42 + ///获取短信余量
  43 + _getSmsInfo();
  44 + }
  45 +
  46 + ///获取短信余量
  47 + _getSmsInfo() async {
  48 + MyModel myModel = Provider.of<MyModel>(context, listen: false);
  49 + SmsInfoData smsInfoData = await myModel.getSmsInfo(context);
  50 + setState(() {
  51 + smsInfo = smsInfoData?.lastNum;
  52 + });
38 } 53 }
39 54
40 //检查版本更新 55 //检查版本更新
@@ -43,7 +58,6 @@ class MyPageState extends State<MyPage> { @@ -43,7 +58,6 @@ class MyPageState extends State<MyPage> {
43 updateModel.checkUpdate(context); 58 updateModel.checkUpdate(context);
44 } 59 }
45 60
46 -  
47 @override 61 @override
48 Widget build(BuildContext context) { 62 Widget build(BuildContext context) {
49 return Stack( 63 return Stack(
@@ -54,6 +68,18 @@ class MyPageState extends State<MyPage> { @@ -54,6 +68,18 @@ class MyPageState extends State<MyPage> {
54 children: <Widget>[ 68 children: <Widget>[
55 VEmptyView(40), 69 VEmptyView(40),
56 MyItem( 70 MyItem(
  71 + title: "短信管理",
  72 + content: smsInfo.isNotEmpty ? '剩余${smsInfo}条' : '',
  73 + callback: () {
  74 + Utils.goMiniProgramZm(context);
  75 + },
  76 + ),
  77 + MyDivider(
  78 + double.infinity,
  79 + ScreenUtil().setHeight(1),
  80 + color: MyColours.color_f3f3f3,
  81 + ),
  82 + MyItem(
57 title: "包间类型置满管理", 83 title: "包间类型置满管理",
58 content: "", 84 content: "",
59 callback: () { 85 callback: () {
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
  2 +import 'package:one_key/constant/constant.dart';
  3 +import 'package:one_key/constant/error.dart';
  4 +import 'package:one_key/models/sms_info.dart';
  5 +import 'package:one_key/net/base_resp.dart';
  6 +import 'package:one_key/net/dio_util.dart';
  7 +import 'package:one_key/net/http_url.dart';
  8 +import 'package:one_key/provider/SmsModel.dart';
  9 +import 'package:one_key/provider/user_model.dart';
  10 +import 'package:one_key/utils/utils.dart';
  11 +import 'package:provider/provider.dart';
2 12
3 -class MyModel extends ChangeNotifier{  
4 -  
5 -}  
  13 +class MyModel extends ChangeNotifier {
  14 + /// 短信余量查询及套餐查询接口
  15 + Future<SmsInfoData> getSmsInfo(BuildContext context) async {
  16 + UserModel userModel = Provider.of<UserModel>(context, listen: false);
  17 + Map<String, String> params = {"seller_id": userModel.user.sellerid};
  18 + try {
  19 + BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
  20 + .request<Map<String, dynamic>>(context, Method.get, HttpUrl.sms_info,
  21 + data: params, showLoading: false)
  22 + .catchError((error) {
  23 + print(error.toString());
  24 + });
  25 + SmsInfoData data;
  26 + if (baseResp?.code == Constant.status_success) {
  27 + SmsInfo smsInfo = SmsInfo.fromJson(baseResp.responseData);
  28 + if (smsInfo.ret == 200) {
  29 + data = smsInfo.data;
  30 + } else {
  31 + Utils.showToast(smsInfo.msg);
  32 + }
  33 + } else {
  34 + Utils.showToast('查询失败');
  35 + }
  36 + return data;
  37 + } catch (error) {
  38 + if (error is MyError) {
  39 + switch (error.type) {
  40 + case 1:
  41 + print('错误');
  42 + break;
  43 + case 2:
  44 + print('超时');
  45 + break;
  46 + default:
  47 + print('错误');
  48 + break;
  49 + }
  50 + }
  51 + }
  52 + }
  53 +}
@@ -81,12 +81,14 @@ class Utils { @@ -81,12 +81,14 @@ class Utils {
81 81
82 //跳转小程序包间类型置满管理 82 //跳转小程序包间类型置满管理
83 static goMiniProgramZm(BuildContext context) { 83 static goMiniProgramZm(BuildContext context) {
84 - UserModel model=Provider.of<UserModel>(context); 84 + UserModel model = Provider.of<UserModel>(context, listen: false);
85 launchWeChatMiniProgram( 85 launchWeChatMiniProgram(
86 username: "gh_487873d353b3", 86 username: "gh_487873d353b3",
87 - path: "pack-book/pages/book/b_index?seller_id=${model.user.sellerid}&seller_openid=oGefL4qKBWIh5xwyg3LVfkMbDumA&manager_id=''&goPath=roomtype/roomtype", 87 + path:
  88 + "pack-book/pages/book/b_index?seller_id=${model.user.sellerid}&seller_openid=oGefL4qKBWIh5xwyg3LVfkMbDumA&manager_id=''&goPath=roomtype/roomtype",
88 miniProgramType: WXMiniProgramType.RELEASE); 89 miniProgramType: WXMiniProgramType.RELEASE);
89 } 90 }
  91 +
90 //跳转拨打电话页面 92 //跳转拨打电话页面
91 static goHelp(BuildContext context) async { 93 static goHelp(BuildContext context) async {
92 NavigatorUtil.goWebviewPage(context); 94 NavigatorUtil.goWebviewPage(context);