recommend_ask.dart 20 KB

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