diff --git a/lib/integral_store/integral_store_details_page.dart b/lib/integral_store/integral_store_details_page.dart index d8792447..812533ec 100644 --- a/lib/integral_store/integral_store_details_page.dart +++ b/lib/integral_store/integral_store_details_page.dart @@ -12,6 +12,7 @@ import 'package:huixiang/retrofit/data/goods.dart'; import 'package:huixiang/retrofit/data/user_info.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -296,7 +297,7 @@ class _IntegralStoreDetailsPage extends State { itemBuilder: (context, position) { return goods == null ? Container() - : Image.network( + : MImage( goods.viceImgPaths.elementAt(position), fit: BoxFit.cover, ) diff --git a/lib/mine/mine_page.dart b/lib/mine/mine_page.dart index 59e35f52..6a118fd1 100644 --- a/lib/mine/mine_page.dart +++ b/lib/mine/mine_page.dart @@ -32,7 +32,7 @@ class MinePage extends StatefulWidget { } } -class _MinePage extends State with AutomaticKeepAliveClientMixin ,WidgetsBindingObserver{ +class _MinePage extends State with AutomaticKeepAliveClientMixin { ApiService apiService; UserInfo userInfo; List ranks = []; @@ -55,29 +55,13 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin ,Widg super.dispose(); if (_refreshController != null) _refreshController.dispose(); - WidgetsBinding.instance.removeObserver(this); //销毁观察者 } - @override - void didChangeAppLifecycleState(AppLifecycleState state) { - print("-didChangeAppLifecycleState-" + state.toString()); - switch (state) { - case AppLifecycleState.inactive: // 处于这种状态的应用程序应该假设它们可能在任何时候暂停。 - break; - case AppLifecycleState.resumed: //从后台切换前台,界面可见 - querySocialInfo(); - break; - case AppLifecycleState.paused: // 界面不可见,后台 - break; - case AppLifecycleState.detached: // APP结束时调用 - break; - } - } + @override void initState() { super.initState(); - WidgetsBinding.instance.addObserver(this); querySocialInfo(); eventBus.on().listen((event) { diff --git a/lib/mine/mine_vip/mine_vip_core.dart b/lib/mine/mine_vip/mine_vip_core.dart index c92bc3d6..94bcaf5b 100644 --- a/lib/mine/mine_vip/mine_vip_core.dart +++ b/lib/mine/mine_vip/mine_vip_core.dart @@ -152,28 +152,30 @@ class _MineVipCore extends State { @override Widget build(BuildContext context) { - return Stack( - children: [ - Container( - // padding: EdgeInsets.only(top: 40.h), - height:260.h, - decoration: BoxDecoration( - gradient: new LinearGradient( - begin: Alignment.bottomCenter, - end: Alignment.topCenter, - colors: [ - Color(0xFF000000), - Color(0xFF585858), - ]), - // border: Border.all(color: Colors.white,width: 0.5), - shape: BoxShape.rectangle, - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(35), - bottomLeft: Radius.circular(35), + return Container( + color: Color(0xFFF7F7F7), + child: Stack( + children: [ + Container( + // padding: EdgeInsets.only(top: 40.h), + height:260.h, + decoration: BoxDecoration( + gradient: new LinearGradient( + begin: Alignment.bottomCenter, + end: Alignment.topCenter, + colors: [ + Color(0xFF000000), + Color(0xFF585858), + ]), + // border: Border.all(color: Colors.white,width: 0.5), + shape: BoxShape.rectangle, + borderRadius: BorderRadius.only( + bottomRight: Radius.circular(35), + bottomLeft: Radius.circular(35), + ), + ), ), - ), - ), - Column( + Column( children: [ SizedBox(height: 40), Container( @@ -232,48 +234,49 @@ class _MineVipCore extends State { child: Column( children: [ ///会员卡 - Container( - height: (MediaQuery.of(context).size.width) / - 1.78 * - AppUtils.textScale(context), - child: Swiper( - viewportFraction: 0.95, - loop: false, - physics: BouncingScrollPhysics(), - controller: controller, - onIndexChanged: (index) { - setState(() { - checkIndex = index; - }); - }, - itemBuilder: (context, position) { - return MineVipView( - vipLevel: !(ranks != null && ranks.isNotEmpty) - ? widget.arguments["rankLevel"] - : position + 1, - curLevel: widget.arguments["rankLevel"], - tag: (widget.arguments["rankLevel"] == (position + 1) || - !(ranks != null && ranks.isNotEmpty)) - ? "vip" - : "", - padding: 6.w, - // rank: !(ranks != null && ranks.isNotEmpty) - // ? 0 - // : widget.arguments["expendAmount"] ?? 0, - rankMax: !(ranks != null && ranks.isNotEmpty) - ? 0 - : ranks[position].rankOrigin, - createTime: widget.arguments["createTime"], - showRank: false, - price: !(ranks != null && ranks.isNotEmpty) - ? "0" - : ranks[position].price, - ); - }, - itemCount: - (ranks != null && ranks.isNotEmpty) ? ranks.length : 1, + if(ranks.length > 0) + Container( + height: (MediaQuery.of(context).size.width) / + 1.78 * + AppUtils.textScale(context), + child: Swiper( + viewportFraction: 0.95, + loop: false, + physics: BouncingScrollPhysics(), + controller: controller, + onIndexChanged: (index) { + setState(() { + checkIndex = index; + }); + }, + itemBuilder: (context, position) { + return MineVipView( + vipLevel: !(ranks != null && ranks.isNotEmpty) + ? widget.arguments["rankLevel"] + : position + 1, + curLevel: widget.arguments["rankLevel"], + tag: (widget.arguments["rankLevel"] == (position + 1) || + !(ranks != null && ranks.isNotEmpty)) + ? "vip" + : "", + padding: 6.w, + // rank: !(ranks != null && ranks.isNotEmpty) + // ? 0 + // : widget.arguments["expendAmount"] ?? 0, + rankMax: !(ranks != null && ranks.isNotEmpty) + ? 0 + : ranks[position].rankOrigin, + createTime: widget.arguments["createTime"], + showRank: false, + price: !(ranks != null && ranks.isNotEmpty) + ? "0" + : ranks[position].price, + ); + }, + itemCount: + (ranks != null && ranks.isNotEmpty) ? ranks.length : 1, + ), ), - ), ///会员权益 Container( @@ -528,45 +531,47 @@ class _MineVipCore extends State { )), ], ), - if (ranks.length > checkIndex && - widget.arguments["rankLevel"] < ranks[checkIndex].level && - ranks[checkIndex].price != "0.00") - Align( - alignment: Alignment.bottomCenter, - child: InkWell( - onTap: () { - setState(() { - buyRank(); - }); - }, - child: Container( - decoration: BoxDecoration( - gradient: new LinearGradient( - begin: Alignment.centerLeft, - end: Alignment.centerRight, - colors: [ - Color(0xFFFFDCA1), - Color(0xFFFAE4C0), - ]), - ), - width: MediaQuery.of(context).size.width, - padding: EdgeInsets.all(16), - height: 54, - alignment: Alignment.center, - child: Text( - "${S.of(context).lijikaitong}¥${ranks.length > checkIndex ? ranks[checkIndex].price : ""}/永久", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 16.sp, - color: Color(0xFF4A4748), + if (ranks.length > checkIndex && + widget.arguments["rankLevel"] < ranks[checkIndex].level && + ranks[checkIndex].price != "0.00") + Align( + alignment: Alignment.bottomCenter, + child: InkWell( + onTap: () { + setState(() { + buyRank(); + }); + }, + child: Container( + decoration: BoxDecoration( + gradient: new LinearGradient( + begin: Alignment.centerLeft, + end: Alignment.centerRight, + colors: [ + Color(0xFFFFDCA1), + Color(0xFFFAE4C0), + ]), + ), + width: MediaQuery.of(context).size.width, + padding: EdgeInsets.all(16), + height: 54, + alignment: Alignment.center, + child: Text( + "${S.of(context).lijikaitong}¥${ranks.length > checkIndex ? ranks[checkIndex].price : ""}/永久", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 16.sp, + color: Color(0xFF4A4748), + ), + ), ), ), - ), - ), - ) + ) + + ], + ), + ); - ], - ); } diff --git a/lib/mine/user_info_page.dart b/lib/mine/user_info_page.dart index 55a8234e..72bd318d 100644 --- a/lib/mine/user_info_page.dart +++ b/lib/mine/user_info_page.dart @@ -11,6 +11,7 @@ import 'package:huixiang/retrofit/data/user_info.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/flutter_utils.dart'; import 'package:huixiang/view_widget/cupertino_date_picker.dart'; +import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:image_pickers/image_pickers.dart'; import 'package:intl/intl.dart'; @@ -410,7 +411,7 @@ class _UserInfoPage extends State { borderRadius: BorderRadius.circular(4), child: filePath == null || filePath == "" ? (modifyInfo["headimg"] != null && modifyInfo["headimg"] != "" - ? Image.network( + ? MImage( modifyInfo["headimg"], width: 42, height: 42, diff --git a/lib/view_widget/hot_item.dart b/lib/view_widget/hot_item.dart index 3ff50286..6a8bb590 100644 --- a/lib/view_widget/hot_item.dart +++ b/lib/view_widget/hot_item.dart @@ -176,7 +176,7 @@ class _HotArticleItem extends State { child:Stack( alignment: Alignment.center, children: [ - Image.network( + MImage( widget.article?.coverImg ?? "", fit: BoxFit.fill, height: double.infinity, diff --git a/lib/view_widget/icon_text.dart b/lib/view_widget/icon_text.dart index 5e90ce53..19cdbd38 100644 --- a/lib/view_widget/icon_text.dart +++ b/lib/view_widget/icon_text.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'custom_image.dart'; + class IconText extends StatelessWidget { final String leftImage; final String rightImage; @@ -48,7 +50,7 @@ class IconText extends StatelessWidget { widgets.add(Padding( padding: EdgeInsets.only(left: 2), child: leftImage.startsWith("http") - ? Image.network( + ? MImage( leftImage, width: iconSize, height: iconSize, diff --git a/lib/view_widget/message_item.dart b/lib/view_widget/message_item.dart index e35a40f8..ff840734 100644 --- a/lib/view_widget/message_item.dart +++ b/lib/view_widget/message_item.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'custom_image.dart'; + class MessageItem extends StatefulWidget { final int stStatus; @@ -19,7 +21,7 @@ class _MessageItemState extends State { if (widget.stStatus != 0) checkView(), Container( margin: EdgeInsets.only(left: widget.stStatus == 0 ? 16 : 0), - child: Image.network( + child: MImage( "https://t7.baidu.com/it/u=1297102096,3476971300&fm=193&f=GIF", width: 44.w, fit: BoxFit.cover, diff --git a/lib/view_widget/mine_vip_view.dart b/lib/view_widget/mine_vip_view.dart index aa4693cb..6766255e 100644 --- a/lib/view_widget/mine_vip_view.dart +++ b/lib/view_widget/mine_vip_view.dart @@ -331,7 +331,6 @@ class MineVipView extends StatelessWidget { .pushNamed('/router/mine_vip_core', arguments: { "rankLevel": curLevel, "userInfo":userInfo.masterCardRankName, - "createTime": (userInfo != null) ? "${userInfo.createTime}" : "", "expendAmount": double.tryParse(userInfo?.expendAmount??"0").toInt(), });