comment.dart 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. import 'package:flustars/flustars.dart' as flustars;
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_screenutil/flutter_screenutil.dart';
  5. import 'package:liftmanager/common/common.dart';
  6. import 'package:liftmanager/internal/account/provider/user_provider.dart';
  7. import 'package:liftmanager/internal/bbs/bbs_router.dart';
  8. import 'package:liftmanager/internal/bbs/model/liftcase_model.dart';
  9. import 'package:liftmanager/internal/wode/wode_router.dart';
  10. import 'package:liftmanager/net/api_service.dart';
  11. import 'package:liftmanager/res/resources.dart';
  12. import 'package:liftmanager/routers/fluro_navigator.dart';
  13. import 'package:liftmanager/utils/time_format.dart';
  14. import 'package:liftmanager/utils/toast.dart';
  15. import 'package:liftmanager/widgets/app_bar.dart';
  16. import 'package:liftmanager/widgets/load_image.dart';
  17. import 'package:liftmanager/widgets/star_item.dart';
  18. import 'package:oktoast/oktoast.dart';
  19. import 'package:provider/provider.dart';
  20. class Comment extends StatefulWidget {
  21. Comment(this.id);
  22. final String id;
  23. @override
  24. State<StatefulWidget> createState() {
  25. return CommentState();
  26. }
  27. }
  28. class CommentState extends State<Comment> with AutomaticKeepAliveClientMixin {
  29. UserProvider provider = UserProvider();
  30. bool _hasData = false;
  31. LiftCasesDetailModel detailObj;
  32. void getBrandDetail() {
  33. NewApiService().getLiftcaseDetail(widget.id, onSuccess: (res) {
  34. detailObj = res;
  35. _hasData = true;
  36. setState(() {});
  37. }, onError: (code, msg) {
  38. toasts(msg);
  39. });
  40. }
  41. void submitComment() {
  42. if (serviceLevel == 0 || serviceTaidu == 0 || speed == 0) {
  43. showToast('请打分');
  44. return;
  45. }
  46. if (_controller.text.length == 0) {
  47. showToast('请填写评价');
  48. return;
  49. }
  50. // double serviceLevel = 0;
  51. // double serviceTaidu = 0;
  52. // double speed = 0;
  53. showLoading(context);
  54. NewApiService().submitComments({
  55. "attitude": serviceTaidu,
  56. "comment": _controller.text,
  57. "lifeCaseId": widget.id,
  58. "responseSpeed": speed,
  59. "tech": serviceLevel,
  60. "expertId": detailObj.chargerId,
  61. "userId": int.parse(flustars.SpUtil.getString(Constant.userId)),
  62. }, onSuccess: (res) {
  63. dismissLoading(context);
  64. toasts("评论成功");
  65. NavigatorUtils.push(context, "${WodeRouter.orderPage}?checkType=0");
  66. }, onError: (code, msg) {
  67. dismissLoading(context);
  68. toasts(msg);
  69. });
  70. }
  71. double serviceLevel = 0;
  72. double serviceTaidu = 0;
  73. double speed = 0;
  74. TextEditingController _controller = TextEditingController();
  75. @override
  76. void initState() {
  77. getBrandDetail();
  78. super.initState();
  79. }
  80. @override
  81. void dispose() {
  82. super.dispose();
  83. }
  84. FocusNode blankNode = FocusNode();
  85. @override
  86. Widget build(BuildContext context) {
  87. double width = MediaQuery.of(context).size.width;
  88. return
  89. // Center(child:new Text("个人中心"));
  90. ChangeNotifierProvider<UserProvider>(
  91. create: (_) => provider,
  92. child: Scaffold(
  93. appBar: MyAppBar(
  94. centerTitle: "订单评价",
  95. ),
  96. body: GestureDetector(
  97. onTap: () {
  98. // 点击空白页面关闭键盘
  99. FocusScope.of(context).requestFocus(blankNode);
  100. },
  101. child: Consumer<UserProvider>(
  102. builder: (_, provider, __) {
  103. return Stack(
  104. children: <Widget>[
  105. ListView(
  106. padding: EdgeInsets.all(0.0),
  107. children: <Widget>[
  108. _hasData
  109. ? _orderUserDetail()
  110. : Center(
  111. child: null,
  112. ),
  113. Container(
  114. color: Color(0xffFAF7FA),
  115. height: ScreenUtil().setWidth(5),
  116. ),
  117. SizedBox(
  118. height: 20,
  119. ),
  120. Row(
  121. children: [
  122. Container(
  123. height: 13,
  124. width: 2,
  125. color: Colours.blue_app_main,
  126. ),
  127. SizedBox(
  128. width: 13,
  129. ),
  130. Text(
  131. '打分评价',
  132. style: TextStyle(color: Colours.text, fontSize: 15),
  133. )
  134. ],
  135. ),
  136. Container(
  137. child: Column(
  138. children: <Widget>[
  139. StarItem(
  140. title: "技术水平:",
  141. starRating: serviceLevel,
  142. onRatingChanged: (res) {
  143. serviceLevel = res;
  144. setState(() {});
  145. },
  146. ),
  147. StarItem(
  148. title: "服务态度:",
  149. starRating: serviceTaidu,
  150. onRatingChanged: (res) {
  151. serviceTaidu = res;
  152. setState(() {});
  153. },
  154. ),
  155. StarItem(
  156. title: "响应速度:",
  157. starRating: speed,
  158. onRatingChanged: (res) {
  159. speed = res;
  160. setState(() {});
  161. },
  162. ),
  163. SizedBox(
  164. height: 8,
  165. ),
  166. Container(
  167. color: Color(0xffFAF7FA),
  168. height: ScreenUtil().setWidth(5),
  169. ),
  170. SizedBox(
  171. height: 20,
  172. ),
  173. Row(
  174. children: [
  175. Container(
  176. height: 13,
  177. width: 2,
  178. color: Colours.blue_app_main,
  179. ),
  180. SizedBox(
  181. width: 13,
  182. ),
  183. Text(
  184. '评价描述',
  185. style: TextStyle(
  186. color: Colours.text, fontSize: 15),
  187. )
  188. ],
  189. ),
  190. // Container(
  191. // decoration: BoxDecoration(
  192. // border: Border.all(
  193. // width: 0.5, color: Color(0xffcccccc)),
  194. // color: Colors.white,
  195. // ),
  196. // margin: EdgeInsets.only(
  197. // left: ScreenUtil().setWidth(15),
  198. // right: ScreenUtil().setWidth(15)),
  199. // child: Padding(
  200. // padding: const EdgeInsets.only(
  201. // top: 5,
  202. // left: 15.0,
  203. // right: 15.0,
  204. // bottom: 8.0),
  205. // child: TextField(
  206. // maxLength: 200,
  207. // maxLines: 5,
  208. // autofocus: false,
  209. // controller: _controller,
  210. // decoration: InputDecoration(
  211. // hintText: "您的满意是对专家最大的支持和鼓励",
  212. // border: InputBorder.none,
  213. // hintStyle: TextStyles.textGray14,
  214. // ),
  215. // ),
  216. // ),
  217. // ),
  218. Container(
  219. height: ScreenUtil().setWidth(120),
  220. padding: EdgeInsets.only(
  221. left: 15, right: 15, bottom: 20, top: 10),
  222. child: TextFormField(
  223. // autofocus: true,
  224. maxLength: 100,
  225. cursorColor: Color(0xffcccccc),
  226. controller: _controller,
  227. maxLines: 5,
  228. decoration: InputDecoration(
  229. contentPadding: EdgeInsets.all(0),
  230. hintText: '请描述您对专家本次服务的评价',
  231. hintStyle:
  232. TextStyle(color: Color(0xffcccccc)),
  233. focusedBorder: InputBorder.none,
  234. border: InputBorder.none,
  235. // filled: true, // 背景色
  236. // fillColor: Colors.cyan.withAlpha(35),
  237. // icon: Icon(Icons.person)
  238. ),
  239. ),
  240. ),
  241. ],
  242. ),
  243. ),
  244. Row(
  245. mainAxisAlignment: MainAxisAlignment.center,
  246. children: <Widget>[
  247. Container(
  248. height: 44,
  249. decoration: BoxDecoration(
  250. color: Colours.blue_app_main,
  251. borderRadius: BorderRadius.circular(
  252. ScreenUtil().setWidth(22)),
  253. // gradient: const LinearGradient(
  254. // colors: [Color(0xFF00D9FF), Color(0xFF0287FF)]),
  255. ),
  256. margin: EdgeInsets.only(
  257. top: ScreenUtil().setWidth(20),
  258. bottom: ScreenUtil().setWidth(20)),
  259. width: width * 0.9,
  260. child: FlatButton(
  261. child: Text("提交"),
  262. textColor: Colors.white,
  263. onPressed: () {
  264. // NavigatorUtils.push(context, WodeRouter.orderPage);
  265. submitComment();
  266. },
  267. ),
  268. ),
  269. ],
  270. ),
  271. ],
  272. ),
  273. ],
  274. );
  275. },
  276. ),
  277. ),
  278. ),
  279. );
  280. }
  281. _orderUserDetail() {
  282. return Container(
  283. // height: 20,
  284. padding: EdgeInsets.only(
  285. bottom: ScreenUtil().setWidth(20), top: ScreenUtil().setWidth(10)),
  286. child: Row(
  287. crossAxisAlignment: CrossAxisAlignment.start,
  288. children: <Widget>[
  289. Expanded(
  290. child: GestureDetector(
  291. onTap: () {
  292. NavigatorUtils.push(context,
  293. "${BbsRouter.recommendAsk}?id=${detailObj.id}&type=3");
  294. },
  295. child: Row(
  296. crossAxisAlignment: CrossAxisAlignment.start,
  297. children: <Widget>[
  298. SizedBox(
  299. width: 10,
  300. ),
  301. ClipRRect(
  302. borderRadius: BorderRadius.circular(20),
  303. child: LoadNetworkImage(
  304. detailObj.avatarUrl,
  305. width: ScreenUtil().setWidth(43),
  306. height: ScreenUtil().setWidth(43),
  307. // alignment: Alignment.centerLeft,
  308. ),
  309. ),
  310. SizedBox(
  311. width: 10,
  312. ),
  313. Expanded(
  314. child: Container(
  315. padding:
  316. EdgeInsets.only(right: ScreenUtil().setWidth(15)),
  317. child: Column(
  318. children: <Widget>[
  319. Container(
  320. child: Row(
  321. mainAxisAlignment: MainAxisAlignment.start,
  322. children: <Widget>[
  323. Row(
  324. crossAxisAlignment: CrossAxisAlignment.center,
  325. children: <Widget>[
  326. Text(
  327. detailObj.name ?? '',
  328. style: TextStyle(
  329. fontSize: ScreenUtil().setSp(17),
  330. ),
  331. textAlign: TextAlign.start,
  332. ),
  333. Container(
  334. decoration: BoxDecoration(
  335. //背景
  336. color: detailObj.dataTable == 1
  337. ? Colours.blue_app_main
  338. : Color(0xffFDAF2C),
  339. //设置四周圆角 角度
  340. borderRadius: BorderRadius.all(
  341. Radius.circular(4.0)),
  342. ),
  343. margin: EdgeInsets.only(left: 5),
  344. padding: EdgeInsets.only(
  345. left: 5, right: 5, top: 2, bottom: 2),
  346. child: Text(
  347. detailObj.dataTable == 1
  348. ? '问诊服务'
  349. : '出诊服务',
  350. style: TextStyle(
  351. color: Colors.white,
  352. fontSize: ScreenUtil().setSp(14),
  353. ),
  354. textAlign: TextAlign.start,
  355. ),
  356. ),
  357. ],
  358. ),
  359. ],
  360. ),
  361. ),
  362. Container(
  363. child: Row(
  364. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  365. children: <Widget>[
  366. Row(
  367. crossAxisAlignment: CrossAxisAlignment.center,
  368. children: <Widget>[
  369. Text(
  370. detailObj.createTime != null
  371. ? DateUtils.instance.getFormartData(
  372. timeSamp: detailObj.createTime,
  373. format: "MM月dd日")
  374. : '',
  375. style: TextStyle(
  376. color: Color(0xff999999),
  377. fontSize: ScreenUtil().setSp(13),
  378. ),
  379. textAlign: TextAlign.start,
  380. ),
  381. Container(
  382. padding: EdgeInsets.only(left: 5),
  383. child: Text(
  384. detailObj.brandName ?? '',
  385. style: TextStyle(
  386. color: Colours.blue_app_main,
  387. fontSize: ScreenUtil().setSp(13),
  388. ),
  389. textAlign: TextAlign.start,
  390. ),
  391. )
  392. ],
  393. ),
  394. ],
  395. ),
  396. ),
  397. detailObj.dataTable != 1
  398. ? Container(
  399. child: Row(
  400. mainAxisAlignment:
  401. MainAxisAlignment.spaceBetween,
  402. children: <Widget>[
  403. Row(
  404. crossAxisAlignment:
  405. CrossAxisAlignment.start,
  406. children: <Widget>[
  407. Container(
  408. // padding: EdgeInsets.only(left: 5),
  409. child: Text(
  410. '出诊时间:',
  411. style: TextStyle(
  412. color: Color(0xff999999),
  413. fontSize:
  414. ScreenUtil().setSp(13),
  415. ),
  416. textAlign: TextAlign.start,
  417. ),
  418. ),
  419. Text(
  420. detailObj.createTime != null
  421. ? DateUtils.instance
  422. .getFormartData(
  423. timeSamp: detailObj
  424. .createTime,
  425. format: "MM月dd日 HH:mm")
  426. : '',
  427. style: TextStyle(
  428. color: Color(0xff666666),
  429. fontSize: ScreenUtil().setSp(13),
  430. ),
  431. textAlign: TextAlign.start,
  432. ),
  433. ],
  434. ),
  435. ],
  436. ),
  437. )
  438. : Container(),
  439. detailObj.dataTable != 1
  440. ? Container(
  441. // margin: EdgeInsets.only(top: 6),
  442. child: Row(
  443. children: <Widget>[
  444. Container(
  445. // padding: EdgeInsets.only(left: 5),
  446. child: Text(
  447. '出诊地点:',
  448. style: TextStyle(
  449. color: Color(0xff999999),
  450. fontSize: ScreenUtil().setSp(13),
  451. ),
  452. textAlign: TextAlign.start,
  453. ),
  454. ),
  455. Container(
  456. width: ScreenUtil().setWidth(230),
  457. child: Text(
  458. '${detailObj.address ?? ''}',
  459. style: TextStyle(
  460. color: Color(0xff666666),
  461. fontSize: ScreenUtil().setSp(13),
  462. // color: Color(0xff666666),
  463. // fontSize: ScreenUtil().setSp(15),
  464. ),
  465. textAlign: TextAlign.start,
  466. maxLines: 1,
  467. overflow: TextOverflow.ellipsis,
  468. ),
  469. ),
  470. ],
  471. ),
  472. )
  473. : Container(),
  474. Container(
  475. // margin: EdgeInsets.only(top: 6),
  476. child: Row(
  477. children: <Widget>[
  478. Container(
  479. // padding: EdgeInsets.only(left: 5),
  480. child: Text(
  481. '问题描述:',
  482. style: TextStyle(
  483. color: Color(0xff999999),
  484. fontSize: ScreenUtil().setSp(13),
  485. ),
  486. textAlign: TextAlign.start,
  487. ),
  488. ),
  489. Container(
  490. width: ScreenUtil().setWidth(230),
  491. child: Text(
  492. '${detailObj.expression ?? ''}',
  493. style: TextStyle(
  494. color: Color(0xff666666),
  495. fontSize: ScreenUtil().setSp(13),
  496. // color: Color(0xff666666),
  497. // fontSize: ScreenUtil().setSp(15),
  498. ),
  499. textAlign: TextAlign.start,
  500. maxLines: 1,
  501. overflow: TextOverflow.ellipsis,
  502. ),
  503. ),
  504. ],
  505. ),
  506. ),
  507. ],
  508. ),
  509. ),
  510. )
  511. ],
  512. ),
  513. ),
  514. ),
  515. ],
  516. ),
  517. );
  518. }
  519. @override
  520. bool get wantKeepAlive => true;
  521. }