recommend_ask.dart 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. import 'package:flutter/material.dart';
  2. import 'package:liftmanager/res/gaps.dart';
  3. import 'package:liftmanager/net/api_service.dart';
  4. import 'package:liftmanager/utils/toast.dart';
  5. import 'package:liftmanager/widgets/app_bar.dart';
  6. import 'package:liftmanager/internal/search/search_router.dart';
  7. import 'package:liftmanager/widgets/app_search_bar.dart';
  8. import 'package:liftmanager/res/resources.dart';
  9. import 'package:liftmanager/routers/fluro_navigator.dart';
  10. import 'package:liftmanager/widgets/load_image.dart';
  11. import 'package:liftmanager/widgets/selected_image.dart';
  12. import 'package:image_picker/image_picker.dart';
  13. import 'dart:io';
  14. import 'package:flutter_screenutil/flutter_screenutil.dart';
  15. import 'package:liftmanager/internal/bbs/bbs_router.dart';
  16. import 'package:liftmanager/utils/url.dart';
  17. import 'package:liftmanager/utils/time_format.dart';
  18. import 'dart:convert';
  19. import 'package:liftmanager/widgets/preview_images.dart';
  20. import 'package:liftmanager/utils/utils.dart';
  21. import 'package:liftmanager/utils/theme_utils.dart';
  22. import 'package:video_player/video_player.dart';
  23. import 'package:chewie/chewie.dart';
  24. import 'package:flutter/services.dart';
  25. import 'package:orientation/orientation.dart';
  26. class RecommendAsk extends StatefulWidget {
  27. RecommendAsk(this.id,this.type);
  28. final String id;
  29. final String type;
  30. @override
  31. State<StatefulWidget> createState() {
  32. return RecommendAskState();
  33. }
  34. }
  35. class RecommendAskState extends State<RecommendAsk> {
  36. // NewsDetailItem item = NewsDetailItem();
  37. ScrollController _scrollController = new ScrollController();
  38. VideoPlayerController _controller;
  39. @override
  40. void initState() {
  41. super.initState();
  42. // getDetail();
  43. Future.delayed(Duration(milliseconds: 100),(){
  44. getDetail();
  45. });
  46. }
  47. bool _hasData = false;
  48. List<String> listPreview = [];
  49. var detailObj;
  50. getDetail() {
  51. NewApiService().getLiftcaseDetail(int.parse(widget.id), onSuccess: (res) {
  52. detailObj = res;
  53. if(_controller == null && detailObj.videoUrl!=null){
  54. _controller = VideoPlayerController.network(
  55. Utils.getImagePath(detailObj.videoUrl)
  56. // imgFontUrl + detailObj.url
  57. );
  58. }
  59. listPreview = [];
  60. detailObj.imgs.split(",").forEach((element) {
  61. listPreview.add(Utils.getImagePath(element,isWater: true));
  62. });
  63. print("获取详情成功");
  64. print(JsonEncoder().convert(res));
  65. _hasData = true;
  66. setState(() {});
  67. }, onError: (code, msg) {
  68. toasts(msg);
  69. });
  70. }
  71. orderReceiving(){
  72. var obj = {
  73. "acceptStatus": 1,
  74. "id":detailObj.id
  75. };
  76. NewApiService().orderReceiving(obj, onSuccess: (res) {
  77. toasts("操作成功");
  78. if(_controller!=null){
  79. _controller.pause();
  80. }
  81. NavigatorUtils.push(context, "${BbsRouter.chatRoom}?id=${detailObj.sessionId}&type=someToOne&toUserId=''");
  82. _hasData = true;
  83. setState(() {});
  84. }, onError: (code, msg) {
  85. toasts(msg);
  86. });
  87. }
  88. orderRefuze(){
  89. NewApiService().orderRefuze(detailObj.id, onSuccess: (res) {
  90. toasts("操作成功");
  91. if(_controller!=null){
  92. _controller.pause();
  93. }
  94. NavigatorUtils.push(context, BbsRouter.workPlace);
  95. _hasData = true;
  96. setState(() {});
  97. }, onError: (code, msg) {
  98. toasts(msg);
  99. });
  100. }
  101. getTitle(){
  102. String str;
  103. if(widget.type=="1"){
  104. str = "问诊推荐";
  105. }else if (widget.type=="2"){
  106. str = "出诊推荐";
  107. }else if (widget.type=="3"){
  108. str = "诊单详情";
  109. }
  110. return str;
  111. }
  112. @override
  113. void dispose() {
  114. if(_controller!=null){
  115. _controller.pause();
  116. _controller.dispose();
  117. }
  118. // SystemChrome.setPreferredOrientations([
  119. // DeviceOrientation.portraitUp,
  120. // ]);
  121. OrientationPlugin.forceOrientation(DeviceOrientation.portraitUp);
  122. super.dispose();
  123. }
  124. @override
  125. Widget build(BuildContext context) {
  126. double width = MediaQuery.of(context).size.width;
  127. double height = MediaQuery.of(context).size.height;
  128. if(width > height){
  129. // SystemChrome.setPreferredOrientations([
  130. // DeviceOrientation.portraitUp,
  131. // ]);
  132. OrientationPlugin.forceOrientation(DeviceOrientation.portraitUp);
  133. }
  134. return Scaffold(
  135. resizeToAvoidBottomPadding: false,//不让键盘弹上去
  136. appBar: MyAppBar(
  137. centerTitle: getTitle(),
  138. ),
  139. body:_hasData?Stack(
  140. children:<Widget>[
  141. Container(
  142. padding: EdgeInsets.only(bottom:widget.type!="3"?ScreenUtil().setWidth(70):ScreenUtil().setWidth(10)),
  143. child: ListView(
  144. children: <Widget>[
  145. Column(
  146. crossAxisAlignment: CrossAxisAlignment.start,
  147. children: <Widget>[
  148. Container(
  149. padding: EdgeInsets.only(left:ScreenUtil().setWidth(15),right:ScreenUtil().setWidth(15),top:ScreenUtil().setWidth(10),bottom:ScreenUtil().setWidth(10)),
  150. decoration: BoxDecoration(
  151. border: Border(
  152. bottom: BorderSide(width: 0.5, color: Colours.line),
  153. ),
  154. ),
  155. child: Row(
  156. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  157. children:<Widget>[
  158. Text(
  159. "提问人",
  160. style: TextStyle(
  161. fontSize:ScreenUtil().setSp(17)
  162. ),
  163. textAlign:TextAlign.start,
  164. ),
  165. Row(
  166. children: <Widget>[
  167. Text(
  168. detailObj.name??"",
  169. style: TextStyle(
  170. color:Color(0xff666666),
  171. fontSize:ScreenUtil().setSp(15)
  172. ),
  173. textAlign:TextAlign.start,
  174. ),
  175. Container(
  176. margin: EdgeInsets.only(left:ScreenUtil().setWidth(10),right:ScreenUtil().setWidth(10),top:ScreenUtil().setWidth(5)),
  177. decoration: BoxDecoration(
  178. borderRadius: BorderRadius.circular(ScreenUtil().setWidth(25)),
  179. ),
  180. child:
  181. ClipRRect(
  182. borderRadius:
  183. BorderRadius.circular(ScreenUtil().setWidth(22)),
  184. child: LoadNetworkImage(
  185. detailObj.avatarUrl,
  186. width: ScreenUtil().setWidth(37),
  187. height:ScreenUtil().setWidth(37),
  188. // alignment: Alignment.centerLeft,
  189. ),
  190. ),
  191. ),
  192. ],
  193. )
  194. ]
  195. ),
  196. ),
  197. Container(
  198. padding: EdgeInsets.only(left:ScreenUtil().setWidth(15),right:ScreenUtil().setWidth(15),top:ScreenUtil().setWidth(10),bottom:ScreenUtil().setWidth(10)),
  199. decoration: BoxDecoration(
  200. border: Border(
  201. bottom: BorderSide(width: 0.5, color: Colours.line),
  202. ),
  203. ),
  204. child: Row(
  205. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  206. children:<Widget>[
  207. Text(
  208. "电梯品牌",
  209. style: TextStyle(
  210. fontSize:ScreenUtil().setSp(17)
  211. ),
  212. textAlign:TextAlign.start,
  213. ),
  214. Text(
  215. detailObj.brandName??"",
  216. style: TextStyle(
  217. color:Color(0xff666666),
  218. fontSize:ScreenUtil().setSp(15)
  219. ),
  220. textAlign:TextAlign.start,
  221. ),
  222. ]
  223. ),
  224. ),
  225. detailObj.dataTable==2?Container(
  226. padding: EdgeInsets.only(left:ScreenUtil().setWidth(15),right:ScreenUtil().setWidth(15),top:ScreenUtil().setWidth(10),bottom:ScreenUtil().setWidth(10)),
  227. decoration: BoxDecoration(
  228. border: Border(
  229. bottom: BorderSide(width: 0.5, color: Colours.line),
  230. ),
  231. ),
  232. child: Row(
  233. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  234. children:<Widget>[
  235. Text(
  236. "出诊时间",
  237. style: TextStyle(
  238. fontSize:ScreenUtil().setSp(17)
  239. ),
  240. textAlign:TextAlign.start,
  241. ),
  242. Text(
  243. detailObj.arrivedTime!=null?DateUtils.instance
  244. .getFormartData(
  245. timeSamp: detailObj.arrivedTime,
  246. format: "yyyy-MM-dd HH:mm"):"",
  247. style: TextStyle(
  248. color:Color(0xff666666),
  249. fontSize:ScreenUtil().setSp(15)
  250. ),
  251. textAlign:TextAlign.start,
  252. ),
  253. ]
  254. ),
  255. ):Container(child:null),
  256. detailObj.dataTable==2?Container(
  257. padding: EdgeInsets.only(left:ScreenUtil().setWidth(15),right:ScreenUtil().setWidth(15),top:ScreenUtil().setWidth(10),bottom:ScreenUtil().setWidth(10)),
  258. decoration: BoxDecoration(
  259. border: Border(
  260. bottom: BorderSide(width: 0.5, color: Colours.line),
  261. ),
  262. ),
  263. child: Row(
  264. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  265. crossAxisAlignment: CrossAxisAlignment.start,
  266. children:<Widget>[
  267. Text(
  268. "出诊地点",
  269. style: TextStyle(
  270. fontSize:ScreenUtil().setSp(17)
  271. ),
  272. textAlign:TextAlign.start,
  273. ),
  274. Container(
  275. width:width*0.7,
  276. child:Text(
  277. detailObj.address!=null?detailObj.address.split(",")[0]:"",
  278. style: TextStyle(
  279. color:Color(0xff666666),
  280. fontSize:ScreenUtil().setSp(18)
  281. ),
  282. textAlign:TextAlign.end,
  283. ),
  284. )
  285. ]
  286. ),
  287. ):Container(child:null),
  288. Column(
  289. crossAxisAlignment: CrossAxisAlignment.start,
  290. mainAxisAlignment: MainAxisAlignment.start,
  291. children: <Widget>[
  292. Container(
  293. padding:EdgeInsets.only(left:ScreenUtil().setWidth(15),top:ScreenUtil().setWidth(10),bottom:ScreenUtil().setWidth(5)),
  294. child: Text(
  295. "问题描述",
  296. style: TextStyle(
  297. fontSize:ScreenUtil().setSp(17),
  298. ),
  299. textAlign:TextAlign.left,
  300. ),
  301. ),
  302. Container(
  303. padding: EdgeInsets.only(left:ScreenUtil().setWidth(15),right:ScreenUtil().setWidth(15),bottom:ScreenUtil().setWidth(50)),
  304. child: Text(
  305. detailObj.expression??"",
  306. style: TextStyle(
  307. color:Color(0xff666666),
  308. fontSize:ScreenUtil().setSp(15),
  309. ),
  310. textAlign:TextAlign.left,
  311. ),
  312. ),
  313. ],
  314. ),
  315. SizedBox(
  316. height:6,
  317. child: Container(
  318. color:ThemeUtils.getDialogTextFieldColor(context)
  319. ),
  320. ),
  321. Column(
  322. crossAxisAlignment: CrossAxisAlignment.start,
  323. mainAxisAlignment: MainAxisAlignment.start,
  324. children: <Widget>[
  325. Container(
  326. padding:EdgeInsets.only(left:ScreenUtil().setWidth(15),top:ScreenUtil().setWidth(10),bottom:ScreenUtil().setWidth(5)),
  327. child: Text(
  328. "已尝试方法",
  329. style: TextStyle(
  330. fontSize:ScreenUtil().setSp(17),
  331. ),
  332. textAlign:TextAlign.left,
  333. ),
  334. ),
  335. Container(
  336. padding: EdgeInsets.only(left:ScreenUtil().setWidth(15),right:ScreenUtil().setWidth(15),bottom:ScreenUtil().setWidth(50)),
  337. child: Text(
  338. detailObj.usedMethods??"",
  339. style: TextStyle(
  340. color:Color(0xff666666),
  341. fontSize:ScreenUtil().setSp(15),
  342. ),
  343. textAlign:TextAlign.left,
  344. ),
  345. ),
  346. ],
  347. ),
  348. detailObj.imgs!=null&&detailObj.imgs!=""?SizedBox(
  349. height:6,
  350. child: Container(
  351. color:ThemeUtils.getDialogTextFieldColor(context)
  352. ),
  353. ):Container(child:null),
  354. detailObj.imgs!=null&&detailObj.imgs!=""?Container(
  355. padding: EdgeInsets.all(15),
  356. color: ThemeUtils.getTabsBg(context),
  357. child: Wrap(
  358. spacing: 20,
  359. runSpacing : 15,
  360. children:List<Widget>.from(
  361. detailObj.imgs.split(",").asMap().keys.map((index){
  362. return
  363. GestureDetector(
  364. onTap: (){
  365. Navigator.of(context).push(
  366. new FadeRoute(
  367. page: PhotoViewGalleryScreen(
  368. images: listPreview, //传入图片list
  369. index: index, //传入当前点击的图片的index
  370. // heroTag: img,//传入当前点击的图片的hero tag (可选)
  371. ),
  372. ),
  373. );
  374. },
  375. child: LoadNetworkImage(
  376. detailObj.imgs.split(",")[index],
  377. width: ScreenUtil().setWidth(100),
  378. height:ScreenUtil().setWidth(100),
  379. isWater: true,
  380. // alignment: Alignment.centerLeft,
  381. ),
  382. );
  383. }).toList()
  384. )
  385. )
  386. ):Container(child:null),
  387. detailObj.videoUrl!=null&&detailObj.videoUrl!=""?SizedBox(
  388. height:6,
  389. child: Container(
  390. color:ThemeUtils.getDialogTextFieldColor(context)
  391. ),
  392. ):Container(child:null),
  393. detailObj.videoUrl!=null&&detailObj.videoUrl!="" ? Container(
  394. padding: EdgeInsets.only(
  395. left: ScreenUtil().setWidth(15),
  396. right: ScreenUtil().setWidth(15),
  397. top: ScreenUtil().setWidth(15)),
  398. child: ClipRRect(
  399. borderRadius: BorderRadius.circular(5),
  400. child: new Chewie(
  401. controller: ChewieController(
  402. videoPlayerController:
  403. // VideoPlayerController.network(
  404. // imgFontUrl + detailObj.url
  405. // ),
  406. _controller,
  407. aspectRatio: 3 / 2,
  408. autoPlay: false,
  409. looping: true,
  410. showControls: true,
  411. deviceOrientationsAfterFullScreen:[DeviceOrientation.portraitUp,],
  412. // 占位图
  413. // placeholder: Image.network(
  414. // imgFontUrl+detailObj.cover,
  415. // fit: BoxFit.contain,
  416. // ),
  417. // 是否在 UI 构建的时候就加载视频
  418. autoInitialize: true,
  419. // 拖动条样式颜色
  420. materialProgressColors:
  421. new ChewieProgressColors(
  422. playedColor: Colors.red,
  423. handleColor: Colors.blue,
  424. backgroundColor: Colors.grey,
  425. bufferedColor: Colors.lightGreen,
  426. ),
  427. ),
  428. ),
  429. )):Container(child:null),
  430. ],
  431. ),
  432. ]
  433. )
  434. ),
  435. Positioned(
  436. bottom:0,
  437. left:0,
  438. child:widget.type!="3"? Container(
  439. width: width,
  440. child: Row(
  441. children:<Widget>[
  442. Container(
  443. height:ScreenUtil().setWidth(70),
  444. width:width/2,
  445. color: Colors.white,
  446. child: FlatButton(
  447. // padding: EdgeInsets.all(15.0),
  448. child: Text("拒绝",style: TextStyle(fontSize:ScreenUtil().setSp(16)),),
  449. textColor: Color(0xff222222),
  450. onPressed: () {
  451. // NavigatorUtils.push(context, BbsRouter.questionPay);
  452. orderRefuze();
  453. },
  454. ),
  455. ),
  456. Container(
  457. height:ScreenUtil().setWidth(70),
  458. width:width/2,
  459. color: Color(0xff0388FD),
  460. child: FlatButton(
  461. // padding: EdgeInsets.all(15.0),
  462. child: Text("接单",style: TextStyle(fontSize:ScreenUtil().setSp(16)),),
  463. textColor: Colors.white,
  464. onPressed: () {
  465. // NavigatorUtils.push(context, BbsRouter.questionPay);
  466. orderReceiving();
  467. },
  468. ),
  469. ),
  470. ]
  471. )
  472. ):Container(child:null)
  473. )
  474. ]
  475. ):Center(
  476. child: Text("正在加载..."),
  477. ),
  478. );
  479. }
  480. }
  481. class FadeRoute extends PageRouteBuilder {
  482. final Widget page;
  483. FadeRoute({this.page})
  484. : super(
  485. pageBuilder: (
  486. BuildContext context,
  487. Animation<double> animation,
  488. Animation<double> secondaryAnimation,
  489. ) =>
  490. page,
  491. transitionsBuilder: (
  492. BuildContext context,
  493. Animation<double> animation,
  494. Animation<double> secondaryAnimation,
  495. Widget child,
  496. ) =>
  497. FadeTransition(
  498. opacity: animation,
  499. child: child,
  500. ),
  501. );
  502. }