Commit 102ad3eb03b7ab0c49109e35d5d9dcccf80ca6b3

Authored by “gaiyaguang”
2 parents 4cade740 9ffa252c

Merge branch 'v1.2+' of http://123.56.79.57/xt/Flutter-ReserveApp into v1.2+

@@ -43,8 +43,8 @@ android { @@ -43,8 +43,8 @@ android {
43 applicationId "com.naji.one_key" 43 applicationId "com.naji.one_key"
44 minSdkVersion 21 44 minSdkVersion 21
45 targetSdkVersion 28 45 targetSdkVersion 28
46 - versionCode 117  
47 - versionName "1.1.7" 46 + versionCode 118
  47 + versionName "1.1.8"
48 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 48 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
49 49
50 ndk { 50 ndk {
  1 +
  2 +class MyError extends Error{
  3 + final int type;
  4 +
  5 + MyError({this.type=1});//1 ConnectivityError 2 ConnectivityTimeOut
  6 +
  7 +
  8 +}
  1 +/**
  2 + * 页面状态
  3 + */
  4 +enum PageState{
  5 + Loading,//加载中
  6 + ConnectivityTimeOut,//请求超时
  7 + ConnectivityError,//请求错误
  8 + Empty,//空页面
  9 + First,
  10 + Success//成功
  11 +}
@@ -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/constant/error.dart';
6 import 'package:one_key/utils/log_util.dart'; 7 import 'package:one_key/utils/log_util.dart';
7 import 'package:one_key/utils/utils.dart'; 8 import 'package:one_key/utils/utils.dart';
8 import 'package:one_key/widgets/loading.dart'; 9 import 'package:one_key/widgets/loading.dart';
@@ -173,10 +174,10 @@ class DioUtil { @@ -173,10 +174,10 @@ class DioUtil {
173 CancelToken cancelToken, 174 CancelToken cancelToken,
174 bool showLoading = true}) async { 175 bool showLoading = true}) async {
175 bool connectivity = await Utils.checkConnectiviy(); 176 bool connectivity = await Utils.checkConnectiviy();
176 -// if(!connectivity){ 177 + if (!connectivity) {
177 // Utils.showToast("网络错误,请稍后重试"); 178 // Utils.showToast("网络错误,请稍后重试");
178 -// return new Future.error("网络错误,请稍后重试");  
179 -// } 179 + throw MyError(type: 1);
  180 + }
180 if (showLoading) Loading.showLoading(context); 181 if (showLoading) Loading.showLoading(context);
181 try { 182 try {
182 Response response = await _dio.request(path, 183 Response response = await _dio.request(path,
@@ -236,9 +237,11 @@ class DioUtil { @@ -236,9 +237,11 @@ class DioUtil {
236 Loading.hideLoading(context); 237 Loading.hideLoading(context);
237 } 238 }
238 if (error is DioError && error.type == DioErrorType.CONNECT_TIMEOUT) { 239 if (error is DioError && error.type == DioErrorType.CONNECT_TIMEOUT) {
239 - Utils.showToast("网络链接超时,请稍后重试"); 240 +// Utils.showToast("网络链接超时,请稍后重试");
  241 + }
  242 + if (error.type != DioErrorType.CANCEL) {
  243 + throw MyError(type: 2);
240 } 244 }
241 - throw error;  
242 } 245 }
243 } 246 }
244 247
@@ -21,6 +21,8 @@ import 'package:one_key/widgets/v_empty_view.dart'; @@ -21,6 +21,8 @@ import 'package:one_key/widgets/v_empty_view.dart';
21 import 'package:provider/provider.dart'; 21 import 'package:provider/provider.dart';
22 import 'package:one_key/utils/event_bus.dart'; 22 import 'package:one_key/utils/event_bus.dart';
23 23
  24 +import '../../app.dart';
  25 +
24 class HandleOnlinePage extends StatefulWidget { 26 class HandleOnlinePage extends StatefulWidget {
25 final String rid; 27 final String rid;
26 final String mid; 28 final String mid;
@@ -45,6 +47,10 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { @@ -45,6 +47,10 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
45 47
46 Manager manager = Manager(); 48 Manager manager = Manager();
47 49
  50 + bool isCallTel=false;
  51 +
  52 + String formatPhone="";//格式客户号码
  53 +
48 @override 54 @override
49 void initState() { 55 void initState() {
50 // TODO: implement initState 56 // TODO: implement initState
@@ -56,6 +62,15 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { @@ -56,6 +62,15 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
56 setState(() { 62 setState(() {
57 //未处理 63 //未处理
58 cusmanText = detailEntity.cusman.isEmpty ? "请选择" : detailEntity.cusman; 64 cusmanText = detailEntity.cusman.isEmpty ? "请选择" : detailEntity.cusman;
  65 + formatPhone=detailEntity.phone;
  66 + if(App.sp.getString("is_call_tel")!=null&&App.sp.getString("is_call_tel")=="1"){
  67 + isCallTel=true;
  68 + }else{
  69 + isCallTel=false;
  70 + if(detailEntity.phone.isNotEmpty&&detailEntity.phone.length==11&&(detailEntity.status=="0"||detailEntity.status=="6")){
  71 + formatPhone=detailEntity.phone.substring(0,3)+"****"+detailEntity.phone.substring(7);
  72 + }
  73 + }
59 }); 74 });
60 if (detailEntity.status != "0") { 75 if (detailEntity.status != "0") {
61 //已处理 76 //已处理
@@ -68,6 +83,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { @@ -68,6 +83,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
68 managers = await detailModel.getManagers(context); 83 managers = await detailModel.getManagers(context);
69 } 84 }
70 }); 85 });
  86 +
71 } 87 }
72 88
73 //设置当前客户经理 89 //设置当前客户经理
@@ -148,7 +164,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { @@ -148,7 +164,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
148 }; 164 };
149 bool success = 165 bool success =
150 await detailModel.setReserveStatus(context, params, showLoading: true); 166 await detailModel.setReserveStatus(context, params, showLoading: true);
151 - if (success) { 167 + if (success!=null&&success) {
152 bus.emit("refresh_book_list"); 168 bus.emit("refresh_book_list");
153 } 169 }
154 } 170 }
@@ -164,9 +180,12 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { @@ -164,9 +180,12 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
164 detailModel.setMessageStatus(context, params); 180 detailModel.setMessageStatus(context, params);
165 } 181 }
166 182
  183 +
  184 +
167 @override 185 @override
168 Widget build(BuildContext context) { 186 Widget build(BuildContext context) {
169 // TODO: implement build 187 // TODO: implement build
  188 +
170 return SafeArea( 189 return SafeArea(
171 child: WillPopScope( 190 child: WillPopScope(
172 child: detailEntity == null 191 child: detailEntity == null
@@ -268,7 +287,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { @@ -268,7 +287,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
268 RowMultiText( 287 RowMultiText(
269 "客户姓名", detailEntity.rnameStr), 288 "客户姓名", detailEntity.rnameStr),
270 RowMultiText( 289 RowMultiText(
271 - "客户电话", detailEntity.phone), 290 + "客户电话", formatPhone),
272 RowMultiText("备注信息", 291 RowMultiText("备注信息",
273 detailEntity.cusdem ?? ""), 292 detailEntity.cusdem ?? ""),
274 MyDivider(double.infinity, 293 MyDivider(double.infinity,
@@ -357,7 +376,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { @@ -357,7 +376,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
357 int.parse(detailEntity.ddate) * 376 int.parse(detailEntity.ddate) *
358 1000, 377 1000,
359 detailEntity.ddate_solt); 378 detailEntity.ddate_solt);
360 - if (map['tid'] != null) { 379 + if (map!=null&&map['tid'] != null) {
361 setReserveStatus("5", 380 setReserveStatus("5",
362 tid: map['tid']); 381 tid: map['tid']);
363 } 382 }
@@ -393,34 +412,42 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { @@ -393,34 +412,42 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
393 _showRefuseDialog(); 412 _showRefuseDialog();
394 }, 413 },
395 )), 414 )),
396 - MyDivider(  
397 - ScreenUtil().setWidth(2),  
398 - ScreenUtil().setHeight(52),  
399 - color: MyColours.color_199095,  
400 - ),  
401 - Expanded(  
402 - child: GestureDetector(  
403 - child: Center(  
404 - child: Text(  
405 - "联系顾客",  
406 - style: TextStyle(  
407 - color:  
408 - MyColours.color_199095,  
409 - fontSize:  
410 - ScreenUtil().setSp(34)),  
411 - ), 415 + Offstage(
  416 + offstage: !isCallTel,
  417 + child: Row(
  418 + mainAxisSize: MainAxisSize.min,
  419 + children: [
  420 + MyDivider(
  421 + ScreenUtil().setWidth(2),
  422 + ScreenUtil().setHeight(52),
  423 + color: MyColours.color_199095,
  424 + ),
  425 + Expanded(
  426 + child: GestureDetector(
  427 + child: Center(
  428 + child: Text(
  429 + "联系顾客",
  430 + style: TextStyle(
  431 + color:
  432 + MyColours.color_199095,
  433 + fontSize:
  434 + ScreenUtil().setSp(34)),
  435 + ),
  436 + ),
  437 + onTap: () {
  438 + if (detailEntity.phone != null &&
  439 + detailEntity
  440 + .phone.isNotEmpty) {
  441 + Utils.goPhone(
  442 + detailEntity.phone);
  443 + } else {
  444 + Utils.showToast("没有客户电话!");
  445 + }
  446 + },
  447 + )),
  448 + ],
412 ), 449 ),
413 - onTap: () {  
414 - if (detailEntity.phone != null &&  
415 - detailEntity  
416 - .phone.isNotEmpty) {  
417 - Utils.goPhone(  
418 - detailEntity.phone);  
419 - } else {  
420 - Utils.showToast("没有客户电话!");  
421 - }  
422 - },  
423 - )), 450 + )
424 ], 451 ],
425 ), 452 ),
426 ) 453 )
@@ -28,6 +28,8 @@ import 'package:one_key/models/table.dart' as t; @@ -28,6 +28,8 @@ import 'package:one_key/models/table.dart' as t;
28 import 'package:one_key/widgets/v_empty_view.dart'; 28 import 'package:one_key/widgets/v_empty_view.dart';
29 import 'package:provider/provider.dart'; 29 import 'package:provider/provider.dart';
30 30
  31 +import '../../app.dart';
  32 +
31 class NotebookDetailPage extends StatefulWidget { 33 class NotebookDetailPage extends StatefulWidget {
32 final String rid; 34 final String rid;
33 final String mid; 35 final String mid;
@@ -61,6 +63,9 @@ class NotebookDetailPageState extends State<NotebookDetailPage> { @@ -61,6 +63,9 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
61 StateSetter _cancelState; 63 StateSetter _cancelState;
62 64
63 ScrollController _scrollController; 65 ScrollController _scrollController;
  66 +
  67 + String formatPhone="";
  68 +
64 @override 69 @override
65 void initState() { 70 void initState() {
66 // TODO: implement initState 71 // TODO: implement initState
@@ -114,6 +119,13 @@ class NotebookDetailPageState extends State<NotebookDetailPage> { @@ -114,6 +119,13 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
114 }); 119 });
115 setState(() { 120 setState(() {
116 cusmanText = detailEntity.cusman.isEmpty ? "请选择" : detailEntity.cusman; 121 cusmanText = detailEntity.cusman.isEmpty ? "请选择" : detailEntity.cusman;
  122 + formatPhone=detailEntity.phone;
  123 + if(App.sp.getString("is_call_tel")!=null&&App.sp.getString("is_call_tel")=="1"){
  124 + }else{
  125 + if(detailEntity.phone.isNotEmpty&&detailEntity.phone.length==11&&(detailEntity.status=="0"||detailEntity.status=="6")){
  126 + formatPhone=detailEntity.phone.substring(0,3)+"****"+detailEntity.phone.substring(7);
  127 + }
  128 + }
117 }); 129 });
118 if (detailEntity.status == "4") { 130 if (detailEntity.status == "4") {
119 setMessageStatus(); 131 setMessageStatus();
@@ -526,7 +538,7 @@ class NotebookDetailPageState extends State<NotebookDetailPage> { @@ -526,7 +538,7 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
526 )), 538 )),
527 RowMultiText("客户姓名", detailEntity.rnameStr), 539 RowMultiText("客户姓名", detailEntity.rnameStr),
528 RowMultiText( 540 RowMultiText(
529 - "客户电话", detailEntity.phone ?? ""), 541 + "客户电话", formatPhone),
530 Offstage( 542 Offstage(
531 offstage: detailEntity.cusdem == '' || 543 offstage: detailEntity.cusdem == '' ||
532 detailEntity.cusdem == null, 544 detailEntity.cusdem == null,
@@ -90,6 +90,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -90,6 +90,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
90 if (Platform.isIOS && param != null) { 90 if (Platform.isIOS && param != null) {
91 notifyParam = json.decode(param['custom'].toString()); 91 notifyParam = json.decode(param['custom'].toString());
92 } 92 }
  93 + LogUtil.v(param.toString());
93 if (notifyParam != null && notifyParam.isNotEmpty) { 94 if (notifyParam != null && notifyParam.isNotEmpty) {
94 switch (notifyParam["messageType"]) { 95 switch (notifyParam["messageType"]) {
95 case "10": 96 case "10":
@@ -247,7 +248,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -247,7 +248,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
247 super.didChangeAppLifecycleState(state); 248 super.didChangeAppLifecycleState(state);
248 switch (state) { 249 switch (state) {
249 case AppLifecycleState.resumed: //应用前台可见 250 case AppLifecycleState.resumed: //应用前台可见
250 -// getUntreatedMessage(); 251 + getUntreatedMessage();
251 break; 252 break;
252 case AppLifecycleState.inactive: 253 case AppLifecycleState.inactive:
253 print('inactive'); 254 print('inactive');
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:flutter_easyrefresh/easy_refresh.dart'; 2 import 'package:flutter_easyrefresh/easy_refresh.dart';
  3 +import 'package:one_key/constant/state.dart';
3 import 'package:one_key/pages/message/messsage_item.dart'; 4 import 'package:one_key/pages/message/messsage_item.dart';
4 import 'package:one_key/provider/message_dialog_model.dart'; 5 import 'package:one_key/provider/message_dialog_model.dart';
5 import 'package:one_key/provider/message_model.dart'; 6 import 'package:one_key/provider/message_model.dart';
6 import 'package:one_key/provider/user_model.dart'; 7 import 'package:one_key/provider/user_model.dart';
7 import 'package:one_key/widgets/page_error.dart'; 8 import 'package:one_key/widgets/page_error.dart';
  9 +import 'package:one_key/widgets/page_exception.dart';
8 import 'package:provider/provider.dart'; 10 import 'package:provider/provider.dart';
9 import 'package:one_key/utils/event_bus.dart'; 11 import 'package:one_key/utils/event_bus.dart';
10 12
@@ -55,11 +57,15 @@ class MessageLeftPageState extends State<MessageLeftPage> { @@ -55,11 +57,15 @@ class MessageLeftPageState extends State<MessageLeftPage> {
55 // TODO: implement build 57 // TODO: implement build
56 return Consumer<MessageModel>( 58 return Consumer<MessageModel>(
57 builder: (context,model,_){ 59 builder: (context,model,_){
58 - if(!model.connect_timeout){  
59 - return Center(  
60 - child: ErrorPage(callback: (){ 60 + if (model.pageState != PageState.Success) {
  61 + return ExceptionPage(
  62 + pageState: model.pageState,
  63 + callback: () {
61 getUntreatedMessage(); 64 getUntreatedMessage();
62 - },), 65 + },
  66 + emptyMsg: "暂时没有未处理的消息哦",
  67 + emptyImg: "empty_search",
  68 + showMsg: "加载中,请稍后...",
63 ); 69 );
64 }else{ 70 }else{
65 return EasyRefresh.custom( 71 return EasyRefresh.custom(
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:flutter_easyrefresh/easy_refresh.dart'; 2 import 'package:flutter_easyrefresh/easy_refresh.dart';
  3 +import 'package:one_key/constant/state.dart';
3 import 'package:one_key/pages/message/messsage_item.dart'; 4 import 'package:one_key/pages/message/messsage_item.dart';
4 import 'package:one_key/provider/message_model.dart'; 5 import 'package:one_key/provider/message_model.dart';
5 import 'package:one_key/provider/user_model.dart'; 6 import 'package:one_key/provider/user_model.dart';
6 import 'package:one_key/widgets/page_error.dart'; 7 import 'package:one_key/widgets/page_error.dart';
  8 +import 'package:one_key/widgets/page_exception.dart';
7 import 'package:provider/provider.dart'; 9 import 'package:provider/provider.dart';
8 10
9 class MessageRightPage extends StatefulWidget{ 11 class MessageRightPage extends StatefulWidget{
@@ -50,11 +52,15 @@ class MessageRightPageState extends State<MessageRightPage>{ @@ -50,11 +52,15 @@ class MessageRightPageState extends State<MessageRightPage>{
50 // TODO: implement build 52 // TODO: implement build
51 return Consumer<MessageModel>( 53 return Consumer<MessageModel>(
52 builder: (context,model,_){ 54 builder: (context,model,_){
53 - if(!model.connect_timeout){  
54 - return Center(  
55 - child: ErrorPage(callback: (){ 55 + if (model.pageState != PageState.Success) {
  56 + return ExceptionPage(
  57 + pageState: model.pageState,
  58 + callback: () {
56 getTreatedMessage(); 59 getTreatedMessage();
57 - },), 60 + },
  61 + emptyMsg: "暂时没有已处理的消息哦",
  62 + emptyImg: "empty_search",
  63 + showMsg: "加载中,请稍后...",
58 ); 64 );
59 }else{ 65 }else{
60 return EasyRefresh.custom( 66 return EasyRefresh.custom(
@@ -2,6 +2,7 @@ import 'package:dio/dio.dart'; @@ -2,6 +2,7 @@ import 'package:dio/dio.dart';
2 import 'package:flutter/material.dart'; 2 import 'package:flutter/material.dart';
3 import 'package:flutter_easyrefresh/easy_refresh.dart'; 3 import 'package:flutter_easyrefresh/easy_refresh.dart';
4 import 'package:flutter_screenutil/flutter_screenutil.dart'; 4 import 'package:flutter_screenutil/flutter_screenutil.dart';
  5 +import 'package:one_key/constant/state.dart';
5 import 'package:one_key/pages/notebook/notebook_item_widget.dart'; 6 import 'package:one_key/pages/notebook/notebook_item_widget.dart';
6 import 'package:one_key/provider/notebook_model.dart'; 7 import 'package:one_key/provider/notebook_model.dart';
7 import 'package:one_key/provider/update_model.dart'; 8 import 'package:one_key/provider/update_model.dart';
@@ -15,6 +16,7 @@ import 'package:one_key/widgets/MyDivider.dart'; @@ -15,6 +16,7 @@ import 'package:one_key/widgets/MyDivider.dart';
15 import 'package:one_key/widgets/app_bar.dart'; 16 import 'package:one_key/widgets/app_bar.dart';
16 import 'package:one_key/widgets/common_button.dart'; 17 import 'package:one_key/widgets/common_button.dart';
17 import 'package:one_key/widgets/page_error.dart'; 18 import 'package:one_key/widgets/page_error.dart';
  19 +import 'package:one_key/widgets/page_exception.dart';
18 import 'package:provider/provider.dart'; 20 import 'package:provider/provider.dart';
19 21
20 class NoteBookPage extends StatefulWidget { 22 class NoteBookPage extends StatefulWidget {
@@ -412,13 +414,15 @@ class NoteBookPageState extends State<NoteBookPage> { @@ -412,13 +414,15 @@ class NoteBookPageState extends State<NoteBookPage> {
412 _buildListTitle(), 414 _buildListTitle(),
413 Expanded(child: Consumer<NoteBookModel>( 415 Expanded(child: Consumer<NoteBookModel>(
414 builder: (context, model, _) { 416 builder: (context, model, _) {
415 - if (model.connect_timeout) {  
416 - return Center(  
417 - child: ErrorPage(  
418 - callback: () {  
419 - _getReserveList();  
420 - },  
421 - ), 417 + if (model.pageState != PageState.Success) {
  418 + return ExceptionPage(
  419 + pageState: model.pageState,
  420 + callback: () {
  421 + _getReserveList();
  422 + },
  423 + emptyMsg: "暂时没有预订哦",
  424 + emptyImg: "empty_search",
  425 + showMsg: "加载中,请稍后...",
422 ); 426 );
423 } else { 427 } else {
424 return EasyRefresh.custom( 428 return EasyRefresh.custom(
@@ -59,7 +59,7 @@ class ContactModel{ @@ -59,7 +59,7 @@ class ContactModel{
59 "data":jsonEncode(callLogs) 59 "data":jsonEncode(callLogs)
60 }; 60 };
61 BaseResp<String> baseResp = await DioUtil() 61 BaseResp<String> baseResp = await DioUtil()
62 - .request<String>(context, Method.get, HttpUrl.upload_contact, 62 + .request<String>(context, Method.get, HttpUrl.upload_contact,showLoading: false,
63 data: params,options: Options(method: Method.post,contentType: ContentType.parse("application/x-www-form-urlencoded"))) 63 data: params,options: Options(method: Method.post,contentType: ContentType.parse("application/x-www-form-urlencoded")))
64 .catchError((error) { 64 .catchError((error) {
65 print(error.toString()); 65 print(error.toString());
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';
  4 +import 'package:one_key/constant/state.dart';
3 import 'package:one_key/models/message.dart'; 5 import 'package:one_key/models/message.dart';
4 import 'package:one_key/net/base_resp.dart'; 6 import 'package:one_key/net/base_resp.dart';
5 import 'package:one_key/net/dio_util.dart'; 7 import 'package:one_key/net/dio_util.dart';
@@ -13,18 +15,30 @@ class MessageModel extends ChangeNotifier{ @@ -13,18 +15,30 @@ class MessageModel extends ChangeNotifier{
13 List<Message> untreatedMsgs=[];//未处理在线预订消息 15 List<Message> untreatedMsgs=[];//未处理在线预订消息
14 List<Message> treatedMsgs=[];//已处理在线预订消息 16 List<Message> treatedMsgs=[];//已处理在线预订消息
15 17
16 - bool connect_timeout=true; 18 + PageState pageState = PageState.Loading;
17 19
18 //获取未处理在线预订消息 20 //获取未处理在线预订消息
19 getUntreatedMsg(BuildContext context,Map<String,String> params) async { 21 getUntreatedMsg(BuildContext context,Map<String,String> params) async {
20 - connect_timeout=true; 22 + pageState = PageState.Loading;
21 notifyListeners(); 23 notifyListeners();
22 BaseResp<List> baseResp = await DioUtil() 24 BaseResp<List> baseResp = await DioUtil()
23 .request<List>(context, Method.get, HttpUrl.get_message_list, 25 .request<List>(context, Method.get, HttpUrl.get_message_list,
24 - data: params) 26 + data: params,showLoading: false)
25 .catchError((error) { 27 .catchError((error) {
26 print(error.toString()); 28 print(error.toString());
27 - connect_timeout=false; 29 + if (error is MyError) {
  30 + switch (error.type) {
  31 + case 1:
  32 + pageState = PageState.ConnectivityError;
  33 + break;
  34 + case 2:
  35 + pageState = PageState.ConnectivityTimeOut;
  36 + break;
  37 + default:
  38 + pageState = PageState.ConnectivityError;
  39 + break;
  40 + }
  41 + }
28 notifyListeners(); 42 notifyListeners();
29 }); 43 });
30 if (baseResp!=null&&baseResp.code == Constant.status_success) { 44 if (baseResp!=null&&baseResp.code == Constant.status_success) {
@@ -42,20 +56,39 @@ class MessageModel extends ChangeNotifier{ @@ -42,20 +56,39 @@ class MessageModel extends ChangeNotifier{
42 } 56 }
43 return true; 57 return true;
44 }); 58 });
  59 + if (untreatedMsgs.isEmpty) {
  60 + pageState = PageState.Empty;
  61 + } else {
  62 + pageState = PageState.Success;
  63 + }
45 notifyListeners(); 64 notifyListeners();
46 } 65 }
47 } 66 }
48 67
49 //获取未处理在线预订消息 68 //获取未处理在线预订消息
50 getTreatedMsg(BuildContext context,Map<String,String> params) async { 69 getTreatedMsg(BuildContext context,Map<String,String> params) async {
51 - connect_timeout=true;  
52 - notifyListeners(); 70 + if (params["offset"] == "0") {
  71 + pageState = PageState.Loading;
  72 + notifyListeners();
  73 + }
53 BaseResp<List> baseResp = await DioUtil() 74 BaseResp<List> baseResp = await DioUtil()
54 .request<List>(context, Method.get, HttpUrl.get_message_list, 75 .request<List>(context, Method.get, HttpUrl.get_message_list,
55 - data: params) 76 + data: params,showLoading: false)
56 .catchError((error) { 77 .catchError((error) {
57 print(error.toString()); 78 print(error.toString());
58 - connect_timeout=false; 79 + if (error is MyError) {
  80 + switch (error.type) {
  81 + case 1:
  82 + pageState = PageState.ConnectivityError;
  83 + break;
  84 + case 2:
  85 + pageState = PageState.ConnectivityTimeOut;
  86 + break;
  87 + default:
  88 + pageState = PageState.ConnectivityError;
  89 + break;
  90 + }
  91 + }
59 notifyListeners(); 92 notifyListeners();
60 }); 93 });
61 if (baseResp!=null&&baseResp.code == Constant.status_success) { 94 if (baseResp!=null&&baseResp.code == Constant.status_success) {
@@ -74,6 +107,11 @@ class MessageModel extends ChangeNotifier{ @@ -74,6 +107,11 @@ class MessageModel extends ChangeNotifier{
74 } 107 }
75 return true; 108 return true;
76 }); 109 });
  110 + if (treatedMsgs.isEmpty) {
  111 + pageState = PageState.Empty;
  112 + } else {
  113 + pageState = PageState.Success;
  114 + }
77 notifyListeners(); 115 notifyListeners();
78 } 116 }
79 } 117 }
@@ -61,7 +61,7 @@ class NotebookDetailModel extends ChangeNotifier { @@ -61,7 +61,7 @@ class NotebookDetailModel extends ChangeNotifier {
61 } 61 }
62 62
63 //安排在线预订 63 //安排在线预订
64 - setReserveStatus(BuildContext context, Map<String, String> params, 64 + Future<bool> setReserveStatus(BuildContext context, Map<String, String> params,
65 {ifPush = true, showLoading = false}) async { 65 {ifPush = true, showLoading = false}) async {
66 BaseResp<Map<String, dynamic>> baseResp = await DioUtil() 66 BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
67 .request<Map<String, dynamic>>( 67 .request<Map<String, dynamic>>(
@@ -70,6 +70,7 @@ class NotebookDetailModel extends ChangeNotifier { @@ -70,6 +70,7 @@ class NotebookDetailModel extends ChangeNotifier {
70 .catchError((error) { 70 .catchError((error) {
71 print(error.toString()); 71 print(error.toString());
72 }); 72 });
  73 + if(baseResp==null) return false;
73 if (baseResp.code == Constant.status_success) { 74 if (baseResp.code == Constant.status_success) {
74 if (ifPush) { 75 if (ifPush) {
75 NavigatorUtil.goNotebookDetailPage(context, params["rid"], 76 NavigatorUtil.goNotebookDetailPage(context, params["rid"],
@@ -78,6 +79,7 @@ class NotebookDetailModel extends ChangeNotifier { @@ -78,6 +79,7 @@ class NotebookDetailModel extends ChangeNotifier {
78 return true; 79 return true;
79 } else { 80 } else {
80 Utils.showToast(baseResp.msg); 81 Utils.showToast(baseResp.msg);
  82 + return false;
81 } 83 }
82 } 84 }
83 85
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';
  4 +import 'package:one_key/constant/state.dart';
3 import 'package:one_key/models/notebook.dart'; 5 import 'package:one_key/models/notebook.dart';
4 import 'package:one_key/net/base_resp.dart'; 6 import 'package:one_key/net/base_resp.dart';
5 import 'package:one_key/net/dio_util.dart'; 7 import 'package:one_key/net/dio_util.dart';
@@ -14,18 +16,30 @@ class NoteBookModel extends ChangeNotifier{ @@ -14,18 +16,30 @@ class NoteBookModel extends ChangeNotifier{
14 16
15 String total="";//一天统计 17 String total="";//一天统计
16 18
17 - bool connect_timeout=false; 19 + PageState pageState = PageState.Loading;
18 20
19 //获取已预订订单 21 //获取已预订订单
20 Future<List<Notebook>> getReserveList(BuildContext context,Map<String,String> params) async { 22 Future<List<Notebook>> getReserveList(BuildContext context,Map<String,String> params) async {
21 - connect_timeout=false; 23 + pageState = PageState.Loading;
22 notifyListeners(); 24 notifyListeners();
23 BaseResp<List> baseResp = await DioUtil() 25 BaseResp<List> baseResp = await DioUtil()
24 .request<List>(context, Method.get, HttpUrl.get_reserve_list, 26 .request<List>(context, Method.get, HttpUrl.get_reserve_list,
25 - data: params,showLoading: true) 27 + data: params,showLoading: false)
26 .catchError((error) { 28 .catchError((error) {
27 print(error.toString()); 29 print(error.toString());
28 - connect_timeout=true; 30 + if (error is MyError) {
  31 + switch (error.type) {
  32 + case 1:
  33 + pageState = PageState.ConnectivityError;
  34 + break;
  35 + case 2:
  36 + pageState = PageState.ConnectivityTimeOut;
  37 + break;
  38 + default:
  39 + pageState = PageState.ConnectivityError;
  40 + break;
  41 + }
  42 + }
29 notifyListeners(); 43 notifyListeners();
30 }); 44 });
31 if(baseResp==null)return null; 45 if(baseResp==null)return null;
@@ -34,6 +48,11 @@ class NoteBookModel extends ChangeNotifier{ @@ -34,6 +48,11 @@ class NoteBookModel extends ChangeNotifier{
34 notebooks=baseResp.data.map<Notebook>((value){ 48 notebooks=baseResp.data.map<Notebook>((value){
35 return Notebook.fromJson(value); 49 return Notebook.fromJson(value);
36 }).toList(); 50 }).toList();
  51 + if (notebooks.isEmpty) {
  52 + pageState = PageState.Empty;
  53 + } else {
  54 + pageState = PageState.Success;
  55 + }
37 }else{ 56 }else{
38 Utils.showToast(baseResp.msg??""); 57 Utils.showToast(baseResp.msg??"");
39 } 58 }
@@ -39,7 +39,7 @@ class UpdateModel { @@ -39,7 +39,7 @@ class UpdateModel {
39 "make":make,//3 android 4 ios 39 "make":make,//3 android 4 ios
40 }; 40 };
41 BaseResp<List> baseResp = await DioUtil() 41 BaseResp<List> baseResp = await DioUtil()
42 - .request<List>(context, Method.get, HttpUrl.check_update, data: params) 42 + .request<List>(context, Method.get, HttpUrl.check_update, data: params,showLoading: false)
43 .catchError((error) { 43 .catchError((error) {
44 print(error.toString()); 44 print(error.toString());
45 if(showToast){ 45 if(showToast){
@@ -103,6 +103,7 @@ class UserModel with ChangeNotifier { @@ -103,6 +103,7 @@ class UserModel with ChangeNotifier {
103 user['night'] = daily['night']; 103 user['night'] = daily['night'];
104 _saveUserInfo(User.fromJson(user)); 104 _saveUserInfo(User.fromJson(user));
105 App.sp.setBool("isLogin", true); 105 App.sp.setBool("isLogin", true);
  106 + App.sp.setString("is_call_tel", seller['is_call_tel'].toString());
106 NavigatorUtil.goHomePage(context); 107 NavigatorUtil.goHomePage(context);
107 return null; 108 return null;
108 } 109 }
@@ -111,7 +112,7 @@ class UserModel with ChangeNotifier { @@ -111,7 +112,7 @@ class UserModel with ChangeNotifier {
111 ///初始化推送token 112 ///初始化推送token
112 userTokenInit(BuildContext context, Map<String, String> params) async { 113 userTokenInit(BuildContext context, Map<String, String> params) async {
113 BaseResp<dynamic> baseResp = await DioUtil() 114 BaseResp<dynamic> baseResp = await DioUtil()
114 - .request<dynamic>(context, Method.get, HttpUrl.user_token_init, 115 + .request<dynamic>(context, Method.get, HttpUrl.user_token_init,showLoading: false,
115 data: params) 116 data: params)
116 .catchError((error) { 117 .catchError((error) {
117 print(error.toString()); 118 print(error.toString());
@@ -19,6 +19,11 @@ class Utils { @@ -19,6 +19,11 @@ class Utils {
19 Fluttertoast.showToast(msg: msg, gravity: ToastGravity.CENTER); 19 Fluttertoast.showToast(msg: msg, gravity: ToastGravity.CENTER);
20 } 20 }
21 21
  22 + //本地图片资源路径
  23 + static String getImgPath(String name, {String format: 'png'}) {
  24 + return 'assets/$name.$format';
  25 + }
  26 +
22 //给数字前面加0 27 //给数字前面加0
23 static String addZeroNumber(int num) { 28 static String addZeroNumber(int num) {
24 return num < 10 ? "0" + num.toString() : num.toString(); 29 return num < 10 ? "0" + num.toString() : num.toString();
  1 +import 'package:flutter/material.dart';
  2 +import 'package:flutter_screenutil/flutter_screenutil.dart';
  3 +import 'package:one_key/res/colors.dart';
  4 +import 'package:one_key/utils/utils.dart';
  5 +import 'package:one_key/widgets/v_empty_view.dart';
  6 +
  7 +class EmptyPage extends StatefulWidget {
  8 + final String content;
  9 + final String imgname;
  10 +
  11 + const EmptyPage({Key key, this.content, this.imgname = "bg_error"}) : super(key: key);
  12 +
  13 + @override
  14 + State<StatefulWidget> createState() {
  15 + // TODO: implement createState
  16 + return new EmptyPageState();
  17 + }
  18 +}
  19 +
  20 +class EmptyPageState extends State<EmptyPage> {
  21 + @override
  22 + Widget build(BuildContext context) {
  23 + // TODO: implement build
  24 + return Container(
  25 + width: double.infinity,
  26 + height: double.infinity,
  27 + child: Stack(
  28 + children: <Widget>[
  29 + Container(
  30 + width: double.infinity,
  31 + height: double.infinity,
  32 + margin: EdgeInsets.only(top: ScreenUtil().setWidth(132)),
  33 + child: Column(
  34 + mainAxisSize: MainAxisSize.min,
  35 + children: <Widget>[
  36 + Image.asset(
  37 + Utils.getImgPath(widget.imgname),
  38 + width: ScreenUtil().setWidth(520),
  39 + height: ScreenUtil().setWidth(384),
  40 + ),
  41 + VEmptyView(40),
  42 + Text(
  43 + widget.content ?? "数据为空",
  44 + textAlign: TextAlign.center,
  45 + strutStyle: StrutStyle(leading: ScreenUtil().setWidth(1)),
  46 + style: TextStyle(
  47 + fontSize: ScreenUtil().setSp(28),
  48 + color: MyColours.color_353535),
  49 + )
  50 + ],
  51 + ),
  52 + ),
  53 + ],
  54 + )
  55 + );
  56 + }
  57 +}
@@ -4,10 +4,12 @@ import 'package:one_key/res/colors.dart'; @@ -4,10 +4,12 @@ import 'package:one_key/res/colors.dart';
4 import 'package:one_key/widgets/v_empty_view.dart'; 4 import 'package:one_key/widgets/v_empty_view.dart';
5 5
6 class ErrorPage extends StatefulWidget{ 6 class ErrorPage extends StatefulWidget{
7 - 7 +
  8 + final String content;
  9 +
8 final VoidCallback callback; 10 final VoidCallback callback;
9 11
10 - const ErrorPage({Key key, this.callback}) : super(key: key); 12 + const ErrorPage({Key key, this.callback,this.content="哎呀~网络好像走失了呢"}) : super(key: key);
11 13
12 @override 14 @override
13 State<StatefulWidget> createState() { 15 State<StatefulWidget> createState() {
@@ -24,32 +26,31 @@ class ErrorPageState extends State<ErrorPage>{ @@ -24,32 +26,31 @@ class ErrorPageState extends State<ErrorPage>{
24 return Container( 26 return Container(
25 width: double.infinity, 27 width: double.infinity,
26 height: double.infinity, 28 height: double.infinity,
27 - child: Center(  
28 - child: Column(  
29 - mainAxisSize: MainAxisSize.min,  
30 - children: <Widget>[  
31 - Image.asset("assets/bg_error.png",width: ScreenUtil().setWidth(311),height: ScreenUtil().setWidth(215),),  
32 - VEmptyView(40),  
33 - Text("哎呀~网络好像走失了呢",style: TextStyle(fontSize: ScreenUtil().setSp(32),color: MyColours.color_353535),),  
34 - VEmptyView(20),  
35 - widget.callback!=null?GestureDetector(  
36 - onTap: widget.callback,  
37 - child: Container(  
38 - width: ScreenUtil().setWidth(148),  
39 - height: ScreenUtil().setWidth(58),  
40 - decoration: BoxDecoration(  
41 - color: MyColours.color_2bb5b7,  
42 - borderRadius: BorderRadius.all(Radius.circular(ScreenUtil().setWidth(12)))  
43 - ),  
44 - child: Center(  
45 - child: Text("点击刷新",style: TextStyle(fontSize: ScreenUtil().setSp(30),color: MyColours.color_ffffff),),  
46 - ), 29 + child: Column(
  30 + mainAxisSize: MainAxisSize.min,
  31 + children: <Widget>[
  32 + VEmptyView(120),
  33 + Image.asset("assets/bg_error.png",width: ScreenUtil().setWidth(520),height: ScreenUtil().setWidth(384),),
  34 + VEmptyView(40),
  35 + Text("${widget.content}",style: TextStyle(fontSize: ScreenUtil().setSp(28),color: MyColours.color_353535),),
  36 + VEmptyView(20),
  37 + widget.callback!=null?GestureDetector(
  38 + onTap: widget.callback,
  39 + child: Container(
  40 + width: ScreenUtil().setWidth(152),
  41 + height: ScreenUtil().setWidth(58),
  42 + decoration: BoxDecoration(
  43 + color: MyColours.app_main,
  44 + borderRadius: BorderRadius.all(Radius.circular(ScreenUtil().setWidth(28)))
47 ), 45 ),
48 - ):Container()  
49 - ],  
50 - ),  
51 - ), 46 + child: Center(
  47 + child: Text("点击刷新",style: TextStyle(fontSize: ScreenUtil().setSp(28),color: MyColours.color_ffffff),),
  48 + ),
  49 + ),
  50 + ):Container()
  51 + ],
  52 + )
52 ); 53 );
53 } 54 }
54 55
55 -}  
  56 +}
  1 +import 'package:flutter/material.dart';
  2 +import 'package:one_key/constant/state.dart';
  3 +import 'package:one_key/res/colors.dart';
  4 +import 'package:one_key/widgets/page_empty.dart';
  5 +import 'package:one_key/widgets/page_error.dart';
  6 +import 'package:one_key/widgets/page_loading.dart';
  7 +
  8 +class ExceptionPage extends StatefulWidget {
  9 + final PageState pageState;
  10 + final VoidCallback callback;
  11 +
  12 + final String emptyMsg;
  13 + final String emptyImg;
  14 + final String showMsg;
  15 + final Color defalutColor;
  16 +
  17 + const ExceptionPage(
  18 + {Key key,
  19 + this.pageState = PageState.Loading,
  20 + this.callback,
  21 + this.emptyMsg = "数据为空",
  22 + this.emptyImg = 'bg_error',
  23 + this.showMsg = '',
  24 + this.defalutColor = MyColours.color_ffffff})
  25 + : super(key: key);
  26 +
  27 + @override
  28 + State<StatefulWidget> createState() {
  29 + // TODO: implement createState
  30 + return ExceptionPageState();
  31 + }
  32 +}
  33 +
  34 +class ExceptionPageState extends State<ExceptionPage> {
  35 + @override
  36 + Widget build(BuildContext context) {
  37 + // TODO: implement build
  38 + Widget page = ErrorPage(
  39 + content: "哎呀~网络好像走失了呢",
  40 + callback: widget.callback,
  41 + );
  42 + switch (widget.pageState) {
  43 + case PageState.Loading:
  44 + page = LoadingPage(
  45 + defalutColor: widget.defalutColor, showMsg: widget.showMsg);
  46 + break;
  47 + case PageState.ConnectivityTimeOut:
  48 + page = ErrorPage(
  49 + content: "请求超时啦~刷新一下看看",
  50 + callback: widget.callback,
  51 + );
  52 + break;
  53 + case PageState.ConnectivityError:
  54 + page = ErrorPage(
  55 + content: "哎呀~网络好像走失了呢",
  56 + callback: widget.callback,
  57 + );
  58 + break;
  59 + case PageState.Empty:
  60 + page = EmptyPage(
  61 + content: widget.emptyMsg,
  62 + imgname: widget.emptyImg,
  63 + );
  64 + break;
  65 + case PageState.First:
  66 + page = Container(
  67 + width: 0,
  68 + height: 10,
  69 + color: Colors.blue,
  70 + );
  71 + break;
  72 + default:
  73 + page = ErrorPage(
  74 + content: "哎呀~网络好像走失了呢",
  75 + callback: widget.callback,
  76 + );
  77 + break;
  78 + }
  79 + return page;
  80 + }
  81 +}
  1 +import 'package:flutter/cupertino.dart';
  2 +import 'package:flutter/material.dart';
  3 +import 'package:flutter_screenutil/flutter_screenutil.dart';
  4 +import 'package:one_key/res/colors.dart';
  5 +import 'package:one_key/widgets/v_empty_view.dart';
  6 +
  7 +class LoadingPage extends StatefulWidget {
  8 + final Color defalutColor;
  9 + final String showMsg;
  10 +
  11 + const LoadingPage(
  12 + {Key key, this.defalutColor = MyColours.color_ffffff, this.showMsg})
  13 + : super(key: key);
  14 +
  15 + @override
  16 + State<StatefulWidget> createState() {
  17 + // TODO: implement createState
  18 + return LoadingPageState();
  19 + }
  20 +}
  21 +
  22 +class LoadingPageState extends State<LoadingPage> {
  23 + @override
  24 + Widget build(BuildContext context) {
  25 + // TODO: implement build
  26 + return Scaffold(
  27 + backgroundColor: widget.defalutColor,
  28 + body: Center(
  29 + child: Column(
  30 + mainAxisAlignment: MainAxisAlignment.center,
  31 + crossAxisAlignment: CrossAxisAlignment.center,
  32 + children: <Widget>[
  33 + SizedBox(
  34 + width: ScreenUtil().setWidth(80),
  35 + height: ScreenUtil().setWidth(80),
  36 + child: CupertinoActivityIndicator()),
  37 + VEmptyView(30),
  38 + Text(
  39 + widget.showMsg,
  40 + style: TextStyle(
  41 + color: MyColours.color_666666,
  42 + fontSize: ScreenUtil().setSp(24)),
  43 + )
  44 + ],
  45 + ),
  46 + ),
  47 + );
  48 + }
  49 +}