import 'dart:async';
import 'dart:convert';

import 'package:flustars/flustars.dart' as FlutterStars;
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:liftmanager/common/common.dart';
import 'package:liftmanager/internal/bbs/bbs_router.dart';
import 'package:liftmanager/internal/bbs/model/liftcase_model.dart';
import 'package:liftmanager/internal/bbs/presenter/liftcase_list_presenter.dart';
import 'package:liftmanager/internal/search/presenter/base_list_provider.dart';
import 'package:liftmanager/internal/wode/order_const.dart';
import 'package:liftmanager/mvp/base_page_state.dart';
import 'package:liftmanager/net/api_service.dart';
import 'package:liftmanager/res/resources.dart';
import 'package:liftmanager/routers/fluro_navigator.dart';
import 'package:liftmanager/utils/theme_utils.dart';
import 'package:liftmanager/utils/time_format.dart';
import 'package:liftmanager/utils/toast.dart';
import 'package:liftmanager/widgets/app_bar.dart';
import 'package:liftmanager/widgets/clip_widgets.dart';
import 'package:liftmanager/widgets/load_image.dart';
import 'package:liftmanager/widgets/my_refresh_list.dart';
import 'package:liftmanager/widgets/popup_window.dart';
import 'package:provider/provider.dart';

class WorkPlace extends StatefulWidget {
  @override
  WorkPlaceState createState() => WorkPlaceState();
}

class WorkPlaceState extends BasePageState<WorkPlace, LiftcaseListPresenter> {
  BaseListProvider<LiftCasesDetailModel> provider =
      BaseListProvider<LiftCasesDetailModel>();
  // ExpertListState({Key key}) : super(key: key);
  bool sortBool = true;
  String sortName = "排序";
  int indexNowConst = 999;
  String checkId = "";
  bool isOnline = true;
  bool isSelect = false;
  int _page = 1;
  List<String> labelList = ["特邀专家", "普通专家"];
  List<dynamic> expertType = [
    {"value": 0, "label": "特邀专家"},
    {"value": 1, "label": "普通专家"}
  ];

  GlobalKey _addKey = GlobalKey();
  @override
  void initState() {
    super.initState();
    getBrandDetail();
    _onRefresh();
    startTimer();
  }

  getLevel(level) {
    String img;
    if (level == 1) {
      img = "L1@2x";
    } else if (level == 2) {
      img = "L2@2x";
    } else if (level == 3) {
      img = "L3@2x";
    } else if (level == 4) {
      img = "L4@2x";
    } else if (level == 5) {
      img = "L5@2x";
    }
    return img;
  }

  bool _hasData = false;
  var detailObj;
  getBrandDetail() {
    NewApiService().getExpertDetail(
        FlutterStars.SpUtil.getString(Constant.userId), onSuccess: (res) {
      detailObj = res;
      print("获取详情成功");
      if (detailObj.statuz == 1) {
        isOnline = true;
      } else {
        isOnline = false;
      }
      print(JsonEncoder().convert(res));
      print(123123);
      _hasData = true;
      setState(() {});
    }, onError: (code, msg) {
      toasts(msg);
    });
  }

  updateUser(int status) {
    NewApiService().updateUser({
      "userId": FlutterStars.SpUtil.getString(Constant.userId),
      "statuz": status
    }, onSuccess: (res) {
      getBrandDetail();
      setState(() {});
    }, onError: (code, msg) {
      toasts(msg);
    });
  }

  Timer _timer;
  void startTimer() {
    //设置 30 秒回调一次
    const period = const Duration(seconds: 30);
    _timer = Timer.periodic(period, (timer) {
      _onRefresh();
      //更新界面
      setState(() {});
    });
  }

  void cancelTimer() {
    if (_timer != null) {
      _timer.cancel();
      _timer = null;
    }
  }

  @override
  void dispose() {
    super.dispose();
    cancelTimer();
  }

  Widget expertDetailWisget() {
    double width = MediaQuery.of(context).size.width;
    double height = MediaQuery.of(context).size.height;

    List<Widget> textWidgets = [Text('擅长品牌:')];
    detailObj.proficiencyBrandName.split(',').forEach((element) {
      if (element != '') {
        textWidgets.add(ClipText(title: element));
      }
    });

    return Column(
      children: <Widget>[
        Container(
            // height: ScreenUtil().setWidth(150),
            padding: EdgeInsets.only(bottom: 10),
            // decoration: BoxDecoration(
            //   gradient: const LinearGradient(
            //       colors: [Color(0xFF00D9FF), Color(0xFF0287FF)]),
            // ),
            child: Column(
              children: <Widget>[
                Container(
                  child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        Container(
                            margin: EdgeInsets.only(
                                left: ScreenUtil().setWidth(10),
                                right: ScreenUtil().setWidth(10),
                                top: ScreenUtil().setWidth(5)),
                            decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(
                                  ScreenUtil().setWidth(25)),
                            ),
                            child: Container(
                              width: ScreenUtil().setWidth(50),
                              height: ScreenUtil().setWidth(70),
                              child: Stack(
                                children: <Widget>[
                                  Container(
                                    padding: EdgeInsets.only(
                                        left: ScreenUtil().setWidth(3)),
                                    child: ClipRRect(
                                      borderRadius:
                                          BorderRadius.all(Radius.circular(50)),
                                      child: LoadNetworkImage(
                                        // image: AssetImage(i['img']),
                                        detailObj.avatarUrl,
                                        width: ScreenUtil().setWidth(44),
                                        height: ScreenUtil().setWidth(44),
                                        // alignment: Alignment.centerLeft,
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            )),
                        Expanded(
                            child: Container(
                                padding: EdgeInsets.only(
                                    right: ScreenUtil().setWidth(15)),
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: <Widget>[
                                    Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.spaceBetween,
                                      children: <Widget>[
                                        Text(
                                          detailObj.name ?? "",
                                          style: TextStyle(
                                              color: Color(0xff333333),
                                              fontSize: ScreenUtil().setSp(18)),
                                        ),
                                        // StarItemShow(
                                        //   starRating:
                                        //       detailObj.averageScore != null
                                        //           ? double.parse(detailObj
                                        //               .averageScore
                                        //               .toString())
                                        //           : 0.0,
                                        // ),
                                      ],
                                    ),
                                    Container(
                                      alignment: Alignment.topLeft,
                                      child: Wrap(
                                          spacing: 2.0,
                                          runSpacing: 3.0,
                                          children: textWidgets),
                                    ),
                                    detailObj.platformInvitedFlag == 0
                                        ? Container(
                                            padding: EdgeInsets.only(
                                                left: 5, right: 5),
                                            margin: EdgeInsets.only(
                                                right: 5, top: 5),
                                            // color:Colors.red,
                                            decoration: BoxDecoration(
                                              borderRadius:
                                                  BorderRadius.circular(1.0),
                                              border: Border.all(
                                                width: 0.5,
                                                color: Color(0xffB0E2FF),
                                              ),
                                            ),
                                            child: Text(
                                              "特邀专家",
                                              style: TextStyle(
                                                  color: Colours.blue_app_main,
                                                  fontSize:
                                                      ScreenUtil().setSp(12)),
                                              textAlign: TextAlign.center,
                                            ),
                                          )
                                        : Container(
                                            child: null,
                                          ),
                                    Row(
                                      children: <Widget>[
                                        Expanded(
                                          child: Container(
                                              decoration: BoxDecoration(
                                                  color: Color(0x195887FF),
                                                  borderRadius:
                                                      new BorderRadius.circular(
                                                          (5.0))),
                                              padding: EdgeInsets.all(5),
                                              margin: EdgeInsets.only(
                                                  right: 5, top: 5),
                                              child: Row(
                                                crossAxisAlignment:
                                                    CrossAxisAlignment.start,
                                                children: <Widget>[
                                                  Icon(
                                                    const IconData(0xe64a,
                                                        fontFamily: "Iconfont"),
                                                    size: 17.0,
                                                    color: Color(0x195887FF),
                                                  ),
                                                  SizedBox(
                                                    width: 5,
                                                  ),
                                                  Expanded(
                                                      child: Container(
                                                    child: Text(
                                                      // "detailObj",
                                                      detailObj.address != null
                                                          ? detailObj.address
                                                              .split(",")[0]
                                                          : "",
                                                      style: TextStyle(
                                                          color: Colours
                                                              .blue_app_main,
                                                          fontSize: ScreenUtil()
                                                              .setSp(12)),
                                                      textAlign: TextAlign.left,
                                                      // overflow:TextOverflow.ellipsis,
                                                    ),
                                                  ))
                                                ],
                                              )),
                                        )
                                      ],
                                    ),
                                  ],
                                )))
                      ]),
                ),
                Container(
                    padding: EdgeInsets.only(top: ScreenUtil().setWidth(10)),
                    child: Row(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        mainAxisAlignment: MainAxisAlignment.spaceAround,
                        children: <Widget>[
                          Container(
                              child: Row(
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: <Widget>[
                                Text(
                                  detailObj.workDate != null
                                      ? detailObj.workDate.toString()
                                      : "0",
                                  style: TextStyle(
                                      color: Color(0xff333333),
                                      fontSize: ScreenUtil().setSp(19),
                                      fontWeight: FontWeight.w500),
                                  textAlign: TextAlign.start,
                                ),
                                Text(
                                  " 从业年数",
                                  style: TextStyle(
                                      color: Color(0xff666666),
                                      fontSize: ScreenUtil().setSp(12),
                                      fontWeight: FontWeight.w400),
                                  textAlign: TextAlign.start,
                                ),
                              ])),
                          Container(
                              child: Row(
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: <Widget>[
                                Text(
                                  detailObj.serviceCounts != null
                                      ? detailObj.serviceCounts.toString()
                                      : "0",
                                  style: TextStyle(
                                      color: Color(0xff333333),
                                      fontSize: ScreenUtil().setSp(19),
                                      fontWeight: FontWeight.w500),
                                  textAlign: TextAlign.start,
                                ),
                                Text(
                                  " 服务次数",
                                  style: TextStyle(
                                      color: Color(0xff666666),
                                      fontSize: ScreenUtil().setSp(12),
                                      fontWeight: FontWeight.w400),
                                  textAlign: TextAlign.start,
                                ),
                              ])),
                          // Container(
                          //   child:Column(
                          //     crossAxisAlignment: CrossAxisAlignment.center,
                          //     children:<Widget>[
                          //       Text(
                          //         "99.9",
                          //         style: TextStyle(
                          //           color:Colors.white,
                          //           fontSize:ScreenUtil().setSp(16)
                          //         ),
                          //         textAlign:TextAlign.start,
                          //       ),
                          //       Text(
                          //         "好评率(%)",
                          //         style: TextStyle(
                          //           color:Colors.white,
                          //           fontSize:ScreenUtil().setSp(14)
                          //         ),
                          //         textAlign:TextAlign.start,
                          //       ),
                          //     ]
                          //   )
                          // ),
                          Container(
                              child: Row(
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: <Widget>[
                                Text(
                                  detailObj.adoptCounts != null
                                      ? detailObj.adoptCounts.toString()
                                      : "0",
                                  style: TextStyle(
                                      color: Color(0xff333333),
                                      fontSize: ScreenUtil().setSp(19),
                                      fontWeight: FontWeight.w500),
                                  textAlign: TextAlign.start,
                                ),
                                Text(
                                  " 采纳次数",
                                  style: TextStyle(
                                      color: Color(0xff666666),
                                      fontSize: ScreenUtil().setSp(12),
                                      fontWeight: FontWeight.w400),
                                  textAlign: TextAlign.start,
                                ),
                              ])),
                        ])),
              ],
            )),
      ],
    );
  }

  _showAddMenu() {
    final RenderBox button = _addKey.currentContext.findRenderObject();
    final RenderBox overlay = Overlay.of(context).context.findRenderObject();
    var a = button.localToGlobal(
        Offset(button.size.width - 8.0, button.size.height - 0.0),
        ancestor: overlay);
    var b = button.localToGlobal(button.size.bottomLeft(Offset(0, -0.0)),
        ancestor: overlay);
    final RelativeRect position = RelativeRect.fromRect(
      Rect.fromPoints(a, b),
      Offset.zero & overlay.size,
    );
    final Color backgroundColor = ThemeUtils.getBackgroundColor(context);
    final Color _iconColor = ThemeUtils.getIconColor(context);
    showPopupWindow(
      context: context,
      fullWidth: false,
      isShowBg: false,
      position: position,
      elevation: 0.0,
      child: GestureDetector(
        onTap: () => NavigatorUtils.goBack(context),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.end,
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.only(right: 12.0),
              child: LoadAssetImage(
                "icon_jt",
                width: 8.0,
                height: 4.0,
              ),
            ),
            SizedBox(
                width: 70.0,
                height: 40.0,
                child: InkWell(
                    onTap: () {
                      Navigator.pop(context);
                      setState(() {
                        isSelect = false;
                        isOnline = true;
                        updateUser(1);
                        // if (isOnline == true) {

                        // } else {
                        //   updateUser(0);
                        // }
                      });
                    },
                    child: Container(
                      alignment: Alignment.center,
                      child: Text(
                        "在线",
                        style: TextStyle(
                            color: isOnline
                                ? Colours.blue_app_main
                                : Colours.text),
                      ),
                      decoration: BoxDecoration(
                        color: backgroundColor,
                        borderRadius: BorderRadius.only(
                            topLeft: Radius.circular(8.0),
                            topRight: Radius.circular(8.0)),
                      ),
                    ))
                // child: FlatButton.icon(
                //     textColor: Theme.of(context).textTheme.body1.color,
                //     onPressed: () {
                //       Navigator.pop(context);
                //       // NavigatorUtils.pushResult(
                //       //     context, '${TeamRouter.teamCreatePage}', (res) {
                //       //   _onRefresh();
                //       // });
                //     },
                //     color: backgroundColor,
                //     shape: RoundedRectangleBorder(
                //       borderRadius: BorderRadius.only(
                //           topLeft: Radius.circular(8.0),
                //           topRight: Radius.circular(8.0)),
                //     ),
                //     icon: LoadAssetImage(
                //       "wode/icon_team_add",
                //       width: 16.0,
                //       height: 16.0,
                //       color: _iconColor,
                //     ),
                //     label: const Text("创建团队")),
                ),
            Container(width: 120.0, height: 0.6, color: Colours.line),
            SizedBox(
                width: 70.0,
                height: 40.0,
                child: InkWell(
                  onTap: () {
                    Navigator.pop(context);
                    setState(() {
                      isSelect = false;
                      isOnline = false;
                      updateUser(0);
                    });
                  },
                  child: Container(
                    alignment: Alignment.center,
                    child: Text(
                      "离线",
                      style: TextStyle(
                          color:
                              !isOnline ? Colours.blue_app_main : Colours.text),
                    ),
                    decoration: BoxDecoration(
                      color: backgroundColor,
                      borderRadius: BorderRadius.only(
                          bottomLeft: Radius.circular(8.0),
                          bottomRight: Radius.circular(8.0)),
                    ),
                  ),
                )

                //  FlatButton.icon(
                //     textColor: Theme.of(context).textTheme.body1.color,
                //     color: backgroundColor,
                //     onPressed: () {
                //       Navigator.pop(context);
                //       // NavigatorUtils.push(
                //       //     context, '${TeamRouter.teamSearchPage}');
                //     },
                //     shape: RoundedRectangleBorder(
                //       borderRadius: BorderRadius.only(
                //           bottomLeft: Radius.circular(8.0),
                //           bottomRight: Radius.circular(8.0)),
                //     ),
                //     // icon: LoadAssetImage(
                //     //   "wode/icon_team_add",
                //     //   width: 16.0,
                //     //   height: 16.0,
                //     //   color: _iconColor,
                //     // ),
                //     label: const Text("加入团队")),
                ),
          ],
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    double width = MediaQuery.of(context).size.width;
    double height = MediaQuery.of(context).size.height;

    return Container(
        child: ChangeNotifierProvider<BaseListProvider<LiftCasesDetailModel>>(
      create: (_) => provider,
      child: Scaffold(
          appBar: MyAppBar(
            centerTitle: '专家工单',
            isFun: true,
            fun: () {
              Navigator.popUntil(context, ModalRoute.withName('/home'));
            },
            actions: [
              ClipRRect(
                borderRadius: BorderRadius.circular(20),
                child: InkWell(
                  key: _addKey,
                  onTap: () {
                    setState(() {
                      isSelect = true;
                    });
                    _showAddMenu();
                  },
                  child: Container(
                    padding:
                        EdgeInsets.only(left: 5, right: 5, top: 2, bottom: 2),
                    color: Colours.blue_app_main,
                    child: Row(
                      children: [
                        Icon(
                          isOnline
                              ? const IconData(0xe62d, fontFamily: 'Iconfont')
                              : const IconData(0xe6e0, fontFamily: 'Iconfont'),
                          color: Colors.white,
                          size: 14,
                        ),
                        SizedBox(
                          width: 3,
                        ),
                        Text(
                          isOnline ? '在线' : '离线',
                          style: TextStyle(color: Colors.white),
                        ),
                        SizedBox(
                          width: 3,
                        ),
                        Icon(
                          isSelect ? Icons.expand_less : Icons.expand_more,
                          color: Colors.white,
                          size: 16,
                        ),
                      ],
                    ),
                  ),
                ),
              ),
              SizedBox(
                width: 10,
              ),
            ],
          ),
          body: Container(
              child: Stack(
            children: <Widget>[
              Column(
                children: <Widget>[
                  _hasData ? expertDetailWisget() : Container(child: null),
                  Container(
                    color: Color(0xffF9F9F9),
                    child: SizedBox(
                      height: 10,
                    ),
                  ),
                  Expanded(
                      flex: 1,
                      child: Consumer<BaseListProvider<LiftCasesDetailModel>>(
                          builder: (_, provider, __) {
                        return provider.list.length > 0
                            ? MyListView(
                                key: Key('liftcase_list'),
                                pageSize: 10,
                                itemCount: provider.list.length,
                                stateType: provider.stateType,
                                onRefresh: _onRefresh,
                                loadMore: _loadMore,
                                hasMore: provider.hasMore,
                                itemBuilder: (_, index) {
                                  return WorkListWidget(
                                      item: provider.list[index]);
                                },
                              )
                            : Container(
                                child: Column(
                                children: [
                                  Expanded(child: Container()),
                                  LoadAssetImage(
                                    "work/img_noworklist",
                                    width: 250,
                                    height: 150,
                                  ),
                                  Text(
                                    '您暂时还没有工单哦～',
                                    style:
                                        TextStyle(color: Colours.text_gray_c),
                                  ),
                                  Expanded(child: Container()),
                                ],
                              ));
                      }))
                ],
              ),
            ],
          ))),
    ));
  }

  Future _onRefresh() async {
    _page = 1;
    await presenter.getLiftcaseList(_page);
  }

  Future _loadMore() async {
    _page++;
    await presenter.getLiftcaseList(_page);
  }

  @override
  LiftcaseListPresenter createPresenter() {
    return LiftcaseListPresenter();
  }
}

class WorkListWidget extends StatelessWidget {
  WorkListWidget({Key key, this.item}) : super(key: key);
  dynamic item;

  @override
  Widget build(BuildContext context) {
    double width = MediaQuery.of(context).size.width;
    return Container(
      // height: 20,
      padding: EdgeInsets.only(
          bottom: ScreenUtil().setWidth(20), top: ScreenUtil().setWidth(10)),
      decoration: BoxDecoration(
        border: Border(
          bottom: BorderSide(width: 0.5, color: Colours.line),
        ),
      ),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Expanded(
            child: GestureDetector(
              behavior: HitTestBehavior.opaque,
              onTap: () {
                if (item.dataTable == 1) {
                  NavigatorUtils.push(context,
                      "${BbsRouter.recommendAsk}?id=${item.id}&type=1");
                } else if (item.dataTable == 2) {
                  NavigatorUtils.push(context,
                      "${BbsRouter.recommendAsk}?id=${item.id}&type=2");
                }
              },
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Container(
                    margin: EdgeInsets.only(
                      left: ScreenUtil().setWidth(10),
                      right: ScreenUtil().setWidth(10),
                      top: ScreenUtil().setWidth(5),
                    ),
                    decoration: BoxDecoration(
                      borderRadius:
                          BorderRadius.circular(ScreenUtil().setWidth(22)),
                    ),
                    child: ClipRRect(
                      borderRadius: BorderRadius.all(Radius.circular(50)),
                      child: LoadNetworkImage(
                        // image: AssetImage(i['img']),

                        item.avatarUrl,
                        width: ScreenUtil().setWidth(43),
                        height: ScreenUtil().setWidth(43),
                        // alignment: Alignment.centerLeft,
                      ),
                    ),
                  ),
                  Expanded(
                    child: Container(
                      padding:
                          EdgeInsets.only(right: ScreenUtil().setWidth(15)),
                      child: Column(
                        children: <Widget>[
                          Container(
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: <Widget>[
                                Row(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: <Widget>[
                                    Container(
                                      // width: width * 0.3,
                                      child: Text(
                                        item.name ?? "",
                                        style: TextStyle(
                                          color: Color(0xff333333),
                                          fontSize: ScreenUtil().setSp(17),
                                        ),
                                        textAlign: TextAlign.start,
                                        maxLines: 1,
                                        overflow: TextOverflow.ellipsis,
                                      ),
                                    ),
                                    Container(
                                      decoration: BoxDecoration(
                                        //背景
                                        color: item.dataTable == 1
                                            ? Colours.blue_app_main
                                            : Color(0xffFDAF2C),
                                        //设置四周圆角 角度
                                        borderRadius: BorderRadius.all(
                                            Radius.circular(4.0)),
                                      ),
                                      margin: EdgeInsets.only(left: 5),
                                      padding: EdgeInsets.only(
                                          left: 5, right: 5, top: 2, bottom: 2),
                                      // padding: EdgeInsets.only(left: 5),
                                      // color: item.dataTable == 1,
                                      child: Text(
                                        item.dataTable == 1 ? "问诊服务" : "出诊服务",
                                        style: TextStyle(
                                          color: Colors.white,
                                          fontSize: ScreenUtil().setSp(14),
                                        ),
                                        textAlign: TextAlign.start,
                                      ),
                                    )
                                  ],
                                ),
                                Container(
                                  child: Text(
                                    OrderConstant.getStatusName(
                                        item.statuz, item.dataTable,
                                        arrivedFlag: item.arrivedFlag),
                                    style: TextStyle(
                                      color: Color(0xffF84203),
                                      fontSize: ScreenUtil().setSp(14),
                                    ),
                                    textAlign: TextAlign.end,
                                  ),
                                )
                              ],
                            ),
                          ),
                          Container(
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: <Widget>[
                                Row(
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: <Widget>[
                                    Text(
                                      item.createTime != null
                                          ? DateUtils.instance.getFormartData(
                                              timeSamp: item.createTime,
                                              format: "yyyy-MM-dd")
                                          : "",
                                      style: TextStyle(
                                        color: Color(0xff999999),
                                        fontSize: ScreenUtil().setSp(13),
                                      ),
                                      textAlign: TextAlign.start,
                                    ),
                                    Container(
                                      padding: EdgeInsets.only(left: 5),
                                      child: Text(
                                        item.brandName ?? "",
                                        style: TextStyle(
                                          color: Colours.blue_app_main,
                                          fontSize: ScreenUtil().setSp(13),
                                        ),
                                        textAlign: TextAlign.start,
                                      ),
                                    )
                                  ],
                                ),
                              ],
                            ),
                          ),
                          item.dataTable == 2
                              ? Container(
                                  child: Row(
                                    mainAxisAlignment:
                                        MainAxisAlignment.spaceBetween,
                                    children: <Widget>[
                                      Row(
                                        crossAxisAlignment:
                                            CrossAxisAlignment.center,
                                        children: <Widget>[
                                          Text(
                                            '出诊时间：',
                                            style: TextStyle(
                                              color: Color(0xff666666),
                                              fontSize: ScreenUtil().setSp(14),
                                            ),
                                            textAlign: TextAlign.start,
                                          ),
                                          Container(
                                            padding: EdgeInsets.only(left: 5),
                                            child: Text(
                                              item.arrivedTime != null
                                                  ? DateUtils.instance
                                                      .getFormartData(
                                                          timeSamp:
                                                              item.arrivedTime,
                                                          format:
                                                              "yyyy-MM-dd HH:mm")
                                                  : "",
                                              style: TextStyle(
                                                color: Color(0xff666666),
                                                fontSize:
                                                    ScreenUtil().setSp(14),
                                              ),
                                              textAlign: TextAlign.start,
                                            ),
                                          )
                                        ],
                                      ),
                                    ],
                                  ),
                                )
                              : Container(child: null),
                          item.dataTable == 2
                              ? Container(
                                  child: Row(
                                    mainAxisAlignment:
                                        MainAxisAlignment.spaceBetween,
                                    children: <Widget>[
                                      Row(
                                        crossAxisAlignment:
                                            CrossAxisAlignment.center,
                                        children: <Widget>[
                                          Text(
                                            '出诊地点：',
                                            style: TextStyle(
                                              color: Color(0xff666666),
                                              fontSize: ScreenUtil().setSp(14),
                                            ),
                                            textAlign: TextAlign.start,
                                          ),
                                          Container(
                                            width: width * 0.6,
                                            padding: EdgeInsets.only(left: 5),
                                            child: Text(
                                              item.address ?? "",
                                              style: TextStyle(
                                                color: Color(0xff666666),
                                                fontSize:
                                                    ScreenUtil().setSp(14),
                                              ),
                                              textAlign: TextAlign.start,
                                              maxLines: 1,
                                              overflow: TextOverflow.ellipsis,
                                            ),
                                          )
                                        ],
                                      ),
                                    ],
                                  ),
                                )
                              : Container(child: null),
                          Container(
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: <Widget>[
                                Container(
                                  width: width * 0.7,
                                  child: Text(
                                    '问题描述：' +
                                        (item.expression != null
                                            ? item.expression
                                            : ""),
                                    style: TextStyle(
                                      color: Color(0xff666666),
                                      fontSize: ScreenUtil().setSp(14),
                                    ),
                                    textAlign: TextAlign.start,
                                    maxLines: 1,
                                    overflow: TextOverflow.ellipsis,
                                  ),
                                )
                              ],
                            ),
                          ),
                          // list[i]["type"] != "1"
                          //     ? Container(
                          //         margin: EdgeInsets.only(top: 6),
                          //         child: Row(
                          //           children: <Widget>[
                          //             Container(
                          //               padding:
                          //                   EdgeInsets.only(right: 5),
                          //               child: Text(
                          //                 "￥${list[i]["price"]}",
                          //                 style: TextStyle(
                          //                     color: Color(0xffFD0808),
                          //                     fontSize:
                          //                         ScreenUtil().setSp(15)),
                          //                 textAlign: TextAlign.start,
                          //               ),
                          //             ),
                          //           ],
                          //         ),
                          //       )
                          //     : Container(child: null)
                        ],
                      ),
                    ),
                  )
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}
