浏览代码

[new]增加用户电量显示

zk 1 年之前
父节点
当前提交
459b34e646
共有 3 个文件被更改,包括 67 次插入55 次删除
  1. 1 1
      assets/string/base/string.xml
  2. 4 1
      lib/module/main/drawer/controller.dart
  3. 62 53
      lib/module/main/drawer/view.dart

+ 1 - 1
assets/string/base/string.xml

@@ -121,5 +121,5 @@
     <string name="store_pay_not_connect_store">无法连接到商店</string>
     <string name="store_pay_error">支付失败,请稍后重试</string>
     <string name="store_query_pay_state">正在查询订单状态..</string>
-    <string name="store_pay_success">订购成功</string>
+    <string name="store_pay_success">充电成功</string>
 </resources>

+ 4 - 1
lib/module/main/drawer/controller.dart

@@ -6,6 +6,7 @@ import 'package:flutter/cupertino.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
 import 'package:get/get.dart';
 
+import '../../../data/api/response/user_info_response.dart';
 import '../../../data/repositories/account_repository.dart';
 import '../../../dialog/alert_dialog.dart';
 import '../../../resource/string.gen.dart';
@@ -18,7 +19,9 @@ class MainDrawerController extends BaseController {
   String get loginTxt =>
       accountRepository.getUserSubName(accountRepository.phone);
 
-  String get electricityTxt => '${StringName.mainLoginChargeTips.tr}';
+  final Rxn<UserInfoResponse> _userInfo = accountRepository.userInfo;
+
+  UserInfoResponse? get userInfo => _userInfo.value;
 
   void accountLogout() {
     EAAlertDialog.show(

+ 62 - 53
lib/module/main/drawer/view.dart

@@ -26,59 +26,68 @@ class MainDrawerView extends BasePage<MainDrawerController> {
             SizedBox(height: 12.h),
             buildUserInfoView(),
             SizedBox(height: 12.h),
-            // Container(
-            //   height: 72.w,
-            //   decoration: BoxDecoration(
-            //     borderRadius: BorderRadius.circular(12.w),
-            //     border: Border.all(color: ColorName.white20, width: 2.w),
-            //     gradient: LinearGradient(
-            //       colors: ['#5B618D'.toColor(), '#283B58'.toColor()],
-            //       begin: Alignment.centerLeft,
-            //       end: Alignment.centerRight,
-            //       transform: const GradientRotation(-1.64061),
-            //       stops: const [0, 1.0],
-            //     ),
-            //   ),
-            //   child: Row(
-            //     children: [
-            //       SizedBox(width: 16.w),
-            //       IntrinsicHeight(
-            //         child: Column(
-            //           children: [
-            //             SizedBox(
-            //                 height: 18.h,
-            //                 child: Assets.images.iconChargeCenterTxt.image()),
-            //             SizedBox(height: 4.h),
-            //             Text(controller.electricityTxt,
-            //                 style: TextStyle(
-            //                     fontSize: 12.sp, color: ColorName.white))
-            //           ],
-            //         ),
-            //       ),
-            //       const Spacer(),
-            //       DecoratedBox(
-            //         decoration: BoxDecoration(
-            //           color: Colors.white,
-            //           borderRadius: BorderRadius.circular(12.w),
-            //         ),
-            //         child: Padding(
-            //           padding: const EdgeInsets.symmetric(
-            //                   vertical: 4, horizontal: 11)
-            //               .w,
-            //           child: Text(
-            //             StringName.mainGoCharge.tr,
-            //             style: TextStyle(
-            //                 fontSize: 14.sp,
-            //                 color: '#374668'.toColor(),
-            //                 fontWeight: FontWeight.bold),
-            //           ),
-            //         ),
-            //       ),
-            //       SizedBox(width: 18.w),
-            //     ],
-            //   ),
-            // ),
-            // SizedBox(height: 12.h),
+            Container(
+              height: 72.w,
+              decoration: BoxDecoration(
+                borderRadius: BorderRadius.circular(12.w),
+                border: Border.all(color: ColorName.white20, width: 2.w),
+                gradient: LinearGradient(
+                  colors: ['#5B618D'.toColor(), '#283B58'.toColor()],
+                  begin: Alignment.centerLeft,
+                  end: Alignment.centerRight,
+                  transform: const GradientRotation(-1.64061),
+                  stops: const [0, 1.0],
+                ),
+              ),
+              child: Row(
+                children: [
+                  SizedBox(width: 16.w),
+                  IntrinsicHeight(
+                    child: Column(
+                      crossAxisAlignment: CrossAxisAlignment.start,
+                      children: [
+                        SizedBox(
+                            height: 18.h,
+                            child: Assets.images.iconChargeCenterTxt.image()),
+                        SizedBox(height: 4.h),
+                        Row(
+                          children: [
+                            Text(StringName.mainLoginChargeTips.tr,
+                                style: TextStyle(
+                                    fontSize: 12.sp, color: ColorName.white)),
+                            Text(
+                                '${controller.userInfo?.memberInfo?.electric ?? '0'}',
+                                style: TextStyle(
+                                    fontSize: 12.sp, color: ColorName.white))
+                          ],
+                        )
+                      ],
+                    ),
+                  ),
+                  const Spacer(),
+                  DecoratedBox(
+                    decoration: BoxDecoration(
+                      color: Colors.white,
+                      borderRadius: BorderRadius.circular(12.w),
+                    ),
+                    child: Padding(
+                      padding: const EdgeInsets.symmetric(
+                              vertical: 4, horizontal: 11)
+                          .w,
+                      child: Text(
+                        StringName.mainGoCharge.tr,
+                        style: TextStyle(
+                            fontSize: 14.sp,
+                            color: '#374668'.toColor(),
+                            fontWeight: FontWeight.bold),
+                      ),
+                    ),
+                  ),
+                  SizedBox(width: 18.w),
+                ],
+              ),
+            ),
+            SizedBox(height: 12.h),
             _buildContent1(),
             SizedBox(height: 8.h),
             _buildContent2(),