order_detail.dart 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664
  1. import 'dart:async';
  2. import 'dart:io';
  3. import 'package:amap_location_flutter_plugin/amap_location_flutter_plugin.dart';
  4. import 'package:chewie/chewie.dart';
  5. import 'package:flutter/cupertino.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:flutter/services.dart';
  8. import 'package:flutter_screenutil/flutter_screenutil.dart';
  9. import 'package:image_picker/image_picker.dart';
  10. import 'package:liftmanager/internal/account/provider/user_provider.dart';
  11. import 'package:liftmanager/internal/bbs/bbs_router.dart';
  12. import 'package:liftmanager/internal/bbs/model/liftcase_model.dart';
  13. import 'package:liftmanager/internal/wode/order_const.dart';
  14. import 'package:liftmanager/internal/wode/page/order_master/check.dart';
  15. import 'package:liftmanager/internal/wode/wode_router.dart';
  16. import 'package:liftmanager/net/api_service.dart';
  17. import 'package:liftmanager/res/colors.dart';
  18. import 'package:liftmanager/routers/fluro_navigator.dart';
  19. import 'package:liftmanager/utils/fast_notification.dart';
  20. import 'package:liftmanager/utils/oss_upload.dart';
  21. import 'package:liftmanager/utils/theme_utils.dart';
  22. import 'package:liftmanager/utils/time_format.dart';
  23. import 'package:liftmanager/utils/toast.dart';
  24. import 'package:liftmanager/utils/utils.dart';
  25. import 'package:liftmanager/widgets/app_bar.dart';
  26. import 'package:liftmanager/widgets/bbs_content.dart';
  27. import 'package:liftmanager/widgets/load_image.dart';
  28. import 'package:liftmanager/widgets/selected_video_change.dart';
  29. import 'package:orientation/orientation.dart';
  30. import 'package:permission_handler/permission_handler.dart';
  31. import 'package:provider/provider.dart';
  32. import 'package:video_player/video_player.dart';
  33. class OrderDetailMaster extends StatefulWidget {
  34. OrderDetailMaster(this.id);
  35. final String id;
  36. @override
  37. State<StatefulWidget> createState() {
  38. return OrderDetailMasterState();
  39. }
  40. }
  41. class OrderDetailMasterState extends State<OrderDetailMaster>
  42. with AutomaticKeepAliveClientMixin {
  43. UserProvider provider = UserProvider();
  44. bool _hasData = false;
  45. LiftCasesDetailModel detailObj;
  46. double totalPay;
  47. String videoUrl;
  48. String str;
  49. String imagesUrl;
  50. double percent = 0.0;
  51. var latitude;
  52. var longitude;
  53. String address;
  54. Map<String, Object> _locationResult;
  55. StreamSubscription<Map<String, Object>> _locationListener;
  56. AmapLocationFlutterPlugin _locationPlugin = new AmapLocationFlutterPlugin();
  57. getBrandDetail() {
  58. // showLoading(context);
  59. NewApiService().getLiftcaseDetail(widget.id, onSuccess: (res) {
  60. detailObj = res;
  61. print("获取详情成功");
  62. if (_controllerBefore == null && detailObj.beforeRepair != null) {
  63. _controllerBefore?.pause();
  64. _controllerBefore?.dispose();
  65. _controllerBefore = VideoPlayerController.network(
  66. Utils.getImagePath(detailObj.beforeRepair));
  67. }
  68. if (_controllerAfter == null && detailObj.afterRepair != null) {
  69. _controllerAfter?.pause();
  70. _controllerAfter?.dispose();
  71. _controllerAfter = VideoPlayerController.network(
  72. Utils.getImagePath(detailObj.afterRepair));
  73. }
  74. double serviceCost =
  75. detailObj.serviceCost != null ? detailObj.serviceCost : 0.0;
  76. double travelCost =
  77. detailObj.travelCost != null ? detailObj.travelCost : 0.0;
  78. double couponDeduction =
  79. detailObj.couponDeduction != null ? detailObj.couponDeduction : 0.0;
  80. double redEnvelopeDeduction = detailObj.redEnvelopeDeduction != null
  81. ? detailObj.redEnvelopeDeduction
  82. : 0.0;
  83. totalPay =
  84. (serviceCost + travelCost) - (couponDeduction + redEnvelopeDeduction);
  85. if (totalPay < 0) {
  86. totalPay = 0.0;
  87. }
  88. _hasData = true;
  89. // dismissLoading(context);
  90. setState(() {});
  91. }, onError: (code, msg) {
  92. // dismissLoading(context);
  93. toasts(msg);
  94. });
  95. }
  96. VideoPlayerController _controllerBefore;
  97. VideoPlayerController _controllerAfter;
  98. // 确认完成
  99. void _confirmComplete() {
  100. showLoading(context);
  101. NewApiService().chargeMakeSureCase({
  102. "id": widget.id,
  103. }, onSuccess: (res) {
  104. toasts("确认完成");
  105. getBrandDetail();
  106. dismissLoading(context);
  107. setState(() {});
  108. }, onError: (code, msg) {
  109. dismissLoading(context);
  110. toasts(msg);
  111. });
  112. }
  113. @override
  114. void initState() {
  115. if (this.mounted) {
  116. getBrandDetail();
  117. }
  118. super.initState();
  119. // _locationListener = _locationPlugin
  120. // .onLocationChanged()
  121. // .listen((Map<String, Object> result) {
  122. // setState(() {
  123. // _locationPlugin.stopLocation();
  124. // _locationResult = result;
  125. // // address latitude longitude
  126. // _locationResult.forEach((key, value) {
  127. // if (key == 'address') {
  128. // address = '$value';
  129. // setState(() {});
  130. // } else if (key == 'latitude') {
  131. // latitude = double.parse('$value');
  132. // setState(() {});
  133. // } else if (key == 'longitude') {
  134. // longitude = double.parse('$value');
  135. // setState(() {});
  136. // }
  137. // print(111);
  138. // print('key:$key :');
  139. // print('value:$value :');
  140. // });
  141. // });
  142. // });
  143. // getLocation();
  144. }
  145. @override
  146. void dispose() {
  147. _controller?.pause();
  148. _controller?.dispose();
  149. _chewieController?.dispose();
  150. if (detailObj.beforeRepair != null) {
  151. _controllerBefore?.pause();
  152. _controllerBefore?.dispose();
  153. }
  154. if (detailObj.afterRepair != null) {
  155. _controllerAfter?.pause();
  156. _controllerAfter?.dispose();
  157. }
  158. // SystemChrome.setPreferredOrientations([
  159. // DeviceOrientation.portraitUp,
  160. // ]);
  161. OrientationPlugin.forceOrientation(DeviceOrientation.portraitUp);
  162. // provider.dispose();
  163. super.dispose();
  164. }
  165. getHeight(detailObj) {
  166. bool isHeight = false;
  167. if ((OrderConstant.isShow(
  168. detailObj.statuz, detailObj.dataTable, 'showExpertQuoteButton')) ||
  169. (OrderConstant.isShow(detailObj.statuz, detailObj.dataTable,
  170. 'showExpertPunchButton') &&
  171. detailObj.arrivedFlag == 0) ||
  172. (OrderConstant.isShow(detailObj.statuz, detailObj.dataTable,
  173. 'showExpertConfirmOrderButton',
  174. arrivedFlag: detailObj.arrivedFlag)) ||
  175. (OrderConstant.isShow(detailObj.statuz, detailObj.dataTable,
  176. 'showExpertArchiveButton'))) {
  177. isHeight = true;
  178. }
  179. return isHeight;
  180. }
  181. @override
  182. Widget build(BuildContext context) {
  183. double width = MediaQuery.of(context).size.width;
  184. double height = MediaQuery.of(context).size.height;
  185. if (width > height) {
  186. // SystemChrome.setPreferredOrientations([
  187. // DeviceOrientation.portraitUp,
  188. // ]);
  189. OrientationPlugin.forceOrientation(DeviceOrientation.portraitUp);
  190. }
  191. return ChangeNotifierProvider<UserProvider>(
  192. create: (_) => provider,
  193. child: Scaffold(
  194. appBar: MyAppBar(
  195. centerTitle: "订单详情",
  196. ),
  197. body: _hasData
  198. ? Consumer<UserProvider>(
  199. builder: (_, provider, __) {
  200. return SafeArea(
  201. child: Stack(
  202. children: <Widget>[
  203. ListView(
  204. padding: EdgeInsets.all(0.0),
  205. children: <Widget>[
  206. _orderTypeHead(),
  207. _lineSpase(),
  208. _orderUserDetail(),
  209. isShowMoneyDetail() ? _lineSpase() : Container(),
  210. isShowMoneyDetail()
  211. ? _orderMoneyDetail()
  212. : Container(),
  213. _lineSpase(),
  214. _orderTime(),
  215. _lineSpase(),
  216. OrderConstant.isShow(
  217. detailObj.statuz,
  218. detailObj.dataTable,
  219. 'showExpertPunchButton') &&
  220. detailObj.arrivedFlag == 0
  221. ? _uploadLiveVideo()
  222. : Container(),
  223. OrderConstant.isShow(
  224. detailObj.statuz,
  225. detailObj.dataTable,
  226. 'showExpertConfirmOrderButton',
  227. arrivedFlag: detailObj.arrivedFlag) &&
  228. detailObj.dataTable == 2
  229. ? _uploadLiveVideo()
  230. : Container(),
  231. (detailObj.dataTable == 1 &&
  232. detailObj.arrivedFlag == 5 &&
  233. detailObj.examineFlag == '2')
  234. ? _boHuiTip()
  235. : Container(),
  236. isShowOrderLive()
  237. ? _orderLiveVideo()
  238. : Container(),
  239. SizedBox(height: 80),
  240. ]),
  241. Positioned(
  242. bottom: 0,
  243. left: 0,
  244. child: Container(
  245. width: width,
  246. height: !getHeight(detailObj) ? 0 : 60,
  247. padding: EdgeInsets.only(
  248. // right: ScreenUtil().setWidth(15),
  249. // left: ScreenUtil().setWidth(15),
  250. top: 7.5,
  251. bottom: 7.5,
  252. ),
  253. decoration: BoxDecoration(
  254. border: Border(
  255. top: BorderSide(
  256. width: 0.5, color: Color(0xffeeeeee)),
  257. ),
  258. color:
  259. ThemeUtils.getDialogTextFieldColor(context),
  260. ),
  261. child: Row(
  262. mainAxisAlignment: MainAxisAlignment.end,
  263. crossAxisAlignment: CrossAxisAlignment.center,
  264. children: <Widget>[
  265. OrderConstant.isShow(
  266. detailObj.statuz,
  267. detailObj.dataTable,
  268. 'showExpertQuoteButton')
  269. ? BottomBtn(
  270. title: detailObj.statuz == 1
  271. ? "立即报价"
  272. : "修改报价",
  273. fun: () {
  274. if (_controllerBefore != null) {
  275. _controllerBefore?.pause();
  276. }
  277. if (_controllerAfter != null) {
  278. _controllerAfter?.pause();
  279. }
  280. NavigatorUtils.push(context,
  281. "${WodeRouter.baoPrice}?id=${detailObj.id}&travelCost=${detailObj.travelCost != null ? detailObj.travelCost.toString() : ''}&serviceCost=${detailObj.serviceCost != null ? detailObj.serviceCost.toString() : ''}");
  282. },
  283. )
  284. : Container(child: null),
  285. // detailObj.statuz == 3 || detailObj.statuz == 6
  286. // ? BottomBtn(
  287. // title: "上传视频",
  288. // fun: () {
  289. // // NavigatorUtils.push(context,WodeRouter.representations);
  290. // },
  291. // )
  292. // : Container(child: null),
  293. OrderConstant.isShow(
  294. detailObj.statuz,
  295. detailObj.dataTable,
  296. 'showExpertPunchButton') &&
  297. detailObj.arrivedFlag == 0
  298. ? BottomBtn(
  299. title: "立即打卡",
  300. fun: () {
  301. punchin();
  302. // if (_controllerBefore != null) {
  303. // _controllerBefore.pause();
  304. // }
  305. // if (_controllerAfter != null) {
  306. // _controllerAfter.pause();
  307. // }
  308. // NavigatorUtils.push(context,
  309. // "${WodeRouter.punchin}?id=${detailObj.id}");
  310. },
  311. )
  312. : Container(child: null),
  313. OrderConstant.isShow(
  314. detailObj.statuz,
  315. detailObj.dataTable,
  316. 'showExpertConfirmOrderButton',
  317. arrivedFlag: detailObj.arrivedFlag)
  318. ? BottomBtn(
  319. title: "确认完成",
  320. fun: () {
  321. if (detailObj.dataTable == 1) {
  322. _confirmComplete();
  323. } else {
  324. submitApply();
  325. // punchin();
  326. // if (_controllerBefore != null) {
  327. // _controllerBefore.pause();
  328. // }
  329. // if (_controllerAfter != null) {
  330. // _controllerAfter.pause();
  331. // }
  332. // NavigatorUtils.push(context,
  333. // "${WodeRouter.confirmOrder}?id=${detailObj.id}");
  334. }
  335. },
  336. )
  337. : Container(child: null),
  338. OrderConstant.isShow(
  339. detailObj.statuz,
  340. detailObj.dataTable,
  341. 'showExpertArchiveButton',
  342. examineFlag: detailObj
  343. .questionBankEntity?.examineFlag)
  344. ? BottomBtn(
  345. title: detailObj.questionBankEntity
  346. ?.examineFlag ==
  347. 2
  348. ? '重新提交'
  349. : "立即归档",
  350. fun: () {
  351. if (_controllerBefore != null) {
  352. _controllerBefore.pause();
  353. }
  354. if (_controllerAfter != null) {
  355. _controllerAfter.pause();
  356. }
  357. NavigatorUtils.push(context,
  358. "${WodeRouter.archive}?id=${detailObj.id}");
  359. },
  360. )
  361. : Container(child: null),
  362. ],
  363. ),
  364. ),
  365. )
  366. ],
  367. ),
  368. );
  369. },
  370. )
  371. : Center(
  372. child: Text("正在加载..."),
  373. ),
  374. ),
  375. );
  376. }
  377. _lineSpase() {
  378. return Container(
  379. color: ThemeUtils.getDialogTextFieldColor(context),
  380. height: ScreenUtil().setWidth(5),
  381. );
  382. }
  383. _orderTypeHead() {
  384. return Container(
  385. // decoration: BoxDecoration(
  386. // gradient: const LinearGradient(
  387. // colors: [Color(0xFF00D9FF), Color(0xFF0287FF)],
  388. // ),
  389. // ),
  390. padding: EdgeInsets.only(
  391. top: ScreenUtil().setWidth(10), left: ScreenUtil().setWidth(10)),
  392. height: ScreenUtil().setWidth(90),
  393. child: Column(
  394. crossAxisAlignment: CrossAxisAlignment.start,
  395. children: <Widget>[
  396. Row(
  397. // crossAxisAlignment: CrossAxisAlignment.start,
  398. // mainAxisAlignment: MainAxisAlignment.center,
  399. children: [
  400. Icon(
  401. // : 0xe604,
  402. OrderConstant.getIconFontCode(
  403. detailObj.statuz, detailObj.dataTable),
  404. size: 20.0,
  405. color: Color(0xff333333),
  406. ),
  407. SizedBox(
  408. width: 5,
  409. ),
  410. Text(
  411. OrderConstant.getStatusName(
  412. detailObj.statuz, detailObj.dataTable,
  413. arrivedFlag: detailObj.arrivedFlag,
  414. userType: 'Expert',
  415. examineFlag: detailObj.questionBankEntity?.examineFlag),
  416. textAlign: TextAlign.left,
  417. style: TextStyle(
  418. fontSize: ScreenUtil().setSp(14),
  419. color: Colours.text,
  420. ),
  421. ),
  422. Expanded(child: Container()),
  423. Text(
  424. '订单号:',
  425. textAlign: TextAlign.left,
  426. style: TextStyle(
  427. fontSize: ScreenUtil().setSp(14),
  428. color: Colours.text,
  429. ),
  430. ),
  431. Text(
  432. '${detailObj.orderNo ?? '无'}',
  433. textAlign: TextAlign.left,
  434. style: TextStyle(
  435. fontSize: ScreenUtil().setSp(14),
  436. color: Colours.text_gray,
  437. ),
  438. ),
  439. //
  440. SizedBox(
  441. width: 10,
  442. )
  443. ],
  444. ),
  445. Container(
  446. margin: EdgeInsets.only(left: 25, top: 10),
  447. child: Text(
  448. // '',
  449. OrderConstant.getdetailStatusName(
  450. detailObj.statuz, detailObj.dataTable,
  451. arrivedFlag: detailObj.arrivedFlag, userType: 'Expert'),
  452. textAlign: TextAlign.left,
  453. style: TextStyle(
  454. fontSize: ScreenUtil().setSp(13),
  455. color: Colours.dark_text_gray,
  456. ),
  457. ),
  458. )
  459. ],
  460. ),
  461. );
  462. }
  463. _orderUserDetail() {
  464. return Container(
  465. // height: 20,
  466. padding: EdgeInsets.only(
  467. bottom: ScreenUtil().setWidth(20), top: ScreenUtil().setWidth(10)),
  468. child: Row(
  469. crossAxisAlignment: CrossAxisAlignment.start,
  470. children: <Widget>[
  471. Expanded(
  472. child: GestureDetector(
  473. onTap: () {
  474. if (_controllerBefore != null) {
  475. _controllerBefore?.pause();
  476. }
  477. if (_controllerAfter != null) {
  478. _controllerAfter?.pause();
  479. }
  480. NavigatorUtils.push(context,
  481. "${BbsRouter.recommendAsk}?id=${detailObj.id}&type=3");
  482. },
  483. child: Row(
  484. crossAxisAlignment: CrossAxisAlignment.start,
  485. children: <Widget>[
  486. SizedBox(
  487. width: 10,
  488. ),
  489. ClipRRect(
  490. borderRadius: BorderRadius.circular(20),
  491. child: LoadNetworkImage(
  492. detailObj.avatarUrl,
  493. width: ScreenUtil().setWidth(43),
  494. height: ScreenUtil().setWidth(43),
  495. // alignment: Alignment.centerLeft,
  496. ),
  497. // Container(
  498. // margin: EdgeInsets.only(
  499. // left: ScreenUtil().setWidth(15),
  500. // right: ScreenUtil().setWidth(10),
  501. // // top: ScreenUtil().setWidth(5)
  502. // ),
  503. // decoration: BoxDecoration(
  504. // borderRadius: BorderRadius.circular(
  505. // ScreenUtil().setWidth(22)),
  506. // ),
  507. // child: LoadNetworkImage(
  508. // detailObj.avatarUrl,
  509. // width: ScreenUtil().setWidth(43),
  510. // height: ScreenUtil().setWidth(43),
  511. // // alignment: Alignment.centerLeft,
  512. // ),
  513. // ),
  514. ),
  515. SizedBox(
  516. width: 10,
  517. ),
  518. Expanded(
  519. child: Container(
  520. padding:
  521. EdgeInsets.only(right: ScreenUtil().setWidth(15)),
  522. child: Column(
  523. children: <Widget>[
  524. Container(
  525. child: Row(
  526. mainAxisAlignment: MainAxisAlignment.start,
  527. children: <Widget>[
  528. Row(
  529. crossAxisAlignment: CrossAxisAlignment.center,
  530. children: <Widget>[
  531. Text(
  532. detailObj.name ?? '',
  533. style: TextStyle(
  534. fontSize: ScreenUtil().setSp(17),
  535. ),
  536. textAlign: TextAlign.start,
  537. ),
  538. Container(
  539. decoration: BoxDecoration(
  540. //背景
  541. color: detailObj.dataTable == 1
  542. ? Colours.blue_app_main
  543. : Color(0xffFDAF2C),
  544. //设置四周圆角 角度
  545. borderRadius: BorderRadius.all(
  546. Radius.circular(4.0)),
  547. ),
  548. margin: EdgeInsets.only(left: 5),
  549. padding: EdgeInsets.only(
  550. left: 5, right: 5, top: 2, bottom: 2),
  551. child: Text(
  552. detailObj.dataTable == 1
  553. ? '问诊服务'
  554. : '出诊服务',
  555. style: TextStyle(
  556. color: Colors.white,
  557. fontSize: ScreenUtil().setSp(14),
  558. ),
  559. textAlign: TextAlign.start,
  560. ),
  561. ),
  562. ],
  563. ),
  564. ],
  565. ),
  566. ),
  567. Container(
  568. child: Row(
  569. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  570. children: <Widget>[
  571. Row(
  572. crossAxisAlignment: CrossAxisAlignment.center,
  573. children: <Widget>[
  574. Text(
  575. detailObj.createTime != null
  576. ? DateUtils.instance.getFormartData(
  577. timeSamp: detailObj.createTime,
  578. format: "MM月dd日")
  579. : '',
  580. style: TextStyle(
  581. color: Color(0xff999999),
  582. fontSize: ScreenUtil().setSp(13),
  583. ),
  584. textAlign: TextAlign.start,
  585. ),
  586. Container(
  587. padding: EdgeInsets.only(left: 5),
  588. child: Text(
  589. detailObj.brandName ?? '',
  590. style: TextStyle(
  591. color: Colours.blue_app_main,
  592. fontSize: ScreenUtil().setSp(13),
  593. ),
  594. textAlign: TextAlign.start,
  595. ),
  596. )
  597. ],
  598. ),
  599. ],
  600. ),
  601. ),
  602. detailObj.dataTable != 1
  603. ? Container(
  604. child: Row(
  605. mainAxisAlignment:
  606. MainAxisAlignment.spaceBetween,
  607. children: <Widget>[
  608. Row(
  609. crossAxisAlignment:
  610. CrossAxisAlignment.start,
  611. children: <Widget>[
  612. Container(
  613. // padding: EdgeInsets.only(left: 5),
  614. child: Text(
  615. '出诊时间:',
  616. style: TextStyle(
  617. color: Color(0xff999999),
  618. fontSize:
  619. ScreenUtil().setSp(13),
  620. ),
  621. textAlign: TextAlign.start,
  622. ),
  623. ),
  624. Text(
  625. detailObj.arrivedTime != null
  626. ? DateUtils.instance
  627. .getFormartData(
  628. timeSamp: detailObj
  629. .arrivedTime,
  630. format: "MM月dd日 HH:mm")
  631. : '',
  632. style: TextStyle(
  633. color: Color(0xff666666),
  634. fontSize: ScreenUtil().setSp(13),
  635. ),
  636. textAlign: TextAlign.start,
  637. ),
  638. ],
  639. ),
  640. ],
  641. ),
  642. )
  643. : Container(),
  644. detailObj.dataTable != 1
  645. ? Container(
  646. // margin: EdgeInsets.only(top: 6),
  647. child: Row(
  648. children: <Widget>[
  649. Container(
  650. // padding: EdgeInsets.only(left: 5),
  651. child: Text(
  652. '出诊地点:',
  653. style: TextStyle(
  654. color: Color(0xff999999),
  655. fontSize: ScreenUtil().setSp(13),
  656. ),
  657. textAlign: TextAlign.start,
  658. ),
  659. ),
  660. Container(
  661. width: ScreenUtil().setWidth(230),
  662. child: Text(
  663. '${detailObj.address ?? ''}',
  664. style: TextStyle(
  665. color: Color(0xff666666),
  666. fontSize: ScreenUtil().setSp(13),
  667. // color: Color(0xff666666),
  668. // fontSize: ScreenUtil().setSp(15),
  669. ),
  670. textAlign: TextAlign.start,
  671. maxLines: 1,
  672. overflow: TextOverflow.ellipsis,
  673. ),
  674. ),
  675. ],
  676. ),
  677. )
  678. : Container(),
  679. Container(
  680. // margin: EdgeInsets.only(top: 6),
  681. child: Row(
  682. children: <Widget>[
  683. Container(
  684. // padding: EdgeInsets.only(left: 5),
  685. child: Text(
  686. '问题描述:',
  687. style: TextStyle(
  688. color: Color(0xff999999),
  689. fontSize: ScreenUtil().setSp(13),
  690. ),
  691. textAlign: TextAlign.start,
  692. ),
  693. ),
  694. Container(
  695. width: ScreenUtil().setWidth(230),
  696. child: Text(
  697. '${detailObj.expression ?? ''}',
  698. style: TextStyle(
  699. color: Color(0xff666666),
  700. fontSize: ScreenUtil().setSp(13),
  701. // color: Color(0xff666666),
  702. // fontSize: ScreenUtil().setSp(15),
  703. ),
  704. textAlign: TextAlign.start,
  705. maxLines: 1,
  706. overflow: TextOverflow.ellipsis,
  707. ),
  708. ),
  709. ],
  710. ),
  711. ),
  712. Container(
  713. // margin: EdgeInsets.only(top: 6),
  714. child: Row(
  715. children: <Widget>[
  716. Container(
  717. // padding: EdgeInsets.only(left: 5),
  718. child: Text(
  719. '出厂日期:',
  720. style: TextStyle(
  721. color: Color(0xff999999),
  722. fontSize: ScreenUtil().setSp(13),
  723. ),
  724. textAlign: TextAlign.start,
  725. ),
  726. ),
  727. Container(
  728. width: ScreenUtil().setWidth(230),
  729. child: Text(
  730. '${detailObj.productionDate ?? ''}',
  731. style: TextStyle(
  732. color: Color(0xff666666),
  733. fontSize: ScreenUtil().setSp(13),
  734. // color: Color(0xff666666),
  735. // fontSize: ScreenUtil().setSp(15),
  736. ),
  737. textAlign: TextAlign.start,
  738. maxLines: 1,
  739. overflow: TextOverflow.ellipsis,
  740. ),
  741. ),
  742. ],
  743. ),
  744. ),
  745. // Container(
  746. // child: Row(
  747. // mainAxisAlignment:
  748. // MainAxisAlignment.start,
  749. // children: <Widget>[
  750. // Row(
  751. // crossAxisAlignment:
  752. // CrossAxisAlignment
  753. // .center,
  754. // children: <Widget>[
  755. // Text(
  756. // detailObj.createTime !=
  757. // null
  758. // ? DateUtils
  759. // .instance
  760. // .getFormartData(
  761. // timeSamp:
  762. // detailObj
  763. // .createTime,
  764. // format:
  765. // "MM月dd日",
  766. // )
  767. // : '',
  768. // style: TextStyle(
  769. // color: Color(
  770. // 0xff999999),
  771. // fontSize:
  772. // ScreenUtil()
  773. // .setSp(
  774. // 13),
  775. // ),
  776. // textAlign:
  777. // TextAlign.left,
  778. // ),
  779. // Container(
  780. // padding:
  781. // EdgeInsets.only(
  782. // left: 5),
  783. // child: Text(
  784. // detailObj
  785. // .brandName ??
  786. // '',
  787. // style: TextStyle(
  788. // color: Color(
  789. // 0xff999999),
  790. // fontSize:
  791. // ScreenUtil()
  792. // .setSp(
  793. // 13),
  794. // ),
  795. // textAlign:
  796. // TextAlign
  797. // .left,
  798. // ),
  799. // )
  800. // ],
  801. // ),
  802. // ],
  803. // ),
  804. // ),
  805. // Row(
  806. // mainAxisAlignment:
  807. // MainAxisAlignment.start,
  808. // children: <Widget>[
  809. // Container(
  810. // width: 260,
  811. // child: Text(
  812. // detailObj.expression ??
  813. // '',
  814. // style: TextStyle(
  815. // color:
  816. // Color(0xff0288FF),
  817. // fontSize: ScreenUtil()
  818. // .setSp(15),
  819. // ),
  820. // textAlign:
  821. // TextAlign.left,
  822. // maxLines: 1,
  823. // overflow: TextOverflow
  824. // .ellipsis,
  825. // ),
  826. // ),
  827. // ],
  828. // ),
  829. ],
  830. ),
  831. ),
  832. )
  833. ],
  834. ),
  835. ),
  836. ),
  837. ],
  838. ),
  839. );
  840. }
  841. _orderMoneyDetail() {
  842. return Column(
  843. children: [
  844. detailObj.dataTable == 2
  845. ? Heng(
  846. left: "差旅费",
  847. right: detailObj.travelCost != null
  848. ? "¥" + detailObj.travelCost.toString()
  849. : '¥0',
  850. leftColor: 0xff333333,
  851. rightColor: 0xff333333,
  852. )
  853. : Container(),
  854. Heng(
  855. left: "技术服务费",
  856. right: detailObj.serviceCost != null
  857. ? "¥" + detailObj.serviceCost.toString()
  858. : '¥0',
  859. leftColor: 0xff333333,
  860. rightColor: 0xff333333,
  861. ),
  862. Heng(
  863. left: "优惠券抵扣",
  864. right: detailObj.couponDeduction != null
  865. ? "-¥" + detailObj.couponDeduction.toString()
  866. : '-¥0',
  867. leftColor: 0xff333333,
  868. rightColor: 0xff333333,
  869. ),
  870. Heng(
  871. left: "红包抵扣",
  872. right: detailObj.redEnvelopeDeduction != null
  873. ? "-¥" + detailObj.redEnvelopeDeduction.toString()
  874. : '-¥0',
  875. leftColor: 0xff333333,
  876. rightColor: 0xff333333,
  877. ),
  878. Heng(
  879. left: "实付款",
  880. right: detailObj.payCost != null && getPayCost()
  881. ? "¥" + detailObj.payCost.toString()
  882. : '¥' + totalPay.toStringAsFixed(2).toString(),
  883. leftColor: 0xff333333,
  884. rightColor: 0xffFD0808,
  885. ),
  886. ],
  887. );
  888. }
  889. _orderTime() {
  890. return Container(
  891. padding: EdgeInsets.only(
  892. left: ScreenUtil().setWidth(15),
  893. top: ScreenUtil().setWidth(10),
  894. bottom: ScreenUtil().setWidth(10)),
  895. child: Row(
  896. children: <Widget>[
  897. Text(
  898. '下单时间:',
  899. textAlign: TextAlign.left,
  900. style: TextStyle(
  901. fontSize: 14,
  902. color: Color(0xff333333),
  903. ),
  904. ),
  905. Text(
  906. detailObj.createTime != null
  907. ? DateUtils.instance.getFormartData(
  908. timeSamp: detailObj.createTime,
  909. format: "yyyy-MM-dd HH:mm:ss")
  910. : '',
  911. textAlign: TextAlign.left,
  912. style: TextStyle(
  913. fontSize: ScreenUtil().setSp(13),
  914. color: Color(0xff999999),
  915. ),
  916. ),
  917. ],
  918. ),
  919. );
  920. }
  921. ///现场视频维修前维修后
  922. _orderLiveVideo() {
  923. double width = MediaQuery.of(context).size.width;
  924. return Column(
  925. crossAxisAlignment: CrossAxisAlignment.start,
  926. children: <Widget>[
  927. Container(
  928. width: width,
  929. padding: EdgeInsets.only(
  930. left: ScreenUtil().setWidth(15),
  931. top: ScreenUtil().setWidth(10),
  932. bottom: ScreenUtil().setWidth(10)),
  933. decoration: BoxDecoration(
  934. border: Border(
  935. bottom: BorderSide(width: .5, color: Color(0xfff5f5f5)),
  936. ),
  937. ),
  938. child: Text(
  939. '现场情况(维修前)',
  940. textAlign: TextAlign.left,
  941. style: TextStyle(
  942. fontSize: 17,
  943. color: Color(0xff333333),
  944. ),
  945. ),
  946. ),
  947. detailObj.beforeRepair != null
  948. ? Container(
  949. padding: EdgeInsets.only(
  950. left: ScreenUtil().setWidth(15),
  951. right: ScreenUtil().setWidth(15),
  952. top: ScreenUtil().setWidth(15)),
  953. child: ClipRRect(
  954. borderRadius: BorderRadius.circular(5),
  955. child: new Chewie(
  956. controller: ChewieController(
  957. videoPlayerController:
  958. // VideoPlayerController.network(
  959. // Utils.getImagePath(detailObj.beforeRepair)
  960. // // imgFontUrl + detailObj.url
  961. // )
  962. _controllerBefore,
  963. aspectRatio: 3 / 2,
  964. autoPlay: false,
  965. looping: true,
  966. showControls: true,
  967. deviceOrientationsAfterFullScreen: [
  968. DeviceOrientation.portraitUp,
  969. ],
  970. // 占位图
  971. // placeholder: Image.network(
  972. // imgFontUrl+detailObj.cover,
  973. // fit: BoxFit.contain,
  974. // ),
  975. // 是否在 UI 构建的时候就加载视频
  976. autoInitialize: true,
  977. // 拖动条样式颜色
  978. materialProgressColors: new ChewieProgressColors(
  979. playedColor: Colors.red,
  980. handleColor: Colors.blue,
  981. backgroundColor: Colors.grey,
  982. bufferedColor: Colors.lightGreen,
  983. ),
  984. ),
  985. ),
  986. ))
  987. : Container(
  988. padding: EdgeInsets.only(left: 15),
  989. child: Text("暂无"),
  990. ),
  991. Container(
  992. width: width,
  993. padding: EdgeInsets.only(
  994. left: ScreenUtil().setWidth(15),
  995. top: ScreenUtil().setWidth(10),
  996. bottom: ScreenUtil().setWidth(10)),
  997. decoration: BoxDecoration(
  998. border: Border(
  999. bottom: BorderSide(width: .5, color: Color(0xfff5f5f5)),
  1000. ),
  1001. ),
  1002. child: Text(
  1003. '现场情况(维修后)',
  1004. textAlign: TextAlign.left,
  1005. style: TextStyle(
  1006. fontSize: 17,
  1007. color: Color(0xff333333),
  1008. ),
  1009. ),
  1010. ),
  1011. detailObj.afterRepair != null
  1012. ? Container(
  1013. padding: EdgeInsets.only(
  1014. left: ScreenUtil().setWidth(15),
  1015. right: ScreenUtil().setWidth(15),
  1016. top: ScreenUtil().setWidth(15)),
  1017. child: ClipRRect(
  1018. borderRadius: BorderRadius.circular(5),
  1019. child: new Chewie(
  1020. controller: ChewieController(
  1021. videoPlayerController:
  1022. // VideoPlayerController.network(
  1023. // Utils.getImagePath(detailObj.afterRepair)
  1024. // // imgFontUrl + detailObj.url
  1025. // )
  1026. _controllerAfter,
  1027. aspectRatio: 3 / 2,
  1028. autoPlay: false,
  1029. looping: true,
  1030. showControls: true,
  1031. deviceOrientationsAfterFullScreen: [
  1032. DeviceOrientation.portraitUp,
  1033. ],
  1034. // 占位图
  1035. // placeholder: Image.network(
  1036. // imgFontUrl+detailObj.cover,
  1037. // fit: BoxFit.contain,
  1038. // ),
  1039. // 是否在 UI 构建的时候就加载视频
  1040. autoInitialize: true,
  1041. // 拖动条样式颜色
  1042. materialProgressColors: new ChewieProgressColors(
  1043. playedColor: Colors.red,
  1044. handleColor: Colors.blue,
  1045. backgroundColor: Colors.grey,
  1046. bufferedColor: Colors.lightGreen,
  1047. ),
  1048. ),
  1049. ),
  1050. ))
  1051. : Container(
  1052. padding: EdgeInsets.only(left: 15),
  1053. child: Text("暂无"),
  1054. ),
  1055. ],
  1056. );
  1057. }
  1058. _boHuiTip() {
  1059. double width = MediaQuery.of(context).size.width;
  1060. return Container(
  1061. padding: EdgeInsets.only(
  1062. left: ScreenUtil().setWidth(15),
  1063. top: ScreenUtil().setWidth(10),
  1064. bottom: ScreenUtil().setWidth(10)),
  1065. child: Column(
  1066. children: <Widget>[
  1067. detailObj.questionBankEntity != null
  1068. ? Row(
  1069. crossAxisAlignment: CrossAxisAlignment.start,
  1070. children: <Widget>[
  1071. Text(
  1072. '驳回原因:',
  1073. textAlign: TextAlign.left,
  1074. style: TextStyle(
  1075. fontSize: ScreenUtil().setSp(13),
  1076. color: Color(0xff666666),
  1077. ),
  1078. ),
  1079. Container(
  1080. width: width * 0.75,
  1081. child: Text(
  1082. detailObj.questionBankEntity?.notExamineReason ?? "",
  1083. textAlign: TextAlign.left,
  1084. style: TextStyle(
  1085. fontSize: ScreenUtil().setSp(13),
  1086. color: Color(0xff666666),
  1087. ),
  1088. ),
  1089. )
  1090. ],
  1091. )
  1092. : Container(
  1093. child: null,
  1094. ),
  1095. ],
  1096. ),
  1097. );
  1098. }
  1099. _uploadLiveVideo() {
  1100. return Column(
  1101. children: [
  1102. detailObj.arrivedFlag != 1
  1103. ? Row(
  1104. children: [
  1105. Container(
  1106. height: 11,
  1107. width: 2,
  1108. color: Colours.blue_app_main,
  1109. ),
  1110. SizedBox(
  1111. width: 13,
  1112. ),
  1113. Text('打卡信息')
  1114. ],
  1115. )
  1116. : Container(),
  1117. detailObj.arrivedFlag != 1
  1118. ? Container(
  1119. height: 40,
  1120. child: InkWell(
  1121. onTap: () {
  1122. Navigator.of(context).push(MaterialPageRoute(
  1123. builder: (context) => ExpertCheckPage(
  1124. backFun: (lat, lon, add) {
  1125. latitude = lat;
  1126. longitude = lon;
  1127. address = add;
  1128. print(address);
  1129. setState(() {});
  1130. },
  1131. )));
  1132. },
  1133. child: Row(
  1134. children: [
  1135. SizedBox(
  1136. width: 15,
  1137. ),
  1138. Icon(
  1139. const IconData(0xe638, fontFamily: "Iconfont"),
  1140. size: 17.0,
  1141. color: Colours.blue_app_main,
  1142. ),
  1143. Text(
  1144. '${address ?? '点击查看位置'}',
  1145. style: TextStyle(color: Colours.blue_app_main),
  1146. ),
  1147. Expanded(child: Container()),
  1148. Icon(
  1149. Icons.arrow_forward_ios,
  1150. size: 12,
  1151. color: Color(0xff999999),
  1152. ),
  1153. SizedBox(
  1154. width: 15,
  1155. ),
  1156. ],
  1157. ),
  1158. ),
  1159. )
  1160. : Container(),
  1161. Row(
  1162. children: [
  1163. Container(
  1164. height: 11,
  1165. width: 2,
  1166. color: Colours.blue_app_main,
  1167. ),
  1168. SizedBox(
  1169. width: 13,
  1170. ),
  1171. Text(detailObj.arrivedFlag != 1 ? '现场情况(维修前)' : '现场情况(维修后)')
  1172. ],
  1173. ),
  1174. Container(
  1175. // color: ThemeUtils.getDialogTextFieldColor(context),
  1176. // color: Colors.red,
  1177. child: GridView.builder(
  1178. shrinkWrap: true,
  1179. padding: const EdgeInsets.fromLTRB(8.0, 0, 8.0, 12.0),
  1180. physics: NeverScrollableScrollPhysics(),
  1181. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  1182. crossAxisCount: 1, childAspectRatio: 1.5),
  1183. itemCount: 1,
  1184. itemBuilder: (_, index) {
  1185. return Stack(
  1186. children: <Widget>[
  1187. Center(
  1188. child: SelectedVideo(
  1189. image: videoUrl,
  1190. index: index,
  1191. videoPlay: videoPlay(),
  1192. onTap: () {
  1193. if (videoUrl == null) {
  1194. selectPicker();
  1195. }
  1196. },
  1197. ),
  1198. ),
  1199. videoUrl != null
  1200. ? Positioned(
  1201. top: 0,
  1202. right: 0,
  1203. child: GestureDetector(
  1204. onTap: () {
  1205. setState(() {
  1206. videoUrl = null;
  1207. str = null;
  1208. _controller.pause();
  1209. // player.reset();
  1210. });
  1211. },
  1212. child: Icon(
  1213. const IconData(0xe651, fontFamily: "Iconfont"),
  1214. size: 24.0,
  1215. color: Color(0xff999999),
  1216. ),
  1217. ),
  1218. )
  1219. : Container(
  1220. child: null,
  1221. )
  1222. ],
  1223. );
  1224. },
  1225. ),
  1226. )
  1227. ],
  1228. );
  1229. }
  1230. _orderSSInfo() {
  1231. return Container(
  1232. padding: EdgeInsets.only(
  1233. left: ScreenUtil().setWidth(15),
  1234. top: ScreenUtil().setWidth(10),
  1235. bottom: ScreenUtil().setWidth(10)),
  1236. child: Column(
  1237. children: <Widget>[
  1238. Row(
  1239. children: <Widget>[
  1240. Text(
  1241. '申诉内容:',
  1242. textAlign: TextAlign.left,
  1243. style: TextStyle(
  1244. fontSize: 14,
  1245. color: Color(0xff333333),
  1246. ),
  1247. ),
  1248. Text(
  1249. detailObj.liftCaseAppealEntity != null &&
  1250. detailObj.liftCaseAppealEntity.content != null
  1251. ? detailObj.liftCaseAppealEntity.content
  1252. : '',
  1253. textAlign: TextAlign.left,
  1254. style: TextStyle(
  1255. fontSize: 14,
  1256. color: Color(0xff999999),
  1257. ),
  1258. ),
  1259. ],
  1260. ),
  1261. Row(
  1262. children: <Widget>[
  1263. Text(
  1264. '申诉时间:',
  1265. textAlign: TextAlign.left,
  1266. style: TextStyle(
  1267. fontSize: 14,
  1268. color: Color(0xff333333),
  1269. ),
  1270. ),
  1271. Text(
  1272. detailObj.liftCaseAppealEntity != null &&
  1273. detailObj.liftCaseAppealEntity.createTime != null
  1274. ? DateUtils.instance.getFormartData(
  1275. timeSamp: detailObj.liftCaseAppealEntity.createTime,
  1276. format: "yyyy-MM-dd HH:mm:ss")
  1277. : '',
  1278. textAlign: TextAlign.left,
  1279. style: TextStyle(
  1280. fontSize: 14,
  1281. color: Color(0xff999999),
  1282. ),
  1283. ),
  1284. ],
  1285. ),
  1286. ],
  1287. ),
  1288. );
  1289. }
  1290. VideoPlayerController _controller;
  1291. VideoPlayerController _controllerFile;
  1292. ChewieController _chewieController;
  1293. ///选择图片
  1294. void selectPicker() {
  1295. showDialog(
  1296. context: context,
  1297. builder: (BuildContext context) {
  1298. return SimpleDialog(
  1299. title: Text("选择方式"),
  1300. children: ["拍照", '从手机相册选择'].map((String value) {
  1301. print("$value");
  1302. return SimpleDialogOption(
  1303. child: Text(
  1304. "${value}",
  1305. style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
  1306. ),
  1307. onPressed: () {
  1308. _getImage(value == '拍照' ? 1 : 0);
  1309. Navigator.of(context).pop();
  1310. },
  1311. );
  1312. }).toList(),
  1313. );
  1314. },
  1315. );
  1316. }
  1317. void _getImage(int key) async {
  1318. print(key);
  1319. print(333);
  1320. try {
  1321. await ImagePicker.pickVideo(
  1322. source: key == 1 ? ImageSource.camera : ImageSource.gallery,
  1323. ).then((File f) async {
  1324. if (f != null) {
  1325. _controllerFile = VideoPlayerController.file(f);
  1326. _controllerFile.initialize().then((val) {
  1327. _controllerFile.setLooping(true);
  1328. int seconds = _controllerFile.value.duration.inSeconds;
  1329. print("视频时长:$seconds");
  1330. int fileSize = f.lengthSync(); //单位B
  1331. print("视频大小:${fileSize}");
  1332. print("视频大小:${f.path}");
  1333. if (seconds <= 300) {
  1334. _uploadImage(f.path);
  1335. // upLoadFileOnce(_imageFile.path);
  1336. // setState(() {});
  1337. } else {
  1338. toasts("视频时长不能大于5分钟!");
  1339. }
  1340. }).catchError((error) {
  1341. print(error);
  1342. print("error");
  1343. toasts("上传失败,不支持此格式");
  1344. });
  1345. }
  1346. });
  1347. } catch (e) {
  1348. toasts("没有权限,无法打开相册!");
  1349. }
  1350. }
  1351. upLoadFileOnce(path) {
  1352. showLoading(context, "正在上传...");
  1353. NewApiService().upload(path, onSuccess: (res) {
  1354. dismissLoading(context);
  1355. setState(() {
  1356. videoUrl = res.pathUrl;
  1357. imagesUrl = res.coverUrl;
  1358. });
  1359. }, onError: (code, msg) {
  1360. dismissLoading(context);
  1361. toasts(msg);
  1362. });
  1363. }
  1364. void _uploadImage(filePath) async {
  1365. showPercent(context, () {
  1366. dismissLoading(context);
  1367. toasts("上传失败");
  1368. }, () {
  1369. if (videoUrl == null && str != null) {
  1370. setState(() {
  1371. videoUrl = str;
  1372. settingVideoVC();
  1373. print("videoUrl:" + videoUrl);
  1374. dismissLoading(context);
  1375. toasts("上传成功");
  1376. });
  1377. }
  1378. });
  1379. String uploadName = OssUtil.instance.getImageUploadName(filePath);
  1380. await NewApiService.uploadImage(context, uploadName, filePath).then((data) {
  1381. if (data.statusCode == 200) {
  1382. str = NewApiUrl.URL_UPLOAD_IMAGE_OSS + "/" + uploadName;
  1383. print("str:" + str);
  1384. print(videoUrl);
  1385. if (str != null) {
  1386. Map obj = {"uploadName": uploadName, "success": true};
  1387. FastNotification.push("percent", obj);
  1388. }
  1389. } else {
  1390. Map obj = {"uploadName": uploadName, "success": false};
  1391. FastNotification.push("percent", obj);
  1392. }
  1393. }).catchError((data) {
  1394. Map obj = {"uploadName": uploadName, "success": false};
  1395. FastNotification.push("percent", obj);
  1396. });
  1397. }
  1398. settingVideoVC() {
  1399. _controller?.pause();
  1400. _controller?.dispose();
  1401. _chewieController?.dispose();
  1402. _controller = VideoPlayerController.network(Utils.getImagePath(videoUrl)
  1403. // imgFontUrl + detailObj.url
  1404. );
  1405. _chewieController = ChewieController(
  1406. videoPlayerController:
  1407. // VideoPlayerController.network(
  1408. // imgFontUrl + detailObj.url
  1409. // ),
  1410. _controller,
  1411. aspectRatio: 3 / 2,
  1412. autoPlay: false,
  1413. looping: true,
  1414. showControls: true,
  1415. deviceOrientationsAfterFullScreen: [
  1416. DeviceOrientation.portraitUp,
  1417. ],
  1418. // 占位图
  1419. // placeholder: Image.network(
  1420. // imgFontUrl+detailObj.cover,
  1421. // fit: BoxFit.contain,
  1422. // ),
  1423. // 是否在 UI 构建的时候就加载视频
  1424. autoInitialize: true,
  1425. // 拖动条样式颜色
  1426. materialProgressColors: new ChewieProgressColors(
  1427. playedColor: Colors.red,
  1428. handleColor: Colors.blue,
  1429. backgroundColor: Colors.grey,
  1430. bufferedColor: Colors.lightGreen,
  1431. ),
  1432. );
  1433. }
  1434. Widget videoPlay() {
  1435. if (_controller == null) return Container();
  1436. double width = MediaQuery.of(context).size.width;
  1437. return Container(
  1438. width: width,
  1439. height: width * 2 / 3,
  1440. padding: EdgeInsets.only(
  1441. left: ScreenUtil().setWidth(15),
  1442. right: ScreenUtil().setWidth(15),
  1443. top: ScreenUtil().setWidth(15)),
  1444. child: ClipRRect(
  1445. borderRadius: BorderRadius.circular(5),
  1446. child: new Chewie(controller: _chewieController),
  1447. ));
  1448. }
  1449. // 获取定位权限
  1450. Future<bool> requestPermission() async {
  1451. final permissions = await PermissionHandler()
  1452. .requestPermissions([PermissionGroup.location]);
  1453. if (permissions[PermissionGroup.location] == PermissionStatus.granted) {
  1454. return true;
  1455. } else {
  1456. toasts('需要定位权限!');
  1457. return false;
  1458. }
  1459. }
  1460. // 获取位置信息
  1461. Future<void> punchin() async {
  1462. ///开始定位之前设置定位参数
  1463. if (longitude == null) {
  1464. toasts("请选择打卡地点");
  1465. return;
  1466. }
  1467. if (longitude != null && latitude != null) {
  1468. if (videoUrl == null || videoUrl == '') {
  1469. toasts("请上传视频");
  1470. return;
  1471. }
  1472. showLoading(context);
  1473. NewApiService().chargeToClock({
  1474. "id": detailObj.id,
  1475. "lng": longitude,
  1476. "lat": latitude,
  1477. "beforeRepair": videoUrl,
  1478. }, onSuccess: (res) {
  1479. dismissLoading(context);
  1480. toasts("确认打卡成功");
  1481. if (_controller != null) {
  1482. _controller.pause();
  1483. }
  1484. getBrandDetail();
  1485. // NavigatorUtils.push(
  1486. // context, "${WodeRouter.orderPageMaster}?checkType=0");
  1487. setState(() {});
  1488. }, onError: (code, msg) {
  1489. dismissLoading(context);
  1490. toasts(msg);
  1491. });
  1492. }
  1493. }
  1494. ///确认完成
  1495. submitApply() {
  1496. if (videoUrl == null || videoUrl == '') {
  1497. toasts("请上传视频");
  1498. return;
  1499. }
  1500. showLoading(context);
  1501. NewApiService().chargeMakeSureCase({
  1502. "id": widget.id,
  1503. "afterRepair": videoUrl,
  1504. }, onSuccess: (res) {
  1505. dismissLoading(context);
  1506. toasts("确认完成");
  1507. if (_controller != null) {
  1508. _controller.pause();
  1509. }
  1510. NavigatorUtils.push(context, "${WodeRouter.orderPageMaster}?checkType=0");
  1511. setState(() {});
  1512. }, onError: (code, msg) {
  1513. dismissLoading(context);
  1514. toasts(msg);
  1515. });
  1516. }
  1517. getPayCost() {
  1518. bool isPay = true;
  1519. if ((detailObj.dataTable == 1 && detailObj.statuz == 0) ||
  1520. (detailObj.dataTable == 2 && detailObj.statuz == 2)) {
  1521. isPay = false;
  1522. }
  1523. return isPay;
  1524. }
  1525. isShowMoneyDetail() {
  1526. bool show = true;
  1527. if (detailObj.dataTable == 2) {
  1528. switch (detailObj.statuz) {
  1529. case 0:
  1530. case 1:
  1531. show = false;
  1532. break;
  1533. default:
  1534. }
  1535. }
  1536. // if ((detailObj.dataTable == 2 && (detailObj.statuz == 2)) ||
  1537. // (detailObj.dataTable == 2 && detailObj.statuz == 2)) {
  1538. // show = false;
  1539. // }
  1540. return show;
  1541. }
  1542. isShowOrderLive() {
  1543. bool show = false;
  1544. if (detailObj.dataTable == 2) {
  1545. show = true;
  1546. switch (detailObj.statuz) {
  1547. case 0:
  1548. case 1:
  1549. case 2:
  1550. case 3:
  1551. {
  1552. if (detailObj.arrivedFlag == 2) {
  1553. show = true;
  1554. } else {
  1555. show = false;
  1556. }
  1557. }
  1558. break;
  1559. default:
  1560. }
  1561. }
  1562. return show;
  1563. }
  1564. @override
  1565. bool get wantKeepAlive => true;
  1566. }
  1567. class BottomBtn extends StatelessWidget {
  1568. BottomBtn({Key key, this.title, this.fun}) : super(key: key);
  1569. Function fun;
  1570. String title;
  1571. @override
  1572. Widget build(BuildContext context) {
  1573. return Expanded(
  1574. // margin: EdgeInsets.only(left: 10),
  1575. child: GestureDetector(
  1576. onTap: () {
  1577. fun();
  1578. },
  1579. child: Container(
  1580. child: Container(
  1581. margin: EdgeInsets.only(left: 15, right: 15),
  1582. // // height:22,
  1583. // padding: EdgeInsets.only(
  1584. // left: ScreenUtil().setWidth(20),
  1585. // right: ScreenUtil().setWidth(20),
  1586. // ),
  1587. decoration: BoxDecoration(
  1588. border: Border.all(width: 1, color: Color(0xff1B87F6)),
  1589. borderRadius: BorderRadius.circular(23),
  1590. color: Colours.blue_app_main),
  1591. child: Column(
  1592. mainAxisAlignment: MainAxisAlignment.center,
  1593. children: <Widget>[
  1594. Text(
  1595. title,
  1596. textAlign: TextAlign.center,
  1597. style: TextStyle(
  1598. fontSize: ScreenUtil().setSp(15),
  1599. color: Colors.white,
  1600. ),
  1601. ),
  1602. ],
  1603. ),
  1604. ),
  1605. ),
  1606. ),
  1607. );
  1608. }
  1609. }