online_consultation_detail.dart 15 KB

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