jyj преди 4 години
родител
ревизия
15493f9c81

BIN
assets/images/video_image.png


+ 242 - 63
lib/internal/bbs/page/interrogation_page.dart

@@ -18,6 +18,14 @@ import 'package:shared_preferences/shared_preferences.dart';
 import 'package:liftmanager/common/common.dart';
 import 'package:flustars/flustars.dart' as flustars;
 import 'package:liftmanager/utils/theme_utils.dart';
+import 'package:chewie/chewie.dart';
+import 'package:liftmanager/utils/oss_upload.dart';
+import 'package:video_player/video_player.dart';
+import 'package:liftmanager/widgets/selected_video_change.dart';
+import 'package:liftmanager/utils/utils.dart';
+import 'package:orientation/orientation.dart';
+import 'package:flutter/services.dart';
+import 'package:liftmanager/utils/fast_notification.dart';
 
 class InterrogationPage extends StatefulWidget {
   InterrogationPage(this.brandName,this.brandId);
@@ -37,8 +45,11 @@ class InterrogationPageState extends State<InterrogationPage> {
   
 
   List<String> imagesUrl = [];
-  List<String> imagesUrlVideo = [];
-   List<String> videoUrl = [];
+  String videoUrl;
+  String str;
+  double percent = 0.0;
+  String addressName = "";
+  VideoPlayerController _controller;
   @override
   void initState() {
     super.initState();
@@ -68,8 +79,8 @@ class InterrogationPageState extends State<InterrogationPage> {
       // imagesUrl.add(res.path);
       dismissLoading(context);
       setState(() {
-        videoUrl.add(res.pathUrl);
-        imagesUrlVideo.add(res.coverUrl);
+        // videoUrl.add(res.pathUrl);
+        // imagesUrlVideo.add(res.coverUrl);
       });
     }, onError: (code, msg) {
       dismissLoading(context);
@@ -135,8 +146,8 @@ class InterrogationPageState extends State<InterrogationPage> {
         // print(_imageFile);
         // print(jsonEncode(_imageFile));
         print(123);
-        
-        upLoadFileOnceVideo(_imageFile.path);
+        _uploadImage(_imageFile.path);
+        // upLoadFileOnceVideo(_imageFile.path);
         setState(() {});
       }
     } catch (e) {
@@ -144,6 +155,49 @@ class InterrogationPageState extends State<InterrogationPage> {
     }
   }
 
+  void _uploadImage(filePath) async {
+    showPercent(context, (){
+      dismissLoading(context);
+      toasts("上传失败");
+    },(){
+      if(videoUrl == null && str != null){
+        setState(() {
+            videoUrl = str;
+            print("videoUrl:"+videoUrl);
+            dismissLoading(context);
+            toasts("上传成功");
+          });
+      }
+    });
+    String uploadName = OssUtil.instance.getImageUploadName(filePath);
+    await NewApiService.uploadImage(context, uploadName, filePath).then((data) {
+      if (data.statusCode == 200) {
+        str = NewApiUrl.URL_UPLOAD_IMAGE_OSS + "/" + uploadName;
+        print("str:"+str);
+        print(videoUrl);
+        if(str != null){
+          Map obj = {
+            "uploadName":uploadName,
+            "success":true
+          };
+          FastNotification.push("percent",obj);
+        }
+      }else {
+        Map obj = {
+            "uploadName":uploadName,
+            "success":false
+          };
+        FastNotification.push("percent",obj);
+      }
+    }).catchError((data) {
+      Map obj = {
+            "uploadName":uploadName,
+            "success":false
+          };
+      FastNotification.push("percent",obj);
+    });
+  }
+
 
     // 焦点控制
     // FocusNode _focusNode1 = new FocusNode(); 
@@ -408,7 +462,7 @@ class InterrogationPageState extends State<InterrogationPage> {
               ),
               Container(
                 width: width,
-                padding: EdgeInsets.only(left:15),
+                padding: EdgeInsets.only(left:15,bottom:15),
                 child: Text(
                                                         "(建议时长3分钟,建议大小50M)",
                                                         style: TextStyle(
@@ -420,59 +474,114 @@ class InterrogationPageState extends State<InterrogationPage> {
                                                             textAlign: TextAlign.left,
                                                       ),
               ),
-              Container(
-                color: ThemeUtils.getTabsBg(context),
-                child: GridView.builder(
-                  shrinkWrap: true,
-                  padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
-                  physics: NeverScrollableScrollPhysics(),
-                  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
-                      crossAxisCount: 3, childAspectRatio: 1.18),
-                  itemCount: videoUrl.length >= 1 ? 1 : videoUrl.length + 1,
-                  itemBuilder: (_, index) {
-                    return Stack(
-                      children: <Widget>[
-                        Center(
-                          child: SelectedImage(
-                              image: index < videoUrl.length ? imagesUrlVideo[index] : null,
-                              index:index,
-                              onTap: () {
-                                if(index >= videoUrl.length){
-                                  selectPicker("video");
-                                }
-                                FocusScope.of(context).requestFocus(FocusNode());
-                                print(index);
-                                print(videoUrl);
-                              }),
-                        ),
-                        index < videoUrl.length?Positioned(
-                          top:0,
-                          right:0,
-                          child:GestureDetector(
-                            onTap: (){
-                              print(index);
-                              videoUrl.remove(videoUrl[index]);
-                              imagesUrlVideo.remove(imagesUrlVideo[index]);
-                              setState(() {
+              // Container(
+              //   color: ThemeUtils.getTabsBg(context),
+              //   child: GridView.builder(
+              //     shrinkWrap: true,
+              //     padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
+              //     physics: NeverScrollableScrollPhysics(),
+              //     gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+              //         crossAxisCount: 3, childAspectRatio: 1.18),
+              //     itemCount: videoUrl.length >= 1 ? 1 : videoUrl.length + 1,
+              //     itemBuilder: (_, index) {
+              //       return Stack(
+              //         children: <Widget>[
+              //           Center(
+              //             child: SelectedImage(
+              //                 image: index < videoUrl.length ? imagesUrlVideo[index] : null,
+              //                 index:index,
+              //                 onTap: () {
+              //                   if(index >= videoUrl.length){
+              //                     selectPicker("video");
+              //                   }
+              //                   FocusScope.of(context).requestFocus(FocusNode());
+              //                   print(index);
+              //                   print(videoUrl);
+              //                 }),
+              //           ),
+              //           index < videoUrl.length?Positioned(
+              //             top:0,
+              //             right:0,
+              //             child:GestureDetector(
+              //               onTap: (){
+              //                 print(index);
+              //                 videoUrl.remove(videoUrl[index]);
+              //                 imagesUrlVideo.remove(imagesUrlVideo[index]);
+              //                 setState(() {
                                 
-                              });
-                            },
-                            child:Icon(
-                                IconData(
-                                  0xe62a,
-                                  fontFamily:"myfont"
-                                ),
-                                size: 24.0,
-                                color:Color(0xff999999),
+              //                 });
+              //               },
+              //               child:Icon(
+              //                   IconData(
+              //                     0xe62a,
+              //                     fontFamily:"myfont"
+              //                   ),
+              //                   size: 24.0,
+              //                   color:Color(0xff999999),
+              //                 ),
+              //             )
+              //           ):Container(child: null,)
+              //         ],
+              //       );
+              //     },
+              //   )
+              // ),
+              Container(
+                    color: ThemeUtils.getDialogTextFieldColor(context),
+                    child: GridView.builder(
+                      shrinkWrap: true,
+                      padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
+                      physics: NeverScrollableScrollPhysics(),
+                      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+                          crossAxisCount: 1, childAspectRatio: 1.18),
+                      itemCount: 1,
+                      itemBuilder: (_, index) {
+                        return Stack(
+                          children: <Widget>[
+                            Center(
+                              child: SelectedVideo(
+                                image: videoUrl,
+                                index: index,
+                                videoPlay:videoPlay(),
+                                onTap: () {
+                                  if(videoUrl == null){
+                                    selectPicker("video");
+                                  }
+                                  
+                                },
                               ),
-                          )
-                        ):Container(child: null,)
-                      ],
-                    );
-                  },
-                )
-              ),
-              
+                            ),
+                            videoUrl != null
+                                ? Positioned(
+                                    top: 0,
+                                    right: 0,
+                                    child: GestureDetector(
+                                      onTap: () {
+                                        print(index);
+                                        
+                                        // imagesUrl = null;
+                                        setState(() {
+                                          videoUrl = null;
+                                          str = null;
+                                          _controller.pause();
+                                          // player.reset();
+                                        });
+                                      },
+                                      child: Icon(
+                                        IconData(0xe62a, fontFamily: "myfont"),
+                                        size: 24.0,
+                                        color: Color(0xff999999),
+                                      ),
+                                    ),
+                                  )
+                                : Container(
+                                    child: null,
+                                  )
+                          ],
+                        );
+                      },
+                    ),
+                  ),
             ],
           ),
               )
@@ -508,10 +617,10 @@ class InterrogationPageState extends State<InterrogationPage> {
                             if(imagesUrl.length > 0){
                               imgs = imagesUrl.join(",");
                             }
-                            String videoImgs = "";
-                            if(videoUrl.length > 0){
-                              videoImgs = videoUrl.join(",");
-                            }
+                            // String videoImgs = "";
+                            // if(videoUrl.length > 0){
+                            //   videoImgs = videoUrl.join(",");
+                            // }
                             
                           if((_formKey.currentState as FormState).validate()){
                             dynamic obj = {
@@ -520,7 +629,7 @@ class InterrogationPageState extends State<InterrogationPage> {
                               "expression":_questionController.text,
                               "usedMethods":_methodController.text,
                               "imgs":imgs,
-                              "videoUrl":videoImgs,
+                              "videoUrl":videoUrl,
                               "createUserId":int.parse(flustars.SpUtil.getString(Constant.userId)),
                               "chargerId":1
                             };
@@ -564,4 +673,74 @@ class InterrogationPageState extends State<InterrogationPage> {
     prefs.setString("questionType", type);
     
   }
+
+  Widget videoPlay() {
+    
+    _controller = VideoPlayerController.network(
+                                        Utils.getImagePath(videoUrl) 
+                                        // imgFontUrl + detailObj.url
+                                        );
+    double width = MediaQuery.of(context).size.width;
+    return 
+    // Container(
+    //                     width: width,
+    //                     height: width*0.6,
+    //                     alignment: Alignment.center,
+    //                     child: FijkView(
+    //                       player: player,
+    //                       color: Colors.black,
+    //                       fit:FijkFit.fill,
+    //                       // cover: NetworkImage(detailObj.cover),
+    //                       // cover: new Image(image: detailObj.cover!=null&& detailObj.cover!=""?NetworkImage(detailObj.cover):AssetImage("assets/images/video_image.png"),).image,
+    //                       // 
+    //                     ),
+    //                   );
+    Container(
+                          padding: EdgeInsets.only(
+                              left: ScreenUtil().setWidth(15),
+                              right: ScreenUtil().setWidth(15),
+                              top: ScreenUtil().setWidth(15)),
+                          child: ClipRRect(
+                            borderRadius: BorderRadius.circular(5),
+                            child: 
+                            new Chewie(
+                              controller: ChewieController(
+                                videoPlayerController:
+                                    // VideoPlayerController.network(
+                                    //     imgFontUrl + detailObj.url
+                                    //     ),
+                                    _controller,
+                                aspectRatio: 3 / 2,
+                                allowFullScreen:false,
+                                autoPlay: false,
+                                looping: true,
+                                // startAt: Duration(seconds: 1,minutes: 1),
+                                showControls: true,
+                                deviceOrientationsAfterFullScreen:[DeviceOrientation.portraitUp],
+                                // 占位图
+                                // placeholder: Image.network(
+                                //     imgFontUrl+detailObj.cover,
+                                //     fit: BoxFit.contain,
+
+                                //   ),
+
+                                // 是否在 UI 构建的时候就加载视频
+                                autoInitialize: true,
+
+                                // 拖动条样式颜色
+                                materialProgressColors:
+                                    new ChewieProgressColors(
+                                  playedColor: Colors.red,
+                                  handleColor: Colors.blue,
+                                  backgroundColor: Colors.grey,
+                                  bufferedColor: Colors.lightGreen,
+                                ),
+                              ),
+                            ),
+
+                            
+                            
+                          )
+                      );
+  }
 }

+ 45 - 78
lib/internal/bbs/page/tab/video/video_detail.dart

@@ -28,7 +28,6 @@ import 'package:flustars/flustars.dart' as FlutterStars;
 import 'package:liftmanager/common/common.dart';
 import 'package:flutter/services.dart';
 import 'package:orientation/orientation.dart';
-import 'package:fijkplayer/fijkplayer.dart';
 
 class VideoDetail extends StatefulWidget {
   VideoDetail(this.id);
@@ -53,24 +52,6 @@ class VideoDetailState extends State<VideoDetail> {
     
   }
 
-  void _fijkValueListener() {
-    FijkValue value = player.value;
-
-    print(value.fullScreen);
-    print("fullScreenfullScreenfullScreenfullScreen------------------");
-    // if(value.fullScreen == false){
-    //   OrientationPlugin.forceOrientation(DeviceOrientation.portraitUp);
-    // }
-}
-
-  final FijkPlayer player = FijkPlayer();
-  bool _isPlaying = false;
-  bool _isFullscreen = false;
-  bool get isPlaying => _isPlaying;
-  set isPlaying(bool playing) {
-    print("playing  $playing");
-    _isPlaying = playing;
-  }
   bool _hasData = false;
   VideoDetailModel detailObj;
   // var _storageLikeId;
@@ -88,8 +69,8 @@ class VideoDetailState extends State<VideoDetail> {
                                         Utils.getImagePath(detailObj.url) 
                                         // imgFontUrl + detailObj.url
                                         );
-        player.setDataSource(detailObj.url, autoPlay: false);
-        player.addListener(_fijkValueListener);
+        // player.setDataSource(detailObj.url, autoPlay: false,showCover: true);
+        // player.addListener(_fijkValueListener);
         setState(() {});
       }
     }, onError: (code, msg) {
@@ -174,8 +155,8 @@ class VideoDetailState extends State<VideoDetail> {
     //   DeviceOrientation.portraitUp,
     // ]);
     // OrientationPlugin.forceOrientation(DeviceOrientation.portraitUp);
-    player.release();
-    player.removeListener(_fijkValueListener);
+    // player.release();
+    // player.removeListener(_fijkValueListener);
     super.dispose();
   }
 
@@ -206,68 +187,54 @@ class VideoDetailState extends State<VideoDetail> {
                     mainAxisAlignment: MainAxisAlignment.start,
                     crossAxisAlignment: CrossAxisAlignment.start,
                     children: <Widget>[
-                      
+                 
                       Container(
-                        width: width,
-                        height: width*0.6,
-                        alignment: Alignment.center,
-                        child: FijkView(
-                          player: player,
-                          color: Colors.black,
-                          fit:FijkFit.contain,
-                          cover: new Image(image: detailObj.cover!=null?NetworkImage(detailObj.cover):AssetImage("assets/images/no_image.png"),).image,
-                          // 
-                        ),
-                      ),
-
-
-                      // Container(
-                      //     padding: EdgeInsets.only(
-                      //         left: ScreenUtil().setWidth(15),
-                      //         right: ScreenUtil().setWidth(15),
-                      //         top: ScreenUtil().setWidth(15)),
-                      //     child: ClipRRect(
-                      //       borderRadius: BorderRadius.circular(5),
-                      //       child: 
-                      //       new Chewie(
-                      //         controller: ChewieController(
-                      //           videoPlayerController:
-                      //               // VideoPlayerController.network(
-                      //               //     imgFontUrl + detailObj.url
-                      //               //     ),
-                      //               _controller,
-                      //           aspectRatio: 3 / 2,
-                      //           allowFullScreen:true,
-                      //           autoPlay: false,
-                      //           looping: true,
-                      //           // startAt: Duration(seconds: 1,minutes: 1),
-                      //           showControls: true,
-                      //           deviceOrientationsAfterFullScreen:[DeviceOrientation.portraitUp],
-                      //           // 占位图
-                      //           // placeholder: Image.network(
-                      //           //     imgFontUrl+detailObj.cover,
-                      //           //     fit: BoxFit.contain,
+                          padding: EdgeInsets.only(
+                              left: ScreenUtil().setWidth(15),
+                              right: ScreenUtil().setWidth(15),
+                              top: ScreenUtil().setWidth(15)),
+                          child: ClipRRect(
+                            borderRadius: BorderRadius.circular(5),
+                            child: 
+                            new Chewie(
+                              controller: ChewieController(
+                                videoPlayerController:
+                                    // VideoPlayerController.network(
+                                    //     imgFontUrl + detailObj.url
+                                    //     ),
+                                    _controller,
+                                aspectRatio: 3 / 2,
+                                allowFullScreen:true,
+                                autoPlay: false,
+                                looping: true,
+                                // startAt: Duration(seconds: 1,minutes: 1),
+                                showControls: true,
+                                deviceOrientationsAfterFullScreen:[DeviceOrientation.portraitUp],
+                                // 占位图
+                                // placeholder: Image.network(
+                                //     imgFontUrl+detailObj.cover,
+                                //     fit: BoxFit.contain,
 
-                      //           //   ),
+                                //   ),
 
-                      //           // 是否在 UI 构建的时候就加载视频
-                      //           autoInitialize: true,
+                                // 是否在 UI 构建的时候就加载视频
+                                autoInitialize: true,
 
-                      //           // 拖动条样式颜色
-                      //           materialProgressColors:
-                      //               new ChewieProgressColors(
-                      //             playedColor: Colors.red,
-                      //             handleColor: Colors.blue,
-                      //             backgroundColor: Colors.grey,
-                      //             bufferedColor: Colors.lightGreen,
-                      //           ),
-                      //         ),
-                      //       ),
+                                // 拖动条样式颜色
+                                materialProgressColors:
+                                    new ChewieProgressColors(
+                                  playedColor: Colors.red,
+                                  handleColor: Colors.blue,
+                                  backgroundColor: Colors.grey,
+                                  bufferedColor: Colors.lightGreen,
+                                ),
+                              ),
+                            ),
 
                             
                             
-                      //     )
-                      // ),
+                          )
+                      ),
                       Container(
                         width: width,
                         padding: EdgeInsets.only(

+ 580 - 0
lib/internal/bbs/page/tab/video/video_upload copy.dart

@@ -0,0 +1,580 @@
+import 'package:flutter/material.dart';
+import 'package:liftmanager/res/gaps.dart';
+import 'package:liftmanager/net/api_service.dart';
+import 'package:liftmanager/utils/toast.dart';
+import 'package:liftmanager/widgets/app_bar.dart';
+import 'package:liftmanager/internal/search/search_router.dart';
+import 'package:liftmanager/widgets/app_search_bar.dart';
+import 'package:liftmanager/res/resources.dart';
+import 'package:liftmanager/routers/fluro_navigator.dart';
+import 'package:liftmanager/widgets/load_image.dart';
+import 'package:liftmanager/widgets/selected_image_change.dart';
+import 'package:image_picker/image_picker.dart';
+import 'dart:io';
+import 'package:liftmanager/widgets/bbs_content.dart';
+import 'package:flutter_screenutil/flutter_screenutil.dart';
+import 'package:flutter_spinkit/flutter_spinkit.dart';
+import 'package:video_player/video_player.dart';
+import 'package:liftmanager/utils/image_utils.dart';
+import 'package:liftmanager/internal/bbs/bbs_router.dart';
+import 'package:flustars/flustars.dart' as FlutterStars;
+import 'package:liftmanager/common/common.dart';
+import 'package:liftmanager/utils/theme_utils.dart';
+
+class VideoUpload extends StatefulWidget {
+  // BrandPage(this.id);
+
+  // final String id;
+
+  @override
+  State<StatefulWidget> createState() {
+    return VideoUploadState();
+  }
+}
+
+class VideoUploadState extends State<VideoUpload> {
+  // NewsDetailItem item = NewsDetailItem();
+
+  ScrollController _scrollController = new ScrollController();
+  String brandChiose = '请选择';
+  String brandName = "品牌";
+  int brandIdss;
+  bool sortBool = true;
+  List<String> imagesUrl = [];
+  List<String> videoUrl = [];
+  @override
+  void initState() {
+    super.initState();
+  }
+
+  upLoadFileOnce(path) {
+    showLoading(context, "正在上传...");
+    NewApiService().upload(path, onSuccess: (res) {
+      // imagesUrl.add(res.path);
+      dismissLoading(context);
+
+      setState(() {
+        videoUrl = [];
+        imagesUrl = [];
+        videoUrl.add(res.pathUrl);
+        imagesUrl.add(res.coverUrl);
+      });
+    }, onError: (code, msg) {
+      dismissLoading(context);
+      toasts(msg);
+    });
+  }
+
+  List<dynamic> brandList;
+  Future getBrandList() async {
+    await NewApiService().getBrandListNoPage(onSuccess: (res) {
+      if (res != null) {
+        brandList = res;
+        setState(() {});
+      }
+    }, onError: (code, msg) {
+      toasts(msg);
+    });
+  }
+
+  ///选择视频
+  void selectPicker() {
+    showDialog(
+        context: context,
+        builder: (BuildContext context) {
+          return SimpleDialog(
+              title: Text("选择方式"),
+              children: ["拍照", '从手机相册选择'].map((String value) {
+                print("$value");
+                return SimpleDialogOption(
+                  child: Text(
+                    "${value}",
+                    style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
+                  ),
+                  onPressed: () {
+                    _getImage(value == '拍照' ? 1 : 0);
+                    Navigator.of(context).pop();
+                  },
+                );
+              }).toList());
+        });
+  }
+
+  void _getImage(int key) async {
+    print(key);
+    print(333);
+    try {
+      var _imageFile = await ImagePicker.pickVideo(
+        source: key == 1 ? ImageSource.camera : ImageSource.gallery,
+      );
+      if (_imageFile != null) {
+        upLoadFileOnce(_imageFile.path);
+        setState(() {});
+      }
+    } catch (e) {
+      toasts("没有权限,无法打开相册!");
+    }
+  }
+
+  // 焦点控制
+  FocusNode focusNode1 = new FocusNode();
+  GlobalKey _formKey = new GlobalKey<FormState>();
+  TextEditingController _titleController = new TextEditingController();
+  TextEditingController _descController = new TextEditingController();
+  
+
+  @override
+  Widget build(BuildContext context) {
+    double width = MediaQuery.of(context).size.width;
+    double height = MediaQuery.of(context).size.height;
+
+    return Scaffold(
+      resizeToAvoidBottomPadding: false, //不让键盘弹上去
+      appBar: MyAppBar(
+        centerTitle: "上传视频",
+      ),
+      body: GestureDetector(
+        onTap: () {
+          // 点击空白页面关闭键盘
+          FocusScope.of(context).requestFocus(focusNode1);
+        },
+        child: Stack(
+          children: <Widget>[
+            Container(
+                child: ListView(children: <Widget>[
+              Form(
+                key: _formKey, //设置globalKey,用于后面获取FormState
+                // autovalidate: true, //开启自动校验
+                child: Column(
+                  children: <Widget>[
+                    ChioseThisRight(
+                        label: "电梯品牌",
+                        value: brandChiose,
+                        fun: () {
+                          setState(() {
+                            // brandChiose = brandListChiose[index];
+                            sortBool = false;
+                            print(5656333);
+                          });
+                          getBrandList();
+                          // Navigator.maybePop(context);
+                        }),
+                    Row(
+                      crossAxisAlignment: CrossAxisAlignment.start,
+                      mainAxisAlignment: MainAxisAlignment.start,
+                      children: <Widget>[
+                        Container(
+                          padding: EdgeInsets.only(
+                              left: ScreenUtil().setWidth(15),
+                              top: ScreenUtil().setWidth(10),
+                              bottom: ScreenUtil().setWidth(5)),
+                          child: Text(
+                            "视频标题",
+                            style: TextStyle(
+                              // fontSize:ScreenUtil().setSp(14),
+                            ),
+                            textAlign: TextAlign.left,
+                          ),
+                        ),
+                      ],
+                    ),
+                    Container(
+                      height: 80,
+                      padding: EdgeInsets.only(
+                          left: ScreenUtil().setWidth(15),
+                          right: ScreenUtil().setWidth(15),
+                          bottom: ScreenUtil().setWidth(20)),
+                      child: TextFormField(
+                          // autofocus: true,
+                          maxLength: 50,
+                          cursorColor: Color(0xffcccccc),
+                          controller: _titleController,
+                          maxLines: 5,
+                          decoration: InputDecoration(
+                            contentPadding: EdgeInsets.all(0),
+
+                            hintText: '请输入你上传视频的标题',
+                            hintStyle: TextStyle(color: Color(0xffcccccc)),
+                            focusedBorder: InputBorder.none,
+                            border: InputBorder.none,
+                            // filled: true, // 背景色
+                            // fillColor: Colors.cyan.withAlpha(35),
+                            // icon: Icon(Icons.person)
+                          ),
+
+                          // 校验
+                          validator: (val) {
+                            return val.trim().length > 0 ? null : "不能为空";
+                          }),
+                    ),
+                    SizedBox(
+                      height: 6,
+                      child: Container(color: ThemeUtils.getDialogTextFieldColor(context)),
+                    ),
+                    Row(
+                      crossAxisAlignment: CrossAxisAlignment.start,
+                      mainAxisAlignment: MainAxisAlignment.start,
+                      children: <Widget>[
+                        Container(
+                          padding: EdgeInsets.only(
+                              left: ScreenUtil().setWidth(15),
+                              top: ScreenUtil().setWidth(10),
+                              bottom: ScreenUtil().setWidth(5)),
+                          child: Text(
+                            "视频简介",
+                            style: TextStyle(
+                              // fontSize:ScreenUtil().setSp(14),
+                            ),
+                            textAlign: TextAlign.left,
+                          ),
+                        ),
+                      ],
+                    ),
+                    Container(
+                      height: 120,
+                      padding: EdgeInsets.only(
+                          left: ScreenUtil().setWidth(15),
+                          right: ScreenUtil().setWidth(15),
+                          bottom: ScreenUtil().setWidth(20)),
+                      child: TextFormField(
+                          // autofocus: true,
+                          maxLength: 500,
+                          cursorColor: Color(0xffcccccc),
+                          controller: _descController,
+                          maxLines: 5,
+                          decoration: InputDecoration(
+                            contentPadding: EdgeInsets.all(0),
+
+                            hintText: '请输入您上传视频的简介',
+                            hintStyle: TextStyle(color: Color(0xffcccccc)),
+                            focusedBorder: InputBorder.none,
+                            border: InputBorder.none,
+                            // filled: true, // 背景色
+                            // fillColor: Colors.cyan.withAlpha(35),
+                            // icon: Icon(Icons.person)
+                          ),
+
+                          // 校验
+                          validator: (val) {
+                            return val.trim().length > 0 ? null : "不能为空";
+                          }),
+                    ),
+                    SizedBox(
+                      height: 6,
+                      child: Container(color: ThemeUtils.getDialogTextFieldColor(context)),
+                    ),
+                    Container(
+                width: width,
+                padding: EdgeInsets.only(left:15,top:15),
+                child: Text(
+                                                        "(建议时长3分钟,建议大小50M)",
+                                                        style: TextStyle(
+                                                          color: Colors.red,
+                                                            fontSize:
+                                                                ScreenUtil()
+                                                                    .setSp(14),
+                                                            ),
+                                                            textAlign: TextAlign.left,
+                                                      ),
+              ),
+                    Container(
+                        color: ThemeUtils.getTabsBg(context),
+                        child: GridView.builder(
+                          shrinkWrap: true,
+                          padding:
+                              const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
+                          physics: NeverScrollableScrollPhysics(),
+                          gridDelegate:
+                              SliverGridDelegateWithFixedCrossAxisCount(
+                                  crossAxisCount: 3, childAspectRatio: 1.18),
+                          itemCount:
+                              videoUrl.length >= 1 ? 1 : videoUrl.length + 1,
+                          itemBuilder: (_, index) {
+                            return Stack(
+                              children: <Widget>[
+                                Center(
+                                  child: SelectedImage(
+                                      image: index < videoUrl.length
+                                          ? imagesUrl[index]
+                                          : null,
+                                      // image: index < videoUrl.length ? videoUrl[index] : null,
+                                      index: index,
+                                      onTap: () {
+                                        if (index >= videoUrl.length) {
+                                          selectPicker();
+                                        }
+                                        FocusScope.of(context)
+                                            .requestFocus(FocusNode());
+                                        print(index);
+                                        print(videoUrl);
+                                      }),
+                                ),
+                                index < videoUrl.length
+                                    ? Positioned(
+                                        top: 0,
+                                        right: 0,
+                                        child: GestureDetector(
+                                          onTap: () {
+                                            print(index);
+                                            videoUrl.remove(videoUrl[index]);
+                                            imagesUrl.remove(imagesUrl[index]);
+                                            setState(() {});
+                                          },
+                                          child: Icon(
+                                            IconData(0xe62a,
+                                                fontFamily: "myfont"),
+                                            size: 24.0,
+                                            color: Color(0xff999999),
+                                          ),
+                                        ))
+                                    : Container(
+                                        child: null,
+                                      )
+                              ],
+                            );
+                          },
+                        )),
+                    SizedBox(
+                      height: ScreenUtil().setWidth(80),
+                    ),
+                  ],
+                ),
+              )
+            ])),
+            Positioned(
+                bottom: 0,
+                left: 0,
+                child: Container(
+                  width: width,
+                  padding: EdgeInsets.only(
+                      top: ScreenUtil().setWidth(15),
+                      bottom: ScreenUtil().setWidth(15),
+                      left: ScreenUtil().setWidth(25),
+                      right: ScreenUtil().setWidth(25)),
+                  color: ThemeUtils.getDialogTextFieldColor(context),
+                  child: Container(
+                    height: ScreenUtil().setWidth(44),
+                    decoration: BoxDecoration(
+                      borderRadius:
+                          BorderRadius.circular(ScreenUtil().setWidth(22)),
+                      gradient: const LinearGradient(
+                          colors: [Color(0xFF00D9FF), Color(0xFF0287FF)]),
+                    ),
+                    child: FlatButton(
+                      // padding: EdgeInsets.all(15.0),
+                      child: Text("提交"),
+                      textColor: Colors.white,
+                      onPressed: () {
+                        if (brandIdss == null) {
+                          toasts("请选择品牌");
+                          return;
+                        }
+                        if (videoUrl.length < 1) {
+                          toasts("请上传视频");
+                          return;
+                        }
+                        String videos = videoUrl.join(",");
+                        String images = imagesUrl.join(",");
+                        if ((_formKey.currentState as FormState).validate()) {
+                          dynamic obj = {
+                            "brandId": brandIdss,
+                            "title": _titleController.text,
+                            "descr": _descController.text,
+                            "url": videos,
+                            "cover": images,
+                            "checkFlag": 2,
+                            "statuz": 1,
+                            "platformFlag": 1,
+                            "userId":FlutterStars.SpUtil.getString(Constant.userId),
+                          };
+                          showLoading(context, "正在提交...");
+
+                          NewApiService().addVideo(obj, onSuccess: (res) {
+                            dismissLoading(context);
+                            toasts("提交成功");
+
+                            Navigator.pop(context);
+                          }, onError: (code, msg) {
+                            dismissLoading(context);
+                            toasts(msg);
+                          });
+                        }
+                      },
+                    ),
+                  ),
+                )),
+            !sortBool
+                ? Positioned(
+                    top: 0,
+                    left: 0,
+                    child: Container(
+                        width: width,
+                        height: height,
+                        color: Color.fromRGBO(0, 0, 0, 0.5)))
+                : Container(child: null),
+            !sortBool
+                ? Positioned(
+                    top: 0,
+                    right: 0,
+                    child: Container(
+                        width: width / 4 * 3,
+                        height: height,
+                        color: Colors.white,
+                        padding: EdgeInsets.all(10),
+                        child: ListView(
+                          children: <Widget>[
+                            Container(
+                              padding:
+                                  EdgeInsets.only(left: 5, top: 5, bottom: 10),
+                              child: Text(
+                                "品牌",
+                                style: TextStyle(
+                                    color: Color(0xff666666),
+                                    fontSize: ScreenUtil().setSp(16)),
+                                textAlign: TextAlign.start,
+                              ),
+                            ),
+                            brandList != null && brandList != []
+                                ? Container(
+                                    child: Wrap(
+                                    alignment: WrapAlignment.start,
+                                    crossAxisAlignment:
+                                        WrapCrossAlignment.center,
+                                    children:
+                                        brandList.asMap().keys.map((index) {
+                                      return InkWell(
+                                        onTap: () {
+                                          print("666");
+
+                                          setState(() {
+                                            sortBool = true;
+                                            brandChiose =
+                                                brandList[index].name ?? "";
+                                            brandIdss = brandList[index].id;
+                                          });
+                                        },
+                                        child: Container(
+                                          width: width / 4 - 17,
+                                          padding: EdgeInsets.only(
+                                              bottom: ScreenUtil().setWidth(10),
+                                              top: ScreenUtil().setWidth(10)),
+                                          margin: EdgeInsets.only(
+                                              left: 5,
+                                              right: 5,
+                                              bottom: 5,
+                                              top: 5),
+                                          decoration: BoxDecoration(
+                                              // border: Border(
+                                              //   bottom: BorderSide(width: 0.5, color: Colours.line),
+                                              // ),
+                                              color: Color(0xfff5f5f5)),
+                                          child: Text(
+                                            brandList[index].name ?? "",
+                                            style: TextStyle(
+                                                color: Color(0xff666666),
+                                                fontSize:
+                                                    ScreenUtil().setSp(15)),
+                                            textAlign: TextAlign.center,
+                                          ),
+                                        ),
+                                      );
+                                    }).toList(),
+                                  ))
+                                : loadCircle()
+                          ],
+                        )))
+                : Container(child: null),
+          ],
+        ),
+      ),
+    );
+  }
+
+  Widget loadCircle() {
+    return Container(
+      padding: EdgeInsets.only(top: 10, bottom: 10),
+      color: ThemeUtils.getTabsBg(context),
+      child: Center(
+        child: SpinKitFadingCircle(
+          color: Colors.blueAccent,
+          size: 30.0,
+        ),
+      ),
+    );
+  }
+}
+
+class ChioseThisRight extends StatelessWidget {
+  ChioseThisRight(
+      {Key key, this.value, this.label, this.fun, this.labelText = '请选择'})
+      : super(key: key);
+  String value;
+  String label;
+  Function fun;
+  String labelText;
+  @override
+  Widget build(BuildContext context) {
+    double width = MediaQuery.of(context).size.width;
+    return InkWell(
+      onTap: () {
+        fun();
+      },
+      child: Container(
+        padding: EdgeInsets.only(
+            top: ScreenUtil().setWidth(15), bottom: ScreenUtil().setWidth(15)),
+        margin: EdgeInsets.only(left: ScreenUtil().setWidth(15)),
+        decoration: BoxDecoration(
+          border: Border(
+            bottom: BorderSide(width: 0.5, color: Colours.line),
+          ),
+        ),
+        child: Row(
+            mainAxisAlignment: MainAxisAlignment.spaceBetween,
+            children: <Widget>[
+              Text(
+                label,
+                style: TextStyle(
+                  // fontSize: ScreenUtil().setSp(14)
+                ),
+                textAlign: TextAlign.start,
+              ),
+              value.isEmpty
+                  ? Container(
+                      child: Row(children: <Widget>[
+                        Text(
+                          labelText,
+                          style: TextStyle(
+                            color: Color(0xffcccccc),
+                            // fontSize: ScreenUtil().setSp(14)
+                          ),
+                          textAlign: TextAlign.start,
+                        ),
+                        Container(
+                          padding: EdgeInsets.only(top: 3),
+                          child: Icon(
+                            Icons.keyboard_arrow_right,
+                            size: 20.0,
+                            color: Color(0xffcccccc),
+                          ),
+                        ),
+                        SizedBox(width: 10)
+                      ]),
+                    )
+                  : Container(
+                      padding:
+                          EdgeInsets.only(right: ScreenUtil().setWidth(15)),
+                      child: Row(children: <Widget>[
+                        Text(
+                          value,
+                          style: TextStyle(
+                              color: Color(0xff222222),
+                              fontSize: ScreenUtil().setSp(14)),
+                          textAlign: TextAlign.start,
+                        ),
+                      ]),
+                    ),
+            ]),
+      ),
+    );
+  }
+}

+ 280 - 87
lib/internal/bbs/page/tab/video/video_upload.dart

@@ -8,7 +8,8 @@ import 'package:liftmanager/widgets/app_search_bar.dart';
 import 'package:liftmanager/res/resources.dart';
 import 'package:liftmanager/routers/fluro_navigator.dart';
 import 'package:liftmanager/widgets/load_image.dart';
-import 'package:liftmanager/widgets/selected_image_change.dart';
+// import 'package:liftmanager/widgets/selected_image_change.dart';
+import 'package:liftmanager/widgets/selected_video_change.dart';
 import 'package:image_picker/image_picker.dart';
 import 'dart:io';
 import 'package:liftmanager/widgets/bbs_content.dart';
@@ -20,6 +21,14 @@ import 'package:liftmanager/internal/bbs/bbs_router.dart';
 import 'package:flustars/flustars.dart' as FlutterStars;
 import 'package:liftmanager/common/common.dart';
 import 'package:liftmanager/utils/theme_utils.dart';
+import 'package:liftmanager/utils/oss_upload.dart';
+import 'package:liftmanager/utils/log_util.dart';
+import 'package:chewie/chewie.dart';
+import 'package:flutter/services.dart';
+import 'package:liftmanager/utils/utils.dart';
+import 'package:orientation/orientation.dart';
+import 'dart:async';
+import 'package:liftmanager/utils/fast_notification.dart';
 
 class VideoUpload extends StatefulWidget {
   // BrandPage(this.id);
@@ -33,38 +42,24 @@ class VideoUpload extends StatefulWidget {
 }
 
 class VideoUploadState extends State<VideoUpload> {
-  // NewsDetailItem item = NewsDetailItem();
-
-  ScrollController _scrollController = new ScrollController();
   String brandChiose = '请选择';
   String brandName = "品牌";
   int brandIdss;
+  Timer _timer;
   bool sortBool = true;
-  List<String> imagesUrl = [];
-  List<String> videoUrl = [];
+  VideoPlayerController _controller;
+  // final FijkPlayer player = FijkPlayer();
+  // List<String> imagesUrl = [];
+  // List<String> videoUrl = [];
+  String videoUrl;
+  String str;
+  String imagesUrl;
+  double percent = 0.0;
   @override
   void initState() {
     super.initState();
   }
 
-  upLoadFileOnce(path) {
-    showLoading(context, "正在上传...");
-    NewApiService().upload(path, onSuccess: (res) {
-      // imagesUrl.add(res.path);
-      dismissLoading(context);
-
-      setState(() {
-        videoUrl = [];
-        imagesUrl = [];
-        videoUrl.add(res.pathUrl);
-        imagesUrl.add(res.coverUrl);
-      });
-    }, onError: (code, msg) {
-      dismissLoading(context);
-      toasts(msg);
-    });
-  }
-
   List<dynamic> brandList;
   Future getBrandList() async {
     await NewApiService().getBrandListNoPage(onSuccess: (res) {
@@ -108,14 +103,68 @@ class VideoUploadState extends State<VideoUpload> {
         source: key == 1 ? ImageSource.camera : ImageSource.gallery,
       );
       if (_imageFile != null) {
-        upLoadFileOnce(_imageFile.path);
-        setState(() {});
+        _uploadImage(_imageFile.path);
+        // upLoadFileOnce(_imageFile.path);
+        // setState(() {});
       }
     } catch (e) {
       toasts("没有权限,无法打开相册!");
     }
   }
 
+  void _uploadImage(filePath) async {
+    showPercent(context, (){
+      dismissLoading(context);
+      toasts("上传失败");
+    },(){
+      if(videoUrl == null && str != null){
+        setState(() {
+            videoUrl = str;
+            print("videoUrl:"+videoUrl);
+            dismissLoading(context);
+            toasts("上传成功");
+          });
+      }
+    });
+    String uploadName = OssUtil.instance.getImageUploadName(filePath);
+    await NewApiService.uploadImage(context, uploadName, filePath).then((data) {
+      if (data.statusCode == 200) {
+        str = NewApiUrl.URL_UPLOAD_IMAGE_OSS + "/" + uploadName;
+        print("str:"+str);
+        print(videoUrl);
+        if(str != null){
+          Map obj = {
+            "uploadName":uploadName,
+            "success":true
+          };
+          FastNotification.push("percent",obj);
+        }
+      }else {
+        Map obj = {
+            "uploadName":uploadName,
+            "success":false
+          };
+        FastNotification.push("percent",obj);
+      }
+    }).catchError((data) {
+      Map obj = {
+            "uploadName":uploadName,
+            "success":false
+          };
+      FastNotification.push("percent",obj);
+    });
+  }
+  
+  @override
+  void dispose() {
+    _controller.pause();
+    _controller.dispose();
+    FlutterStars.SpUtil.putString('uploadName', "");
+    // player.release();
+    super.dispose();
+  }
+   
+
   // 焦点控制
   FocusNode focusNode1 = new FocusNode();
   GlobalKey _formKey = new GlobalKey<FormState>();
@@ -127,7 +176,12 @@ class VideoUploadState extends State<VideoUpload> {
   Widget build(BuildContext context) {
     double width = MediaQuery.of(context).size.width;
     double height = MediaQuery.of(context).size.height;
-
+    if(width > height){
+      // SystemChrome.setPreferredOrientations([
+      //   DeviceOrientation.portraitUp,
+      // ]);
+      OrientationPlugin.forceOrientation(DeviceOrientation.portraitUp);
+    }
     return Scaffold(
       resizeToAvoidBottomPadding: false, //不让键盘弹上去
       appBar: MyAppBar(
@@ -265,7 +319,7 @@ class VideoUploadState extends State<VideoUpload> {
                     ),
                     Container(
                 width: width,
-                padding: EdgeInsets.only(left:15,top:15),
+                padding: EdgeInsets.only(left:15,top:15,bottom:15),
                 child: Text(
                                                         "(建议时长3分钟,建议大小50M)",
                                                         style: TextStyle(
@@ -277,63 +331,121 @@ class VideoUploadState extends State<VideoUpload> {
                                                             textAlign: TextAlign.left,
                                                       ),
               ),
+                    // Container(
+                    //     color: ThemeUtils.getTabsBg(context),
+                    //     child: GridView.builder(
+                    //       shrinkWrap: true,
+                    //       padding:
+                    //           const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
+                    //       physics: NeverScrollableScrollPhysics(),
+                    //       gridDelegate:
+                    //           SliverGridDelegateWithFixedCrossAxisCount(
+                    //               crossAxisCount: 3, childAspectRatio: 1.18),
+                    //       itemCount:
+                    //           videoUrl.length >= 1 ? 1 : videoUrl.length + 1,
+                    //       itemBuilder: (_, index) {
+                    //         return Stack(
+                    //           children: <Widget>[
+                    //             Center(
+                    //               child: SelectedImage(
+                    //                   image: index < videoUrl.length
+                    //                       ? imagesUrl[index]
+                    //                       : null,
+                    //                   // image: index < videoUrl.length ? videoUrl[index] : null,
+                    //                   index: index,
+                    //                   onTap: () {
+                    //                     if (index >= videoUrl.length) {
+                    //                       selectPicker();
+                    //                     }
+                    //                     FocusScope.of(context)
+                    //                         .requestFocus(FocusNode());
+                    //                     print(index);
+                    //                     print(videoUrl);
+                    //                   }),
+                    //             ),
+                    //             index < videoUrl.length
+                    //                 ? Positioned(
+                    //                     top: 0,
+                    //                     right: 0,
+                    //                     child: GestureDetector(
+                    //                       onTap: () {
+                    //                         print(index);
+                    //                         videoUrl.remove(videoUrl[index]);
+                    //                         imagesUrl.remove(imagesUrl[index]);
+                    //                         setState(() {});
+                    //                       },
+                    //                       child: Icon(
+                    //                         IconData(0xe62a,
+                    //                             fontFamily: "myfont"),
+                    //                         size: 24.0,
+                    //                         color: Color(0xff999999),
+                    //                       ),
+                    //                     ))
+                    //                 : Container(
+                    //                     child: null,
+                    //                   )
+                    //           ],
+                    //         );
+                    //       },
+                    //     )
+                    // ),
+
                     Container(
-                        color: ThemeUtils.getTabsBg(context),
-                        child: GridView.builder(
-                          shrinkWrap: true,
-                          padding:
-                              const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
-                          physics: NeverScrollableScrollPhysics(),
-                          gridDelegate:
-                              SliverGridDelegateWithFixedCrossAxisCount(
-                                  crossAxisCount: 3, childAspectRatio: 1.18),
-                          itemCount:
-                              videoUrl.length >= 1 ? 1 : videoUrl.length + 1,
-                          itemBuilder: (_, index) {
-                            return Stack(
-                              children: <Widget>[
-                                Center(
-                                  child: SelectedImage(
-                                      image: index < videoUrl.length
-                                          ? imagesUrl[index]
-                                          : null,
-                                      // image: index < videoUrl.length ? videoUrl[index] : null,
-                                      index: index,
+                    color: ThemeUtils.getDialogTextFieldColor(context),
+                    child: GridView.builder(
+                      shrinkWrap: true,
+                      padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
+                      physics: NeverScrollableScrollPhysics(),
+                      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+                          crossAxisCount: 1, childAspectRatio: 1.18),
+                      itemCount: 1,
+                      itemBuilder: (_, index) {
+                        return Stack(
+                          children: <Widget>[
+                            Center(
+                              child: SelectedVideo(
+                                image: videoUrl,
+                                index: index,
+                                videoPlay:videoPlay(),
+                                onTap: () {
+                                  if(videoUrl == null){
+                                    selectPicker();
+                                  }
+                                  
+                                },
+                              ),
+                            ),
+                            videoUrl != null
+                                ? Positioned(
+                                    top: 0,
+                                    right: 0,
+                                    child: GestureDetector(
                                       onTap: () {
-                                        if (index >= videoUrl.length) {
-                                          selectPicker();
-                                        }
-                                        FocusScope.of(context)
-                                            .requestFocus(FocusNode());
                                         print(index);
-                                        print(videoUrl);
-                                      }),
-                                ),
-                                index < videoUrl.length
-                                    ? Positioned(
-                                        top: 0,
-                                        right: 0,
-                                        child: GestureDetector(
-                                          onTap: () {
-                                            print(index);
-                                            videoUrl.remove(videoUrl[index]);
-                                            imagesUrl.remove(imagesUrl[index]);
-                                            setState(() {});
-                                          },
-                                          child: Icon(
-                                            IconData(0xe62a,
-                                                fontFamily: "myfont"),
-                                            size: 24.0,
-                                            color: Color(0xff999999),
-                                          ),
-                                        ))
-                                    : Container(
-                                        child: null,
-                                      )
-                              ],
-                            );
-                          },
-                        )),
+                                        
+                                        // imagesUrl = null;
+                                        setState(() {
+                                          videoUrl = null;
+                                          str = null;
+                                          _controller.pause();
+                                          // player.reset();
+                                        });
+                                      },
+                                      child: Icon(
+                                        IconData(0xe62a, fontFamily: "myfont"),
+                                        size: 24.0,
+                                        color: Color(0xff999999),
+                                      ),
+                                    ),
+                                  )
+                                : Container(
+                                    child: null,
+                                  )
+                          ],
+                        );
+                      },
+                    ),
+                  ),
                     SizedBox(
                       height: ScreenUtil().setWidth(80),
                     ),
@@ -369,19 +481,23 @@ class VideoUploadState extends State<VideoUpload> {
                           toasts("请选择品牌");
                           return;
                         }
-                        if (videoUrl.length < 1) {
+                        if (videoUrl == null || videoUrl == "") {
                           toasts("请上传视频");
                           return;
                         }
-                        String videos = videoUrl.join(",");
-                        String images = imagesUrl.join(",");
+                        // if (videoUrl.length < 1) {
+                        //   toasts("请上传视频");
+                        //   return;
+                        // }
+                        // String videos = videoUrl.join(",");
+                        // String images = imagesUrl.join(",");
                         if ((_formKey.currentState as FormState).validate()) {
                           dynamic obj = {
                             "brandId": brandIdss,
                             "title": _titleController.text,
                             "descr": _descController.text,
-                            "url": videos,
-                            "cover": images,
+                            "url": videoUrl,
+                            // "cover": images,
                             "checkFlag": 2,
                             "statuz": 1,
                             "platformFlag": 1,
@@ -484,6 +600,13 @@ class VideoUploadState extends State<VideoUpload> {
                           ],
                         )))
                 : Container(child: null),
+            // Positioned(
+            //   width: width,
+            //   height:height,
+            //   child: Container(
+            //     color: Colors.red,
+            //   ),
+            // )
           ],
         ),
       ),
@@ -502,6 +625,76 @@ class VideoUploadState extends State<VideoUpload> {
       ),
     );
   }
+
+  Widget videoPlay() {
+    
+    _controller = VideoPlayerController.network(
+                                        Utils.getImagePath(videoUrl) 
+                                        // imgFontUrl + detailObj.url
+                                        );
+    double width = MediaQuery.of(context).size.width;
+    return 
+    // Container(
+    //                     width: width,
+    //                     height: width*0.6,
+    //                     alignment: Alignment.center,
+    //                     child: FijkView(
+    //                       player: player,
+    //                       color: Colors.black,
+    //                       fit:FijkFit.fill,
+    //                       // cover: NetworkImage(detailObj.cover),
+    //                       // cover: new Image(image: detailObj.cover!=null&& detailObj.cover!=""?NetworkImage(detailObj.cover):AssetImage("assets/images/video_image.png"),).image,
+    //                       // 
+    //                     ),
+    //                   );
+    Container(
+                          padding: EdgeInsets.only(
+                              left: ScreenUtil().setWidth(15),
+                              right: ScreenUtil().setWidth(15),
+                              top: ScreenUtil().setWidth(15)),
+                          child: ClipRRect(
+                            borderRadius: BorderRadius.circular(5),
+                            child: 
+                            new Chewie(
+                              controller: ChewieController(
+                                videoPlayerController:
+                                    // VideoPlayerController.network(
+                                    //     imgFontUrl + detailObj.url
+                                    //     ),
+                                    _controller,
+                                aspectRatio: 3 / 2,
+                                allowFullScreen:false,
+                                autoPlay: false,
+                                looping: true,
+                                // startAt: Duration(seconds: 1,minutes: 1),
+                                showControls: true,
+                                deviceOrientationsAfterFullScreen:[DeviceOrientation.portraitUp],
+                                // 占位图
+                                // placeholder: Image.network(
+                                //     imgFontUrl+detailObj.cover,
+                                //     fit: BoxFit.contain,
+
+                                //   ),
+
+                                // 是否在 UI 构建的时候就加载视频
+                                autoInitialize: true,
+
+                                // 拖动条样式颜色
+                                materialProgressColors:
+                                    new ChewieProgressColors(
+                                  playedColor: Colors.red,
+                                  handleColor: Colors.blue,
+                                  backgroundColor: Colors.grey,
+                                  bufferedColor: Colors.lightGreen,
+                                ),
+                              ),
+                            ),
+
+                            
+                            
+                          )
+                      );
+  }
 }
 
 class ChioseThisRight extends StatelessWidget {

+ 256 - 64
lib/internal/bbs/page/visit_page.dart

@@ -22,13 +22,18 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
 import 'package:shared_preferences/shared_preferences.dart';
 import 'package:liftmanager/utils/time_format.dart';
 import 'package:liftmanager/utils/fast_notification.dart';
-
+import 'package:chewie/chewie.dart';
+import 'package:liftmanager/utils/oss_upload.dart';
+import 'package:video_player/video_player.dart';
 import 'package:liftmanager/common/common.dart';
 import 'package:flustars/flustars.dart' as flustars;
 import 'package:permission_handler/permission_handler.dart';
 // import 'package:amap_all_fluttify/amap_all_fluttify.dart';
 import 'package:liftmanager/utils/theme_utils.dart';
-
+import 'package:liftmanager/widgets/selected_video_change.dart';
+import 'package:liftmanager/utils/utils.dart';
+import 'package:orientation/orientation.dart';
+import 'package:flutter/services.dart';
 
 class VisitPage extends StatefulWidget {
   VisitPage(this.brandName, this.brandId);
@@ -48,9 +53,12 @@ class VisitPageState extends State<VisitPage> {
   ScrollController _scrollController = new ScrollController();
   String extAddress;
   List<String> imagesUrl = [];
-  List<String> imagesUrlVideo = [];
-   List<String> videoUrl = [];
+  // List<String> imagesUrlVideo = [];
+  String videoUrl;
+  String str;
+  double percent = 0.0;
   String addressName = "";
+  VideoPlayerController _controller;
   // String addressName = "湖北省武汉市洪山区武大科技园豪迈大厦,30.46139,114.414463";
   @override
   void initState() {
@@ -90,6 +98,14 @@ class VisitPageState extends State<VisitPage> {
   //   }
   // }
 
+  @override
+  void dispose() {
+    _controller.pause();
+    _controller.dispose();
+    // player.release();
+    super.dispose();
+  }
+
   upLoadFileOnce(path) {
     showLoading(context, "正在上传...");
     NewApiService().upload(path, onSuccess: (res) {
@@ -111,8 +127,8 @@ class VisitPageState extends State<VisitPage> {
       // imagesUrl.add(res.path);
       dismissLoading(context);
       setState(() {
-        videoUrl.add(res.pathUrl);
-        imagesUrlVideo.add(res.coverUrl);
+        // videoUrl.add(res.pathUrl);
+        // imagesUrlVideo.add(res.coverUrl);
       });
     }, onError: (code, msg) {
       dismissLoading(context);
@@ -177,8 +193,8 @@ class VisitPageState extends State<VisitPage> {
         // print(_imageFile);
         // print(jsonEncode(_imageFile));
         print(123);
-        
-        upLoadFileOnceVideo(_imageFile.path);
+        _uploadImage(_imageFile.path);
+        // upLoadFileOnceVideo(_imageFile.path);
         setState(() {});
       }
     } catch (e) {
@@ -186,6 +202,49 @@ class VisitPageState extends State<VisitPage> {
     }
   }
 
+  void _uploadImage(filePath) async {
+    showPercent(context, (){
+      dismissLoading(context);
+      toasts("上传失败");
+    },(){
+      if(videoUrl == null && str != null){
+        setState(() {
+            videoUrl = str;
+            print("videoUrl:"+videoUrl);
+            dismissLoading(context);
+            toasts("上传成功");
+          });
+      }
+    });
+    String uploadName = OssUtil.instance.getImageUploadName(filePath);
+    await NewApiService.uploadImage(context, uploadName, filePath).then((data) {
+      if (data.statusCode == 200) {
+        str = NewApiUrl.URL_UPLOAD_IMAGE_OSS + "/" + uploadName;
+        print("str:"+str);
+        print(videoUrl);
+        if(str != null){
+          Map obj = {
+            "uploadName":uploadName,
+            "success":true
+          };
+          FastNotification.push("percent",obj);
+        }
+      }else {
+        Map obj = {
+            "uploadName":uploadName,
+            "success":false
+          };
+        FastNotification.push("percent",obj);
+      }
+    }).catchError((data) {
+      Map obj = {
+            "uploadName":uploadName,
+            "success":false
+          };
+      FastNotification.push("percent",obj);
+    });
+  }
+
   FocusNode blankNode = FocusNode();
 
   // 文本编辑控制
@@ -203,6 +262,13 @@ class VisitPageState extends State<VisitPage> {
   @override
   Widget build(BuildContext context) {
     double width = MediaQuery.of(context).size.width;
+    double height = MediaQuery.of(context).size.height;
+    if(width > height){
+      // SystemChrome.setPreferredOrientations([
+      //   DeviceOrientation.portraitUp,
+      // ]);
+      OrientationPlugin.forceOrientation(DeviceOrientation.portraitUp);
+    }
 
     var _datetime = formatDate(
         _nowDate, [yyyy, "-", mm, "-", dd, " ", HH, ":", nn]);
@@ -587,7 +653,7 @@ class VisitPageState extends State<VisitPage> {
               ),
               Container(
                 width: width,
-                padding: EdgeInsets.only(left:15),
+                padding: EdgeInsets.only(left:15,bottom:15),
                 child: Text(
                                                         "(建议时长3分钟,建议大小50M)",
                                                         style: TextStyle(
@@ -599,58 +665,114 @@ class VisitPageState extends State<VisitPage> {
                                                             textAlign: TextAlign.left,
                                                       ),
               ),
-              Container(
-                color: ThemeUtils.getTabsBg(context),
-                child: GridView.builder(
-                  shrinkWrap: true,
-                  padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
-                  physics: NeverScrollableScrollPhysics(),
-                  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
-                      crossAxisCount: 3, childAspectRatio: 1.18),
-                  itemCount: videoUrl.length >= 1 ? 1 : videoUrl.length + 1,
-                  itemBuilder: (_, index) {
-                    return Stack(
-                      children: <Widget>[
-                        Center(
-                          child: SelectedImage(
-                              image: index < videoUrl.length ? imagesUrlVideo[index] : null,
-                              index:index,
-                              onTap: () {
-                                if(index >= videoUrl.length){
-                                  selectPicker("video");
-                                }
-                                FocusScope.of(context).requestFocus(FocusNode());
-                                print(index);
-                                print(videoUrl);
-                              }),
-                        ),
-                        index < videoUrl.length?Positioned(
-                          top:0,
-                          right:0,
-                          child:GestureDetector(
-                            onTap: (){
-                              print(index);
-                              videoUrl.remove(videoUrl[index]);
-                              imagesUrlVideo.remove(imagesUrlVideo[index]);
-                              setState(() {
+              // Container(
+              //   color: ThemeUtils.getTabsBg(context),
+              //   child: GridView.builder(
+              //     shrinkWrap: true,
+              //     padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
+              //     physics: NeverScrollableScrollPhysics(),
+              //     gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+              //         crossAxisCount: 3, childAspectRatio: 1.18),
+              //     itemCount: videoUrl.length >= 1 ? 1 : videoUrl.length + 1,
+              //     itemBuilder: (_, index) {
+              //       return Stack(
+              //         children: <Widget>[
+              //           Center(
+              //             child: SelectedImage(
+              //                 image: index < videoUrl.length ? imagesUrlVideo[index] : null,
+              //                 index:index,
+              //                 onTap: () {
+              //                   if(index >= videoUrl.length){
+              //                     selectPicker("video");
+              //                   }
+              //                   FocusScope.of(context).requestFocus(FocusNode());
+              //                   print(index);
+              //                   print(videoUrl);
+              //                 }),
+              //           ),
+              //           index < videoUrl.length?Positioned(
+              //             top:0,
+              //             right:0,
+              //             child:GestureDetector(
+              //               onTap: (){
+              //                 print(index);
+              //                 videoUrl.remove(videoUrl[index]);
+              //                 imagesUrlVideo.remove(imagesUrlVideo[index]);
+              //                 setState(() {
                                 
-                              });
-                            },
-                            child:Icon(
-                                IconData(
-                                  0xe62a,
-                                  fontFamily:"myfont"
-                                ),
-                                size: 24.0,
-                                color:Color(0xff999999),
+              //                 });
+              //               },
+              //               child:Icon(
+              //                   IconData(
+              //                     0xe62a,
+              //                     fontFamily:"myfont"
+              //                   ),
+              //                   size: 24.0,
+              //                   color:Color(0xff999999),
+              //                 ),
+              //             )
+              //           ):Container(child: null,)
+              //         ],
+              //       );
+              //     },
+              //   )
+              // ),
+              Container(
+                    color: ThemeUtils.getDialogTextFieldColor(context),
+                    child: GridView.builder(
+                      shrinkWrap: true,
+                      padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
+                      physics: NeverScrollableScrollPhysics(),
+                      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+                          crossAxisCount: 1, childAspectRatio: 1.18),
+                      itemCount: 1,
+                      itemBuilder: (_, index) {
+                        return Stack(
+                          children: <Widget>[
+                            Center(
+                              child: SelectedVideo(
+                                image: videoUrl,
+                                index: index,
+                                videoPlay:videoPlay(),
+                                onTap: () {
+                                  if(videoUrl == null){
+                                    selectPicker("video");
+                                  }
+                                  
+                                },
                               ),
-                          )
-                        ):Container(child: null,)
-                      ],
-                    );
-                  },
-                )
-              ),
+                            ),
+                            videoUrl != null
+                                ? Positioned(
+                                    top: 0,
+                                    right: 0,
+                                    child: GestureDetector(
+                                      onTap: () {
+                                        print(index);
+                                        
+                                        // imagesUrl = null;
+                                        setState(() {
+                                          videoUrl = null;
+                                          str = null;
+                                          _controller.pause();
+                                          // player.reset();
+                                        });
+                                      },
+                                      child: Icon(
+                                        IconData(0xe62a, fontFamily: "myfont"),
+                                        size: 24.0,
+                                        color: Color(0xff999999),
+                                      ),
+                                    ),
+                                  )
+                                : Container(
+                                    child: null,
+                                  )
+                          ],
+                        );
+                      },
+                    ),
+                  ),
                     ],
                   ),
                 )
@@ -704,10 +826,10 @@ class VisitPageState extends State<VisitPage> {
                             if(imagesUrl.length > 0){
                               imgs = imagesUrl.join(",");
                             }
-                            String videoImgs = "";
-                            if(videoUrl.length > 0){
-                              videoImgs = videoUrl.join(",");
-                            }
+                            // String videoImgs = "";
+                            // if(videoUrl.length > 0){
+                            //   videoImgs = videoUrl.join(",");
+                            // }
                       if ((_formKey.currentState as FormState).validate()) {
                         dynamic obj = {
                           "dataTable": "2",
@@ -715,7 +837,7 @@ class VisitPageState extends State<VisitPage> {
                           "expression": _questionController.text,
                           "usedMethods": _methodController.text,
                           "imgs": imgs,
-                          "videoUrl":videoImgs,
+                          "videoUrl":videoUrl,
                           "createUserId": int.parse(
                               flustars.SpUtil.getString(Constant.userId)),
                           "chargerId": 1,
@@ -767,4 +889,74 @@ class VisitPageState extends State<VisitPage> {
   //   extAddress = prefs.getString("extAddress");
 
   // }
+
+  Widget videoPlay() {
+    
+    _controller = VideoPlayerController.network(
+                                        Utils.getImagePath(videoUrl) 
+                                        // imgFontUrl + detailObj.url
+                                        );
+    double width = MediaQuery.of(context).size.width;
+    return 
+    // Container(
+    //                     width: width,
+    //                     height: width*0.6,
+    //                     alignment: Alignment.center,
+    //                     child: FijkView(
+    //                       player: player,
+    //                       color: Colors.black,
+    //                       fit:FijkFit.fill,
+    //                       // cover: NetworkImage(detailObj.cover),
+    //                       // cover: new Image(image: detailObj.cover!=null&& detailObj.cover!=""?NetworkImage(detailObj.cover):AssetImage("assets/images/video_image.png"),).image,
+    //                       // 
+    //                     ),
+    //                   );
+    Container(
+                          padding: EdgeInsets.only(
+                              left: ScreenUtil().setWidth(15),
+                              right: ScreenUtil().setWidth(15),
+                              top: ScreenUtil().setWidth(15)),
+                          child: ClipRRect(
+                            borderRadius: BorderRadius.circular(5),
+                            child: 
+                            new Chewie(
+                              controller: ChewieController(
+                                videoPlayerController:
+                                    // VideoPlayerController.network(
+                                    //     imgFontUrl + detailObj.url
+                                    //     ),
+                                    _controller,
+                                aspectRatio: 3 / 2,
+                                allowFullScreen:false,
+                                autoPlay: false,
+                                looping: true,
+                                // startAt: Duration(seconds: 1,minutes: 1),
+                                showControls: true,
+                                deviceOrientationsAfterFullScreen:[DeviceOrientation.portraitUp],
+                                // 占位图
+                                // placeholder: Image.network(
+                                //     imgFontUrl+detailObj.cover,
+                                //     fit: BoxFit.contain,
+
+                                //   ),
+
+                                // 是否在 UI 构建的时候就加载视频
+                                autoInitialize: true,
+
+                                // 拖动条样式颜色
+                                materialProgressColors:
+                                    new ChewieProgressColors(
+                                  playedColor: Colors.red,
+                                  handleColor: Colors.blue,
+                                  backgroundColor: Colors.grey,
+                                  bufferedColor: Colors.lightGreen,
+                                ),
+                              ),
+                            ),
+
+                            
+                            
+                          )
+                      );
+  }
 }

+ 58 - 6
lib/internal/wode/page/order_master/punchin.dart

@@ -19,6 +19,8 @@ import 'package:video_player/video_player.dart';
 import 'package:chewie/chewie.dart';
 import 'package:flutter/services.dart';
 import 'package:orientation/orientation.dart';
+import 'package:liftmanager/utils/fast_notification.dart';
+import 'package:liftmanager/utils/oss_upload.dart';
 
 class Punchin extends StatefulWidget {
   Punchin(this.id);
@@ -33,7 +35,9 @@ class Punchin extends StatefulWidget {
 
 class PunchinState extends State<Punchin> {
   String videoUrl;
+  String str;
   String imagesUrl;
+  double percent = 0.0;
 
   Map<String, Object> _locationResult;
   StreamSubscription<Map<String, Object>> _locationListener;
@@ -143,7 +147,8 @@ class PunchinState extends State<Punchin> {
         source: key == 1 ? ImageSource.camera : ImageSource.gallery,
       );
       if (_imageFile != null) {
-        upLoadFileOnce(_imageFile.path);
+        // upLoadFileOnce(_imageFile.path);
+        _uploadImage(_imageFile.path);
       }
     } catch (e) {
       toasts("没有权限,无法打开相册!");
@@ -164,6 +169,49 @@ class PunchinState extends State<Punchin> {
     });
   }
 
+  void _uploadImage(filePath) async {
+    showPercent(context, (){
+      dismissLoading(context);
+      toasts("上传失败");
+    },(){
+      if(videoUrl == null && str != null){
+        setState(() {
+            videoUrl = str;
+            print("videoUrl:"+videoUrl);
+            dismissLoading(context);
+            toasts("上传成功");
+          });
+      }
+    });
+    String uploadName = OssUtil.instance.getImageUploadName(filePath);
+    await NewApiService.uploadImage(context, uploadName, filePath).then((data) {
+      if (data.statusCode == 200) {
+        str = NewApiUrl.URL_UPLOAD_IMAGE_OSS + "/" + uploadName;
+        print("str:"+str);
+        print(videoUrl);
+        if(str != null){
+          Map obj = {
+            "uploadName":uploadName,
+            "success":true
+          };
+          FastNotification.push("percent",obj);
+        }
+      }else {
+        Map obj = {
+            "uploadName":uploadName,
+            "success":false
+          };
+        FastNotification.push("percent",obj);
+      }
+    }).catchError((data) {
+      Map obj = {
+            "uploadName":uploadName,
+            "success":false
+          };
+      FastNotification.push("percent",obj);
+    });
+  }
+
 
   // 获取位置信息
   initGetLocation() async {
@@ -307,7 +355,9 @@ class PunchinState extends State<Punchin> {
                                 index: index,
                                 videoPlay:videoPlay(),
                                 onTap: () {
-                                  selectPicker();
+                                  if(videoUrl == null){
+                                    selectPicker();
+                                  }
                                 },
                               ),
                             ),
@@ -317,10 +367,12 @@ class PunchinState extends State<Punchin> {
                                     right: 0,
                                     child: GestureDetector(
                                       onTap: () {
-                                        print(index);
-                                        videoUrl = null;
-                                        imagesUrl = null;
-                                        setState(() {});
+                                        setState(() {
+                                          videoUrl = null;
+                                          str = null;
+                                          _controller.pause();
+                                          // player.reset();
+                                        });
                                       },
                                       child: Icon(
                                         IconData(0xe62a, fontFamily: "myfont"),

+ 19 - 5
lib/internal/wode/page/video/video_detail.dart

@@ -24,6 +24,9 @@ import 'package:liftmanager/internal/wode/wode_router.dart';
 import 'package:liftmanager/utils/utils.dart';
 import 'package:flutter/services.dart';
 import 'package:orientation/orientation.dart';
+import 'package:image/image.dart' as I;
+import 'dart:math';
+import 'dart:typed_data';
 
 class VideoDetail extends StatefulWidget {
   VideoDetail(this.id);
@@ -42,16 +45,14 @@ class VideoDetailState extends State<VideoDetail> {
     super.initState();
     getVideoDetail();
   }
-
+  // final FijkPlayer player = FijkPlayer();
   bool _hasData = false;
   VideoDetailModel detailObj;
-  var _storageLikeId;
-  var _storageFavId;
   VideoPlayerController _controller;
 
   Future getVideoDetail() async {
     await NewApiService().getVideoDetail(int.parse(widget.id), 1,
-        onSuccess: (res) {
+        onSuccess: (res) async {
       if (res != null) {
         _hasData = true;
         detailObj = res;
@@ -59,6 +60,18 @@ class VideoDetailState extends State<VideoDetail> {
                                         Utils.getImagePath(detailObj.url) 
                                         // imgFontUrl + detailObj.url
                                         );
+        // player.setDataSource(detailObj.url, autoPlay: false,showCover: true);
+        // player.setOption(FijkOption.playerCategory, "cover-after-prepared", 1);
+        // var imageData = await player.takeSnapShot();
+        // Image.memory(imageData);
+        // MemoryImage(imageData);
+        // I.Image _img = I.decodeImage(imageData);
+        // _img = I.encodeJpg(_img) as I.Image;
+        // String s = new String.fromCharCodes(imageData);
+        // var outputAsUint8List = new Uint8List.fromList(s.codeUnits);
+        // print(123456);
+        // print(outputAsUint8List);
+        // print(1234561);
         setState(() {});
       }
     }, onError: (code, msg) {
@@ -73,7 +86,8 @@ class VideoDetailState extends State<VideoDetail> {
     // SystemChrome.setPreferredOrientations([
     //   DeviceOrientation.portraitUp,
     // ]);
-    OrientationPlugin.forceOrientation(DeviceOrientation.portraitUp);
+    // player.release();
+    // OrientationPlugin.forceOrientation(DeviceOrientation.portraitUp);
     super.dispose();
   }
 

+ 251 - 72
lib/internal/wode/page/video/video_upload.dart

@@ -26,7 +26,14 @@ import 'package:liftmanager/common/common.dart';
 import 'dart:math';
 import 'package:liftmanager/utils/fast_notification.dart';
 import 'package:liftmanager/utils/theme_utils.dart';
-
+import 'package:liftmanager/utils/oss_upload.dart';
+import 'package:liftmanager/utils/log_util.dart';
+import 'package:chewie/chewie.dart';
+import 'package:flutter/services.dart';
+import 'package:liftmanager/utils/utils.dart';
+import 'package:orientation/orientation.dart';
+import 'dart:async';
+import 'package:liftmanager/widgets/selected_video_change.dart';
 
 class VideoUpload extends StatefulWidget {
   VideoUpload(this.id);
@@ -48,10 +55,14 @@ class VideoUploadState extends State<VideoUpload> {
   String brandName = "品牌";
   int brandIdss;
   bool sortBool = true;
-   List<String> imagesUrl = [];
-   List<String> videoUrl = [];
+  //  List<String> imagesUrl = [];
+  //  List<String> videoUrl = [];
    VideoDetailModel detailObj;
-
+  VideoPlayerController _controller;
+  String videoUrl;
+  String str;
+  String imagesUrl;
+  double percent = 0.0;
    // 焦点控制
     FocusNode _focusNode1 = new FocusNode(); 
     GlobalKey _formKey= new GlobalKey<FormState>();
@@ -74,10 +85,8 @@ class VideoUploadState extends State<VideoUpload> {
         print(88885);
         
         setState(() {
-          videoUrl = [];
-          imagesUrl = [];
-          videoUrl.add(res.url);
-          imagesUrl.add(res.cover);
+          videoUrl = null;
+          videoUrl = res.url;
           _titleController.text = res.title;
           _descController.text = res.descr;
           brandIdss = res.brandId;
@@ -97,10 +106,10 @@ class VideoUploadState extends State<VideoUpload> {
       // imagesUrl.add(res.path);
       dismissLoading(context);
       setState(() {
-        videoUrl = [];
-        imagesUrl = [];
-        videoUrl.add(res.pathUrl);
-        imagesUrl.add(res.coverUrl);
+        // videoUrl = [];
+        // imagesUrl = [];
+        // videoUrl.add(res.pathUrl);
+        // imagesUrl.add(res.coverUrl);
         
       });
     }, onError: (code, msg) {
@@ -164,7 +173,8 @@ class VideoUploadState extends State<VideoUpload> {
         LogUtil.d(_imageFile.hashCode);
         LogUtil.d(_imageFile.path);
         print(123);
-        upLoadFileOnce(_imageFile.path);
+        // upLoadFileOnce(_imageFile.path);
+        _uploadImage(_imageFile.path);
         setState(() {});
       }
     } catch (e) {
@@ -172,6 +182,49 @@ class VideoUploadState extends State<VideoUpload> {
     }
   }
 
+  void _uploadImage(filePath) async {
+    showPercent(context, (){
+      dismissLoading(context);
+      toasts("上传失败");
+    },(){
+      if(videoUrl == null && str != null){
+        setState(() {
+            videoUrl = str;
+            print("videoUrl:"+videoUrl);
+            dismissLoading(context);
+            toasts("上传成功");
+          });
+      }
+    });
+    String uploadName = OssUtil.instance.getImageUploadName(filePath);
+    await NewApiService.uploadImage(context, uploadName, filePath).then((data) {
+      if (data.statusCode == 200) {
+        str = NewApiUrl.URL_UPLOAD_IMAGE_OSS + "/" + uploadName;
+        print("str:"+str);
+        print(videoUrl);
+        if(str != null){
+          Map obj = {
+            "uploadName":uploadName,
+            "success":true
+          };
+          FastNotification.push("percent",obj);
+        }
+      }else {
+        Map obj = {
+            "uploadName":uploadName,
+            "success":false
+          };
+        FastNotification.push("percent",obj);
+      }
+    }).catchError((data) {
+      Map obj = {
+            "uploadName":uploadName,
+            "success":false
+          };
+      FastNotification.push("percent",obj);
+    });
+  }
+
 
     FocusNode focusNode1 = new FocusNode();
 
@@ -329,7 +382,7 @@ class VideoUploadState extends State<VideoUpload> {
             ),
             Container(
                 width: width,
-                padding: EdgeInsets.only(left:15,top:15),
+                padding: EdgeInsets.only(left:15,top:15,bottom:15),
                 child: Text(
                                                         "(建议时长3分钟,建议大小50M)",
                                                         style: TextStyle(
@@ -341,59 +394,115 @@ class VideoUploadState extends State<VideoUpload> {
                                                             textAlign: TextAlign.left,
                                                       ),
               ),
-            Container(
-              color: ThemeUtils.getTabsBg(context),
-              child: GridView.builder(
-                shrinkWrap: true,
-                padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
-                physics: NeverScrollableScrollPhysics(),
-                gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
-                    crossAxisCount: 3, childAspectRatio: 1.18),
-                itemCount: videoUrl.length >= 1 ? 1 : videoUrl.length + 1,
-                itemBuilder: (_, index) {
-                  return Stack(
-                    children: <Widget>[
-                      Center(
-                        child: SelectedImage(
-                            image: index < videoUrl.length ? imagesUrl[index] : null,
-                            // image: index < videoUrl.length ? videoUrl[index] : null,
-                            index:index,
-                            onTap: () {
-                              if(index >= videoUrl.length){
-                                selectPicker();
-                              }
-                              FocusScope.of(context).requestFocus(FocusNode());
-                              print(index);
-                              print(videoUrl);
-                            }),
-                      ),
-                      index < videoUrl.length?Positioned(
-                        top:0,
-                        right:0,
-                        child:GestureDetector(
-                          onTap: (){
-                            print(index);
-                            videoUrl.remove(videoUrl[index]);
-                            imagesUrl.remove(imagesUrl[index]);
-                            setState(() {
+            // Container(
+            //   color: ThemeUtils.getTabsBg(context),
+            //   child: GridView.builder(
+            //     shrinkWrap: true,
+            //     padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
+            //     physics: NeverScrollableScrollPhysics(),
+            //     gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+            //         crossAxisCount: 3, childAspectRatio: 1.18),
+            //     itemCount: videoUrl.length >= 1 ? 1 : videoUrl.length + 1,
+            //     itemBuilder: (_, index) {
+            //       return Stack(
+            //         children: <Widget>[
+            //           Center(
+            //             child: SelectedImage(
+            //                 image: index < videoUrl.length ? imagesUrl[index] : null,
+            //                 // image: index < videoUrl.length ? videoUrl[index] : null,
+            //                 index:index,
+            //                 onTap: () {
+            //                   if(index >= videoUrl.length){
+            //                     selectPicker();
+            //                   }
+            //                   FocusScope.of(context).requestFocus(FocusNode());
+            //                   print(index);
+            //                   print(videoUrl);
+            //                 }),
+            //           ),
+            //           index < videoUrl.length?Positioned(
+            //             top:0,
+            //             right:0,
+            //             child:GestureDetector(
+            //               onTap: (){
+            //                 print(index);
+            //                 videoUrl.remove(videoUrl[index]);
+            //                 imagesUrl.remove(imagesUrl[index]);
+            //                 setState(() {
                               
-                            });
-                          },
-                          child:Icon(
-                              IconData(
-                                0xe62a,
-                                fontFamily:"myfont"
+            //                 });
+            //               },
+            //               child:Icon(
+            //                   IconData(
+            //                     0xe62a,
+            //                     fontFamily:"myfont"
+            //                   ),
+            //                   size: 24.0,
+            //                   color:Color(0xff999999),
+            //                 ),
+            //             )
+            //           ):Container(child: null,)
+            //         ],
+            //       );
+            //     },
+            //   )
+            // ),
+            Container(
+                    color: ThemeUtils.getDialogTextFieldColor(context),
+                    child: GridView.builder(
+                      shrinkWrap: true,
+                      padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
+                      physics: NeverScrollableScrollPhysics(),
+                      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+                          crossAxisCount: 1, childAspectRatio: 1.18),
+                      itemCount: 1,
+                      itemBuilder: (_, index) {
+                        return Stack(
+                          children: <Widget>[
+                            Center(
+                              child: SelectedVideo(
+                                image: videoUrl,
+                                index: index,
+                                videoPlay:videoPlay(),
+                                onTap: () {
+                                  if(videoUrl == null){
+                                    selectPicker();
+                                  }
+                                  
+                                },
                               ),
-                              size: 24.0,
-                              color:Color(0xff999999),
                             ),
-                        )
-                      ):Container(child: null,)
-                    ],
-                  );
-                },
-              )
-            ),
+                            videoUrl != null
+                                ? Positioned(
+                                    top: 0,
+                                    right: 0,
+                                    child: GestureDetector(
+                                      onTap: () {
+                                        print(index);
+                                        
+                                        // imagesUrl = null;
+                                        setState(() {
+                                          videoUrl = null;
+                                          str = null;
+                                          _controller.pause();
+                                          // player.reset();
+                                        });
+                                      },
+                                      child: Icon(
+                                        IconData(0xe62a, fontFamily: "myfont"),
+                                        size: 24.0,
+                                        color: Color(0xff999999),
+                                      ),
+                                    ),
+                                  )
+                                : Container(
+                                    child: null,
+                                  )
+                          ],
+                        );
+                      },
+                    ),
+                  ),
             SizedBox(
               height:ScreenUtil().setWidth(80),
             ),
@@ -427,12 +536,12 @@ class VideoUploadState extends State<VideoUpload> {
                             toasts("请选择品牌");
                             return; 
                           }
-                          if(videoUrl.length<1){
+                          if(videoUrl==null){
                             toasts("请上传视频");
                             return; 
                           }
-                          String videos = videoUrl.join(",");
-                          String images = imagesUrl.join(",");
+                          // String videos = videoUrl.join(",");
+                          // String images = imagesUrl.join(",");
                         if((_formKey.currentState as FormState).validate()){
                           
                           
@@ -442,8 +551,8 @@ class VideoUploadState extends State<VideoUpload> {
                               "brandId":brandIdss,
                               "title":_titleController.text,
                               "descr":_descController.text,
-                              "url":videos,
-                              "cover": images,
+                              "url":videoUrl,
+                              // "cover": images,
                               "checkFlag":2,
                               "statuz":1,
                               "platformFlag":1,
@@ -455,7 +564,7 @@ class VideoUploadState extends State<VideoUpload> {
                               toasts("修改成功");
                               String initThisMyVideo = randomInt(1111,9999).toString() + DateTime.now().millisecondsSinceEpoch.toString();
                               FastNotification.push("initMyVideo",initThisMyVideo);
-                              Navigator.pop(context);
+                              Navigator.of(context)..pop()..pop();
                             }, onError: (code, msg) {
                               dismissLoading(context);
                               toasts(msg);
@@ -465,8 +574,8 @@ class VideoUploadState extends State<VideoUpload> {
                               "brandId":brandIdss,
                               "title":_titleController.text,
                               "descr":_descController.text,
-                              "url":videos,
-                              "cover": images,
+                              "url":videoUrl,
+                              // "cover": images,
                               "checkFlag":2,
                               "statuz":1,
                               "platformFlag":1,
@@ -597,6 +706,76 @@ class VideoUploadState extends State<VideoUpload> {
       ),
     );
   }
+
+  Widget videoPlay() {
+    
+    _controller = VideoPlayerController.network(
+                                        Utils.getImagePath(videoUrl) 
+                                        // imgFontUrl + detailObj.url
+                                        );
+    double width = MediaQuery.of(context).size.width;
+    return 
+    // Container(
+    //                     width: width,
+    //                     height: width*0.6,
+    //                     alignment: Alignment.center,
+    //                     child: FijkView(
+    //                       player: player,
+    //                       color: Colors.black,
+    //                       fit:FijkFit.fill,
+    //                       // cover: NetworkImage(detailObj.cover),
+    //                       // cover: new Image(image: detailObj.cover!=null&& detailObj.cover!=""?NetworkImage(detailObj.cover):AssetImage("assets/images/video_image.png"),).image,
+    //                       // 
+    //                     ),
+    //                   );
+    Container(
+                          padding: EdgeInsets.only(
+                              left: ScreenUtil().setWidth(15),
+                              right: ScreenUtil().setWidth(15),
+                              top: ScreenUtil().setWidth(15)),
+                          child: ClipRRect(
+                            borderRadius: BorderRadius.circular(5),
+                            child: 
+                            new Chewie(
+                              controller: ChewieController(
+                                videoPlayerController:
+                                    // VideoPlayerController.network(
+                                    //     imgFontUrl + detailObj.url
+                                    //     ),
+                                    _controller,
+                                aspectRatio: 3 / 2,
+                                allowFullScreen:false,
+                                autoPlay: false,
+                                looping: true,
+                                // startAt: Duration(seconds: 1,minutes: 1),
+                                showControls: true,
+                                deviceOrientationsAfterFullScreen:[DeviceOrientation.portraitUp],
+                                // 占位图
+                                // placeholder: Image.network(
+                                //     imgFontUrl+detailObj.cover,
+                                //     fit: BoxFit.contain,
+
+                                //   ),
+
+                                // 是否在 UI 构建的时候就加载视频
+                                autoInitialize: true,
+
+                                // 拖动条样式颜色
+                                materialProgressColors:
+                                    new ChewieProgressColors(
+                                  playedColor: Colors.red,
+                                  handleColor: Colors.blue,
+                                  backgroundColor: Colors.grey,
+                                  bufferedColor: Colors.lightGreen,
+                                ),
+                              ),
+                            ),
+
+                            
+                            
+                          )
+                      );
+  }
 }
 
 

+ 3 - 3
lib/main.dart

@@ -25,9 +25,9 @@ void main() {
   WidgetsFlutterBinding.ensureInitialized();
   FlutterBugly.postCatchedException(() async {
     // 强制竖屏
-    // SystemChrome.setPreferredOrientations(
-    //     [DeviceOrientation.portraitUp]);
-    OrientationPlugin.forceOrientation(DeviceOrientation.portraitUp);
+    SystemChrome.setPreferredOrientations(
+        [DeviceOrientation.portraitUp]);
+    // OrientationPlugin.forceOrientation(DeviceOrientation.portraitUp);
     FlutterBugly.init(androidAppId: "ae4e3d567d", iOSAppId: "4f09cdc82c");
     // 透明状态栏
     if (Platform.isAndroid) {

+ 31 - 0
lib/net/api_service.dart

@@ -45,6 +45,7 @@ import 'package:liftmanager/internal/work/model/banner_entity.dart';
 import 'package:liftmanager/internal/work/model/count_doing_item.dart';
 import 'package:liftmanager/internal/yearly/model/yearly_list_entity.dart';
 import 'package:liftmanager/net/dio_utils.dart';
+import 'package:liftmanager/net/net_utils.dart';
 import 'package:liftmanager/routers/fluro_navigator.dart';
 import 'package:liftmanager/utils/toast.dart';
 import 'package:flustars/flustars.dart' as f;
@@ -91,6 +92,8 @@ import 'package:liftmanager/internal/wode/model/table_dicts_model.dart';
 import 'package:liftmanager/internal/wode/model/privilege_model.dart';
 import 'package:liftmanager/internal/wode/model/vipfee_model.dart';
 import 'package:liftmanager/internal/wode/model/share_model.dart';
+import 'package:liftmanager/utils/oss_upload.dart';
+import 'package:liftmanager/utils/url.dart';
 
 class ApiUrl {
   ///上传图片
@@ -3258,6 +3261,11 @@ class NewApiUrl {
   ///我的消息列表
   static const String mynotifica_list = "/push/message/list";
   static const String mynotifica_updata = "/push/message/read";
+  //获取OSS Token
+  static final String URL_TOKEN= "****/getAliyunOssToken";
+
+  //获取OS上传图片服务器地址
+  static final String URL_UPLOAD_IMAGE_OSS= ossUrl;
 }
 
 class NewApiService {
@@ -4805,4 +4813,27 @@ class NewApiService {
         onError: onError);
   }
 
+  static Future<Response> uploadImage(
+      BuildContext context, String uploadName, String filePath,
+      {cancelToken}) async {
+    BaseOptions options = new BaseOptions();
+    options.responseType = ResponseType.plain; //必须,否则上传失败后aliyun返回的提示信息(非JSON格式)看不到
+    //创建一个formdata,作为dio的参数
+    File file = new File(filePath);
+    FormData data = new FormData.fromMap({
+      'Filename': uploadName,//文件名,随意
+      'key': uploadName, //"可以填写文件夹名(对应于oss服务中的文件夹)/" + fileName
+      'policy': OssUtil.policy,
+      'OSSAccessKeyId':OssUtil.accesskeyId,//Bucket 拥有者的AccessKeyId。
+      'success_action_status': '200',//让服务端返回200,不然,默认会返回204
+      'signature': OssUtil.instance.getSignature(OssUtil.accessKeySecret),
+      'x-oss-security-token':OssUtil.stsToken,//临时用户授权时必须,需要携带后台返回的security-token
+      'file': await MultipartFile.fromFile(filePath, filename: OssUtil.instance.getImageNameByPath(filePath))//必须放在参数最后
+    });
+    return NetUtils.instance
+        .post(context, NewApiUrl.URL_UPLOAD_IMAGE_OSS, data: data, options: options);
+  }
+
+  
+
 }

+ 2 - 1
lib/net/dio_utils.dart

@@ -13,6 +13,7 @@ import 'base_entity.dart';
 import 'error_handle.dart';
 import 'intercept.dart';
 import 'package:liftmanager/utils/log_util.dart' as logg;
+import 'package:liftmanager/utils/url.dart';
 
 /// @weilu https://github.com/simplezhli
 class DioUtils {
@@ -45,7 +46,7 @@ class DioUtils {
       // baseUrl: "http://192.168.31.112:20226",
       // baseUrl: "http://lift.whlhcx.com",
 //      baseUrl: "http://111.47.6.224:10227",
-      baseUrl: "http://111.47.6.224:10227",
+      baseUrl: baseUrl,
       // baseUrl: "http://221.234.44.30:10227",
 //      baseUrl: "http://192.168.1.16",
 //      contentType: ContentType('application', 'x-www-form-urlencoded', charset: 'utf-8'),

+ 116 - 0
lib/net/net_utils.dart

@@ -0,0 +1,116 @@
+import 'package:flutter/material.dart';
+import 'dart:io';
+import 'dart:convert';
+import 'package:dio/dio.dart';
+import 'package:fluttertoast/fluttertoast.dart';
+import 'package:common_utils/common_utils.dart';
+import 'package:liftmanager/utils/url.dart';
+/*
+* Http请求配置工具类
+*/
+class NetUtils {
+  static BuildContext context = null;
+
+  BaseOptions _options;
+  Dio dio;
+
+  // 工厂模式
+  factory NetUtils() => _getInstance();
+
+  static NetUtils get instance => _getInstance();
+  static NetUtils _instance;
+
+  NetUtils._internal() {
+    //初始化
+    dio = getDio();
+  }
+
+  static NetUtils _getInstance() {
+    LogUtil.init(isDebug: false,tag: "****NetUtils****");
+    if (_instance == null) {
+      _instance = new NetUtils._internal();
+    }
+    return _instance;
+  }
+
+  /**
+   * 获取dio实例,不配置根url,完全使用传入的绝对路径url
+   */
+  Dio getDio({String url, BaseOptions options}) {
+    if (options == null) {
+      _options = new BaseOptions(
+          baseUrl: baseUrl,
+          connectTimeout: 1500000,
+          receiveTimeout: 15000,
+          contentType: "multipart/form-data",
+        );
+    } else {
+      _options = options;
+    }
+    Dio _dio = new Dio(_options);
+//    _dio.interceptors.add(new TokenInterceptor());//待完善
+//    _dio.interceptors.add(new ErrorInterceptor(_dio));//待优化
+    // _dio.interceptors.add(new HeaderInterceptor());
+//    _dio.interceptors.add(new LogInterceptor());
+    // setProxy(_dio);
+    return _dio;
+  }
+
+  /**
+   * 设置代理
+   * */
+  // void setProxy(Dio dio) {
+  //   //debug模式且为wifi网络时设置代理
+  //   if (Config.debug) {
+  //     //debug模式下设置代理
+  //     (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
+  //         (client) {
+  //       //设置代理
+  //       client.findProxy = (uri) {
+  //         return "PROXY " + UrlConstant.PROXY_URI;
+  //       };
+  //     };
+  //   }
+  // }
+
+  Future<Response> post(BuildContext context, url, {data, BaseOptions options,cancelToken}) async {
+    LogUtil.v('启动post请求 url:$url ,body: $data');
+    Response response;
+    try {
+      if (url != null &&
+          (url.startsWith("http://") || url.startsWith("https://"))) {
+        dio = getDio(url: url,options: options);
+      }
+      response = await dio.post(url, data: data, cancelToken: cancelToken);
+      print('post请求成功 response.data:${response.statusCode.toString()}');
+      return response;
+      // LogUtil.v('post请求成功 response.data:${response.toString()}');
+    } on DioError catch (e) {
+      if (CancelToken.isCancel(e)) {
+        LogUtil.v('post请求取消:' + e.message);
+      }
+      LogUtil.v('post请求发生错误:$e');
+    }
+    return response; //response.data.toString()这种方式不是标准json,不能使用
+  }
+
+  get(BuildContext context, url, {data,BaseOptions options,cancelToken}) async {
+    LogUtil.v('启动get请求 url:$url ,body: $data');
+    Response response;
+    try {
+      if (url != null &&
+          (url.startsWith("http://") || url.startsWith("https://"))) {
+        dio = getDio(url: url,options: options);
+      }
+      response =
+          await dio.get(url, queryParameters: data, cancelToken: cancelToken);
+      LogUtil.v('get请求成功 response.data:${response.toString()}');
+    } on DioError catch (e) {
+      if (CancelToken.isCancel(e)) {
+        LogUtil.v('get请求取消:' + e.message);
+      }
+      LogUtil.v('get请求发生错误:$e');
+    }
+    return response;
+  }
+}

+ 102 - 0
lib/utils/oss_upload.dart

@@ -0,0 +1,102 @@
+import 'dart:convert';
+import 'package:crypto/crypto.dart';
+import 'dart:math';
+import 'package:liftmanager/utils/time_format.dart';
+/*
+* Oss工具类
+* PostObject方式上传图片官方文档:https://help.aliyun.com/document_detail/31988.html
+*/
+class OssUtil {
+
+//  static String accesskeyId = '******';//Bucket 拥有者的accesskeyId 。
+//  static String accessKeySecret = '******';//Bucket 拥有者的accessKeySecret。
+  static String accesskeyId = 'LTAI4G1iLTczu8JxM2En57gY';//临时用户的AccessKeyId,通过后台接口动态获取
+  static String accessKeySecret = 'VHeRj3C2br87Uh447ruHsSTvYSDWeC';//临时用户的accessKeySecret,通过后台接口动态获取
+  static String stsToken="";//临时用户鉴权Token,临时用户认证时必传,通过后台接口动态获取
+  //验证文本域
+  static String _policyText =
+      '{"expiration": "2069-05-22T03:15:00.000Z","conditions": [["content-length-range", 0, 1048576000]]}';//UTC时间+8=北京时间
+
+  //进行utf8编码
+  static List<int> _policyText_utf8 = utf8.encode(_policyText);
+  //进行base64编码
+  static String policy= base64.encode(_policyText_utf8);
+
+  //再次进行utf8编码
+  static List<int> _policy_utf8 = utf8.encode(policy);
+
+  // 工厂模式
+  factory OssUtil() => _getInstance();
+
+  static OssUtil get instance => _getInstance();
+  static OssUtil _instance;
+
+  OssUtil._internal() {
+
+  }
+
+  static OssUtil _getInstance() {
+    if (_instance == null) {
+      _instance = new OssUtil._internal();
+    }
+    return _instance;
+  }
+
+  /*
+  *获取signature签名参数
+  */
+  String getSignature(String _accessKeySecret){
+    //进行utf8 编码
+    List<int> _accessKeySecret_utf8 = utf8.encode(_accessKeySecret);
+
+    //通过hmac,使用sha1进行加密
+    List<int> signature_pre = new Hmac(sha1, _accessKeySecret_utf8).convert(_policy_utf8).bytes;
+
+    //最后一步,将上述所得进行base64 编码
+    String signature = base64.encode(signature_pre);
+    return signature;
+  }
+
+  /**
+   * 生成上传上传图片的名称 ,获得的格式:photo/20171027175940_oCiobK
+   * 可以定义上传的路径uploadPath(Oss中保存文件夹的名称)
+   * @param uploadPath 上传的路径 如:/photo
+   * @return photo/20171027175940_oCiobK
+   */
+  String getImageUploadName(String filePath) {
+    String imageMame = "";
+    int time = DateTime.now().millisecondsSinceEpoch;
+    String nums = DateUtils.instance.getFormartData(timeSamp: time,format: "yyyy-MM-dd");
+    String year = nums.split("-")[0];
+    String mounth = nums.split("-")[1];
+    String day = nums.split("-")[2];
+    String uploadPath = "upload/" + year + "/" + mounth + "/" + day;
+    var timestamp = new DateTime.now().millisecondsSinceEpoch;
+    imageMame =timestamp.toString()+"_"+getRandom(6);
+    if(uploadPath!=null&&uploadPath.isNotEmpty){
+      imageMame=uploadPath+"/"+imageMame;
+    }
+    String imageType=filePath?.substring(filePath?.lastIndexOf("."),filePath?.length);
+    return imageMame+imageType;
+  }
+
+  /*
+  * 生成固定长度的随机字符串
+  * */
+  String getRandom(int num) {
+    String alphabet = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
+    String left = '';
+    for (var i = 0; i < num; i++) {
+//    right = right + (min + (Random().nextInt(max - min))).toString();
+      left = left + alphabet[Random().nextInt(alphabet.length)];
+    }
+    return left;
+  }
+
+  /*
+  * 根据图片本地路径获取图片名称
+  * */
+  String getImageNameByPath(String filePath) {
+    return filePath?.substring(filePath?.lastIndexOf("/")+1,filePath?.length);
+  }
+}

+ 112 - 1
lib/utils/toast.dart

@@ -2,7 +2,12 @@
 import 'package:fluttertoast/fluttertoast.dart';
 import 'package:flutter/material.dart';
 import 'package:liftmanager/utils/loading_dialog.dart';
-
+// import 'package:percent_indicator_example/sample_linear_page.dart';
+import 'package:percent_indicator/percent_indicator.dart';
+import 'dart:async';
+import 'package:liftmanager/utils/fast_notification.dart';
+import 'dart:math';
+import 'package:flustars/flustars.dart' as FlutterStars;
 /// Toast工具类
 //class Toast {
 //  static show(String msg, {duration = 2000}) {
@@ -81,3 +86,109 @@ showAlert(BuildContext context, String title, String content, String txt1,
 dismissLoading(BuildContext context) {
   Navigator.pop(context);
 }
+
+randomInt(int min, int max) {
+    return new Random().nextInt(max) % (max - min + 1) + min;
+  }  
+
+showPercent(BuildContext context,Function fun,Function funBack) {
+  
+  double percent = 0.0;
+  double width = MediaQuery.of(context).size.width;
+  showDialog<Null>(
+      context: context, //BuildContext对象
+      barrierDismissible: false,
+      builder: (BuildContext context) {
+        return StatefulBuilder(
+            builder: (context, state) {
+              String textss = '上传中,请稍后~';
+              Color col = Colors.white;
+              FastNotification.addListener("percent", (obj) {
+                print(obj);
+                print("-----------/*/");
+                print(FlutterStars.SpUtil.getString('uploadName'));
+                
+                // if(FlutterStars.SpUtil.getString('uploadName') == ""){
+                //   FlutterStars.SpUtil.putString('uploadName', obj["uploadName"]);
+                  
+                // }
+
+                if(obj["success"] == true){
+                  state(() {
+                    percent = 1.0;
+                    textss = "上传成功!";
+                    print("这里是成功");
+                    // col = Colors.green;
+                  });
+                  // FastNotification.push("percent_back",percent);
+                  // funBack();
+                  new Future.delayed(Duration(milliseconds: 1000), () {
+                    funBack();
+          
+                  });
+                }else {
+                  state((){
+                    textss = "上传失败!";
+                    col = Colors.red;
+                  });
+                  // fun();
+                  new Future.delayed(Duration(milliseconds: 1000), () {
+                    fun();
+          
+                  });
+                }
+                
+                print("complate-----------------------------------------------------");
+              });
+
+              Timer _timer;
+              
+              const period = const Duration(seconds: 3);
+              _timer = Timer.periodic(period, (timer) {
+                if(percent >= 0.9){
+                  _timer.cancel();
+                }else {
+                  state(() {
+                    percent = double.parse((0.1 + percent).toStringAsFixed(2));
+                    print(percent);
+                  });
+              }});
+             
+                return Center(
+                  child: Column(
+                    mainAxisAlignment: MainAxisAlignment.center,
+                    children: <Widget>[
+                      
+                      Container(
+                        child: 
+                          new LinearPercentIndicator(
+                            alignment:MainAxisAlignment.center,
+                            width: 300,
+                            animation: false,
+                            animationDuration: 1000,
+                            lineHeight: 20.0,
+                            percent: percent,
+                            center: Text(
+                              (percent*100).toString()+'%',
+                              style: new TextStyle(fontSize: 12.0,color:Colors.white)
+                            ),
+                            linearStrokeCap: LinearStrokeCap.roundAll,
+                            backgroundColor: Colors.grey,
+                            progressColor: Colors.blue,
+                        )
+                        ),
+                      // Container(
+                      //   padding: EdgeInsets.only(top:15),
+                      //   child: Text(
+                      //         textss,
+                      //         style: new TextStyle(fontSize: 12.0,color:Colors.white,decoration: TextDecoration.none),
+                      //       ),
+                      // ),
+                    ],
+                  ),
+                );
+            });
+
+        
+      });
+}

+ 2 - 0
lib/utils/url.dart

@@ -5,6 +5,8 @@ const String imgFontUrl = "http://sellerAdminpp.udreamtech.com/files/ty/";
 // const String socketUrl = "ws://192.168.1.111:8002/ws";
 const String socketUrl = "ws://111.47.6.224:8002/ws";
 const String jumpUrl = "http://lift.whlhcx.com";
+const String baseUrl = "http://111.47.6.224:10227";
+const String ossUrl = "http://ty-oss-file.oss-cn-hangzhou.aliyuncs.com";
 // const String socketUrl = "ws://221.234.44.30:8002/ws";
 // const String socketUrl = "ws://lift.whlhcx.com:8002/ws";
 // const String socketUrl = "ws://192.168.0.110:8002/ws";

+ 3 - 1
pubspec.yaml

@@ -75,6 +75,8 @@ dependencies:
   crypto: ^2.1.3
   # toast
   fluttertoast: ^3.1.3
+  # percent
+  percent_indicator: ^2.1.5
   # 微信登录
   fluwx: ^1.2.1
 #  fluwx_no_pay: ^2.1.1
@@ -117,7 +119,7 @@ dependencies:
 
   orientation: ^1.2.0
 
-  fijkplayer: ^0.8.7
+  
 
 dev_dependencies:
   flutter_test: