vip.dart 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191
  1. // import 'dart:html';
  2. import 'package:flustars/flustars.dart' as flustars;
  3. import 'package:flutter/services.dart';
  4. import 'package:flutter_spinkit/flutter_spinkit.dart';
  5. import 'package:liftmanager/internal/bbs/model/expert_model.dart'
  6. as ExportModel;
  7. import 'package:flutter/material.dart';
  8. import 'package:flutter_screenutil/flutter_screenutil.dart';
  9. import 'package:flutter_swiper/flutter_swiper.dart';
  10. import 'package:liftmanager/common/common.dart';
  11. import 'package:liftmanager/common/user_db.dart';
  12. import 'package:liftmanager/internal/account/account_router.dart';
  13. import 'package:liftmanager/internal/account/provider/user_provider.dart';
  14. import 'package:liftmanager/internal/bbs/provide/websocket.dart';
  15. import 'package:liftmanager/internal/wode/model/privilege_model.dart';
  16. import 'package:liftmanager/internal/wode/model/vipfee_model.dart';
  17. import 'package:liftmanager/internal/wode/wode_router.dart';
  18. import 'package:liftmanager/net/api_service.dart';
  19. import 'package:liftmanager/res/colors.dart';
  20. import 'package:liftmanager/routers/fluro_navigator.dart';
  21. import 'package:liftmanager/utils/fast_notification.dart';
  22. import 'package:liftmanager/utils/theme_utils.dart';
  23. import 'package:liftmanager/utils/time_format.dart';
  24. import 'package:liftmanager/utils/toast.dart';
  25. import 'package:liftmanager/widgets/app_bar.dart';
  26. import 'package:liftmanager/widgets/load_image.dart';
  27. import 'package:liftmanager/widgets/round_widget.dart';
  28. import 'package:oktoast/oktoast.dart';
  29. import 'package:provider/provider.dart';
  30. class Vip extends StatefulWidget {
  31. Vip(this.id);
  32. final String id;
  33. @override
  34. State<StatefulWidget> createState() {
  35. return VipState();
  36. }
  37. }
  38. class VipState extends State<Vip> with AutomaticKeepAliveClientMixin {
  39. UserProvider provider = UserProvider();
  40. int currentIndex = -1;
  41. /// 月卡季卡年卡
  42. int selectVipType = 0;
  43. ///选中的套餐
  44. Records selectedRecord = Records();
  45. List<PrivilegeModel> vipList = [];
  46. ///推荐套餐列表
  47. List<Records> moneyList = [];
  48. ExportModel.Records _userInfo = ExportModel.Records();
  49. TextEditingController _vipnumController = TextEditingController();
  50. void getUserInfo() {
  51. NewApiService().getExpertDetail(flustars.SpUtil.getString(Constant.userId),
  52. onSuccess: (res) {
  53. _userInfo = res;
  54. setState(() {});
  55. print("res");
  56. }, onError: (code, msg) {
  57. toasts(msg);
  58. });
  59. ApiService(context: context).userInfo(
  60. onSuccess: (data) {
  61. provider.setUser(data);
  62. // setUser(data);
  63. },
  64. onError: (code, msg) {},
  65. );
  66. }
  67. void getMemberAllMenu() {
  68. NewApiService().getVipFeeList(widget.id, onSuccess: (res) {
  69. moneyList = res.records;
  70. selectedRecord = moneyList[0];
  71. setState(() {});
  72. }, onError: (code, msg) {
  73. toasts(msg);
  74. });
  75. NewApiService().getMemberAllMenu(onSuccess: (res) {
  76. vipList = res;
  77. currentIndex = res.length > 0 ? 0 : -1;
  78. setState(() {});
  79. }, onError: (code, msg) {
  80. vipList = [];
  81. toasts(msg);
  82. });
  83. }
  84. bool vip = false;
  85. Future isVipOrExpert() async {
  86. await NewApiService().getIsVipOrExpert(onSuccess: (res) {
  87. if (res != null) {
  88. vip = true;
  89. }
  90. }, onError: (code, msg) {
  91. toasts(msg);
  92. });
  93. }
  94. Future becomeLowerMember() async {
  95. await NewApiService().getUserRebates(widget.id, onSuccess: (res) {
  96. toastsF(context, "你已成功接受${res != null ? res.toString() : ''}的邀请,立即成为会员!",
  97. timeInSecForIos: 3);
  98. // toasts("您已成为${res!=null?res.toString():''}的下级用户");
  99. }, onError: (code, msg) {
  100. toasts(msg);
  101. });
  102. }
  103. void updateVip(userLevel) {
  104. NewApiService().updateVip(userLevel, onSuccess: (res) {
  105. toasts("充值成功,请重新登录");
  106. setState(() {});
  107. User().clearUser();
  108. Provider.of<WebSocketProvide>(context, listen: false).closeWebSocket();
  109. // removeSocket();
  110. // _push.unbindAccount(account: flustars.SpUtil.getString(Constant.phone));
  111. NavigatorUtils.push(context, AccountRouter.loginPage, clearStack: true);
  112. }, onError: (code, msg) {
  113. toasts(msg);
  114. });
  115. }
  116. @override
  117. void initState() {
  118. getMemberAllMenu();
  119. getUserInfo();
  120. super.initState();
  121. print(widget.id);
  122. print(66666);
  123. FastNotification.addListener("initUserMoney", (initThisUserMoney) {
  124. if (mounted) {
  125. getUserInfo();
  126. setState(() {});
  127. }
  128. });
  129. if (widget.id != null && widget.id != "") {
  130. print("触发绑定");
  131. becomeLowerMember();
  132. }
  133. }
  134. @override
  135. void dispose() {
  136. // provider.dispose();
  137. super.dispose();
  138. }
  139. @override
  140. Widget build(BuildContext context) {
  141. double width = MediaQuery.of(context).size.width;
  142. double height = MediaQuery.of(context).size.height;
  143. return ChangeNotifierProvider<UserProvider>(
  144. create: (_) => provider,
  145. child: Container(
  146. child: Scaffold(
  147. // resizeToAvoidBottomPadding: false,
  148. appBar: MyAppBar(
  149. centerTitle: "会员中心",
  150. titleColor: Colors.white,
  151. bgColors: [Color(0xff3B3633), Color(0xff5B5350)],
  152. ),
  153. body: Consumer<UserProvider>(
  154. builder: (_, provider, __) {
  155. return Container(
  156. color: Color(0xfff5f5f5),
  157. child: ListView(
  158. padding: EdgeInsets.all(0.0),
  159. children: <Widget>[
  160. _headeWidget(),
  161. _vipTip(),
  162. _setMeal(),
  163. _frindes(),
  164. _buybtn(),
  165. // Container(
  166. // padding:
  167. // EdgeInsets.only(left: 20.0, right: 20.0, top: 10.0),
  168. // // height: ScreenUtil().setWidth(345),
  169. // child: Column(
  170. // children: <Widget>[
  171. // vipList.length > 0
  172. // ? SwipeWidget(
  173. // banners: vipList,
  174. // onClickItem: (index, item) {
  175. // // showAlert(
  176. // // context,
  177. // // "提示",
  178. // // "您确定需要充值升级为Vip吗?",
  179. // // "确认",
  180. // // () {
  181. // // // updateVip(item.id);
  182. // // // NavigatorUtils.goBack(context);
  183. // // },
  184. // // txt2: "取消",
  185. // // onPre2: () {
  186. // // NavigatorUtils.goBack(context);
  187. // // },
  188. // // );
  189. // // print(333);
  190. // // print(provider);
  191. // NavigatorUtils.push(context,
  192. // "${WodeRouter.vipService}?id=${item.id.toString()}");
  193. // },
  194. // onChangItem: (index, item) {
  195. // currentIndex = index;
  196. // setState(() {});
  197. // },
  198. // )
  199. // : Container()
  200. // ],
  201. // ),
  202. // ),
  203. // LabelTitle(
  204. // title: "会员特权",
  205. // isMore: true,
  206. // userTap: () {
  207. // if (currentIndex != -1) {
  208. // NavigatorUtils.push(context,
  209. // "${WodeRouter.privilege}?id=${vipList[currentIndex].id.toString()}");
  210. // }
  211. // },
  212. // ),
  213. // Container(
  214. // color: ThemeUtils.getTabsBg(context),
  215. // height: ScreenUtil().setWidth(150),
  216. // padding: EdgeInsets.only(
  217. // top: ScreenUtil().setWidth(5),
  218. // left: ScreenUtil().setWidth(10),
  219. // right: ScreenUtil().setWidth(10),
  220. // ),
  221. // child: Privilege(
  222. // initList: currentIndex != -1
  223. // ? vipList[currentIndex].menuList
  224. // : []),
  225. // ),
  226. // LabelTitle(
  227. // title: "邀请好友",
  228. // isMore: false,
  229. // userTap: () {},
  230. // ),
  231. // GestureDetector(
  232. // onTap: () async {
  233. // await isVipOrExpert();
  234. // if (vip) {
  235. // NavigatorUtils.push(context, "${WodeRouter.qrshare}");
  236. // vip = false;
  237. // } else {
  238. // print(999);
  239. // toasts("请开通会员或成为专家");
  240. // }
  241. // },
  242. // child: Container(
  243. // color: ThemeUtils.getTabsBg(context),
  244. // height: ScreenUtil().setWidth(110),
  245. // padding: EdgeInsets.only(
  246. // top: ScreenUtil().setWidth(10),
  247. // left: ScreenUtil().setWidth(10),
  248. // right: ScreenUtil().setWidth(10),
  249. // ),
  250. // child: LoadAssetImage(
  251. // "wode/invite_friends",
  252. // width: ScreenUtil().setWidth(724),
  253. // height: ScreenUtil().setWidth(183),
  254. // ),
  255. // ),
  256. // )
  257. ],
  258. ),
  259. );
  260. },
  261. ),
  262. ),
  263. ),
  264. );
  265. }
  266. _headeWidget() {
  267. return Stack(
  268. children: [
  269. Positioned(
  270. // left: 10,
  271. // right: 10,
  272. // bottom: 0,
  273. child: Container(
  274. // margin: EdgeInsets.only(left: 10,right: 10),
  275. width: double.infinity,
  276. height: 160,
  277. decoration: BoxDecoration(
  278. gradient: const LinearGradient(
  279. colors: [Color(0xff3B3633), Color(0xff5B5350)],
  280. )),
  281. )),
  282. Positioned(
  283. bottom: 0,
  284. left: 10,
  285. right: 10,
  286. child: LoadAssetImage(
  287. "img_vipcenter_bg",
  288. width: 350,
  289. height: 152,
  290. fit: BoxFit.fill,
  291. ),
  292. ),
  293. Positioned(
  294. // top: 50,
  295. bottom: 10,
  296. left: 10,
  297. right: 20,
  298. // left: 0,
  299. child: Row(
  300. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  301. // crossAxisAlignment: CrossAxisAlignment.center,
  302. children: <Widget>[
  303. GestureDetector(
  304. onTap: () {
  305. NavigatorUtils.push(context, WodeRouter.personalPage);
  306. },
  307. child: Container(
  308. padding: EdgeInsets.only(
  309. left: ScreenUtil().setWidth(10),
  310. ),
  311. child: Row(
  312. crossAxisAlignment: CrossAxisAlignment.start,
  313. children: <Widget>[
  314. Container(
  315. padding: EdgeInsets.only(
  316. right: ScreenUtil().setWidth(10),
  317. ),
  318. child: ClipRRect(
  319. borderRadius: BorderRadius.circular(
  320. ScreenUtil().setWidth(35)),
  321. child: Container(
  322. child: LoadNetworkImage(
  323. provider.user?.avatarUrl,
  324. // fit: BoxFit.fitWidth,
  325. width: ScreenUtil().setWidth(40),
  326. height: ScreenUtil().setWidth(40),
  327. ),
  328. ))),
  329. Column(
  330. mainAxisAlignment: MainAxisAlignment.start,
  331. crossAxisAlignment: CrossAxisAlignment.start,
  332. children: <Widget>[
  333. Text(
  334. provider.user?.showWhichName == 1
  335. ? (provider.user?.nickName ?? "")
  336. : (provider.user?.userName ?? ""),
  337. // _userInfo.name ?? '',
  338. // '小小维修工',
  339. textAlign: TextAlign.left,
  340. style: TextStyle(
  341. fontSize: ScreenUtil().setSp(16),
  342. color: Color(0xff2F2B29),
  343. ),
  344. ),
  345. Text(
  346. _userInfo.vipFlag == 2 ? '尊敬的会员,您好!' : '',
  347. textAlign: TextAlign.left,
  348. style: TextStyle(
  349. fontSize: ScreenUtil().setSp(13),
  350. color: Color(0xffAB7223),
  351. ),
  352. ),
  353. SizedBox(height: 3),
  354. _userInfo.vipFlag == 2
  355. ? InkWell(
  356. onTap: () {
  357. if (_userInfo.vipId != null) {
  358. showToast('您已经填写了会员id哦');
  359. return;
  360. }
  361. showDialog(
  362. barrierDismissible: false,
  363. context: context,
  364. builder: (context) => new AlertDialog(
  365. title: Text('输入幸运数字'),
  366. content: Container(
  367. child: TextField(
  368. inputFormatters: <
  369. TextInputFormatter>[
  370. LengthLimitingTextInputFormatter(
  371. 8),
  372. FilteringTextInputFormatter
  373. .digitsOnly //限制长度
  374. ],
  375. maxLength: 8,
  376. controller: _vipnumController,
  377. keyboardType: TextInputType.phone,
  378. ),
  379. ),
  380. actions: <Widget>[
  381. FlatButton(
  382. onPressed: () {
  383. NavigatorUtils.goBack(context);
  384. },
  385. child: new Text("取消"),
  386. ),
  387. FlatButton(
  388. onPressed: () {
  389. if (_vipnumController.text ==
  390. '') {
  391. showToast('请输入幸运数字');
  392. return;
  393. }
  394. NewApiService().upLoadVipluckNum(
  395. vipId: _vipnumController.text,
  396. onSuccess: (res) {
  397. showToast(res);
  398. getUserInfo();
  399. print("res");
  400. NavigatorUtils.goBack(
  401. context);
  402. },
  403. onError: (code, msg) {
  404. toasts(msg);
  405. });
  406. },
  407. child: new Text('确认'),
  408. ),
  409. ],
  410. ),
  411. );
  412. },
  413. child: Container(
  414. padding: EdgeInsets.all(2),
  415. decoration: BoxDecoration(
  416. borderRadius: BorderRadius.all(
  417. Radius.circular(8.0)),
  418. gradient: LinearGradient(
  419. colors: [
  420. Color(0xffF3D99E),
  421. Color(0xffF4EDCE)
  422. ],
  423. )),
  424. child: Text(_userInfo.vipId == null
  425. ? ' 抢占自己的幸运id '
  426. : ' ID:${_userInfo.vipId} '),
  427. ),
  428. )
  429. : Container()
  430. ],
  431. ),
  432. ],
  433. ),
  434. ),
  435. ),
  436. Expanded(child: Container()),
  437. InkWell(
  438. onTap: () {
  439. NavigatorUtils.push(context,
  440. "${WodeRouter.vipService}?id=&selectid=${selectedRecord.id.toString()}");
  441. // NavigatorUtils.push(context, WodeRouter.walletPage);
  442. },
  443. child: Column(
  444. crossAxisAlignment: CrossAxisAlignment.end,
  445. // mainAxisAlignment: MainAxisAlignment.end,
  446. children: [
  447. Container(
  448. // alignment: Alignment.centerRight,
  449. child: Text(
  450. _userInfo.vipFlag == 2
  451. ? "您的会员到期日:${DateUtils.instance.getFormartData(timeSamp: _userInfo.vipEndTime, format: 'yyyy/MM/dd')}"
  452. : "",
  453. style: TextStyle(
  454. color: Color(0xff252426),
  455. fontSize: ScreenUtil().setSp(11)),
  456. ),
  457. ),
  458. SizedBox(
  459. height: 20,
  460. ),
  461. Container(
  462. decoration: BoxDecoration(
  463. color: Color(0xff272527),
  464. borderRadius: BorderRadius.all(Radius.circular(15)),
  465. ),
  466. padding: EdgeInsets.all(5),
  467. child: Text(
  468. ' 立即续费 ',
  469. style: TextStyle(
  470. color: Color(0xffFFDBB7),
  471. fontSize: ScreenUtil().setSp(12)),
  472. ),
  473. )
  474. ],
  475. ),
  476. )
  477. ],
  478. ),
  479. ),
  480. ],
  481. );
  482. // Container(
  483. // decoration: BoxDecoration(
  484. // gradient: LinearGradient(
  485. // colors: [Color(0xff3B3633), Color(0xff5B5350)],
  486. // ),
  487. // ),
  488. // // width: double.infinity,
  489. // // color: Colors.redAccent,
  490. // child:
  491. // );
  492. }
  493. _vipTip() {
  494. const OrderTypeList = [
  495. {
  496. 'id': 2,
  497. "title": "题库问答",
  498. "img": "wode/icon_viptag_0",
  499. },
  500. {
  501. 'id': 3,
  502. "title": "海量学堂",
  503. "img": "wode/icon_viptag_1",
  504. },
  505. {
  506. 'id': 4,
  507. "title": "商品专区",
  508. "img": "wode/icon_viptag_2",
  509. },
  510. {
  511. 'id': 5,
  512. "title": "招聘特权",
  513. "img": "wode/icon_viptag_3",
  514. },
  515. {
  516. 'id': 10,
  517. "title": "资料库查看",
  518. "img": "wode/icon_viptag_4",
  519. },
  520. {
  521. 'id': 9,
  522. "title": "附近的人",
  523. "img": "wode/icon_viptag_5",
  524. },
  525. {
  526. 'id': 209,
  527. "title": "快速问诊",
  528. "img": "wode/icon_viptag_6",
  529. },
  530. {
  531. "id": 210,
  532. "title": "专家出诊",
  533. "img": "wode/icon_viptag_7",
  534. },
  535. ];
  536. List<Container> _buildGuidTitleList(int count) {
  537. return List<Container>.generate(
  538. count,
  539. (int index) => Container(
  540. // padding: EdgeInsets.only(top: 15),
  541. child: _iconItem(
  542. title: OrderTypeList[index]["title"],
  543. icon: OrderTypeList[index]['img'],
  544. ontap: () {
  545. NavigatorUtils.push(context,
  546. "${WodeRouter.privilege}?id=${vipList[currentIndex].id.toString()}&index=${OrderTypeList[index]["id"].toString()}");
  547. // int nums = index + 1;
  548. // String index = nums.toString();
  549. // NavigatorUtils.push(
  550. // context, "${WodeRouter.orderPage}?checkType=$index");
  551. },
  552. ),
  553. ));
  554. }
  555. return TitleCard(
  556. title: '会员尊享8大权益',
  557. height: 230,
  558. body: Container(
  559. child: GridView.count(
  560. physics: const NeverScrollableScrollPhysics(),
  561. padding: EdgeInsets.all(10), // 内边距
  562. scrollDirection: Axis.vertical, // 滚动方向
  563. crossAxisSpacing: 10, // 列间距
  564. crossAxisCount:
  565. 4, // 每行的个数(Axis.vertic == 横向三个, Axis.horizontal == 竖方向三个)
  566. mainAxisSpacing: 10,
  567. //次轴元素间距
  568. children: _buildGuidTitleList(8), //添加
  569. ),
  570. ));
  571. // Stack(
  572. // children: [
  573. // // Positioned(
  574. // // top: -20,
  575. // // child: Container(
  576. // // height: 50,
  577. // // color: Colors.redAccent,
  578. // // )),
  579. // Container(
  580. // height: 200,
  581. // color: Colors.blue,
  582. // )
  583. // ],
  584. // );
  585. }
  586. _iconItem({String title, double size = 45, String icon, Function ontap}) {
  587. return InkWell(
  588. onTap: ontap,
  589. child: Container(
  590. // padding: EdgeInsets.only(top: 15),
  591. child: Column(
  592. // crossAxisAlignment: CrossAxisAlignment.center,
  593. children: [
  594. Container(
  595. // height: 70,
  596. // color: Colors.red,
  597. child: LoadAssetImage(
  598. // image: AssetImage(i['img']),
  599. icon,
  600. width: ScreenUtil().setWidth(size),
  601. height: ScreenUtil().setWidth(size),
  602. // alignment: Alignment.centerLeft,
  603. ),
  604. ),
  605. // SizedBox(height: ScreenUtil().setWidth(10)),
  606. Container(
  607. child: Text(
  608. title,
  609. style: TextStyle(
  610. color: Colours.text, fontSize: ScreenUtil().setSp(11)),
  611. textAlign: TextAlign.start,
  612. ),
  613. ),
  614. ],
  615. ),
  616. ),
  617. );
  618. }
  619. _setMeal() {
  620. const setMealList = [
  621. {"title": "月卡", "money": "40", "detalMoney": "50"},
  622. {"title": "季卡", "money": "100", "detalMoney": "150"},
  623. {"title": "半年卡", "money": "200", "detalMoney": "300"},
  624. {"title": "年卡", "money": "400", "detalMoney": "600"},
  625. {"title": "年卡", "money": "400", "detalMoney": "600"},
  626. {"title": "年卡", "money": "400", "detalMoney": "600"},
  627. {"title": "年卡", "money": "400", "detalMoney": "600"},
  628. {"title": "年卡", "money": "400", "detalMoney": "600"},
  629. {"title": "年卡", "money": "400", "detalMoney": "600"},
  630. {"title": "年卡", "money": "400", "detalMoney": "600"},
  631. ];
  632. _cell({title, money, detalMoney, bool isSelect, Function ontap, index}) {
  633. return InkWell(
  634. onTap: ontap,
  635. child: Stack(
  636. children: [
  637. Container(
  638. alignment: Alignment.center,
  639. height: 200,
  640. width: 200,
  641. decoration: BoxDecoration(
  642. color: isSelect ? Color(0x21FA4F21) : Colors.white,
  643. //设置四周圆角 角度
  644. borderRadius: BorderRadius.all(Radius.circular(8.0)),
  645. //设置四周边框
  646. border: Border.all(
  647. width: 1,
  648. color: isSelect ? Colors.red : Colours.text_gray),
  649. ),
  650. child: Column(
  651. // crossAxisAlignment: CrossAxisAlignment.center,
  652. mainAxisAlignment: MainAxisAlignment.center,
  653. children: [
  654. Text(
  655. '${moneyList[index].name}',
  656. // '$title',
  657. style: TextStyle(color: Colours.text, fontSize: 15),
  658. ),
  659. Text(
  660. '${moneyList[index].price}',
  661. // '¥$money',
  662. style: TextStyle(
  663. color: Color(0xffFA4F21),
  664. fontSize: 18,
  665. fontWeight: FontWeight.bold),
  666. ),
  667. // Text(
  668. // '原价${moneyList[index].price}/月',
  669. // style: TextStyle(
  670. // color: Colours.text_gray,
  671. // fontSize: 11,
  672. // decoration: TextDecoration.lineThrough,
  673. // decorationColor: Colours.text_gray,
  674. // ),
  675. // ),
  676. ],
  677. )),
  678. (index == 0 || index == moneyList.length - 1)
  679. ? RoundPathWidget(
  680. pathShape: PathShapeEnum.PartRoundRect,
  681. leftTopRadius: 8,
  682. rightBottomRadius: 8,
  683. child: Container(
  684. height: 20,
  685. width: 35,
  686. alignment: Alignment.center,
  687. decoration: BoxDecoration(
  688. gradient: LinearGradient(
  689. colors: index == 0
  690. ? [Color(0xff840AF5), Color(0xff9D32FE)]
  691. : [Color(0xffFF934C), Color(0xffFC686F)],
  692. )),
  693. // color: Color(0xff840AF5),
  694. child: Text(
  695. index == 0 ? '热销' : '超值',
  696. style: TextStyle(color: Colors.white, fontSize: 11),
  697. ),
  698. ))
  699. : Container(),
  700. ],
  701. ));
  702. }
  703. List<Container> _buildGuidTitleList() {
  704. return List<Container>.generate(
  705. moneyList.length,
  706. // setMealList.length,
  707. (int index) => Container(
  708. // padding: EdgeInsets.only(top: 15),
  709. child: _cell(
  710. title: setMealList[index]["title"],
  711. money: setMealList[index]["money"],
  712. detalMoney: setMealList[index]["detalMoney"],
  713. isSelect: moneyList[index] == selectedRecord,
  714. index: index,
  715. ontap: () {
  716. setState(() {
  717. selectedRecord = moneyList[index];
  718. });
  719. // int nums = index + 1;
  720. // String index = nums.toString();
  721. // NavigatorUtils.push(
  722. // context, "${WodeRouter.orderPage}?checkType=$index");
  723. },
  724. ),
  725. ));
  726. }
  727. return TitleCard(
  728. height: 260,
  729. title: '推荐套餐',
  730. body: Container(
  731. margin: EdgeInsets.only(top: 10),
  732. child: moneyList.length > 0
  733. ? GridView(
  734. // physics: const NeverScrollableScrollPhysics(),
  735. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  736. // 一行几列
  737. crossAxisCount: 2,
  738. // 设置每子元素的大小(宽高比)
  739. childAspectRatio: 2.0,
  740. // 元素的左右的 距离
  741. crossAxisSpacing: 20,
  742. // 子元素上下的 距离
  743. mainAxisSpacing: 10,
  744. ),
  745. //次轴元素间距
  746. children: _buildGuidTitleList(), //添加
  747. )
  748. : loadCircle(),
  749. ));
  750. }
  751. _frindes() {
  752. return GestureDetector(
  753. onTap: () {
  754. NavigatorUtils.push(context, "${WodeRouter.qrshare}");
  755. },
  756. child: Container(
  757. height: 185,
  758. margin: EdgeInsets.only(left: 10, right: 10, bottom: 5),
  759. decoration: new BoxDecoration(
  760. color: Colors.white,
  761. //设置四周圆角 角度
  762. borderRadius: BorderRadius.all(Radius.circular(6.0)),
  763. ),
  764. child: Stack(
  765. children: [
  766. Positioned(
  767. top: 0,
  768. right: -10,
  769. left: -10,
  770. bottom: -10,
  771. child: ClipRRect(
  772. borderRadius: BorderRadius.circular(6),
  773. child: LoadAssetImage("img_Invite_friends_bg",
  774. // width: double.infinity,
  775. // height: ScreenUtil().setHeight(260),
  776. fit: BoxFit.fill),
  777. ),
  778. ),
  779. Positioned(
  780. top: 30,
  781. left: 25,
  782. child: Column(
  783. // mainAxisAlignment: MainAxisAlignment.start,
  784. crossAxisAlignment: CrossAxisAlignment.start,
  785. children: [
  786. RichText(
  787. text: TextSpan(
  788. text: '邀请好友',
  789. style: TextStyle(
  790. fontSize: 24,
  791. color: Colors.black,
  792. fontWeight: FontWeight.bold,
  793. ),
  794. children: [
  795. TextSpan(
  796. text: '返佣金',
  797. style: TextStyle(
  798. fontSize: 24,
  799. color: Colors.red,
  800. fontWeight: FontWeight.bold),
  801. ),
  802. ],
  803. ),
  804. ),
  805. SizedBox(
  806. height: 10,
  807. ),
  808. Text('邀请好友开会员赚佣金')
  809. ],
  810. )),
  811. Positioned(
  812. left: 15,
  813. bottom: 15,
  814. right: 15,
  815. child: Row(
  816. // mainAxisAlignment:MainAxisAlignment.spaceBetween ,
  817. // crossAxisAlignment: CrossAxisAlignment.baseline,
  818. children: [
  819. Column(
  820. crossAxisAlignment: CrossAxisAlignment.start,
  821. children: [
  822. Text(
  823. '邀请好友',
  824. style: TextStyle(color: Color(0xffEEA025)),
  825. ),
  826. Text('多邀多得,超多佣金等你来拿',
  827. style: TextStyle(color: Colours.text_gray))
  828. ],
  829. ),
  830. Expanded(child: Container()),
  831. Container(
  832. padding: EdgeInsets.all(3),
  833. decoration: BoxDecoration(
  834. //背景
  835. color: Colors.white,
  836. //设置四周圆角 角度
  837. borderRadius: BorderRadius.all(Radius.circular(15.0)),
  838. //设置四周边框
  839. border: Border.all(
  840. width: 1,
  841. color: Colors.red,
  842. ),
  843. ),
  844. child: InkWell(
  845. onTap: () {
  846. NavigatorUtils.push(
  847. context, "${WodeRouter.qrshare}");
  848. },
  849. child: Text(' 立即邀请 ',
  850. style:
  851. TextStyle(color: Colors.red, fontSize: 13)),
  852. ),
  853. )
  854. ],
  855. ))
  856. ],
  857. ),
  858. ));
  859. }
  860. _buybtn() {
  861. return InkWell(
  862. onTap: () {
  863. NavigatorUtils.push(context,
  864. "${WodeRouter.vipService}?id=&selectid=${selectedRecord.id.toString()}");
  865. },
  866. child: Container(
  867. height: 72,
  868. margin: EdgeInsets.only(left: 0, right: 0, bottom: 5),
  869. child: Stack(
  870. children: [
  871. Positioned(
  872. top: 0,
  873. right: 0,
  874. left: 0,
  875. bottom: 0,
  876. child: LoadAssetImage(
  877. "img_buyvip_btnbg",
  878. // width: double.infinity,
  879. // height: ScreenUtil().setHeight(260),
  880. fit: BoxFit.cover,
  881. ),
  882. ),
  883. Positioned(
  884. left: 40,
  885. child: Container(
  886. alignment: Alignment.centerLeft,
  887. height: 60,
  888. child: RichText(
  889. text: TextSpan(
  890. text: '¥',
  891. style: TextStyle(
  892. fontSize: 15,
  893. color: Color(0xff3E3835),
  894. fontWeight: FontWeight.bold,
  895. ),
  896. children: [
  897. TextSpan(
  898. text: '${selectedRecord.price}',
  899. style: TextStyle(
  900. fontSize: 30,
  901. color: Color(0xff3E3835),
  902. fontWeight: FontWeight.bold),
  903. ),
  904. TextSpan(
  905. text: '/${selectedRecord.period}个月',
  906. style: TextStyle(
  907. fontSize: 15,
  908. color: Color(0xff3E3835),
  909. fontWeight: FontWeight.bold),
  910. ),
  911. // TextSpan(
  912. // text: '¥${selectedRecord.price}',
  913. // style: TextStyle(
  914. // fontSize: 15,
  915. // color: Color(0xff3E3835),
  916. // fontWeight: FontWeight.bold,
  917. // decoration: TextDecoration.lineThrough,
  918. // decorationColor: Color(0xff3E3835),
  919. // ),
  920. // ),
  921. ],
  922. ),
  923. ),
  924. )),
  925. Positioned(
  926. right: 40,
  927. child: Container(
  928. alignment: Alignment.centerLeft,
  929. height: 65,
  930. child: Text(
  931. '立即续费',
  932. style: TextStyle(color: Colors.white, fontSize: 18),
  933. )))
  934. ],
  935. ),
  936. ),
  937. );
  938. }
  939. Widget loadCircle() {
  940. return Container(
  941. padding: EdgeInsets.only(top: 10, bottom: 10),
  942. color: ThemeUtils.getTabsBg(context),
  943. child: Center(
  944. child: SpinKitFadingCircle(
  945. color: Colors.blueAccent,
  946. size: 30.0,
  947. ),
  948. ),
  949. );
  950. }
  951. @override
  952. bool get wantKeepAlive => true;
  953. }
  954. class TitleCard extends StatelessWidget {
  955. String title;
  956. String rightText;
  957. Function onTapRight;
  958. double height;
  959. Widget body;
  960. TitleCard(
  961. {this.title,
  962. this.rightText,
  963. this.onTapRight,
  964. this.body,
  965. this.height = 120});
  966. @override
  967. Widget build(BuildContext context) {
  968. return Container(
  969. // color: Colors.red,
  970. margin: EdgeInsets.only(left: 10, right: 10, bottom: 10),
  971. decoration: new BoxDecoration(
  972. color: Colors.white,
  973. //设置四周圆角 角度
  974. borderRadius: BorderRadius.all(Radius.circular(6.0)),
  975. ),
  976. padding: EdgeInsets.only(left: 10, right: 10, top: 15, bottom: 15),
  977. height: height,
  978. // width: ScreenUtil().setWidth(355),
  979. child: Column(
  980. children: [
  981. Row(
  982. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  983. children: [
  984. Text(
  985. title,
  986. style: TextStyle(
  987. color: Color(0xff222222),
  988. fontSize: 15,
  989. fontWeight: FontWeight.bold),
  990. ),
  991. rightText != null
  992. ? InkWell(
  993. onTap: onTapRight,
  994. child: Row(
  995. children: [
  996. Text(rightText,
  997. style: TextStyle(
  998. color: Colours.dark_text_gray, fontSize: 13)),
  999. Icon(
  1000. Icons.arrow_forward_ios,
  1001. color: Colours.dark_text_gray,
  1002. size: 15,
  1003. )
  1004. ],
  1005. ),
  1006. )
  1007. : Container()
  1008. ],
  1009. ),
  1010. // SizedBox(
  1011. // height: 15,
  1012. // ),
  1013. Expanded(child: body)
  1014. // body
  1015. ],
  1016. ),
  1017. );
  1018. }
  1019. }
  1020. class SwipeWidget extends StatelessWidget {
  1021. const SwipeWidget({Key key, this.banners, this.onClickItem, this.onChangItem})
  1022. : super(key: key);
  1023. final List<dynamic> banners;
  1024. final Function onClickItem;
  1025. final Function onChangItem;
  1026. @override
  1027. Widget build(BuildContext context) {
  1028. double width = MediaQuery.of(context).size.width;
  1029. double height = ScreenUtil().setWidth(180);
  1030. return Container(
  1031. width: width,
  1032. height: height,
  1033. child: Swiper(
  1034. itemBuilder: (BuildContext context, index) {
  1035. return Container(
  1036. width: width,
  1037. height: height,
  1038. child: LoadNetworkImage(
  1039. banners[index].image,
  1040. width: width,
  1041. height: height,
  1042. // fit: BoxFit.none
  1043. ),
  1044. );
  1045. },
  1046. pagination: SwiperPagination(
  1047. builder: DotSwiperPaginationBuilder(
  1048. color: Colors.grey,
  1049. activeColor: Colors.white,
  1050. size: 6,
  1051. activeSize: 6,
  1052. ),
  1053. ),
  1054. itemCount: banners.length,
  1055. scrollDirection: Axis.horizontal,
  1056. autoplay: false,
  1057. onTap: (index) {
  1058. onClickItem(index, banners[index]);
  1059. },
  1060. onIndexChanged: (index) {
  1061. onChangItem(index, banners[index]);
  1062. },
  1063. ),
  1064. );
  1065. }
  1066. }
  1067. class Privilege extends StatelessWidget {
  1068. const Privilege({Key key, this.initList}) : super(key: key);
  1069. final List<dynamic> initList;
  1070. List<Widget> listWidget(context) => initList.asMap().keys.map((i) {
  1071. double width = MediaQuery.of(context).size.width;
  1072. return GestureDetector(
  1073. child: Container(
  1074. margin: EdgeInsets.only(right: 10),
  1075. padding: EdgeInsets.only(top: 10, bottom: 10),
  1076. child: Row(
  1077. children: <Widget>[
  1078. SizedBox(width: ScreenUtil().setWidth(i == 0 ? 10 : 10)),
  1079. Container(
  1080. width: ScreenUtil().setWidth(120),
  1081. padding: EdgeInsets.only(top: 20, bottom: 20),
  1082. decoration: BoxDecoration(
  1083. color: ThemeUtils.getTabsBg(context),
  1084. borderRadius: BorderRadius.circular(5),
  1085. boxShadow: [
  1086. BoxShadow(
  1087. offset: Offset(0, 0), //x,y轴
  1088. color: Colors.grey[300], //投影颜色
  1089. blurRadius: 5, //投影距离
  1090. )
  1091. ],
  1092. ),
  1093. child: Column(
  1094. crossAxisAlignment: CrossAxisAlignment.center,
  1095. children: <Widget>[
  1096. // Icon(
  1097. // IconData(initList[i]['icon'], fontFamily: "Iconfont"),
  1098. // size: 24.0,
  1099. // color: Color.fromRGBO(51, 51, 51, 1),
  1100. // ),
  1101. Container(
  1102. margin: EdgeInsets.only(bottom: 8),
  1103. child: LoadNetworkImage(
  1104. initList[i].image,
  1105. width: 30,
  1106. height: 30,
  1107. ),
  1108. ),
  1109. Text(
  1110. initList[i].name ?? '',
  1111. textAlign: TextAlign.start,
  1112. style: TextStyle(
  1113. fontSize: ScreenUtil().setSp(14),
  1114. ),
  1115. ),
  1116. Text(
  1117. initList[i].descr ?? '',
  1118. textAlign: TextAlign.start,
  1119. style: TextStyle(
  1120. fontSize: ScreenUtil().setSp(14),
  1121. color: Color(0xff999999),
  1122. ),
  1123. overflow: TextOverflow.ellipsis,
  1124. ),
  1125. ],
  1126. ),
  1127. ),
  1128. ],
  1129. ),
  1130. ),
  1131. onTap: () {
  1132. // print(i);
  1133. },
  1134. );
  1135. }).toList();
  1136. @override
  1137. Widget build(BuildContext context) {
  1138. return ListView(
  1139. scrollDirection: Axis.horizontal,
  1140. padding: EdgeInsets.all(0),
  1141. children: listWidget(context),
  1142. );
  1143. }
  1144. }