Selaa lähdekoodia

格式化时间

daxu0403 7 vuotta sitten
vanhempi
commit
8cd9d30470
5 muutettua tiedostoa jossa 40 lisäystä ja 9 poistoa
  1. 13 0
      .vscode/launch.json
  2. 9 9
      lib/pages/order_taking_page.dart
  3. 9 0
      lib/util/util.dart
  4. 7 0
      pubspec.lock
  5. 2 0
      pubspec.yaml

+ 13 - 0
.vscode/launch.json

@@ -0,0 +1,13 @@
+{
+    // 使用 IntelliSense 了解相关属性。 
+    // 悬停以查看现有属性的描述。
+    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "name": "Flutter",
+            "request": "launch",
+            "type": "dart"
+        }
+    ]
+}

+ 9 - 9
lib/pages/order_taking_page.dart

@@ -384,16 +384,15 @@ class OrderCardContainer extends StatefulWidget {
 }
 
 class _OrderCardContainerState extends State < OrderCardContainer > with SingleTickerProviderStateMixin {
-  Animation < int > animation;
+  Animation < dynamic > animation;
   AnimationController controller;
   String str = "联系方式";
   bool animationStatus = true;
   @override
   initState() {
     super.initState();
-    controller = new AnimationController(
-      duration: const Duration(milliseconds: 200), vsync: this);
-    animation = new Tween(begin: 0, end: 230).animate(controller);
+    controller = new AnimationController(duration: const Duration(milliseconds: 200), vsync: this);
+    animation = Tween(begin: 0, end: 230).animate(controller);
     animation.addStatusListener((status) {
       if (status == AnimationStatus.completed) {
         //动画执行结束时反向执行动画
@@ -444,7 +443,7 @@ class _OrderCardContainerState extends State < OrderCardContainer > with SingleT
       child: Row(
         mainAxisAlignment: MainAxisAlignment.spaceBetween,
         children: < Widget > [
-          GestureDetector(
+          InkWell(
             child: Container(
               width: ScreenUtil.getInstance().setWidth(100),
               height: ScreenUtil.getInstance().setHeight(48),
@@ -463,7 +462,7 @@ class _OrderCardContainerState extends State < OrderCardContainer > with SingleT
               }
             },
           ),
-          GestureDetector(
+          InkWell(
             child: Container(
               width: ScreenUtil.getInstance().setWidth(94),
               height: ScreenUtil.getInstance().setWidth(48),
@@ -509,12 +508,12 @@ class AnimatedOpen extends AnimatedWidget {
   final OrderList openInfo;
   AnimatedOpen({
     Key key,
-    Animation < int > animation,
+    Animation < dynamic > animation,
     @required this.openInfo
   }): super(key: key, listenable: animation);
 
   Widget build(BuildContext context) {
-    final Animation < int > animation = listenable;
+    final Animation < dynamic > animation = listenable;
     return Container(
       height: ScreenUtil.getInstance().setHeight(animation.value),
       child: orderDetailInfo(openInfo),
@@ -522,13 +521,14 @@ class AnimatedOpen extends AnimatedWidget {
   }
 }
 Widget orderNoRow(String orderNo, int createTime) { //订单号及时间
+  String date = fromatDate(createTime);
   return Container(
     margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
     child: Row(
       mainAxisAlignment: MainAxisAlignment.spaceBetween,
       children: < Widget > [
         Text("订单号:${orderNo}", style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
-        Text('${createTime}', style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
+        Text('${date}', style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
       ],
     ),
   );

+ 9 - 0
lib/util/util.dart

@@ -1,6 +1,8 @@
 import 'package:flutter/material.dart';
 import 'package:dio/dio.dart';
 import '../showAlert.dart';
+import 'package:intl/intl.dart';
+
 bool isNotError(BuildContext context,json){
   //print('-----------'+json+'----------');
   if(json is DioError){
@@ -30,3 +32,10 @@ alertError(BuildContext context,String str){
 bool isChinaPhoneLegal(String str) {
   return new RegExp('^((13[0-9])|(15[^4])|(166)|(17[0-8])|(18[0-9])|(19[8-9])|(147,145))\\d{8}\$').hasMatch(str);
 }
+
+String fromatDate(int myDate){
+  var now  = DateTime.fromMicrosecondsSinceEpoch(myDate*1000);
+  var formatter = new DateFormat('yyyy-MM-dd HH:mm:ss');
+  String date = formatter.format(now);
+  return date;
+}

+ 7 - 0
pubspec.lock

@@ -81,6 +81,13 @@ packages:
     description: flutter
     source: sdk
     version: "0.0.0"
+  intl:
+    dependency: "direct main"
+    description:
+      name: intl
+      url: "https://pub.dartlang.org"
+    source: hosted
+    version: "0.15.8"
   lpinyin:
     dependency: transitive
     description:

+ 2 - 0
pubspec.yaml

@@ -31,6 +31,8 @@ dependencies:
   flutter_picker: ^1.0.8
   #拨打电话及调整web页面插件
   url_launcher: ^5.0.1
+  #格式化日期包
+  intl: ^0.15.8
 
 dev_dependencies:
   flutter_test: