yangshen 4 rokov pred
rodič
commit
bb70548f2c

+ 1 - 1
flutter_airplane/.idea/vcs.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="VcsDirectoryMappings">
-    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+    <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
   </component>
 </project>

+ 20 - 3
flutter_airplane/.idea/workspace.xml

@@ -4,7 +4,12 @@
     <option name="TOOL_WINDOW_CONFIGURED_FILTER" value="Show only selected application" />
   </component>
   <component name="ChangeListManager">
-    <list default="true" id="2dee10ab-de6d-4cf0-9e8e-2e73aa405f70" name="Default Changelist" comment="" />
+    <list default="true" id="2dee10ab-de6d-4cf0-9e8e-2e73aa405f70" name="Default Changelist" comment="">
+      <change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/lib/code/YSTabbar.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/code/YSTabbar.dart" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/lib/main.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/main.dart" afterDir="false" />
+    </list>
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -19,16 +24,23 @@
     </option>
   </component>
   <component name="Git.Settings">
-    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
   </component>
   <component name="ProjectId" id="1gf12YWkhfVlomgIPKVtAQ2SJqa" />
   <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
   <component name="PropertiesComponent">
     <property name="dart.analysis.tool.window.force.activate" value="false" />
     <property name="io.flutter.reload.alreadyRun" value="true" />
-    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
+    <property name="last_opened_file_path" value="$PROJECT_DIR$/lib/base" />
+    <property name="settings.editor.selected.configurable" value="project.propVCSSupport.Mappings" />
     <property name="show.migrate.to.gradle.popup" value="false" />
   </component>
+  <component name="RecentsManager">
+    <key name="CopyFile.RECENT_KEYS">
+      <recent name="$PROJECT_DIR$/lib/base" />
+      <recent name="$PROJECT_DIR$/lib/tools" />
+    </key>
+  </component>
   <component name="RunDashboard">
     <option name="ruleStates">
       <list>
@@ -67,4 +79,9 @@
       </map>
     </option>
   </component>
+  <component name="VcsManagerConfiguration">
+    <ignored-roots>
+      <path value="$PROJECT_DIR$" />
+    </ignored-roots>
+  </component>
 </project>

+ 71 - 0
flutter_airplane/lib/base/YSBase.dart

@@ -0,0 +1,71 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/cupertino.dart';
+
+class YSBase extends StatefulWidget {
+  final Widget yschild;
+  final String ystitle;
+  final StatefulWidget ysright;
+  const YSBase({Key key, this.yschild,this.ystitle,this.ysright}) : super(key: key);
+  @override
+  _YSBaseState createState() => _YSBaseState();
+}
+
+class _YSBaseState extends State<YSBase> {
+  @override
+  Widget build(BuildContext context) {
+    return Scaffold(
+      body: Stack(
+        children: [
+          Container(
+            height: MediaQuery.of(context).padding.top+70,
+            width: MediaQuery.of(context).size.width,
+            color: Color(0xFFDB5278),
+          ),
+          Container(
+            margin: EdgeInsets.only(top: 20),
+            padding: EdgeInsets.only(left: 15,right: 15),
+            height: 30+MediaQuery.of(context).padding.top,
+            width: MediaQuery.of(context).size.width,
+            child: Row(
+              mainAxisAlignment: MainAxisAlignment.spaceBetween,
+              children: [
+                Container(
+                  height: 30,
+                  width: 20,
+                  margin: EdgeInsets.only(right: 35),
+                  child: CupertinoButton(
+                    padding: EdgeInsets.all(0),
+                    child: Icon(Icons.arrow_back_ios,size: 20,color: Colors.white,),
+                    onPressed: (){
+                      FocusScope.of(context).unfocus();
+                      Navigator.pop(context);
+                    },
+                  ),
+                ),
+                Container(
+                  child: Text(widget.ystitle,style: TextStyle(color: Colors.white,fontSize: 16,decoration: TextDecoration.none,fontWeight: FontWeight.w600),textAlign: TextAlign.center,),
+                ),
+                Container(
+                  width: 55,
+                  height: 30,
+                  child: widget.ysright,
+                ),
+              ],
+            ),
+          ),
+          Container(
+            margin: EdgeInsets.only(top: 50+MediaQuery.of(context).padding.top),
+            height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-50,
+            width: MediaQuery.of(context).size.width,
+            decoration: BoxDecoration(
+                color: Color(0xFFFAF8F5),
+                borderRadius: BorderRadius.only(topLeft: Radius.circular(20),topRight: Radius.circular(20))
+            ),
+            child: widget.yschild,
+          )
+        ],
+      )
+      ,
+    );
+  }
+}

+ 9 - 5
flutter_airplane/lib/code/YSTabbar.dart

@@ -74,18 +74,22 @@ class _YSPageState extends State<YSTabbar> {
               title: Text('首页')
           ),
           BottomNavigationBarItem(
-              icon: Icon(Icons.photo),
-              title: Text('纪念册')
+              icon: Icon(Icons.calendar_today),
+              title: Text('行程')
           ),
           BottomNavigationBarItem(
-              icon: Icon(Icons.supervised_user_circle),
+              icon: Icon(Icons.camera),
+              title: Text('广场')
+          ),
+          BottomNavigationBarItem(
+              icon: Icon(Icons.person),
               title: Text('我的')
           ),
         ],
         currentIndex: _selectedIndex,
         onTap: onItemTap,
-        activeColor: Color(0xFFDB5278),
-        inactiveColor: Color(0xFFBCBCBC),
+        activeColor: Color(0xFF007AFF),
+        inactiveColor: Color(0xFF999999),
         iconSize: 25,
       ),
       tabBuilder: (context,index){

+ 1 - 1
flutter_airplane/lib/main.dart

@@ -30,7 +30,7 @@ class MyApp extends StatelessWidget {
     return MaterialApp(
       debugShowCheckedModeBanner: false,
       theme: ThemeData(
-        primaryColor: Color(0xFFDB5278),
+        primaryColor: Color(0xFF0088FF),
         visualDensity: VisualDensity.adaptivePlatformDensity,
       ),
       localeListResolutionCallback:

+ 197 - 0
flutter_airplane/lib/tools/YSNetWorking.dart

@@ -0,0 +1,197 @@
+import 'package:dio/dio.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:flutter/material.dart';
+import 'package:flutterairplane/code/YSLogin.dart';
+import 'package:fluttertoast/fluttertoast.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+String base = 'http://fy.rungyun.cn/api/';
+enum requestType{
+  put,
+  delete,
+  get,
+  post
+}
+
+ysRequestHttp(BuildContext context,requestType type,String api,var parameter) async {
+  showDialog(
+    context: context,
+    barrierDismissible: false,
+    builder: (BuildContext context) {return LoadingDialog(text: "正在请求",);}
+  );
+  try {
+    SharedPreferences prefs = await SharedPreferences.getInstance();
+    String token = prefs.getString('token');
+    Map<String, dynamic> httpHeaders = {
+      'Accept': 'application/json,*/*',
+      'Content-Type': 'application/json',
+      'Authorization': token!=null?'Bearer '+token:''
+    };
+    String url = base+api;
+    print('请求网址:$url');
+    print('token:$token');
+    print('请求参数:$parameter');
+    Response response;
+    if(type==requestType.put){
+      response = await Dio().put(url,data: parameter,options: Options(receiveTimeout: 10000,headers: httpHeaders));
+    }else if(type==requestType.post){
+      response = await Dio().post(url,data: parameter,options: Options(receiveTimeout: 10000,headers: httpHeaders));
+    }else if(type==requestType.delete){
+      response = await Dio().delete(url,data: parameter,options: Options(receiveTimeout: 10000,headers: httpHeaders));
+    }else if(type==requestType.get){
+      response = await Dio().get(url,queryParameters: Map<String, dynamic>.from(parameter),options: Options(receiveTimeout: 10000,headers: httpHeaders));
+    }
+    Navigator.of(context,rootNavigator: true).pop();
+    print('请求结果:${response.data}');
+    if(response.data is List){
+      List list = response.data;
+      return list;
+    }else{
+      Map dict = response.data;
+      if(dict['msg']!=null){
+        ysFlutterToast(context,dict['msg'].toString());
+      }else if(dict['message']!=null){
+        ysFlutterToast(context,dict['message'].toString());
+      }
+      if(api=='chapter/list' || api=='user/info' || api=='policy/list' || api=='policy/info' || api=='policy/doctor' || api=='policy/doctorInfo'){
+        return dict;
+      }else if(dict['code']==200 || dict['status']=='0000'){
+        return dict;
+      }
+    }
+  } catch (error) {
+    Navigator.of(context,rootNavigator: true).pop();
+    print('网络错误:$error');
+    if(error.message=='Http status error [401]'){
+      ysFlutterToast(context,'登录失效,请重新登录');
+      Navigator.of(context).pushAndRemoveUntil(
+          MaterialPageRoute(
+              builder: (context){
+                Future<SharedPreferences> _prefer = SharedPreferences.getInstance();
+                _prefer.then((value){
+                  value.remove('token');
+                });
+                return YSLogin();
+              }
+          ), (route) => false);
+    }else{
+      ysFlutterToast(context,'网络错误');
+    }
+  }
+}
+
+ysRequestHttpNoLoading(BuildContext context,requestType type,String api,var parameter) async {
+  try {
+    SharedPreferences prefs = await SharedPreferences.getInstance();
+    String token = prefs.getString('token');
+    Map<String, dynamic> httpHeaders = {
+      'Accept': 'application/json,*/*',
+      'Content-Type': 'application/json',
+      'Authorization': token!=null?'Bearer '+token:''
+    };
+    String url = base+api;
+    print('请求网址:$url');
+    print('token:$token');
+    print('请求参数:$parameter');
+    Response response;
+    if(type==requestType.put){
+      response = await Dio().put(url,data: parameter,options: Options(receiveTimeout: 10000,headers: httpHeaders));
+    }else if(type==requestType.post){
+      response = await Dio().post(url,data: parameter,options: Options(receiveTimeout: 10000,headers: httpHeaders));
+    }else if(type==requestType.delete){
+      response = await Dio().delete(url,data: parameter,options: Options(receiveTimeout: 10000,headers: httpHeaders));
+    }else if(type==requestType.get){
+      response = await Dio().get(url,queryParameters: Map<String, dynamic>.from(parameter),options: Options(receiveTimeout: 10000,headers: httpHeaders));
+    }
+    print('请求结果:${response.data}');
+    if(response.data is List){
+      List list = response.data;
+      return list;
+    }else{
+      Map dict = response.data;
+      if(api=='chapter/list' || api=='wike/list' || api=='upQiniuToken' || api=='basic/BodyStandard' || api=='basic/info' || api=='wike/favoriteList' || api=='policy/list'){
+        return dict;
+      }else if(dict['code']==200 || dict['status']=='0000'){
+        return dict;
+      }else{
+        if(dict['msg']!=null){
+          ysFlutterToast(context,dict['msg'].toString());
+        }else if(dict['message']!=null){
+          ysFlutterToast(context,dict['message'].toString());
+        }
+      }
+    }
+  } catch (error) {
+    print('网络错误:$error');
+    if(error.message=='Http status error [401]'){
+      ysFlutterToast(context,'登录失效,请重新登录');
+      Navigator.of(context).pushAndRemoveUntil(
+          MaterialPageRoute(
+              builder: (context){
+                Future<SharedPreferences> _prefer = SharedPreferences.getInstance();
+                _prefer.then((value){
+                  value.remove('token');
+                });
+                return YSLogin();
+              }
+          ), (route) => false);
+    }else{
+      ysFlutterToast(context,'网络错误');
+    }
+  }
+}
+
+class LoadingDialog extends Dialog {
+  final String text;
+
+  LoadingDialog({Key key, @required this.text}) : super(key: key);
+
+  @override
+  Widget build(BuildContext context) {
+    return Material(
+      type: MaterialType.transparency,
+      child: Center(
+        child: SizedBox(
+          width: 120.0,
+          height: 120.0,
+          child: Container(
+            decoration: ShapeDecoration(
+              color: Color(0xFFDB5278),
+              shape: RoundedRectangleBorder(
+                borderRadius: BorderRadius.all(
+                  Radius.circular(8.0),
+                ),
+              ),
+            ),
+            child: Column(
+              mainAxisAlignment: MainAxisAlignment.center,
+              crossAxisAlignment: CrossAxisAlignment.center,
+              children: <Widget>[
+                CircularProgressIndicator(valueColor: AlwaysStoppedAnimation<Color>(Colors.white),),
+                Padding(
+                  padding: EdgeInsets.only(top: 20.0,),
+                  child: Text(text,style: TextStyle(color: Colors.white),),
+                ),
+              ],
+            ),
+          ),
+        ),
+      ),
+    );
+  }
+}
+
+void ysFlutterToast(BuildContext context,String msg){
+  FlutterToast(context).showToast(
+    child: Container(
+      padding: EdgeInsets.only(left: 20,right: 20,top: 5,bottom: 5),
+      decoration: BoxDecoration(
+        color: Color(0xFFDB5278),
+        borderRadius: BorderRadius.all(Radius.circular(25))
+      ),
+      child: Text(msg,style: TextStyle(fontSize: 14,color: Colors.white),),
+    ),
+    gravity: ToastGravity.BOTTOM,
+    toastDuration: Duration(seconds: 2),
+  );
+}

+ 77 - 0
flutter_airplane/lib/tools/YSTools.dart

@@ -0,0 +1,77 @@
+import 'package:flutter/cupertino.dart';
+import 'package:flutter/material.dart';
+
+class YSDatePicker extends StatefulWidget {
+  final ValueSetter<String> choose;
+
+  const YSDatePicker({Key key, this.choose}) : super(key: key);
+  @override
+  _YSDatePickerState createState() => _YSDatePickerState();
+}
+
+class _YSDatePickerState extends State<YSDatePicker> {
+  String birthday = DateTime.now().year.toString()+'-'+DateTime.now().month.toString()+'-'+DateTime.now().day.toString();
+  @override
+  Widget build(BuildContext context) {
+    return Container(
+      color: Colors.transparent,
+      height: 340,
+      child: Column(
+        crossAxisAlignment: CrossAxisAlignment.end,
+        children: [
+          CupertinoButton(
+            padding: EdgeInsets.all(0),
+            child: Container(
+              height: 20,
+              child: Image.asset('lib/images/off.png'),
+            ),
+            onPressed: (){
+              Navigator.pop(context);
+            },
+          ),
+          Container(
+            height: 240,
+            padding: EdgeInsets.all(10),
+            decoration: BoxDecoration(
+                color: Colors.white,
+                borderRadius: BorderRadius.only(topLeft: Radius.circular(20),topRight: Radius.circular(20))
+            ),
+            child: CupertinoDatePicker(
+              initialDateTime: DateTime.now(),
+              onDateTimeChanged: (date) {
+                birthday = date.year.toString()+'/'+date.month.toString()+'/'+date.day.toString();
+              },
+              mode: CupertinoDatePickerMode.date,
+            ),
+          ),
+          Container(
+            height: 56,
+            width: MediaQuery.of(context).size.width,
+            color: Colors.white,
+            child: CupertinoButton(
+              padding: EdgeInsets.all(0),
+              child: Container(
+                height: 30,
+                width: 80,
+                decoration: BoxDecoration(
+                    color: Colors.white,
+                    borderRadius: BorderRadius.all(Radius.circular(15)),
+                    boxShadow: [
+                      BoxShadow(color: Colors.grey,blurRadius: 3)
+                    ]
+                ),
+                child: Text('确定',style: TextStyle(fontSize: 14,color: Color(0xFF4CC17C),decoration: TextDecoration.none,fontWeight: FontWeight.normal)),
+                alignment: Alignment.center,
+              ),
+              onPressed: (){
+                Navigator.pop(context);
+                widget.choose(birthday);
+              },
+            ),
+            alignment: Alignment.center,
+          )
+        ],
+      ),
+    );
+  }
+}