online_consultation_detail.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. import 'dart:io';
  2. import 'package:cached_network_image/cached_network_image.dart';
  3. import 'package:eitc_erm_app/utils/Component.dart';
  4. import 'package:eitc_erm_app/utils/Constants.dart';
  5. import 'package:eitc_erm_app/utils/logger.dart';
  6. import 'package:eitc_erm_app/widget/circular_loading.dart';
  7. import 'package:eitc_erm_app/widget/image_error.dart';
  8. import 'package:flutter/material.dart';
  9. import 'package:http/http.dart' as http;
  10. import 'bean/disease.dart';
  11. import 'image_view.dart';
  12. import 'online_consultation.dart';
  13. void main() {
  14. WidgetsFlutterBinding.ensureInitialized();
  15. runApp(OnlineConsultationDetail(""));
  16. }
  17. String mPatientId = "";
  18. class OnlineConsultationDetail extends StatefulWidget {
  19. OnlineConsultationDetail(String patientId) {
  20. mPatientId = patientId;
  21. }
  22. @override
  23. State<StatefulWidget> createState() => OnlineConsultationDetailState();
  24. }
  25. class OnlineConsultationDetailState extends State<OnlineConsultationDetail> {
  26. Disease mDisease = new Disease();
  27. late BuildContext cxt;
  28. @override
  29. void initState() {
  30. super.initState();
  31. getChatDisease();
  32. logd(Global.user.data?.id);
  33. }
  34. Future<Disease?> getChatDisease() async {
  35. Uri url = Uri.parse(
  36. '${Global.BaseUrl}chat/getChatDisease?patientId=${Global.appointmentPersonId}');
  37. if (mPatientId.isNotEmpty) {
  38. url = Uri.parse(
  39. '${Global.BaseUrl}chat/getChatDisease?patientId=$mPatientId');
  40. }
  41. final response = await http.get(url, headers: jsonHeaders(withToken: true));
  42. if (response.statusCode == 200) {
  43. final json = decodeBodyToJson(response.bodyBytes);
  44. logd("在线问诊详情=$json");
  45. mDisease = Disease.fromJson(json);
  46. if (mDisease.code == Global.responseSuccessCode) {
  47. if (mDisease.data?.name == null) {
  48. Navigator.push(
  49. context,
  50. MaterialPageRoute(builder: (context) => OnlineConsultation()),
  51. );
  52. }
  53. setState(() {});
  54. } else {
  55. Component.toast(mDisease.msg.toString(), 0);
  56. return null;
  57. }
  58. return mDisease;
  59. } else {
  60. Component.toast("出错了,请稍后再试!", 0);
  61. return null;
  62. }
  63. }
  64. @override
  65. Widget build(BuildContext context) {
  66. this.cxt = context;
  67. return Scaffold(
  68. resizeToAvoidBottomInset: false,
  69. backgroundColor: Global.BackgroundColor,
  70. appBar: new AppBar(
  71. title: new Text('问诊详情',
  72. style: TextStyle(
  73. color: Colors.white,
  74. )),
  75. centerTitle: true,
  76. elevation: 0.5,
  77. backgroundColor: Global.StatusBarColor,
  78. leading: new IconButton(
  79. tooltip: '返回上一页',
  80. icon: const Icon(
  81. Icons.arrow_back_ios,
  82. color: Colors.white,
  83. ),
  84. onPressed: () {
  85. Navigator.of(context).pop();
  86. //_nextPage(-1);
  87. },
  88. ),
  89. ),
  90. body: Container(
  91. padding: EdgeInsets.all(10),
  92. child: Column(
  93. mainAxisSize: MainAxisSize.min,
  94. crossAxisAlignment: CrossAxisAlignment.start,
  95. children: <Widget>[
  96. Padding(
  97. padding: EdgeInsets.all(10),
  98. child: Row(
  99. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  100. children: [
  101. Text(
  102. '问诊资料',
  103. style: TextStyle(fontSize: 20, color: Colors.black),
  104. ),
  105. ]),
  106. ),
  107. ClipRRect(
  108. borderRadius: BorderRadius.circular(10.0),
  109. child: Container(
  110. color: Colors.white,
  111. padding: const EdgeInsets.all(10),
  112. child: Column(
  113. mainAxisSize: MainAxisSize.min,
  114. crossAxisAlignment: CrossAxisAlignment.start,
  115. children: <Widget>[
  116. /*Padding(
  117. padding: EdgeInsets.all(10),
  118. child: Row(
  119. mainAxisAlignment:
  120. MainAxisAlignment.spaceBetween,
  121. children: [
  122. Text(
  123. '挂号费',
  124. style: TextStyle(
  125. fontSize: 15, color: Colors.grey),
  126. ),
  127. Text(
  128. '¥12.5',
  129. style: TextStyle(fontSize: 15),
  130. ),
  131. ]),
  132. ),*/
  133. Padding(
  134. padding: EdgeInsets.all(10),
  135. child: Row(
  136. mainAxisAlignment:
  137. MainAxisAlignment.spaceBetween,
  138. children: [
  139. Text(
  140. '就诊人',
  141. style: TextStyle(
  142. fontSize: 15, color: Colors.grey),
  143. ),
  144. Text(
  145. mDisease.data == null
  146. ? ""
  147. : mDisease.data!.name.toString(),
  148. style: TextStyle(fontSize: 15),
  149. ),
  150. ]),
  151. ),
  152. Padding(
  153. padding: EdgeInsets.all(10),
  154. child: Row(
  155. mainAxisAlignment:
  156. MainAxisAlignment.spaceBetween,
  157. children: [
  158. Text(
  159. '性别',
  160. style: TextStyle(
  161. fontSize: 15, color: Colors.grey),
  162. ),
  163. Text(
  164. mDisease.data == null
  165. ? ""
  166. : mDisease.data!.sex == 0
  167. ? "男"
  168. : "女",
  169. style: TextStyle(fontSize: 15),
  170. ),
  171. ]),
  172. ),
  173. Padding(
  174. padding: EdgeInsets.all(10),
  175. child: Row(
  176. mainAxisAlignment:
  177. MainAxisAlignment.spaceBetween,
  178. children: [
  179. Text(
  180. '年龄',
  181. style: TextStyle(
  182. fontSize: 15, color: Colors.grey),
  183. ),
  184. Text(
  185. mDisease.data == null
  186. ? ""
  187. : mDisease.data!.age.toString(),
  188. style: TextStyle(fontSize: 15),
  189. ),
  190. ]),
  191. ),
  192. Padding(
  193. padding: EdgeInsets.all(10),
  194. child: Row(
  195. mainAxisAlignment:
  196. MainAxisAlignment.spaceBetween,
  197. children: [
  198. Text(
  199. '医生姓名',
  200. style: TextStyle(
  201. fontSize: 15, color: Colors.grey),
  202. ),
  203. Text(
  204. mDisease.data == null
  205. ? ""
  206. : mDisease.data!.docker.toString(),
  207. style: TextStyle(fontSize: 15),
  208. ),
  209. ]),
  210. ),
  211. ]),
  212. ),
  213. ),
  214. SizedBox(height: 8),
  215. Padding(
  216. padding: EdgeInsets.all(10),
  217. child: Row(
  218. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  219. children: [
  220. Text(
  221. '病情资料',
  222. style: TextStyle(fontSize: 20, color: Colors.black),
  223. ),
  224. ]),
  225. ),
  226. ClipRRect(
  227. borderRadius: BorderRadius.circular(10.0),
  228. child: Container(
  229. color: Colors.white,
  230. padding: const EdgeInsets.all(10),
  231. child: Column(
  232. mainAxisSize: MainAxisSize.min,
  233. crossAxisAlignment: CrossAxisAlignment.start,
  234. children: <Widget>[
  235. Padding(
  236. padding: EdgeInsets.all(10),
  237. child: Row(
  238. mainAxisAlignment:
  239. MainAxisAlignment.spaceBetween,
  240. children: [
  241. Expanded(
  242. child: TextField(
  243. maxLines: 5,
  244. enabled: false,
  245. decoration: InputDecoration(
  246. border: OutlineInputBorder(),
  247. hintText: mDisease.data == null
  248. ? ""
  249. : mDisease.data!.resource
  250. .toString(),
  251. ),
  252. ),
  253. ),
  254. ]),
  255. ),
  256. ]),
  257. ),
  258. ),
  259. Padding(
  260. padding: EdgeInsets.all(5),
  261. child: Column(
  262. crossAxisAlignment: CrossAxisAlignment.start,
  263. children: [
  264. Text(
  265. '患处、病历、检查单等照片',
  266. style: TextStyle(fontSize: 10),
  267. ),
  268. SizedBox(height: 3),
  269. GridView.builder(
  270. padding: const EdgeInsets.all(10),
  271. shrinkWrap: true,
  272. physics: NeverScrollableScrollPhysics(),
  273. gridDelegate:
  274. const SliverGridDelegateWithFixedCrossAxisCount(
  275. //注意此行
  276. crossAxisCount: 3, //每行 widget 数量
  277. crossAxisSpacing: 10, //widget 水平之间的距离
  278. mainAxisSpacing: 10, //widget 垂直之间的距离
  279. ),
  280. itemCount: mDisease.data == null
  281. ? 0
  282. : mDisease.data?.url?.split(",").length,
  283. // itemCount: 2,
  284. itemBuilder: _customWidget,
  285. )
  286. ]),
  287. ),
  288. /*ElevatedButton(
  289. child: Text("下一步",
  290. style: TextStyle(
  291. color: Colors.white, fontSize: 15)),
  292. style: ButtonStyle(
  293. backgroundColor:
  294. MaterialStateProperty.resolveWith<Color>(
  295. (states) {
  296. return Colors.blue; // Regular color
  297. }),
  298. fixedSize: MaterialStateProperty.all<Size>(
  299. Size(MediaQuery.of(context).size.width - 30,
  300. 30), // 设置宽度和高度
  301. ),
  302. ),
  303. onPressed: () {
  304. Navigator.push(
  305. context,
  306. MaterialPageRoute(builder: (context) => ChatHome()),
  307. );
  308. },
  309. ),*/
  310. ])));
  311. }
  312. Widget _customWidget(BuildContext context, int index) {
  313. String? imgUrl = mDisease.data?.url!.split(",")[index];
  314. if (imgUrl == null) {
  315. return const SizedBox();
  316. }
  317. return GestureDetector(
  318. onTap: () async {
  319. Navigator.push(
  320. cxt,
  321. MaterialPageRoute(
  322. builder: (context) => ImagePreviewPage(imgUrl),
  323. ));
  324. },
  325. child: Hero(
  326. tag: imgUrl,
  327. child: CachedNetworkImage(
  328. imageUrl: imgUrl,
  329. width: 100,
  330. fit: BoxFit.cover,
  331. progressIndicatorBuilder: (ctx, _, progress) => Circularloading(
  332. value: progress.progress,
  333. width: 50,
  334. height: 50,
  335. ),
  336. errorWidget: (ctx, _, __) => const ImageError(),
  337. )),
  338. );
  339. }
  340. }