YSDoctor.dart 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutterappfuyou/code/base/YSNetWorking.dart';
  4. import 'package:shared_preferences/shared_preferences.dart';
  5. import 'YSAskQuestion.dart';
  6. import 'base/YSBase.dart';
  7. class YSDoctor extends StatefulWidget {
  8. final bool isPolicy;
  9. const YSDoctor({Key key, this.isPolicy}) : super(key: key);
  10. @override
  11. _YSDoctorState createState() => _YSDoctorState();
  12. }
  13. class _YSDoctorState extends State<YSDoctor> {
  14. List _dataArray = [];
  15. @override
  16. void initState() {
  17. Future.delayed(Duration(seconds: 0)).then((value){
  18. widget.isPolicy==false?_getDoctorData():_getPolicyDoctorData();
  19. });
  20. super.initState();
  21. }
  22. @override
  23. Widget build(BuildContext context) {
  24. return YSBase(
  25. ystitle: '选择专家',
  26. yschild: Container(
  27. height: MediaQuery.of(context).size.height,
  28. decoration: BoxDecoration(
  29. color: Colors.white,
  30. borderRadius: BorderRadius.only(topRight: Radius.circular(20),topLeft: Radius.circular(20))
  31. ),
  32. child: ListView.builder(
  33. itemBuilder: (context,index){
  34. return GestureDetector(
  35. behavior: HitTestBehavior.opaque,
  36. onTap: (){
  37. Navigator.of(context).push(
  38. CupertinoPageRoute(
  39. builder: (context){
  40. return YSAskQuestion(info: _dataArray[index],isPolicy: widget.isPolicy,);
  41. }
  42. )
  43. );
  44. },
  45. child: Container(
  46. height: 150,
  47. child: Column(
  48. children: [
  49. Container(
  50. height: 148.5,
  51. child: Row(
  52. children: [
  53. Container(
  54. height: 120,
  55. width: 100,
  56. decoration: BoxDecoration(
  57. color: Color(0xFF41898C),
  58. borderRadius: BorderRadius.all(Radius.circular(5)),
  59. image: DecorationImage(image: NetworkImage('${_dataArray[index]['avatar']}'),fit: BoxFit.cover)
  60. ),
  61. ),
  62. Container(
  63. height: 120,
  64. margin: EdgeInsets.only(left: 10),
  65. child: Column(
  66. children: [
  67. Container(
  68. child: Text('${_dataArray[index]['name']}',style: TextStyle(fontSize: 16,color: Color(0xFF292929),fontWeight: FontWeight.w600),overflow: TextOverflow.ellipsis,),
  69. width: MediaQuery.of(context).size.width-140,
  70. margin: EdgeInsets.only(bottom: 5,top: 5),
  71. ),
  72. Container(
  73. child: Text('${_dataArray[index]['introduction']}',
  74. style: TextStyle(fontSize: 12,color: Color(0xFF808080),fontWeight: FontWeight.normal),overflow: TextOverflow.ellipsis,maxLines: 5,),
  75. width: MediaQuery.of(context).size.width-140,
  76. )
  77. ],
  78. ),
  79. )
  80. ],
  81. ),
  82. ),
  83. Container(
  84. width: MediaQuery.of(context).size.width,
  85. height: 1.5,
  86. child: Image.asset('lib/images/line.png'),
  87. )
  88. ],
  89. ),
  90. ),
  91. );
  92. },
  93. itemCount: _dataArray.length,
  94. padding: EdgeInsets.only(left: 15,right: 15,top: 5,bottom: 5),
  95. ),
  96. ),
  97. );
  98. }
  99. _getDoctorData() async{
  100. SharedPreferences prefer = await SharedPreferences.getInstance();
  101. Map dict = await ysRequestHttp(context, requestType.post, 'doctor/list', {'category_id':prefer.getInt('chapters')+1});
  102. if(dict!=null){
  103. setState(() {
  104. _dataArray = dict['data'];
  105. });
  106. }
  107. }
  108. _getPolicyDoctorData() async{
  109. SharedPreferences prefer = await SharedPreferences.getInstance();
  110. var dict = await ysRequestHttp(context, requestType.get, 'policy/doctor', {});
  111. if(dict!=null){
  112. setState(() {
  113. _dataArray = dict['data']??[];
  114. });
  115. }
  116. }
  117. }