interrogation_page.dart 36 KB

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