recommend_ask.dart 19 KB

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