interrogation_page.dart 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884
  1. import 'dart:io';
  2. import 'package:chewie/chewie.dart';
  3. import 'package:flustars/flustars.dart' as flustars;
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter/services.dart';
  6. import 'package:flutter_picker/flutter_picker.dart';
  7. import 'package:flutter_screenutil/flutter_screenutil.dart';
  8. import 'package:image_picker/image_picker.dart';
  9. import 'package:liftmanager/common/common.dart';
  10. import 'package:liftmanager/internal/bbs/bbs_router.dart';
  11. import 'package:liftmanager/internal/bbs/page/widgets.dart';
  12. import 'package:liftmanager/net/api_service.dart';
  13. import 'package:liftmanager/res/resources.dart';
  14. import 'package:liftmanager/routers/fluro_navigator.dart';
  15. import 'package:liftmanager/utils/fast_notification.dart';
  16. import 'package:liftmanager/utils/oss_upload.dart';
  17. import 'package:liftmanager/utils/theme_utils.dart';
  18. import 'package:liftmanager/utils/toast.dart';
  19. import 'package:liftmanager/utils/utils.dart';
  20. import 'package:liftmanager/widgets/app_bar.dart';
  21. import 'package:liftmanager/widgets/divider.dart';
  22. import 'package:liftmanager/widgets/selected_image_change.dart';
  23. import 'package:liftmanager/widgets/selected_video_change.dart';
  24. import 'package:shared_preferences/shared_preferences.dart';
  25. import 'package:umeng_common_sdk/umeng_common_sdk.dart';
  26. import 'package:video_player/video_player.dart';
  27. class InterrogationPage extends StatefulWidget {
  28. InterrogationPage(this.brandName, this.brandId);
  29. final String brandName;
  30. final String brandId;
  31. @override
  32. State<StatefulWidget> createState() {
  33. return InterrogationPageState();
  34. }
  35. }
  36. class InterrogationPageState extends State<InterrogationPage> {
  37. // NewsDetailItem item = NewsDetailItem();
  38. List<String> imagesUrl = [];
  39. String videoUrl;
  40. String imageUrl;
  41. String str;
  42. double percent = 0.0;
  43. String addressName = "";
  44. String selectDateStr;
  45. VideoPlayerController _controller;
  46. VideoPlayerController _controllerFile;
  47. ChewieController _chewieController;
  48. @override
  49. void initState() {
  50. super.initState();
  51. UmengCommonSdk.onPageStart("快速问诊-我要提问");
  52. print(widget.brandName);
  53. print(widget.brandId);
  54. print(65656);
  55. }
  56. //图片
  57. upLoadFileOnce(path) {
  58. showLoading(context, "正在上传...");
  59. NewApiService().upload(path, onSuccess: (res) {
  60. // imagesUrl.add(res.path);
  61. dismissLoading(context);
  62. setState(() {
  63. imagesUrl.add(res.pathUrl);
  64. // imageUrl = res.pathUrl;
  65. // videoUrl = null;
  66. });
  67. }, onError: (code, msg) {
  68. dismissLoading(context);
  69. toasts(msg);
  70. });
  71. }
  72. //视频
  73. upLoadFileOnceVideo(path) {
  74. showLoading(context, "正在上传...");
  75. NewApiService().upload(path, onSuccess: (res) {
  76. // imagesUrl.add(res.path);
  77. dismissLoading(context);
  78. setState(() {
  79. // videoUrl.add(res.pathUrl);
  80. // imagesUrlVideo.add(res.coverUrl);
  81. });
  82. }, onError: (code, msg) {
  83. dismissLoading(context);
  84. toasts(msg);
  85. });
  86. }
  87. @override
  88. void dispose() {
  89. UmengCommonSdk.onPageEnd("快速问诊-我要提问");
  90. _controller?.pause();
  91. _controller?.dispose();
  92. _chewieController?.dispose();
  93. // _chewieController.videoPlayerController.dispose();
  94. // _chewieController.setLooping(false);
  95. print('销毁');
  96. // _controllerFile.dispose();
  97. super.dispose();
  98. }
  99. // void selectImgOrVideo() {
  100. // showDialog(
  101. // context: context,
  102. // builder: (BuildContext context) {
  103. // return SimpleDialog(
  104. // title: Text("选择"),
  105. // children: ["图片", '视频'].map((String value) {
  106. // print("$value");
  107. // return SimpleDialogOption(
  108. // child: Text(
  109. // "${value}",
  110. // style:
  111. // TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
  112. // ),
  113. // onPressed: () {
  114. // Navigator.of(context).pop();
  115. // value == '图片'
  116. // ? selectPicker('image')
  117. // : selectPicker("video");
  118. // // if (type == "image") {
  119. // // _getImage(value == '拍照' ? 1 : 0);
  120. // // } else if (type == "video") {
  121. // // _getVideo(value == '拍照' ? 1 : 0);
  122. // // }
  123. // },
  124. // );
  125. // }).toList());
  126. // });
  127. // }
  128. void _uploadImage(filePath) async {
  129. showPercent(context, () {
  130. dismissLoading(context);
  131. toasts("上传失败");
  132. }, () {
  133. if (videoUrl == null && str != null) {
  134. setState(() {
  135. // videoUrl = str;
  136. imageUrl = null;
  137. videoUrl = str;
  138. settingVideo();
  139. print("videoUrl:" + videoUrl);
  140. dismissLoading(context);
  141. toasts("上传成功");
  142. });
  143. }
  144. });
  145. String uploadName = OssUtil.instance.getImageUploadName(filePath);
  146. await NewApiService.uploadImage(context, uploadName, filePath).then((data) {
  147. if (data.statusCode == 200) {
  148. str = NewApiUrl.URL_UPLOAD_IMAGE_OSS + "/" + uploadName;
  149. print("str:" + str);
  150. print(videoUrl);
  151. if (str != null) {
  152. Map obj = {"uploadName": uploadName, "success": true};
  153. FastNotification.push("percent", obj);
  154. }
  155. } else {
  156. Map obj = {"uploadName": uploadName, "success": false};
  157. FastNotification.push("percent", obj);
  158. }
  159. }).catchError((data) {
  160. Map obj = {"uploadName": uploadName, "success": false};
  161. FastNotification.push("percent", obj);
  162. });
  163. }
  164. settingVideo() {
  165. _controller?.pause();
  166. _controller?.dispose();
  167. _chewieController?.dispose();
  168. _controller = VideoPlayerController.network(Utils.getImagePath(videoUrl)
  169. // imgFontUrl + detailObj.url
  170. );
  171. _chewieController = ChewieController(
  172. videoPlayerController: _controller,
  173. isLive: true,
  174. // aspectRatio: 1 / 2,
  175. allowFullScreen: false,
  176. autoPlay: false,
  177. looping: false, //循环播放
  178. // startAt: Duration(seconds: 1,minutes: 1),
  179. showControls: true,
  180. deviceOrientationsAfterFullScreen: [DeviceOrientation.portraitUp],
  181. // 是否在 UI 构建的时候就加载视频
  182. autoInitialize: true,
  183. // 拖动条样式颜色
  184. materialProgressColors: new ChewieProgressColors(
  185. playedColor: Colors.red,
  186. handleColor: Colors.blue,
  187. backgroundColor: Colors.grey,
  188. bufferedColor: Colors.lightGreen,
  189. ),
  190. );
  191. }
  192. void _getImage(int key) async {
  193. try {
  194. var _imageFile = await ImagePicker.pickImage(
  195. source: key == 1 ? ImageSource.camera : ImageSource.gallery,
  196. maxWidth: 800,
  197. imageQuality: 95);
  198. print(_imageFile);
  199. print(3333);
  200. if (_imageFile != null) {
  201. // images.add(_imageFile);
  202. upLoadFileOnce(_imageFile.path);
  203. // setState(() {});
  204. }
  205. } catch (e) {
  206. toasts("没有权限,无法打开相册!");
  207. }
  208. }
  209. void _getVideo(int key) async {
  210. print(key);
  211. print(333);
  212. try {
  213. await ImagePicker.pickVideo(
  214. source: key == 1 ? ImageSource.camera : ImageSource.gallery,
  215. ).then((File f) async {
  216. if (f != null) {
  217. _controllerFile = VideoPlayerController.file(f);
  218. _controllerFile.initialize().then((val) {
  219. // _controllerFile.setLooping(true);
  220. int seconds = _controllerFile.value.duration.inSeconds;
  221. print("视频时长:$seconds");
  222. int fileSize = f.lengthSync(); //单位B
  223. print("视频大小:${fileSize}");
  224. print("视频大小:${f.path}");
  225. if (seconds > 300) {
  226. toasts("视频时长不能大于5分钟!");
  227. return;
  228. // upLoadFileOnce(_imageFile.path);
  229. // setState(() {});
  230. } else {}
  231. if (fileSize > (1024 * 1000 * 50)) {
  232. toasts("视频不能超过50M!");
  233. return;
  234. }
  235. _uploadImage(f.path);
  236. }).catchError((error) {
  237. print(error);
  238. print("error");
  239. toasts("上传失败,不支持此格式");
  240. });
  241. }
  242. });
  243. } catch (e) {
  244. toasts("没有权限,无法打开相册!");
  245. }
  246. }
  247. ///选择图片
  248. void selectPicker(type) {
  249. showDialog(
  250. context: context,
  251. builder: (BuildContext context) {
  252. return SimpleDialog(
  253. title: Text("选择方式"),
  254. children: ["拍照", '从手机相册选择'].map((String value) {
  255. print("$value");
  256. return SimpleDialogOption(
  257. child: Text(
  258. "${value}",
  259. style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
  260. ),
  261. onPressed: () {
  262. if (type == "image") {
  263. _getImage(value == '拍照' ? 1 : 0);
  264. } else if (type == "video") {
  265. _getVideo(value == '拍照' ? 1 : 0);
  266. }
  267. Navigator.of(context).pop();
  268. },
  269. );
  270. }).toList());
  271. });
  272. }
  273. void setDataId(int id) async {
  274. SharedPreferences prefs = await SharedPreferences.getInstance();
  275. prefs.setInt("dataId", id);
  276. }
  277. void setType(String type) async {
  278. SharedPreferences prefs = await SharedPreferences.getInstance();
  279. prefs.setString("questionType", type);
  280. }
  281. Widget videoPlay() {
  282. if (_controller == null) return Container();
  283. double width = MediaQuery.of(context).size.width;
  284. return Container(
  285. child: ClipRRect(
  286. borderRadius: BorderRadius.circular(5),
  287. child: new Chewie(controller: _chewieController),
  288. ));
  289. }
  290. // 焦点控制
  291. // FocusNode _focusNode1 = new FocusNode();
  292. GlobalKey _formKey = new GlobalKey<FormState>();
  293. TextEditingController _questionController = new TextEditingController();
  294. TextEditingController _methodController = new TextEditingController();
  295. FocusNode blankNode = FocusNode();
  296. DateTime _nowDate = DateTime.now(); //当前日期
  297. DateTime _nowDateTime = DateTime.now();
  298. // DateTime.parse(formatDate(DateTime.now(),
  299. // [yyyy, "-", mm, "-", "dd", " ", HH, ":", nn, ":", ss])); //当前日期时间
  300. @override
  301. Widget build(BuildContext context) {
  302. double width = MediaQuery.of(context).size.width;
  303. // 监听FocusNode
  304. // _focusNode1.addListener((){
  305. // // _focusNode1.hasFocus 是否聚焦
  306. // print(_focusNode1.hasFocus);
  307. // });
  308. _cupertinoDateTimePicker() {
  309. List yearList = [];
  310. for (var i = 1990; i < DateTime.now().year + 1; i++) {
  311. yearList.add('$i年');
  312. }
  313. yearList.add('不详');
  314. new Picker(
  315. cancelText: "取消",
  316. confirmText: "确认",
  317. adapter: PickerDataAdapter<String>(pickerdata: yearList),
  318. changeToFirst: true,
  319. hideHeader: false,
  320. onConfirm: (Picker picker, List value) {
  321. selectDateStr = picker.getSelectedValues()[0];
  322. // widget.onConfirm(picker.getSelectedValues()[0], value[0]);
  323. setState(() {});
  324. },
  325. ).showModal(this.context);
  326. // DatePicker.showDatePicker(
  327. // context,
  328. // minDateTime: DateTime.parse('1990-05-12'), //起始日期
  329. // maxDateTime: DateTime.parse('2020-11-25'), //终止日期
  330. // //initialDateTime: DateTime.parse(formatDate(_selectedDateTime, [yyyy, "-", mm, "-", "dd", " ", HH, ":", nn, ":", ss])),
  331. // initialDateTime: _nowDateTime, //当前日期时间
  332. // // dateFormat: "yyyy年M月d日 EEE,H时", //显示格式
  333. // dateFormat: "yyyy年", //显示格式
  334. // // dateFormat: "yyyy年M月d日 ,H时:m分:s秒", //显示格式
  335. // locale: DateTimePickerLocale.zh_cn, //语言
  336. // pickerTheme: DateTimePickerTheme(
  337. // showTitle: true,
  338. // ),
  339. // pickerMode: DateTimePickerMode.date, // show TimePicker
  340. // onCancel: () {
  341. // debugPrint('onCancel');
  342. // },
  343. // onChange: (dateTime, List<int> index) {
  344. // setState(() {
  345. // _nowDate = dateTime;
  346. // });
  347. // },
  348. // onConfirm: (dateTime, List<int> index) {
  349. // setState(() {
  350. // _nowDate = dateTime;
  351. // print(_nowDate);
  352. // print(333333);
  353. // });
  354. // },
  355. // );
  356. }
  357. return Scaffold(
  358. resizeToAvoidBottomPadding: false, //不让键盘弹上去
  359. appBar: MyAppBar(
  360. centerTitle: "我要提问",
  361. ),
  362. body: GestureDetector(
  363. onTap: () {
  364. // 点击空白页面关闭键盘
  365. FocusScope.of(context).requestFocus(blankNode);
  366. },
  367. child: Stack(children: <Widget>[
  368. Container(
  369. padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(80)),
  370. child: ListView(children: <Widget>[
  371. Form(
  372. key: _formKey, //设置globalKey,用于后面获取FormState
  373. // autovalidate: true, //开启自动校验
  374. child: Column(
  375. children: <Widget>[
  376. Container(
  377. padding: EdgeInsets.only(
  378. left: ScreenUtil().setWidth(15),
  379. right: ScreenUtil().setWidth(15),
  380. top: ScreenUtil().setWidth(10),
  381. bottom: ScreenUtil().setWidth(10)),
  382. child: Row(
  383. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  384. children: <Widget>[
  385. Text(
  386. "电梯品牌",
  387. style:
  388. TextStyle(fontSize: ScreenUtil().setSp(14)),
  389. textAlign: TextAlign.start,
  390. ),
  391. Text(
  392. widget.brandName,
  393. style: TextStyle(
  394. color: Color(0xff999999),
  395. fontSize: ScreenUtil().setSp(14)),
  396. textAlign: TextAlign.start,
  397. ),
  398. ]),
  399. ),
  400. CzDivider(
  401. margin:
  402. EdgeInsets.only(left: ScreenUtil().setWidth(10)),
  403. width: double.infinity),
  404. SelectCell(
  405. title: '电梯出厂日期',
  406. subTitle: selectDateStr,
  407. onTap: _cupertinoDateTimePicker,
  408. ),
  409. CzDivider(
  410. margin:
  411. EdgeInsets.only(left: ScreenUtil().setWidth(10)),
  412. width: double.infinity),
  413. Row(
  414. crossAxisAlignment: CrossAxisAlignment.start,
  415. mainAxisAlignment: MainAxisAlignment.start,
  416. children: <Widget>[
  417. Container(
  418. margin: EdgeInsets.only(
  419. top: ScreenUtil().setHeight(10)),
  420. width: ScreenUtil().setWidth(2),
  421. height: ScreenUtil().setHeight(13),
  422. color: Color(0xFF568AFF),
  423. ),
  424. Container(
  425. padding: EdgeInsets.only(
  426. left: ScreenUtil().setWidth(13),
  427. top: ScreenUtil().setWidth(10),
  428. bottom: ScreenUtil().setWidth(5)),
  429. child: Text(
  430. "问题描述",
  431. style: TextStyle(
  432. fontSize: ScreenUtil().setSp(14),
  433. ),
  434. textAlign: TextAlign.left,
  435. ),
  436. ),
  437. ],
  438. ),
  439. Container(
  440. height: 120,
  441. padding: EdgeInsets.only(
  442. left: ScreenUtil().setWidth(15),
  443. right: ScreenUtil().setWidth(15),
  444. bottom: ScreenUtil().setWidth(10)),
  445. child: TextFormField(
  446. // autofocus: true,
  447. maxLength: 100,
  448. cursorColor: Color(0xffcccccc),
  449. controller: _questionController,
  450. maxLines: 5,
  451. decoration: InputDecoration(
  452. contentPadding: EdgeInsets.all(0),
  453. hintText: '请详细描述事故问题和现场情况',
  454. hintStyle: TextStyle(
  455. color: Color(0xffcccccc),
  456. fontSize: ScreenUtil().setSp(13),
  457. ),
  458. focusedBorder: InputBorder.none,
  459. border: InputBorder.none,
  460. // filled: true, // 背景色
  461. // fillColor: Colors.cyan.withAlpha(35),
  462. // icon: Icon(Icons.person)
  463. ),
  464. // 校验
  465. validator: (val) {
  466. return val.trim().length > 0 ? null : "不能为空";
  467. }),
  468. ),
  469. CzDivider(
  470. margin:
  471. EdgeInsets.only(left: ScreenUtil().setWidth(10)),
  472. width: double.infinity),
  473. Row(
  474. crossAxisAlignment: CrossAxisAlignment.start,
  475. mainAxisAlignment: MainAxisAlignment.start,
  476. children: <Widget>[
  477. Container(
  478. margin: EdgeInsets.only(
  479. top: ScreenUtil().setHeight(10)),
  480. width: ScreenUtil().setWidth(2),
  481. height: ScreenUtil().setHeight(13),
  482. color: Color(0xFF568AFF),
  483. ),
  484. Container(
  485. padding: EdgeInsets.only(
  486. left: ScreenUtil().setWidth(13),
  487. top: ScreenUtil().setWidth(10),
  488. bottom: ScreenUtil().setWidth(5)),
  489. child: Text(
  490. "已尝试方法",
  491. style: TextStyle(
  492. fontSize: ScreenUtil().setSp(14),
  493. ),
  494. textAlign: TextAlign.left,
  495. ),
  496. ),
  497. ],
  498. ),
  499. Container(
  500. height: 120,
  501. padding: EdgeInsets.only(
  502. left: ScreenUtil().setWidth(15),
  503. right: ScreenUtil().setWidth(15),
  504. bottom: ScreenUtil().setWidth(20)),
  505. child: TextFormField(
  506. // autofocus: true,
  507. maxLength: 100,
  508. cursorColor: Color(0xffcccccc),
  509. controller: _methodController,
  510. maxLines: 5,
  511. decoration: InputDecoration(
  512. contentPadding: EdgeInsets.all(0),
  513. hintText: '请详细描述已尝试方法以及结果',
  514. hintStyle: TextStyle(
  515. color: Color(0xffcccccc),
  516. fontSize: ScreenUtil().setSp(13),
  517. ),
  518. focusedBorder: InputBorder.none,
  519. border: InputBorder.none,
  520. // filled: true, // 背景色
  521. // fillColor: Colors.cyan.withAlpha(35),
  522. // icon: Icon(Icons.person)
  523. ),
  524. // 校验
  525. validator: (val) {
  526. return val.trim().length > 0 ? null : "不能为空";
  527. }),
  528. ),
  529. CzDivider(
  530. margin:
  531. EdgeInsets.only(left: ScreenUtil().setWidth(10)),
  532. width: double.infinity),
  533. Row(
  534. children: [
  535. Container(
  536. margin: EdgeInsets.only(
  537. top: ScreenUtil().setHeight(10)),
  538. width: ScreenUtil().setWidth(2),
  539. height: ScreenUtil().setHeight(13),
  540. color: Color(0xFF568AFF),
  541. ),
  542. Container(
  543. // width: width,
  544. padding: EdgeInsets.only(left: 10, top: 10),
  545. child: Text(
  546. "上传图片:",
  547. style: TextStyle(
  548. fontSize: ScreenUtil().setSp(14),
  549. ),
  550. textAlign: TextAlign.left,
  551. ),
  552. ),
  553. ],
  554. ),
  555. Container(
  556. color: ThemeUtils.getTabsBg(context),
  557. child: GridView.builder(
  558. shrinkWrap: true,
  559. padding:
  560. const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
  561. physics: NeverScrollableScrollPhysics(),
  562. gridDelegate:
  563. SliverGridDelegateWithFixedCrossAxisCount(
  564. crossAxisCount: 3, childAspectRatio: 1.18),
  565. itemCount: imagesUrl.length >= 9
  566. ? 9
  567. : imagesUrl.length + 1,
  568. itemBuilder: (_, index) {
  569. return Stack(
  570. children: <Widget>[
  571. Center(
  572. child: SelectedImage(
  573. image: index < imagesUrl.length
  574. ? imagesUrl[index]
  575. : null,
  576. index: index,
  577. onTap: () {
  578. if (index >= imagesUrl.length) {
  579. selectPicker("image");
  580. }
  581. FocusScope.of(context)
  582. .requestFocus(FocusNode());
  583. print(index);
  584. print(imagesUrl);
  585. }),
  586. ),
  587. index < imagesUrl.length
  588. ? Positioned(
  589. top: 0,
  590. right: 0,
  591. child: GestureDetector(
  592. onTap: () {
  593. print(index);
  594. imagesUrl
  595. .remove(imagesUrl[index]);
  596. setState(() {});
  597. },
  598. child: Icon(
  599. const IconData(0xe651,
  600. fontFamily: "Iconfont"),
  601. size: 24.0,
  602. color: Color(0xff999999),
  603. ),
  604. ))
  605. : Container(
  606. child: null,
  607. )
  608. ],
  609. );
  610. },
  611. )),
  612. // SizedBox(
  613. // height: 6,
  614. // child: Container(
  615. // color: ThemeUtils.getDialogTextFieldColor(context)),
  616. // ),
  617. CzDivider(
  618. margin:
  619. EdgeInsets.only(left: ScreenUtil().setWidth(10)),
  620. width: double.infinity),
  621. Container(
  622. width: width,
  623. padding: EdgeInsets.only(left: 15, top: 15),
  624. child: Text(
  625. "上传视频:",
  626. style: TextStyle(
  627. fontSize: ScreenUtil().setSp(14),
  628. ),
  629. textAlign: TextAlign.left,
  630. ),
  631. ),
  632. Container(
  633. width: width,
  634. padding: EdgeInsets.only(left: 15, bottom: 15),
  635. child: Text(
  636. "(建议时长3分钟,建议大小50M)",
  637. style: TextStyle(
  638. color: Colors.red,
  639. fontSize: ScreenUtil().setSp(14),
  640. ),
  641. textAlign: TextAlign.left,
  642. ),
  643. ),
  644. // Container(
  645. // color: ThemeUtils.getTabsBg(context),
  646. // child: GridView.builder(
  647. // shrinkWrap: true,
  648. // padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
  649. // physics: NeverScrollableScrollPhysics(),
  650. // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  651. // crossAxisCount: 3, childAspectRatio: 1.18),
  652. // itemCount: videoUrl.length >= 1 ? 1 : videoUrl.length + 1,
  653. // itemBuilder: (_, index) {
  654. // return Stack(
  655. // children: <Widget>[
  656. // Center(
  657. // child: SelectedImage(
  658. // image: index < videoUrl.length ? imagesUrlVideo[index] : null,
  659. // index:index,
  660. // onTap: () {
  661. // if(index >= videoUrl.length){
  662. // selectPicker("video");
  663. // }
  664. // FocusScope.of(context).requestFocus(FocusNode());
  665. // print(index);
  666. // print(videoUrl);
  667. // }),
  668. // ),
  669. // index < videoUrl.length?Positioned(
  670. // top:0,
  671. // right:0,
  672. // child:GestureDetector(
  673. // onTap: (){
  674. // print(index);
  675. // videoUrl.remove(videoUrl[index]);
  676. // imagesUrlVideo.remove(imagesUrlVideo[index]);
  677. // setState(() {
  678. // });
  679. // },
  680. // child:Icon(
  681. // IconData(
  682. // 0xe62a,
  683. // fontFamily:"Iconfont"
  684. // ),
  685. // size: 24.0,
  686. // color:Color(0xff999999),
  687. // ),
  688. // )
  689. // ):Container(child: null,)
  690. // ],
  691. // );
  692. // },
  693. // )
  694. // ),
  695. Container(
  696. color: ThemeUtils.getDialogTextFieldColor(context),
  697. child: GridView.builder(
  698. shrinkWrap: true,
  699. padding:
  700. const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
  701. physics: NeverScrollableScrollPhysics(),
  702. gridDelegate:
  703. SliverGridDelegateWithFixedCrossAxisCount(
  704. crossAxisCount: 1, childAspectRatio: 1.18),
  705. itemCount: 1,
  706. itemBuilder: (_, index) {
  707. return Stack(
  708. children: <Widget>[
  709. Center(
  710. child: SelectedVideo(
  711. image: videoUrl,
  712. index: index,
  713. videoPlay: videoPlay(),
  714. onTap: () {
  715. if (videoUrl == null) {
  716. selectPicker("video");
  717. }
  718. },
  719. ),
  720. ),
  721. videoUrl != null
  722. ? Positioned(
  723. top: 0,
  724. right: 0,
  725. child: GestureDetector(
  726. onTap: () {
  727. print(index);
  728. // imagesUrl = null;
  729. setState(() {
  730. videoUrl = null;
  731. str = null;
  732. _controller.pause();
  733. // player.reset();
  734. });
  735. },
  736. child: Icon(
  737. const IconData(0xe651,
  738. fontFamily: "Iconfont"),
  739. size: 24.0,
  740. color: Color(0xff999999),
  741. ),
  742. ),
  743. )
  744. : Container(
  745. child: null,
  746. )
  747. ],
  748. );
  749. },
  750. ),
  751. ),
  752. ],
  753. ),
  754. )
  755. ])),
  756. Positioned(
  757. bottom: 0,
  758. left: 0,
  759. child: Container(
  760. width: width,
  761. padding: EdgeInsets.only(
  762. top: ScreenUtil().setWidth(15),
  763. bottom: ScreenUtil().setWidth(15),
  764. left: ScreenUtil().setWidth(25),
  765. right: ScreenUtil().setWidth(25)),
  766. color: ThemeUtils.getDialogTextFieldColor(context),
  767. child: Container(
  768. height: ScreenUtil().setWidth(44),
  769. decoration: BoxDecoration(
  770. borderRadius: BorderRadius.circular(22.0),
  771. color: Colours.blue_app_main
  772. // gradient: const LinearGradient(
  773. // colors: [Color(0xFF00D9FF), Color(0xFF0287FF)]),
  774. ),
  775. child: FlatButton(
  776. // padding: EdgeInsets.all(15.0),
  777. child: Text("提交"),
  778. textColor: Colors.white,
  779. // textColor: Colors.white,
  780. onPressed: () {
  781. // if(imagesUrl.length<1){
  782. // toasts("请上传图片");
  783. // return;
  784. // }
  785. // String imgs = "";
  786. // if (imagesUrl.length > 0) {
  787. // imgs = imagesUrl.join(",");
  788. // }
  789. String imgs = "";
  790. if (imagesUrl.length > 0) {
  791. imgs = imagesUrl.join(",");
  792. }
  793. if ((_formKey.currentState as FormState).validate()) {
  794. dynamic obj = {
  795. "dataTable": "1",
  796. "brandId": widget.brandId,
  797. "expression": _questionController.text,
  798. "usedMethods": _methodController.text,
  799. "imgs": imgs,
  800. "videoUrl": videoUrl ?? '',
  801. "createUserId": int.parse(
  802. flustars.SpUtil.getString(Constant.userId)),
  803. "chargerId": 1,
  804. 'productionDate': selectDateStr
  805. };
  806. showLoading(context, "正在提交...");
  807. NewApiService().createCase(obj, onSuccess: (res) {
  808. dismissLoading(context);
  809. toasts("提交成功");
  810. FocusScope.of(context).requestFocus(FocusNode());
  811. print(res);
  812. print(999999);
  813. setDataId(res);
  814. setType("1");
  815. print(widget.brandId);
  816. if (_controller != null) {
  817. _controller.pause();
  818. }
  819. NavigatorUtils.push(context,
  820. "${BbsRouter.expertList}?id=${widget.brandId}");
  821. }, onError: (code, msg) {
  822. dismissLoading(context);
  823. toasts(msg);
  824. });
  825. }
  826. },
  827. ),
  828. ),
  829. ))
  830. ]),
  831. ),
  832. );
  833. }
  834. }