vip.dart 43 KB

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