From a598480dbfa9409559b8c87dbf28e7a3f4eb8bce Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Mon, 21 Mar 2022 22:17:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=85=E5=80=BC=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/image/2x/recharge.png | Bin 0 -> 646 bytes assets/image/3x/recharge.png | Bin 0 -> 1127 bytes assets/image/recharge.png | Bin 0 -> 316 bytes lib/mine/recharge_page.dart | 625 +++++++++++++++++++++-------------- 4 files changed, 376 insertions(+), 249 deletions(-) create mode 100644 assets/image/2x/recharge.png create mode 100644 assets/image/3x/recharge.png create mode 100644 assets/image/recharge.png diff --git a/assets/image/2x/recharge.png b/assets/image/2x/recharge.png new file mode 100644 index 0000000000000000000000000000000000000000..a353e7631a378789eb08e6a41c26a7314dd5069c GIT binary patch literal 646 zcmV;10(t$3P)Px%KuJVFR9HvN*k4G~Q53-O@5*wnH8tH*VF-pVkwp>IOF~o&!iON}Rq-K$@Szf` zCq<%%D5CBd&hj_>Cr(Tf4vg?r*#I{oeE8 zo_h}5<3i)LE!xuQ($#0;5Oiq?OySJS(+;>4rycNLoL0beIBkHLa9RNWhbuTR8?K;0 z8C=1Dvbcf(t>E$ww2I3sFc)0jfVtxG0n}@4ieg3%a9vBNukJ;aTP8=Ga4eM;~OJyhsCOaAve)TMyB?xrx5`6MA0VSp@8< z-OkxvM<`lRM9)Z!*!zL3IO!^u#hC}z`l`6G{}g^t*`E~N=3spzXLdFxQ`!CO7LR70 zOW~w|R&c4P!L3F9ZHhr$ef9F@jp1?GZFMXz2{K{(Vw&==ra zVxALEFZ24-q$M2iHRBt!gG(v=C1spzJj%t97!z|Jtm4ekTRbgL15cT(Zq*fHPaktbhRn g5gBWV#+TO1Z%FI;4-+3-w*UYD07*qoM6N<$f(yznGXMYp literal 0 HcmV?d00001 diff --git a/assets/image/3x/recharge.png b/assets/image/3x/recharge.png new file mode 100644 index 0000000000000000000000000000000000000000..0f3c3f3c508e4690d6f14c57771816a4b8fc16b0 GIT binary patch literal 1127 zcmV-t1ep7YP)Px(AxT6*RA@ux*?njecO1v@&-c!xF|o1MXKRgPPB-xZN6JdojaB?-;0FFNb+8Nt z#rcQKhazrLt79?|MNtq0H=PgYlsXuU&c8aatFDbYR$K8QmfC8yRcu;qn>P0w_rr{I zCiaqh$lW!674CZcUirTJ>n|-~h`i?f^ts2$93?aqyfSuJR4f5u^N;}hkFP3|n6w#y z$JXFj#uAgZ$4a&>I6h-}vbG1uXB@vz*>1v#GPW%^S;n>nC(GD&;K4Gs66GBzbx&x}n6);nXY&ba6 z85;^VL&k=J&5*GnU?VbiJ6xDKdMf&*C~mahL!ZKF8?kyBI9xHQCKtg6MX#E zLcHkf!MclkQ2(ScGhn?l9+~CA*M(o;!zu4V6hu7h?ZTRh?{W88i?LuMG9EpABua}` zVZr1%9QU+4j03@+@mr`G5|fMr>zy%yFg-UP8w*yzKjCc-d(hR6{k3ON*>n|A1z7oe zH2WFWJL4(d@!0kLTFl7xK_Eh7$3yI>I*NbVLSSHnPBwOfYH+$4%MX;+@p?=eF^1oFuj2u}{qq?9etcUoR1>h8jOAVSEB`XML?=!)Ttu+-<|~UA zNkCEFY-}p{4Ef%1e3I85-NL?_GiXq-BPV({R83e-#sw4K!QsUve8SD0kMUjgas2hL ze!v>%=gr2pqLmoy9tD7*x}^@gube=0XIsjXRW;#sGmc+nuFH#^3s&R3Ni!j5+Z29; z(o08B*A{|99EK0_=ke=K(E*7u)U-BWXVnjAef}hEY+9R^nvDOyQlEDMHWVz!!pU>_ zC3(^ZgXb~Uox=|m-YgG4JynD*uPeWz2u^QkOu&y4q0wDU_8-1Hd-Rm}4Q(rZ=-X zkDmMVT=c(#hYd59|Mbx$2x93QuJGv?mV<4UF$3W~5&Z(-bTH(rku#3p(a7o<6CunP tnn5IgpuRxNQJu{qEtM;e^(5N5{{<-~8byvY+Mxgd002ovPDHLkV1g-?9t;2g literal 0 HcmV?d00001 diff --git a/assets/image/recharge.png b/assets/image/recharge.png new file mode 100644 index 0000000000000000000000000000000000000000..15ead2f5971cca2209f12eac00fb519477fe8a29 GIT binary patch literal 316 zcmV-C0mJ@@P)Px#_DMuRR5(v#WS}B2T9{DJNG^?0a~I!Aw#cY}mUWpD+q56axu)(_B&;?6Qi3(-^+|{*I;O`~L}U zAR)tuDL4QBXIKX|kSc~T{D1$C@xKKl<%a$L^#4EOo_|dLDlf(_x&;8ni*@ { }); weChatResponseEventHandler.listen((event) async { print("payCallback: ${event.errCode}"); - if(event.errCode == 0){ + if (event.errCode == 0) { Navigator.of(context).pop(); SmartDialog.showToast("充值成功", alignment: Alignment.center); } @@ -59,19 +59,20 @@ class _RechargePage extends State { }); } - ///会员权益列表 queryBenefitList() async { - BaseData> baseData = await apiService.benefitList().catchError((onError) {}); + BaseData> baseData = + await apiService.benefitList().catchError((onError) {}); if (baseData != null && baseData.isSuccess) { setState(() { vipBenefitList.clear(); vipBenefitList.addAll(baseData.data); vipBenefitList.forEach((element) { - if(element.have && element.config != null && element.code == "RECHARGE"){ + if (element.have && + element.config != null && + element.code == "RECHARGE") { discount = double.parse(element.config); } - }); }); } @@ -81,7 +82,7 @@ class _RechargePage extends State { ///会员权益介绍/规则/说明/储值说明 queryRuleDetails() async { BaseData baseData = - await apiService.vipBenefit().catchError((onError) {}); + await apiService.vipBenefit().catchError((onError) {}); if (baseData != null && baseData.isSuccess) { setState(() { vipRuleDetails = baseData.data; @@ -100,266 +101,392 @@ class _RechargePage extends State { background: Color(0xFFFFFFFF), leadingColor: Colors.black, ), - body:Stack( - children: [ - SingleChildScrollView( - physics: BouncingScrollPhysics(), - child: Container( - child: Column( - children: [ - Container( - child: Column(children: [ - ItemInputWidget( - S.of(context).qingshuruchongzhijine, - hintText: "", - controller: controller, - padding: EdgeInsets.all(20), - errorText: S.of(context).chongzhizuixiaojine(100), - titleColor: Color(0xFF727272), - errorTextColor: Color(0xFF32A060), - radius: 8, - discount: discount/10, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 27.sp, - color: color, - ), - inputLimit: 6, - textInputType: TextInputType.number, - textInputFormatter: FilteringTextInputFormatter.digitsOnly, - onChanged: (value) { - if (value != null && - value != "" && - double.tryParse(value) < 100) { - color = Colors.red; - } else { - color = Colors.black; - } - setState(() {}); - }, - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - if (vipRuleDetails?.recharge != null && - vipRuleDetails.recharge != "") - Expanded(child:Container( - color: Colors.white, - padding: EdgeInsets.only(left: 8), - child: Html( - data: "注意:${vipRuleDetails?.recharge??""}", - customImageRenders: { - networkSourceMatcher(): networkImageRender( - loadingWidget: () { - return Container(); - }, - ), - }, - ), - ),) - ], - ), - ],), - ), - Container( - width: double.infinity, - margin: EdgeInsets.only( - left: 0.w, - right: 0.w, - top: 16.h, - bottom: 4.h, - ), - padding: EdgeInsets.only( - left: 20.w, - right: 16.w, - top: 20.h, - bottom: 20.h, - ), - decoration: BoxDecoration( - color: Colors.white, - // borderRadius: BorderRadius.circular(4), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, + body: Container( + color: Color(0xFFFFFFFF), + child: Stack( + children: [ + SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Container( + margin: EdgeInsets.only(left: 16, right: 16), + child: Column( + children: [ + Column( crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ + // ItemInputWidget( + // S.of(context).qingshuruchongzhijine, + // hintText: "", + // controller: controller, + // padding: EdgeInsets.all(20), + // errorText: S.of(context).chongzhizuixiaojine(100), + // titleColor: Color(0xFF727272), + // errorTextColor: Color(0xFF32A060), + // radius: 8, + // discount: discount / 10, + // style: TextStyle( + // fontWeight: FontWeight.bold, + // fontSize: 27.sp, + // color: color, + // ), + // inputLimit: 6, + // textInputType: TextInputType.number, + // textInputFormatter: + // FilteringTextInputFormatter.digitsOnly, + // onChanged: (value) { + // if (value != null && + // value != "" && + // double.tryParse(value) < 100) { + // color = Colors.red; + // } else { + // color = Colors.black; + // } + // setState(() {}); + // }, + // ), Padding( - padding: EdgeInsets.only(bottom: 16.h), + padding: EdgeInsets.only(top: 26, bottom: 28), child: Text( - S.of(context).zhifufangshi, + S.of(context).chongzhi, style: TextStyle( - fontSize: 16.sp, - color: Colors.black, - fontWeight: FontWeight.bold, - ), + fontSize: 28.sp, + color: Color(0xFF181818), + fontWeight: MyFontWeight.semi_bold), ), ), - GestureDetector( - onTap: () { - setState(() { - checkIndex = 1; - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Image.asset("assets/image/icon_we_chat.webp"), + Row( + children: [ + Expanded( + child: Text( + S.of(context).zhanghuyue, + style: TextStyle( + fontSize: 15.sp, + color: Color(0xFF181818), + fontWeight: MyFontWeight.semi_bold), + )), + Text.rich( + TextSpan(children: [ + TextSpan( + text: "0.00", + style: TextStyle( + fontSize: 26.sp, + color: Color(0xFF181818), + fontWeight: MyFontWeight.semi_bold), + ), + TextSpan( + text: "元", + style: TextStyle( + fontSize: 15.sp, + color: Color(0xFF181818), + fontWeight: MyFontWeight.semi_bold), + ), + ]), + ), + ], + ), + SizedBox(height: 28), + rechargeList(), + SizedBox(height:22), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + if (vipRuleDetails?.recharge != null && + vipRuleDetails.recharge != "") Expanded( - flex: 1, - child: Padding( - padding: EdgeInsets.only(left: 8.w), - child: Text( - S.of(context).weixinzhifu, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xff353535), - ), + child: Container( + color: Colors.white, + child: Html( + data: "注意:${vipRuleDetails?.recharge ?? ""}", + style:{ + "html":Style( + color: Color(0xFF000000), + fontWeight: MyFontWeight.medium, + ) + }, + customImageRenders: { + networkSourceMatcher(): networkImageRender( + loadingWidget: () { + return Container(); + }, + ), + }, ), ), - ), - checkView(1), - ], - ), - ), - ], - ), - ), - // InkWell( - // onTap: () { - // recharge(); - // }, - // child: Container( - // // margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 26.h), - // child: Column( - // mainAxisAlignment: MainAxisAlignment.spaceAround, - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // RoundButton( - // width: double.infinity, - // height: 46.h, - // text: S.of(context).querenchongzhi, - // textColor: Colors.white, - // fontSize: 14.sp, - // backgroup: Color(0xff32A060), - // fontWeight: FontWeight.bold, - // ), - // ], - // ), - // ), - // ), - ], - ), - ), - ), - Align(alignment: Alignment.bottomCenter,child: - Container( - height: 56.h, - color: Colors.white, - child: Row( - children: [ - Expanded(child:Container( - padding:EdgeInsets.only(top: 7.h,left:16), - child:Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Text( - S.of(context).heji, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - color: Colors.black, - ), - ), - Text( - controller.text, - style: TextStyle( - fontSize: 16.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF32A060), - ), + ) + ], ), ], ), - if(controller.text != "") - Text.rich( - TextSpan( - children: [ - TextSpan( - text: "充值", - style: TextStyle( - fontSize:12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFFADADAD), - ), - ), - TextSpan( - text:"¥${controller.text}", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color:Color(0xff3541C9), - ), - ), - TextSpan( - text: "赠送", + Container( + width: double.infinity, + margin: EdgeInsets.only( + top: 16.h, + bottom: 4.h, + ), + padding: EdgeInsets.only( + top: 20.h, + bottom: 20.h, + ), + // decoration: BoxDecoration( + // color: Colors.white, + // borderRadius: BorderRadius.circular(4), + // ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(bottom: 16.h), + child: Text( + S.of(context).zhifufangshi, style: TextStyle( - fontSize:12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFFADADAD), + fontSize: 16.sp, + color: Colors.black, + fontWeight: FontWeight.bold, ), ), - TextSpan( - text:"¥${((double.tryParse(controller.text)??0) - ((double.tryParse(controller.text)??0) * (discount/100))).toStringAsFixed(2)}", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xff3541C9), - ), - ),TextSpan( - text: "元", - style: TextStyle( - fontSize:12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFFADADAD), - ), + ), + GestureDetector( + onTap: () { + setState(() { + checkIndex = 1; + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Image.asset("assets/image/icon_we_chat.webp"), + Expanded( + flex: 1, + child: Padding( + padding: EdgeInsets.only(left: 8.w), + child: Text( + S.of(context).weixinzhifu, + style: TextStyle( + fontSize: 14.sp, + color: Color(0xff353535), + ), + ), + ), + ), + checkView(1), + ], ), - ], - ), + ), + ], ), + ), ], - )) ), - GestureDetector( - onTap: () { - recharge(); - }, - child: RoundButton( - width: 103.w, - height: 54.h, - text: S.of(context).chongzhi, - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFF32A060), - radius: 0, - fontSize: 16.sp, - padding: EdgeInsets.symmetric(vertical: 5.h), + ), + ), + Align( + alignment: Alignment.bottomCenter, + child: GestureDetector( + onTap: (){ + recharge(); + }, + child: Container( + height: 56.h, + width: double.infinity, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Color(0xFF32A060), + borderRadius: BorderRadius.circular(27), + ), + margin: EdgeInsets.only(left: 16,right: 16,bottom: 21), + child: Text( + S.of(context).querenchongzhi, + style: TextStyle( + fontSize: 16.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), ), ), - ], - ), - )) - ], - ), + ), + // Container( + // height: 56.h, + // color: Colors.white, + // child: Row( + // children: [ + // Expanded(child:Container( + // padding:EdgeInsets.only(top: 7.h,left:16), + // child:Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Row( + // children: [ + // Text( + // S.of(context).heji, + // style: TextStyle( + // fontSize: 14.sp, + // fontWeight: MyFontWeight.regular, + // color: Colors.black, + // ), + // ), + // Text( + // controller.text, + // style: TextStyle( + // fontSize: 16.sp, + // fontWeight: MyFontWeight.medium, + // color: Color(0xFF32A060), + // ), + // ), + // ], + // ), + // if(controller.text != "") + // Text.rich( + // TextSpan( + // children: [ + // TextSpan( + // text: "充值", + // style: TextStyle( + // fontSize:12.sp, + // fontWeight: MyFontWeight.regular, + // color: Color(0xFFADADAD), + // ), + // ), + // TextSpan( + // text:"¥${controller.text}", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.regular, + // color:Color(0xff3541C9), + // ), + // ), + // TextSpan( + // text: "赠送", + // style: TextStyle( + // fontSize:12.sp, + // fontWeight: MyFontWeight.regular, + // color: Color(0xFFADADAD), + // ), + // ), + // TextSpan( + // text:"¥${((double.tryParse(controller.text)??0) - ((double.tryParse(controller.text)??0) * (discount/100))).toStringAsFixed(2)}", + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.regular, + // color: Color(0xff3541C9), + // ), + // ),TextSpan( + // text: "元", + // style: TextStyle( + // fontSize:12.sp, + // fontWeight: MyFontWeight.regular, + // color: Color(0xFFADADAD), + // ), + // ), + // ], + // ), + // ), + // ], + // )) + // ), + // GestureDetector( + // onTap: () { + // recharge(); + // }, + // child: RoundButton( + // width: 103.w, + // height: 54.h, + // text: S.of(context).chongzhi, + // textColor: Colors.white, + // fontWeight: MyFontWeight.regular, + // backgroup: Color(0xFF32A060), + // radius: 0, + // fontSize: 16.sp, + // padding: EdgeInsets.symmetric(vertical: 5.h), + // ), + // ), + // ], + // ), + // ) + ) + ], + ), + ), ); } var checkIndex = 1; + Widget rechargeList() { + return GridView.builder( + itemCount: 6, + shrinkWrap: true, + physics: BouncingScrollPhysics(), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + //一行的Widget数量 + crossAxisCount: 3, + //水平子Widget之间间距 + crossAxisSpacing:11, + //垂直子Widget之间间距 + mainAxisSpacing: 0, + childAspectRatio: 1.5, + ), + itemBuilder: (context, index) { + return GestureDetector( + onTap: () {}, + child: rechargeItem(), + ); + }, + ); + } + + Widget rechargeItem() { + return Stack( + alignment: Alignment.bottomRight, + children: [ + Container( + alignment: Alignment.center, + height: 69.h, + decoration: BoxDecoration( + color: Color(0xFFFAFAFA), + // color: Color(0x2432A060), + borderRadius: BorderRadius.circular(4), + ), + // margin: EdgeInsets.only(right: 11,bottom: 16), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "100元", + textAlign: TextAlign.center, + style: TextStyle( + color: Color(0xFF868686), + fontWeight: MyFontWeight.medium, + fontSize: 21.sp, + ), + ), + SizedBox(height:2,), + Text( + "实际到账:120元", + textAlign: TextAlign.center, + style: TextStyle( + color: Color(0xFF868686), + fontWeight: MyFontWeight.regular, + fontSize:12.sp, + ), + ), + ], + ), + ), + Image.asset( + "assets/image/recharge.png", + width: 20, + height:20, + ), + ], + ); + } + Widget checkView(var index) { return Container( padding: EdgeInsets.only(right: 16.w), @@ -389,16 +516,17 @@ class _RechargePage extends State { return; } - if(Platform.isAndroid){ - if (!(await Min.isInitialize())) { - // 小程序的微信支付和app的充值支付使用同一个WXPayEntryActivity回调, - // 然而充值时小程序未初始化会导致回调内部代码调用getPackage空指针, - // 故而在此初始化一下 - await Min.initialize(); - }} + if (Platform.isAndroid) { + if (!(await Min.isInitialize())) { + // 小程序的微信支付和app的充值支付使用同一个WXPayEntryActivity回调, + // 然而充值时小程序未初始化会导致回调内部代码调用getPackage空指针, + // 故而在此初始化一下 + await Min.initialize(); + } + } - BaseData baseData = - await apiService.recharge({"amount": amount, "rechargeType": 2}).catchError((error) {}); + BaseData baseData = await apiService.recharge( + {"amount": amount, "rechargeType": 2}).catchError((error) {}); if (baseData != null && baseData.isSuccess) { WxPay wxPay = WxPay.fromJson(baseData.data); await registerWxApi( @@ -415,8 +543,7 @@ class _RechargePage extends State { timeStamp: int.tryParse(wxPay.timeStamp), sign: wxPay.sign, ); - } - else{ + } else { SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } }