interrogation_page.dart 35 KB

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