bind_alipay_page.dart 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. import 'dart:convert';
  2. import 'dart:math';
  3. import 'package:bbyyy/beans/user_bean_entity.dart';
  4. import 'package:bbyyy/https/MyDio.dart';
  5. import 'package:bbyyy/https/url.dart';
  6. import 'package:bbyyy/my_tools/dims.dart';
  7. import 'package:bbyyy/my_tools/event_bus.dart';
  8. import 'package:bbyyy/my_tools/my_colors.dart';
  9. import 'package:bbyyy/my_tools/my_cookie.dart';
  10. import 'package:bbyyy/my_tools/my_tools.dart';
  11. import 'package:bbyyy/my_tools/my_views.dart';
  12. import 'package:bbyyy/paegs/mine_page/bind_alipay_page/set_alipay_page.dart';
  13. import 'package:bbyyy/paegs/mine_page/coupon_page/coupon_view.dart';
  14. import 'package:flutter/cupertino.dart';
  15. import 'package:flutter/material.dart';
  16. import 'package:flutter_svg/svg.dart';
  17. class BindAlipayPage extends StatefulWidget {
  18. @override
  19. _BindAlipayPageState createState() => _BindAlipayPageState();
  20. }
  21. class _BindAlipayPageState extends State<BindAlipayPage> {
  22. TextEditingController controller = TextEditingController();
  23. bool showInput = false;
  24. @override
  25. Widget build(BuildContext context) {
  26. return Scaffold(
  27. body: Container(
  28. decoration: BoxDecoration(
  29. gradient: LinearGradient(
  30. colors: MyColors.lg2,
  31. begin: Alignment.topCenter,
  32. end: Alignment.bottomCenter),
  33. ),
  34. child: Column(
  35. children: [
  36. SafeArea(
  37. child: Container(
  38. height: 45,
  39. width: double.infinity,
  40. child: Stack(
  41. children: [
  42. Text(
  43. '绑定',
  44. style: TextStyle(color: Colors.white, fontSize: 16),
  45. ),
  46. Positioned(
  47. left: 0,
  48. child: GestureDetector(
  49. onTap: () {
  50. Navigator.pop(context);
  51. },
  52. behavior: HitTestBehavior.translucent,
  53. child: Transform.rotate(
  54. angle: pi,
  55. child: Padding(
  56. padding: EdgeInsets.only(
  57. left: 16, right: 16, top: 8, bottom: 8),
  58. child: SvgPicture.asset(
  59. 'images/svg/箭头.svg',
  60. color: Colors.white,
  61. height: 14,
  62. ),
  63. ),
  64. ),
  65. ),
  66. ),
  67. ],
  68. alignment: Alignment.center,
  69. ),
  70. ),
  71. ),
  72. Container(
  73. height: 280,
  74. margin: EdgeInsets.fromLTRB(15, 60, 15, 50),
  75. width: double.infinity,
  76. child: ClipShadowPath(
  77. clipper: TicketClipPath2(),
  78. shadow: Shadow(blurRadius: 5, color: MyColors.c21333333),
  79. child: Scaffold(
  80. body: Stack(
  81. alignment: Alignment.bottomCenter,
  82. children: [
  83. Column(
  84. children: [
  85. Container(
  86. margin: EdgeInsets.only(top: 40),
  87. child: ClipRRect(
  88. child: MyViews().netImg(
  89. imgURL(MyCookie().userBean.picture), 64, 64),
  90. borderRadius: BorderRadius.circular(32),
  91. ),
  92. ),
  93. Container(
  94. child: MyViews()
  95. .myText('当前绑定支付宝账号', MyColors.c333333, 13),
  96. margin: EdgeInsets.only(top: 11, bottom: 11),
  97. ),
  98. Container(
  99. decoration: BoxDecoration(
  100. borderRadius: BorderRadius.circular(22.5),
  101. color: MyColors.cFF4233),
  102. height: 45,
  103. margin: EdgeInsets.symmetric(horizontal: 22),
  104. child: MyViews().myText(
  105. MyCookie().userBean.aliPayAccount,
  106. Colors.white,
  107. 20),
  108. alignment: Alignment.center,
  109. )
  110. ],
  111. ),
  112. Container(
  113. child: CustomPaint(
  114. painter: DashedPainter(),
  115. size: Size(double.infinity, 1),
  116. ),
  117. margin:
  118. EdgeInsets.only(bottom: 38, right: 10, left: 10),
  119. ),
  120. Positioned(
  121. bottom: 0,
  122. child: GestureDetector(
  123. onTap: () {
  124. MyTools().toPage(context, SetAlipayPage(), (then) {
  125. setState(() {});
  126. });
  127. },
  128. behavior: HitTestBehavior.translucent,
  129. child: Container(
  130. height: 39,
  131. child: Row(
  132. children: [
  133. MyViews()
  134. .myText('修改绑定账号', MyColors.c999999, 11),
  135. Container(
  136. margin: EdgeInsets.only(left: 5),
  137. child: SvgPicture.asset(
  138. 'images/svg/箭头.svg',
  139. color: MyColors.c999999,
  140. height: 8,
  141. width: 8,
  142. ),
  143. )
  144. ],
  145. mainAxisAlignment: MainAxisAlignment.center,
  146. crossAxisAlignment: CrossAxisAlignment.center,
  147. ),
  148. alignment: Alignment.center,
  149. ),
  150. ),
  151. ),
  152. ],
  153. ),
  154. ),
  155. ),
  156. )
  157. ],
  158. ),
  159. ),
  160. );
  161. }
  162. void queryPersonalInformation() {
  163. MyDio().query({
  164. "key": "user",
  165. "filters": {
  166. "conditions": ["uid == ${MyCookie().getUID()}"]
  167. },
  168. "dims": userDims,
  169. "paging": [1, 20]
  170. }, (response, hasError) {
  171. if (!hasError) {
  172. UserBeanEntity entity =
  173. UserBeanEntity().fromJson(json.decode(response.data.toString()));
  174. MyCookie().userBean = entity.data.data[0];
  175. EventBus().emit('userChange');
  176. setState(() {});
  177. }
  178. }, (error) {});
  179. }
  180. void saveAlipayNum() {
  181. MyDio().update({
  182. "key": "user",
  183. "values": {
  184. "name": MyCookie().loginInformation.data.extra.name,
  185. "picture": MyCookie().loginInformation.data.extra.picture,
  186. "id": MyCookie().loginInformation.data.extra.id,
  187. "alipay_account": controller.text.toString()
  188. }
  189. }, (response, hasError) {
  190. if (!hasError) {
  191. MyCookie().userBean.aliPayAccount = controller.text.toString();
  192. showInput = false;
  193. setState(() {});
  194. }
  195. }, (error) {});
  196. }
  197. }