YSMine.dart 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/services.dart';
  4. import 'package:flutterappfuyou/code/YSHospital.dart';
  5. import 'package:flutterappfuyou/code/YSHospitalDetail.dart';
  6. import 'package:flutterappfuyou/code/YSMeans.dart';
  7. import 'package:flutterappfuyou/code/base/YSNetWorking.dart';
  8. import 'package:flutterappfuyou/code/base/YSTools.dart';
  9. import 'package:flutterappfuyou/code/version2/YSMineLive.dart';
  10. import 'package:flutterappfuyou/code/version2/YSMineQuestionnaire.dart';
  11. import 'package:flutterappfuyou/code/version3/YSPerfectChapterInfo.dart';
  12. import 'package:url_launcher/url_launcher_string.dart';
  13. import 'YSAddChapter.dart';
  14. import 'YSCollection.dart';
  15. import 'YSDiary.dart';
  16. import 'YSDueDate.dart';
  17. import 'YSFeedback.dart';
  18. import 'YSPeriod.dart';
  19. import 'YSPhoto.dart';
  20. import 'YSSetting.dart';
  21. import 'YSUserInfo.dart';
  22. import 'package:shared_preferences/shared_preferences.dart';
  23. class YSMine extends StatefulWidget {
  24. @override
  25. _YSMineState createState() => _YSMineState();
  26. }
  27. class _YSMineState extends State<YSMine> {
  28. int chapter;
  29. String avatar,name,phone;
  30. List _titleArray = [
  31. {'title':'我的收藏','icon':'collect','isMore':true},
  32. {'title':'我的相册','icon':'photo','isMore':true},
  33. {'title':'调查问卷','icon':'photo','isMore':true},
  34. {'title':'客服电话','icon':'phone'}
  35. ];
  36. bool _isLive = false;
  37. Map _userInfo = {};
  38. @override
  39. void initState() {
  40. Future.delayed(Duration(seconds: 0)).then((value){
  41. _getUserData();
  42. _getPhoneData();
  43. _getLiveData();
  44. });
  45. super.initState();
  46. }
  47. @override
  48. Widget build(BuildContext context) {
  49. chapter = User().chapter;
  50. return AnnotatedRegion<SystemUiOverlayStyle>(
  51. value: SystemUiOverlayStyle.light,
  52. child: CupertinoPageScaffold(
  53. child: RefreshIndicator(
  54. onRefresh: _getLiveData,
  55. child: SingleChildScrollView(
  56. physics: AlwaysScrollableScrollPhysics(),
  57. child: Container(
  58. color: Color(0xFFF5F3F0),
  59. height: ysHeight(context)-40,
  60. child: Stack(
  61. children: [
  62. Container(
  63. width: MediaQuery.of(context).size.width,
  64. height: 211.5,
  65. child: Image(
  66. image: AssetImage('lib/images/minebg.png'),
  67. fit: BoxFit.fill,
  68. )
  69. ),
  70. Container(
  71. margin: EdgeInsets.only(left: 26,top: MediaQuery.of(context).padding.top+15),
  72. child: Text('个人中心',style: TextStyle(fontSize: 16,color: Colors.white,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  73. ),
  74. GestureDetector(
  75. onTap: (){
  76. Navigator.of(context,rootNavigator: true).push(
  77. CupertinoPageRoute(
  78. builder: (context){
  79. return YSUserInfo();
  80. }
  81. )
  82. ).then((value) {
  83. _getUserData();
  84. });
  85. },
  86. child: Container(
  87. margin: EdgeInsets.only(left: 16,top: MediaQuery.of(context).padding.top+75),
  88. height: 60,
  89. width: 60,
  90. decoration: BoxDecoration(
  91. borderRadius: BorderRadius.all(Radius.circular(30)),
  92. color: Color(0xFFEED1C3),
  93. image: DecorationImage(image: avatar!=null?NetworkImage(avatar):AssetImage('lib/images/head.png'),fit: BoxFit.cover)
  94. ),
  95. ),
  96. ),
  97. Container(
  98. height: 20,
  99. width: MediaQuery.of(context).size.width-100,
  100. margin: EdgeInsets.only(left: 86,top: MediaQuery.of(context).padding.top+95),
  101. child: Text(name!=null?name:'',style: TextStyle(fontSize: 16,color: Colors.white,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  102. ),
  103. Container(
  104. margin: EdgeInsets.only(top: 200),
  105. child: Column(
  106. children: [
  107. Container(
  108. decoration: BoxDecoration(
  109. borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10)),
  110. color: Colors.white,
  111. ),
  112. height: 50,
  113. child: Row(
  114. children: [
  115. GestureDetector(
  116. onTap: (){
  117. Navigator.of(context,rootNavigator: true).push(
  118. CupertinoPageRoute(
  119. builder: (context){
  120. return chapter==0?YSDiary():chapter==1?YSDueDate(dueDate: _userInfo['expected_time'],):YSAddChapter(isEdit: true,);
  121. }
  122. )
  123. );
  124. },
  125. child: Container(
  126. width: MediaQuery.of(context).size.width/2-0.25,
  127. child: (chapter==null||chapter==0)?Row(
  128. mainAxisAlignment: MainAxisAlignment.center,
  129. children: [
  130. Image(height: 20,width: 20,image: AssetImage('lib/images/riji2.png'),),
  131. Text(' 备孕日记',style: TextStyle(color: Color(0xFF7F3344),fontSize: 13,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  132. ],
  133. ):chapter==1?Row(
  134. mainAxisAlignment: MainAxisAlignment.center,
  135. children: [
  136. Image(height: 20,width: 20,image: AssetImage('lib/images/rili2.png'),),
  137. Text(' 预产期',style: TextStyle(color: Color(0xFF7F3344),fontSize: 13,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  138. ],
  139. ):Row(
  140. mainAxisAlignment: MainAxisAlignment.center,
  141. children: [
  142. Image(height: 20,width: 20,image: AssetImage('lib/images/babyInfo.png'),),
  143. Text(' 宝宝资料',style: TextStyle(color: Color(0xFF7F3344),fontSize: 13,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  144. ],
  145. ),
  146. ),
  147. ),
  148. Container(
  149. height: 30,
  150. color: Color(0xFFE5E1E1),
  151. width: 0.5,
  152. ),
  153. GestureDetector(
  154. onTap: (){
  155. // Navigator.of(context,rootNavigator: true).push(
  156. // CupertinoPageRoute(
  157. // builder: (context){
  158. // return YSPerfectChapterInfo();
  159. // }
  160. // )
  161. // );
  162. // return;
  163. Navigator.of(context,rootNavigator: true).push(
  164. CupertinoPageRoute(
  165. builder: (context){
  166. return YSFeedback();
  167. }
  168. )
  169. );
  170. },
  171. child: Container(
  172. width: MediaQuery.of(context).size.width/2-0.25,
  173. child: Row(
  174. mainAxisAlignment: MainAxisAlignment.center,
  175. children: [
  176. Image(height: 20,width: 20,image: AssetImage('lib/images/feedback.png'),),
  177. Text(' 意见反馈',style: TextStyle(color: Color(0xFF7F3344),fontSize: 13,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  178. ],
  179. ),
  180. ),
  181. ),
  182. ],
  183. ),
  184. ),
  185. Container(
  186. height: ysHeight(context)-300,
  187. child: SingleChildScrollView(
  188. padding: EdgeInsets.only(bottom: 10),
  189. child: Column(
  190. children: [
  191. // Container(
  192. // height: 500,
  193. // ),
  194. chapter==0?GestureDetector(
  195. onTap: (){
  196. Navigator.of(context,rootNavigator: true).push(
  197. CupertinoPageRoute(
  198. builder: (context){
  199. return YSPeriod();
  200. }
  201. )
  202. );
  203. },
  204. child: Container(
  205. width: MediaQuery.of(context).size.width-10,
  206. height: 50,
  207. margin: EdgeInsets.only(top: 5),
  208. padding: EdgeInsets.only(left: 18),
  209. decoration: BoxDecoration(
  210. color: Colors.white,
  211. borderRadius: BorderRadius.all(Radius.circular(6))
  212. ),
  213. child: Row(
  214. children: [
  215. Image(height: 20,width: 20,image: AssetImage('lib/images/systemMsg.png'),),
  216. Text(' 经期设置',style: TextStyle(color: Color(0xFF292929),fontSize: 14,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  217. ],
  218. ),
  219. ),
  220. ):Container(),
  221. Container(
  222. width: MediaQuery.of(context).size.width-10,
  223. height: 200,
  224. margin: EdgeInsets.only(top: 5),
  225. decoration: BoxDecoration(
  226. color: Colors.white,
  227. borderRadius: BorderRadius.all(Radius.circular(6))
  228. ),
  229. child: ListView.builder(
  230. padding: EdgeInsets.all(0),
  231. itemCount: _titleArray.length,
  232. physics: NeverScrollableScrollPhysics(),
  233. itemBuilder: (context,index){
  234. Map item = _titleArray[index];
  235. String title = item['title'];
  236. return GestureDetector(
  237. behavior: HitTestBehavior.opaque,
  238. onTap: (){
  239. if(title=='客服电话'){
  240. if(phone.isEmpty)return;
  241. showDialog(
  242. context: context,
  243. builder: (context){
  244. return CupertinoAlertDialog(
  245. title: Text('提示\n'),
  246. content: Text('是否拨打$phone'),
  247. actions: [
  248. CupertinoButton(
  249. child: Container(
  250. child: Text('取消',style: TextStyle(fontSize: 16,color: Color(0xFF292929),decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  251. height: 40,
  252. alignment: Alignment.center,
  253. ),
  254. padding: EdgeInsets.all(0),
  255. onPressed: (){
  256. Navigator.pop(context);
  257. },
  258. ),
  259. CupertinoButton(
  260. child: Container(
  261. child: Text('确定',style: TextStyle(fontSize: 16,color: Color(0xFF292929),decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  262. height: 40,
  263. alignment: Alignment.center,
  264. ),
  265. padding: EdgeInsets.all(0),
  266. onPressed: (){
  267. Navigator.pop(context);
  268. launchUrlString('tel:$phone');
  269. },
  270. )
  271. ],
  272. );
  273. }
  274. );
  275. }else{
  276. Navigator.of(context,rootNavigator: true).push(
  277. CupertinoPageRoute(
  278. builder: (context){
  279. return title=='我的收藏'?YSCollection():title=='我的相册'?YSPhoto():title=='调查问卷'?YSMineQuestionnaire():YSMineQuestionnaire();
  280. }
  281. )
  282. );
  283. }
  284. },
  285. child: Container(
  286. height: 50,
  287. padding: EdgeInsets.only(left: 18,right: 18),
  288. child: Row(
  289. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  290. children: [
  291. Row(
  292. children: [
  293. Image(height: 20,width: 20,image: AssetImage('lib/images/${item['icon']}.png'),),
  294. Text(' $title',style: TextStyle(color: Color(0xFF292929),fontSize: 14,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  295. ],
  296. ),
  297. title=='客服电话'?Row(
  298. children: [
  299. Text(phone!=null?phone:'',style: TextStyle(color: Color(0xFFAEB3BD),fontSize: 14,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  300. Icon(Icons.chevron_right,size: 20,color: Color(0xFFAEB3BD),)
  301. ],
  302. ):Icon(Icons.chevron_right,size: 20,color: Color(0xFFAEB3BD),)
  303. ],
  304. ),
  305. ),
  306. );
  307. }
  308. ),
  309. ),
  310. if(_isLive)GestureDetector(
  311. onTap: (){
  312. Navigator.of(context,rootNavigator: true).push(
  313. CupertinoPageRoute(
  314. builder: (context){
  315. return YSMineLive();
  316. }
  317. )
  318. );
  319. },
  320. child: Container(
  321. width: MediaQuery.of(context).size.width-10,
  322. height: 50,
  323. margin: EdgeInsets.only(top: 5),
  324. padding: EdgeInsets.only(left: 18,right: 18),
  325. decoration: BoxDecoration(
  326. color: Colors.white,
  327. borderRadius: BorderRadius.all(Radius.circular(6))
  328. ),
  329. child: Row(
  330. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  331. children: [
  332. Row(
  333. children: [
  334. Image(height: 20,width: 20,image: AssetImage('lib/images/直播培训图标.png'),),
  335. Text(' 直播培训',style: TextStyle(color: Color(0xFF292929),fontSize: 14,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  336. ],
  337. ),
  338. Icon(Icons.chevron_right,size: 20,color: Color(0xFFAEB3BD),)
  339. ],
  340. ),
  341. ),
  342. ),
  343. GestureDetector(
  344. onTap: (){
  345. Navigator.of(context,rootNavigator: true).push(
  346. CupertinoPageRoute(
  347. builder: (context){
  348. return _userInfo['health_id']!=null?YSHospitalDetail(healthId: _userInfo['health_id']):YSHospital(healthId: _userInfo['health_id'], areaId: _userInfo['region_id'],);
  349. }
  350. )
  351. ).then((value) {
  352. _getUserData();
  353. });
  354. },
  355. child: Container(
  356. width: MediaQuery.of(context).size.width-10,
  357. height: 50,
  358. margin: EdgeInsets.only(top: 5),
  359. padding: EdgeInsets.only(left: 18,right: 18),
  360. decoration: BoxDecoration(
  361. color: Colors.white,
  362. borderRadius: BorderRadius.all(Radius.circular(6))
  363. ),
  364. child: Row(
  365. children: [
  366. Image(height: 20,width: 20,image: AssetImage('lib/images/set.png'),),
  367. Container(
  368. width: (ysWidth(context)-86)*0.4,
  369. child: Text(' 卫生院',style: TextStyle(color: Color(0xFF292929),fontSize: 14,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  370. ),
  371. Container(
  372. width: (ysWidth(context)-86)*0.6,
  373. alignment: Alignment.centerRight,
  374. child: Text(_userInfo['health_name']??'',style: TextStyle(color: Color(0xFFB8B6B4),fontSize: 12,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  375. ),
  376. Icon(Icons.chevron_right,size: 20,color: Color(0xFFAEB3BD),)
  377. ],
  378. ),
  379. ),
  380. ),
  381. GestureDetector(
  382. onTap: (){
  383. Navigator.of(context,rootNavigator: true).push(
  384. CupertinoPageRoute(
  385. builder: (context){
  386. return YSMeans(isEdit: true,);
  387. }
  388. )
  389. ).then((value) {
  390. _getUserData();
  391. });
  392. },
  393. child: Container(
  394. width: MediaQuery.of(context).size.width-10,
  395. height: 50,
  396. margin: EdgeInsets.only(top: 5),
  397. padding: EdgeInsets.only(left: 18,right: 18),
  398. decoration: BoxDecoration(
  399. color: Colors.white,
  400. borderRadius: BorderRadius.all(Radius.circular(6))
  401. ),
  402. child: Row(
  403. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  404. children: [
  405. Row(
  406. children: [
  407. Image(height: 20,width: 20,image: AssetImage('lib/images/set.png'),),
  408. Text(' 用户资料',style: TextStyle(color: Color(0xFF292929),fontSize: 14,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  409. ],
  410. ),
  411. Icon(Icons.chevron_right,size: 20,color: Color(0xFFAEB3BD),)
  412. ],
  413. ),
  414. ),
  415. ),
  416. GestureDetector(
  417. onTap: (){
  418. Navigator.of(context,rootNavigator: true).push(
  419. CupertinoPageRoute(
  420. builder: (context){
  421. return YSSetting();
  422. }
  423. )
  424. );
  425. },
  426. child: Container(
  427. width: MediaQuery.of(context).size.width-10,
  428. height: 50,
  429. margin: EdgeInsets.only(top: 5),
  430. padding: EdgeInsets.only(left: 18,right: 18),
  431. decoration: BoxDecoration(
  432. color: Colors.white,
  433. borderRadius: BorderRadius.all(Radius.circular(6))
  434. ),
  435. child: Row(
  436. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  437. children: [
  438. Row(
  439. children: [
  440. Image(height: 20,width: 20,image: AssetImage('lib/images/set.png'),),
  441. Text(' 系统设置',style: TextStyle(color: Color(0xFF292929),fontSize: 14,decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  442. ],
  443. ),
  444. Icon(Icons.chevron_right,size: 20,color: Color(0xFFAEB3BD),)
  445. ],
  446. ),
  447. ),
  448. ),
  449. ],
  450. ),
  451. ),
  452. )
  453. ],
  454. ),
  455. ),
  456. // Positioned(
  457. // bottom: 10,
  458. // child: Container(
  459. // color: Color(0xFFF5F3F0),
  460. // height: 30,
  461. // width: MediaQuery.of(context).size.width,
  462. // child: Text('西安大唐云信息科技有限公司提供技术支持',style: TextStyle(color: Color(0xFFB8B6B4),fontSize: 12,decoration: TextDecoration.none,fontWeight: FontWeight.normal),textAlign: TextAlign.center,),
  463. // ),
  464. // )
  465. ],
  466. ),
  467. ),
  468. ),
  469. ),
  470. ),
  471. );
  472. }
  473. Future<void> _getUserData() async{
  474. Map dict = await ysRequestHttpNoLoading(context, requestType.get, 'user/info', {});
  475. if(dict!=null){
  476. _userInfo = dict;
  477. SharedPreferences prefer = await SharedPreferences.getInstance();
  478. prefer.setString('avatar', '${dict['avatar']}');
  479. prefer.setString('name', dict['simple_name']??dict['username']??'');
  480. User().name = dict['simple_name']??dict['username']??'';
  481. User().idCard = dict['id_card']??'';
  482. setState(() {
  483. avatar = '${dict['avatar']}';
  484. name = dict['simple_name']??dict['username']??'';
  485. });
  486. }
  487. }
  488. Future<void> _getPhoneData() async{
  489. Map dict = await ysRequestHttpNoLoading(context, requestType.get, 'basic/info', {});
  490. if(dict!=null){
  491. setState(() {
  492. phone = '${dict['data']['contact']??''}';
  493. });
  494. }
  495. }
  496. Future<void> _getLiveData() async{
  497. Map dict = await ysRequestHttpNoLoading(context, requestType.get, 'train/live2/canLive', {});
  498. if(dict!=null){
  499. Map data = dict['data'];
  500. _isLive = data['is_can_live']??false;
  501. setState(() {});
  502. }
  503. }
  504. }