@@ -25,6 +25,7 @@ class IntellectCreate { | |||||
try { | try { | ||||
_requestSetData(context); | _requestSetData(context); | ||||
} catch (e, s) { | } catch (e, s) { | ||||
isRequest = false; | |||||
print(e); | print(e); | ||||
print(s); | print(s); | ||||
} | } | ||||
@@ -45,27 +46,22 @@ class IntellectCreate { | |||||
var param = {"webId": ""}; | var param = {"webId": ""}; | ||||
//请求参数 | //请求参数 | ||||
await NetUtil.request('/api/v1/cfg/clipboard_base', params: param, | |||||
onSuccess: (data) async { | |||||
await NetUtil.request('/api/v1/cfg/clipboard_base', params: param, onSuccess: (data) async { | |||||
print("设置参数" + data.toString()); | print("设置参数" + data.toString()); | ||||
///检查是否已缓存过设置信息 | ///检查是否已缓存过设置信息 | ||||
String result = await SharedPreferencesUtil.getStringValue( | |||||
Constants.spIsCacheSetModel); | |||||
_setModel = IntellectSearchSetModel.fromJson( | |||||
json.decode(data['clipboard_base'])); | |||||
String result = await SharedPreferencesUtil.getStringValue(Constants.spIsCacheSetModel); | |||||
_setModel = IntellectSearchSetModel.fromJson(json.decode(data['clipboard_base'])); | |||||
if (result == null || result.isEmpty) { | if (result == null || result.isEmpty) { | ||||
validate(context, _setModel); | validate(context, _setModel); | ||||
} | } | ||||
SharedPreferencesUtil.setNetCacheResult( | |||||
Constants.spIsCacheSetModel, data['clipboard_base']); | |||||
SharedPreferencesUtil.setNetCacheResult(Constants.spIsCacheSetModel, data['clipboard_base']); | |||||
}); | }); | ||||
isRequest = false; | isRequest = false; | ||||
///拿缓存数据 | ///拿缓存数据 | ||||
var cacheData = await SharedPreferencesUtil.getNetCacheResult( | |||||
Constants.spIsCacheSetModel); | |||||
var cacheData = await SharedPreferencesUtil.getNetCacheResult(Constants.spIsCacheSetModel); | |||||
///如果存在缓存直接进入验证阶段 | ///如果存在缓存直接进入验证阶段 | ||||
if (cacheData != null) { | if (cacheData != null) { | ||||
@@ -88,20 +84,21 @@ class IntellectCreate { | |||||
// content = | // content = | ||||
// "6緮置内容 Http:/T¢ZKkjceixTjW¢转移至ta0寶【URBANISTA/爱班Stockholm斯德哥尔摩 真无线蓝牙运动耳机半入耳式】"; | // "6緮置内容 Http:/T¢ZKkjceixTjW¢转移至ta0寶【URBANISTA/爱班Stockholm斯德哥尔摩 真无线蓝牙运动耳机半入耳式】"; | ||||
var params = {"content": content}; | var params = {"content": content}; | ||||
NetUtil.request("/api/v1/clipboard/parse", | |||||
params: params, method: NetMethod.POST, onSuccess: (data) async { | |||||
NetUtil.request("/api/v1/clipboard/parse", params: params, method: NetMethod.POST, onSuccess: (data) async { | |||||
print(data); | print(data); | ||||
isRequest = false; | isRequest = false; | ||||
if (data == null || data.toString().length == 0) { | if (data == null || data.toString().length == 0) { | ||||
///弹起存在不存在商品的弹窗 | |||||
if (!Constants.isShowIntellectDialog) { | if (!Constants.isShowIntellectDialog) { | ||||
Constants.isShowIntellectDialog = true; | Constants.isShowIntellectDialog = true; | ||||
await showDialog( | |||||
context: context, child: IntellectSearchNoGoodsDialog()); | |||||
await showDialog(context: context, child: IntellectSearchNoGoodsDialog()); | |||||
Constants.isShowIntellectDialog = false; | Constants.isShowIntellectDialog = false; | ||||
} | } | ||||
} else if (data.toString() == "403032") { | |||||
//啥也不干 | |||||
} else { | } else { | ||||
IntellectDialogDataModel model = | |||||
IntellectDialogDataModel.fromJson(data); | |||||
///弹起存在商品的弹窗 | |||||
IntellectDialogDataModel model = IntellectDialogDataModel.fromJson(data); | |||||
if (!Constants.isShowIntellectDialog) { | if (!Constants.isShowIntellectDialog) { | ||||
Constants.isShowIntellectDialog = true; | Constants.isShowIntellectDialog = true; | ||||
await showDialog( | await showDialog( | ||||
@@ -116,8 +113,7 @@ class IntellectCreate { | |||||
} | } | ||||
///检查字段是否被监听 | ///检查字段是否被监听 | ||||
static void validate( | |||||
BuildContext context, IntellectSearchSetModel setModel) async { | |||||
static void validate(BuildContext context, IntellectSearchSetModel setModel) async { | |||||
ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain); | ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain); | ||||
String content = data?.text?.trim() ?? ""; | String content = data?.text?.trim() ?? ""; | ||||
//是否监听 | //是否监听 | ||||
@@ -130,9 +126,7 @@ class IntellectCreate { | |||||
} | } | ||||
///长度大小限制 | ///长度大小限制 | ||||
if (setModel.isKeyLength == "1" && | |||||
(int.tryParse(setModel.keyLengthMin) > content.length) || | |||||
(int.tryParse(setModel.keyLengthMax) < content.length)) { | |||||
if (setModel.isKeyLength == "1" && (int.tryParse(setModel.keyLengthMin) > content.length) || (int.tryParse(setModel.keyLengthMax) < content.length)) { | |||||
return; | return; | ||||
} | } | ||||
@@ -151,7 +145,7 @@ class IntellectCreate { | |||||
return; | return; | ||||
} | } | ||||
///是否包含某个排除词 | |||||
///是否包含某个排除词,如果是则不监听 | |||||
if (setModel.banWords != null && setModel.banWords.length > 0) { | if (setModel.banWords != null && setModel.banWords.length > 0) { | ||||
for (var item in setModel.banWords) { | for (var item in setModel.banWords) { | ||||
if (contains(content, item)) { | if (contains(content, item)) { | ||||
@@ -175,7 +175,7 @@ class _PolicyDialogState extends State<PolicyDialog> { | |||||
text: '', | text: '', | ||||
style: TextStyle( | style: TextStyle( | ||||
height: 1.2, | height: 1.2, | ||||
fontSize: 12, | |||||
fontSize: 14, | |||||
color: HexColor.fromHex('#555555'), | color: HexColor.fromHex('#555555'), | ||||
), | ), | ||||
children: texts, | children: texts, | ||||
@@ -156,9 +156,15 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver { | |||||
onTap: ((index) async { | onTap: ((index) async { | ||||
BaseTabModel model = BaseTabModel.fromJson(tabs[index]); | BaseTabModel model = BaseTabModel.fromJson(tabs[index]); | ||||
if (await _checkLimit(model)) { | if (await _checkLimit(model)) { | ||||
setState(() { | |||||
_currentIndex = index; | |||||
}); | |||||
///避免同一个页面多次点击多次重绘 | |||||
if(_currentIndex==index){ | |||||
return; | |||||
}else{ | |||||
setState(() { | |||||
_currentIndex = index; | |||||
}); | |||||
} | |||||
} | } | ||||
}), | }), | ||||
//底部导航栏 | //底部导航栏 | ||||
@@ -4,6 +4,8 @@ import 'package:connectivity/connectivity.dart'; | |||||
import 'package:flutter/cupertino.dart'; | import 'package:flutter/cupertino.dart'; | ||||
import 'package:flutter/foundation.dart'; | import 'package:flutter/foundation.dart'; | ||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:flutter/services.dart'; | |||||
import 'package:zhiying_base_widget/dialog/tip_dialog/tip_dialog.dart'; | |||||
import 'package:zhiying_base_widget/models/app_config_model.dart'; | import 'package:zhiying_base_widget/models/app_config_model.dart'; | ||||
import 'package:zhiying_base_widget/pages/guide_page/guide_page.dart'; | import 'package:zhiying_base_widget/pages/guide_page/guide_page.dart'; | ||||
import 'package:zhiying_base_widget/pages/home_page/home_page.dart'; | import 'package:zhiying_base_widget/pages/home_page/home_page.dart'; | ||||
@@ -27,7 +29,7 @@ class LaunchPage extends StatefulWidget { | |||||
class _LaunchPageState extends State<LaunchPage> { | class _LaunchPageState extends State<LaunchPage> { | ||||
@override | @override | ||||
void initState() { | void initState() { | ||||
Connectivity().checkConnectivity().then((connectivityResult) { | |||||
Connectivity().checkConnectivity().then((connectivityResult) async { | |||||
if (connectivityResult == ConnectivityResult.mobile || | if (connectivityResult == ConnectivityResult.mobile || | ||||
connectivityResult == ConnectivityResult.wifi) { | connectivityResult == ConnectivityResult.wifi) { | ||||
// I am connected to a wifi network. | // I am connected to a wifi network. | ||||
@@ -52,12 +54,19 @@ class _LaunchPageState extends State<LaunchPage> { | |||||
// CupertinoPageRoute(builder: (context) => HomePage())); | // CupertinoPageRoute(builder: (context) => HomePage())); | ||||
Navigator.of(context).pushReplacementNamed('/homePage'); | Navigator.of(context).pushReplacementNamed('/homePage'); | ||||
} | } | ||||
}).catchError((err) { | |||||
}).catchError((err) async { | |||||
if(err.toString().contains("BaseSettingModel")){ | |||||
await showDialog(context: context,child: TipDialog(content: "基本配置加载失败!请检查网络是否可用后再启动应用!",)); | |||||
SystemNavigator.pop(); | |||||
} | |||||
Logger.error(err); | Logger.error(err); | ||||
}); | }); | ||||
} else { | } else { | ||||
///在无网络情况下提示用户打开网络 | |||||
await showDialog(context: context,child: TipDialog(content: "无法连接网络!请打开移动网络/连接WIFI后再尝试",)); | |||||
Logger.error('未知网络,APP初始化失败'); | Logger.error('未知网络,APP初始化失败'); | ||||
print('unknow'); | print('unknow'); | ||||
SystemNavigator.pop(); | |||||
} | } | ||||
}); | }); | ||||
@@ -90,7 +99,7 @@ class _LaunchPageState extends State<LaunchPage> { | |||||
return Image.asset( | return Image.asset( | ||||
'assets/images/launch_image/launch_image.png', | 'assets/images/launch_image/launch_image.png', | ||||
package: 'zhiying_base_widget', | package: 'zhiying_base_widget', | ||||
fit: BoxFit.cover, | |||||
fit: BoxFit.fill, | |||||
); | ); | ||||
} | } | ||||
} | } |
@@ -1,3 +1,4 @@ | |||||
import 'dart:convert'; | |||||
import 'dart:ui'; | import 'dart:ui'; | ||||
import 'package:flutter/cupertino.dart'; | import 'package:flutter/cupertino.dart'; | ||||
@@ -8,6 +9,7 @@ import 'package:zhiying_base_widget/pages/main_page/main_page_bloc.dart'; | |||||
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; | import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; | ||||
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; | import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; | ||||
import 'package:zhiying_base_widget/widgets/home/home_auth/home_auth.dart'; | import 'package:zhiying_base_widget/widgets/home/home_auth/home_auth.dart'; | ||||
import 'package:zhiying_base_widget/widgets/mine/mine_nav/mine_nav_bg.dart'; | |||||
import 'package:zhiying_base_widget/widgets/others/mine_header_bg_widget.dart'; | import 'package:zhiying_base_widget/widgets/others/mine_header_bg_widget.dart'; | ||||
import 'package:zhiying_base_widget/widgets/refresh/refresh_header/refresh_header.dart'; | import 'package:zhiying_base_widget/widgets/refresh/refresh_header/refresh_header.dart'; | ||||
import 'package:zhiying_comm/util/base_bloc.dart'; | import 'package:zhiying_comm/util/base_bloc.dart'; | ||||
@@ -54,8 +56,7 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||||
bool _isEnded = false; | bool _isEnded = false; | ||||
ScrollController _controller = ScrollController(); | ScrollController _controller = ScrollController(); | ||||
MainPageBloc _bloc; | MainPageBloc _bloc; | ||||
RefreshController _refreshController = | |||||
RefreshController(initialRefresh: false); | |||||
RefreshController _refreshController = RefreshController(initialRefresh: false); | |||||
Widget _floatWidget; | Widget _floatWidget; | ||||
@@ -90,13 +91,11 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||||
_controller.addListener(() { | _controller.addListener(() { | ||||
// print('${_controller.offset} ${_controller.position.maxScrollExtent}'); | // print('${_controller.offset} ${_controller.position.maxScrollExtent}'); | ||||
if (_controller.offset >= _controller.position.maxScrollExtent && | |||||
!_isEnded) { | |||||
if (_controller.offset >= _controller.position.maxScrollExtent && !_isEnded) { | |||||
// 滑动到底部 | // 滑动到底部 | ||||
_isEnded = true; | _isEnded = true; | ||||
Provider.of<MainPageNotifier>(context, listen: false).loadMore(); | Provider.of<MainPageNotifier>(context, listen: false).loadMore(); | ||||
} else if (_controller.offset < _controller.position.maxScrollExtent && | |||||
_isEnded) { | |||||
} else if (_controller.offset < _controller.position.maxScrollExtent && _isEnded) { | |||||
_isEnded = false; | _isEnded = false; | ||||
Provider.of<MainPageNotifier>(context, listen: false).reset(); | Provider.of<MainPageNotifier>(context, listen: false).reset(); | ||||
} | } | ||||
@@ -113,11 +112,11 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||||
builder: (BuildContext context, AsyncSnapshot snapshot) { | builder: (BuildContext context, AsyncSnapshot snapshot) { | ||||
List widgets = _createContent(context, snapshot.data ?? []); | List widgets = _createContent(context, snapshot.data ?? []); | ||||
_refreshController.refreshCompleted(); | _refreshController.refreshCompleted(); | ||||
Widget bgWidget = validateBgWidget(context, snapshot.data ?? []); | |||||
return Scaffold( | return Scaffold( | ||||
backgroundColor: Color(0xfff9f9f9), | backgroundColor: Color(0xfff9f9f9), | ||||
floatingActionButton: _floatWidget, | floatingActionButton: _floatWidget, | ||||
floatingActionButtonLocation: | |||||
FloatingActionButtonLocation.centerDocked, | |||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, | |||||
body: MediaQuery.removePadding( | body: MediaQuery.removePadding( | ||||
removeTop: true, | removeTop: true, | ||||
context: context, | context: context, | ||||
@@ -127,6 +126,7 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||||
fit: StackFit.passthrough, | fit: StackFit.passthrough, | ||||
children: <Widget>[ | children: <Widget>[ | ||||
MineHeaderBgWidget( | MineHeaderBgWidget( | ||||
bgWidget: bgWidget, | |||||
controller: _controller, | controller: _controller, | ||||
), | ), | ||||
SmartRefresher( | SmartRefresher( | ||||
@@ -151,12 +151,10 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||||
}); | }); | ||||
} | } | ||||
List<Widget> _createContent( | |||||
BuildContext context, List<Map<String, dynamic>> datas) { | |||||
List<Widget> _createContent(BuildContext context, List<Map<String, dynamic>> datas) { | |||||
List<Widget> list = List(); | List<Widget> list = List(); | ||||
for (int i = 0; i < datas.length; i++) { | for (int i = 0; i < datas.length; i++) { | ||||
WidgetModel item = | |||||
WidgetModel.fromJson(Map<String, dynamic>.from(datas[i])); | |||||
WidgetModel item = WidgetModel.fromJson(Map<String, dynamic>.from(datas[i])); | |||||
print('item.modName ${item.modName}'); | print('item.modName ${item.modName}'); | ||||
if (item.modName == 'index_taobao_auth_tip') { | if (item.modName == 'index_taobao_auth_tip') { | ||||
@@ -181,4 +179,26 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||||
} | } | ||||
return list; | return list; | ||||
} | } | ||||
///处理特殊背景图 | |||||
Widget validateBgWidget(BuildContext context, List<Map<String, dynamic>> datas) { | |||||
for (int i = 0; i < datas.length; i++) { | |||||
WidgetModel item = WidgetModel.fromJson(Map<String, dynamic>.from(datas[i])); | |||||
if (item.modName == "profile_background") { | |||||
final double statusBarHeight = MediaQuery.of(context).padding.top; | |||||
String url=json.decode(item.data)['img']; | |||||
return Container( | |||||
width: double.infinity, | |||||
height: statusBarHeight + 250, | |||||
child: CachedNetworkImage( | |||||
imageUrl: url, | |||||
fit: BoxFit.fitHeight, | |||||
), | |||||
); | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
} | } |
@@ -7,7 +7,7 @@ class MainPageBloc extends BlocBase { | |||||
List<Map<String, dynamic>> _pageData = List(); | List<Map<String, dynamic>> _pageData = List(); | ||||
StreamController<List<Map<String, dynamic>>> _mainController = | StreamController<List<Map<String, dynamic>>> _mainController = | ||||
StreamController<List<Map<String, dynamic>>>(); | |||||
StreamController<List<Map<String, dynamic>>>.broadcast(); | |||||
Stream<List<Map<String, dynamic>>> get outData => _mainController.stream; | Stream<List<Map<String, dynamic>>> get outData => _mainController.stream; | ||||
@@ -102,7 +102,7 @@ class BaseWidgetRegister { | |||||
static void registInit() { | static void registInit() { | ||||
Application.addMethod(() async { | Application.addMethod(() async { | ||||
if (await BaseSettingModel.init() == null) { | if (await BaseSettingModel.init() == null) { | ||||
throw Future.error('BaseSettingModel 初始化失败'); | |||||
throw Exception('BaseSettingModel 初始化失败'); | |||||
} | } | ||||
}); | }); | ||||
@@ -90,6 +90,16 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> | |||||
// 展示的列数 | // 展示的列数 | ||||
int columSize = int.parse(model?.columSize ?? '5'); | int columSize = int.parse(model?.columSize ?? '5'); | ||||
//计算实际显示行数 | |||||
if(totalRowSize*columSize>totalDataSize){ | |||||
for(int index=1;index<=totalRowSize;index++){ | |||||
if(index*columSize>=totalRowSize){ | |||||
totalRowSize=index; | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
// 图标的高度 | // 图标的高度 | ||||
double iconHeight = 40.0; | double iconHeight = 40.0; | ||||
// 标题的高度 | // 标题的高度 | ||||
@@ -19,8 +19,7 @@ class HomeGoodsItemSingle extends StatelessWidget { | |||||
final double marginTop; | final double marginTop; | ||||
final double marginBottom; | final double marginBottom; | ||||
HomeGoodsItemSingle(this.goods, this.style, {Key key, this.data, this.marginBottom = 4, this.marginTop = 4, this.marginLeft= 12.5, this.marginRight = 12.5}) | |||||
: super(key: key) { | |||||
HomeGoodsItemSingle(this.goods, this.style, {Key key, this.data, this.marginBottom = 4, this.marginTop = 4, this.marginLeft = 12.5, this.marginRight = 12.5}) : super(key: key) { | |||||
if (this.data != null && this.data.containsKey('data')) { | if (this.data != null && this.data.containsKey('data')) { | ||||
String data = this.data['data']; | String data = this.data['data']; | ||||
Map<String, dynamic> json = Map<String, dynamic>.from(jsonDecode(data)); | Map<String, dynamic> json = Map<String, dynamic>.from(jsonDecode(data)); | ||||
@@ -31,8 +30,7 @@ class HomeGoodsItemSingle extends StatelessWidget { | |||||
/// 跳到商品详情 | /// 跳到商品详情 | ||||
void _onJumpGoodsDetails(BuildContext context, HomeGoodsModel goods) { | void _onJumpGoodsDetails(BuildContext context, HomeGoodsModel goods) { | ||||
RouterUtil.hideKeyboard(context); | RouterUtil.hideKeyboard(context); | ||||
Navigator.push(context, | |||||
CupertinoPageRoute(builder: (_) => GoodsDetailsPage(goods.toJson()))); | |||||
Navigator.push(context, CupertinoPageRoute(builder: (_) => GoodsDetailsPage(goods.toJson()))); | |||||
} | } | ||||
@override | @override | ||||
@@ -42,9 +40,7 @@ class HomeGoodsItemSingle extends StatelessWidget { | |||||
child: Container( | child: Container( | ||||
margin: EdgeInsets.only(left: marginLeft, right: marginRight, top: marginTop, bottom: marginBottom), | margin: EdgeInsets.only(left: marginLeft, right: marginRight, top: marginTop, bottom: marginBottom), | ||||
padding: EdgeInsets.all(7.5), | padding: EdgeInsets.all(7.5), | ||||
decoration: BoxDecoration( | |||||
color: Colors.white, | |||||
borderRadius: BorderRadius.all(Radius.circular(7.5))), | |||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(7.5))), | |||||
child: Row( | child: Row( | ||||
crossAxisAlignment: CrossAxisAlignment.start, | crossAxisAlignment: CrossAxisAlignment.start, | ||||
children: <Widget>[ | children: <Widget>[ | ||||
@@ -71,10 +67,12 @@ class HomeGoodsItemSingle extends StatelessWidget { | |||||
width: double.infinity, | width: double.infinity, | ||||
child: _createTitle(), | child: _createTitle(), | ||||
), | ), | ||||
_createShop(), | |||||
style?.listStyle?.hotRank?.isOpen == "0" ? _createShop() : Container(), | |||||
_createCupone(), | _createCupone(), | ||||
Expanded(child: Container()), | |||||
style?.listStyle?.hotRank?.isOpen == "0"? Expanded(child: Container()):Container(), | |||||
_createBottom(), | _createBottom(), | ||||
style?.listStyle?.hotRank?.isOpen == "1"? Expanded(child: Container()):Container(), | |||||
style?.listStyle?.hotRank?.isOpen == "1"? _buildHotItem():Container() | |||||
], | ], | ||||
), | ), | ||||
), | ), | ||||
@@ -122,10 +120,7 @@ class HomeGoodsItemSingle extends StatelessWidget { | |||||
} | } | ||||
list.add(TextSpan( | list.add(TextSpan( | ||||
text: goods.goodTitle, | text: goods.goodTitle, | ||||
style: TextStyle( | |||||
fontSize: 15, | |||||
color: HexColor.fromHex('#333333'), | |||||
fontWeight: FontWeight.bold), | |||||
style: TextStyle(fontSize: 15, color: HexColor.fromHex('#333333'), fontWeight: FontWeight.bold), | |||||
)); | )); | ||||
return RichText( | return RichText( | ||||
maxLines: 2, | maxLines: 2, | ||||
@@ -153,11 +148,7 @@ class HomeGoodsItemSingle extends StatelessWidget { | |||||
child: Text( | child: Text( | ||||
goods.shopName, | goods.shopName, | ||||
maxLines: 1, | maxLines: 1, | ||||
style: TextStyle( | |||||
color: HexColor.fromHex( | |||||
style?.listStyle?.shopNameColor ?? '#666666'), | |||||
fontSize: 11, | |||||
fontWeight: FontWeight.w400), | |||||
style: TextStyle(color: HexColor.fromHex(style?.listStyle?.shopNameColor ?? '#666666'), fontSize: 11, fontWeight: FontWeight.w400), | |||||
)) | )) | ||||
], | ], | ||||
), | ), | ||||
@@ -170,15 +161,12 @@ class HomeGoodsItemSingle extends StatelessWidget { | |||||
var couponDe = style?.listStyle?.couponCommission?.coupon?.bgImg == 'img' | var couponDe = style?.listStyle?.couponCommission?.coupon?.bgImg == 'img' | ||||
? BoxDecoration( | ? BoxDecoration( | ||||
image: DecorationImage( | image: DecorationImage( | ||||
image: CachedNetworkImageProvider( | |||||
style?.listStyle?.couponCommission?.coupon?.bgImg ?? | |||||
''), | |||||
image: CachedNetworkImageProvider(style?.listStyle?.couponCommission?.coupon?.bgImg ?? ''), | |||||
), | ), | ||||
borderRadius: BorderRadius.circular(2.5), | borderRadius: BorderRadius.circular(2.5), | ||||
) | ) | ||||
: BoxDecoration( | : BoxDecoration( | ||||
color: HexColor.fromHex( | |||||
style?.listStyle?.couponCommission?.coupon?.bgColor), | |||||
color: HexColor.fromHex(style?.listStyle?.couponCommission?.coupon?.bgColor), | |||||
borderRadius: BorderRadius.circular(2.5), | borderRadius: BorderRadius.circular(2.5), | ||||
); | ); | ||||
@@ -210,18 +198,15 @@ class HomeGoodsItemSingle extends StatelessWidget { | |||||
style: TextStyle( | style: TextStyle( | ||||
height: 1, | height: 1, | ||||
fontSize: 11, | fontSize: 11, | ||||
color: HexColor.fromHex(style | |||||
?.listStyle?.couponCommission?.coupon?.fontColor), | |||||
color: HexColor.fromHex(style?.listStyle?.couponCommission?.coupon?.fontColor), | |||||
), | ), | ||||
children: [ | children: [ | ||||
TextSpan( | TextSpan( | ||||
text: | |||||
'${style?.listStyle?.couponCommission?.coupon?.text ?? '元劵'}', | |||||
text: '${style?.listStyle?.couponCommission?.coupon?.text ?? '元劵'}', | |||||
style: TextStyle( | style: TextStyle( | ||||
height: 1, | height: 1, | ||||
fontSize: 11, | fontSize: 11, | ||||
color: HexColor.fromHex(style | |||||
?.listStyle?.couponCommission?.coupon?.fontColor), | |||||
color: HexColor.fromHex(style?.listStyle?.couponCommission?.coupon?.fontColor), | |||||
), | ), | ||||
) | ) | ||||
]), | ]), | ||||
@@ -230,21 +215,17 @@ class HomeGoodsItemSingle extends StatelessWidget { | |||||
} | } | ||||
if (goods.commission != null || goods.commission != '') { | if (goods.commission != null || goods.commission != '') { | ||||
var commissionDe = | |||||
style?.listStyle?.couponCommission?.commission?.bgType == 'img' | |||||
? BoxDecoration( | |||||
image: DecorationImage( | |||||
image: CachedNetworkImageProvider(style?.listStyle | |||||
?.couponCommission?.commission?.bgImg ?? | |||||
''), | |||||
), | |||||
borderRadius: BorderRadius.circular(2.5), | |||||
) | |||||
: BoxDecoration( | |||||
color: HexColor.fromHex(style?.listStyle?.couponCommission | |||||
?.commission?.bgColor), | |||||
borderRadius: BorderRadius.circular(2.5), | |||||
); | |||||
var commissionDe = style?.listStyle?.couponCommission?.commission?.bgType == 'img' | |||||
? BoxDecoration( | |||||
image: DecorationImage( | |||||
image: CachedNetworkImageProvider(style?.listStyle?.couponCommission?.commission?.bgImg ?? ''), | |||||
), | |||||
borderRadius: BorderRadius.circular(2.5), | |||||
) | |||||
: BoxDecoration( | |||||
color: HexColor.fromHex(style?.listStyle?.couponCommission?.commission?.bgColor), | |||||
borderRadius: BorderRadius.circular(2.5), | |||||
); | |||||
widgets.add( | widgets.add( | ||||
Container( | Container( | ||||
@@ -270,8 +251,7 @@ class HomeGoodsItemSingle extends StatelessWidget { | |||||
maxLines: 1, | maxLines: 1, | ||||
textAlign: TextAlign.center, | textAlign: TextAlign.center, | ||||
text: TextSpan( | text: TextSpan( | ||||
text: | |||||
'${style?.listStyle?.couponCommission?.commission?.text ?? ''}', | |||||
text: '${style?.listStyle?.couponCommission?.commission?.text ?? ''}', | |||||
style: TextStyle( | style: TextStyle( | ||||
height: 1, | height: 1, | ||||
fontSize: 11, | fontSize: 11, | ||||
@@ -308,7 +288,7 @@ class HomeGoodsItemSingle extends StatelessWidget { | |||||
_createPrice(), | _createPrice(), | ||||
_createOriginPrice(), | _createOriginPrice(), | ||||
Expanded(child: Container()), | Expanded(child: Container()), | ||||
_createSale(), | |||||
style?.listStyle?.hotRank?.isOpen == "0"? _createSale():Container(), | |||||
], | ], | ||||
), | ), | ||||
); | ); | ||||
@@ -366,4 +346,71 @@ class HomeGoodsItemSingle extends StatelessWidget { | |||||
style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999')), | style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999')), | ||||
); | ); | ||||
} | } | ||||
///热点 | |||||
_buildHotItem() { | |||||
var hotRank=style?.listStyle?.hotRank; | |||||
return Row( | |||||
children: <Widget>[ | |||||
Expanded( | |||||
child: Stack( | |||||
alignment: Alignment.centerLeft, | |||||
children: <Widget>[ | |||||
Row( | |||||
children: <Widget>[ | |||||
Expanded( | |||||
child: Container( | |||||
alignment: Alignment.centerLeft, | |||||
height: 20, | |||||
padding: EdgeInsets.only( | |||||
left: 20, | |||||
), | |||||
margin: | |||||
EdgeInsets.only(right: 20, left: 10), | |||||
color: HexColor.fromHex( | |||||
hotRank.bgColor ?? ""), | |||||
child: Text( | |||||
(goods.inorderCount??"") , | |||||
style: TextStyle( | |||||
color: Colors.white, | |||||
fontSize: 11, | |||||
fontFamily: 'Din', | |||||
package: 'zhiying_comm'), | |||||
), | |||||
)) | |||||
], | |||||
), | |||||
Container( | |||||
width: 24, | |||||
height: 24, | |||||
child: CachedNetworkImage( | |||||
imageUrl: | |||||
hotRank?.hotSaleImg ?? "", | |||||
width: 24, | |||||
height: 24, | |||||
placeholder: (context, _) => | |||||
Container(color: Colors.yellow), | |||||
fit: BoxFit.fill, | |||||
), | |||||
), | |||||
Align( | |||||
alignment: Alignment.centerRight, | |||||
child: Container( | |||||
height: 24, | |||||
width: 63.5, | |||||
decoration: BoxDecoration( | |||||
image: DecorationImage( | |||||
image: CachedNetworkImageProvider( | |||||
hotRank.buyNowImg ?? | |||||
""), | |||||
fit: BoxFit.fitWidth), | |||||
borderRadius: | |||||
BorderRadius.circular(20)), | |||||
margin: EdgeInsets.only(right: 0), | |||||
)) | |||||
], | |||||
)) | |||||
], | |||||
); | |||||
} | |||||
} | } |
@@ -5,6 +5,10 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; | |||||
import 'package:zhiying_base_widget/dialog/loading/loading.dart'; | import 'package:zhiying_base_widget/dialog/loading/loading.dart'; | ||||
import 'package:zhiying_base_widget/dialog/loading/loading_dialog.dart'; | import 'package:zhiying_base_widget/dialog/loading/loading_dialog.dart'; | ||||
import 'package:zhiying_base_widget/pages/hot_ranking_page/hot_ranking_page_bloc.dart'; | import 'package:zhiying_base_widget/pages/hot_ranking_page/hot_ranking_page_bloc.dart'; | ||||
import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_item_single.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_list_style_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_style_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_goods/hot_ranking_goods.dart'; | import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_goods/hot_ranking_goods.dart'; | ||||
import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_data_model.dart'; | import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_data_model.dart'; | ||||
import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_model.dart'; | import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_model.dart'; | ||||
@@ -29,7 +33,7 @@ class _HotRankingState extends State<HotRankingList> | |||||
HotRankingListBloc _bloc; | HotRankingListBloc _bloc; | ||||
TabController _tabController; | TabController _tabController; | ||||
RefreshController _refreshController; | RefreshController _refreshController; | ||||
List<Good> goods; | |||||
List<HomeGoodsModel> goods; | |||||
HotRankingPageBloc _pageBloc; | HotRankingPageBloc _pageBloc; | ||||
@@ -119,12 +123,15 @@ class _HotRankingState extends State<HotRankingList> | |||||
} | } | ||||
Widget _buildListItem(BuildContext context, int index) { | Widget _buildListItem(BuildContext context, int index) { | ||||
return HotRankingGoods( | |||||
styleModel: | |||||
HotRankingListModel.fromJson(json.decode(widget.data['data'])), | |||||
good: goods[index], | |||||
index: index, | |||||
); | |||||
HomeGoodsStyleModel homeGoodsStyleModel=HomeGoodsStyleModel(); | |||||
homeGoodsStyleModel.listStyle=HomeGoodsListStyleModel.fromJson(json.decode(widget.data['data'])); | |||||
return HomeGoodsItemSingle(goods[index],homeGoodsStyleModel); | |||||
// return HotRankingGoods( | |||||
// styleModel: | |||||
// HotRankingListModel.fromJson(json.decode(widget.data['data'])), | |||||
// good: goods[index], | |||||
// index: index, | |||||
// ); | |||||
} | } | ||||
@override | @override | ||||
@@ -1,15 +1,17 @@ | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_model.dart'; | |||||
class HotRankingListDataModel { | class HotRankingListDataModel { | ||||
String provider; | String provider; | ||||
List<Good> good; | |||||
List<HomeGoodsModel> good; | |||||
HotRankingListDataModel({this.provider, this.good}); | HotRankingListDataModel({this.provider, this.good}); | ||||
HotRankingListDataModel.fromJson(Map<String, dynamic> json) { | HotRankingListDataModel.fromJson(Map<String, dynamic> json) { | ||||
provider = json['provider']; | provider = json['provider']; | ||||
if (json['good'] != null) { | if (json['good'] != null) { | ||||
good = new List<Good>(); | |||||
good = new List<HomeGoodsModel>(); | |||||
json['good'].forEach((v) { | json['good'].forEach((v) { | ||||
good.add(new Good.fromJson(v)); | |||||
good.add(new HomeGoodsModel.fromJson(v)); | |||||
}); | }); | ||||
} | } | ||||
} | } | ||||
@@ -50,7 +50,6 @@ class _MineStaticContainerState extends State<MineStaticContainer> { | |||||
children: <Widget>[ | children: <Widget>[ | ||||
Container( | Container( | ||||
width: 120, | width: 120, | ||||
height: 20, | |||||
child: Text( | child: Text( | ||||
widget.staticModel.loginName, | widget.staticModel.loginName, | ||||
style: TextStyle( | style: TextStyle( | ||||
@@ -9,12 +9,13 @@ import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifi | |||||
class MineNavBg extends StatefulWidget { | class MineNavBg extends StatefulWidget { | ||||
final Map<String, dynamic> data; | final Map<String, dynamic> data; | ||||
Map<String, dynamic> model; | Map<String, dynamic> model; | ||||
MineNavBg(this.data, {Key key}) : super(key: key){ | |||||
try{ | |||||
model = jsonDecode(data['data']); | |||||
} catch(e,s){ | |||||
Logger.error(e,s); | |||||
} | |||||
MineNavBg(this.data, {Key key}) : super(key: key) { | |||||
try { | |||||
model = jsonDecode(data['data']); | |||||
} catch (e, s) { | |||||
Logger.error(e, s); | |||||
} | |||||
} | } | ||||
@override | @override | ||||
@@ -22,6 +23,8 @@ class MineNavBg extends StatefulWidget { | |||||
} | } | ||||
class _MineNavBgState extends State<MineNavBg> { | class _MineNavBgState extends State<MineNavBg> { | ||||
int isFirst = 0; | |||||
@override | @override | ||||
void initState() { | void initState() { | ||||
super.initState(); | super.initState(); | ||||
@@ -45,9 +48,10 @@ class _MineNavBgState extends State<MineNavBg> { | |||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
Future.delayed(Duration.zero, () { | |||||
_updateBg(); | |||||
}); | |||||
return Container(); | |||||
// Future.delayed(Duration.zero, () { | |||||
// print("使用" + isFirst.toString()); | |||||
// _updateBg(); | |||||
// }); | |||||
return Container(); | |||||
} | } | ||||
} | } |
@@ -1,11 +1,17 @@ | |||||
import 'dart:async'; | |||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:provider/provider.dart'; | import 'package:provider/provider.dart'; | ||||
import 'package:zhiying_base_widget/pages/main_page/main_page_bloc.dart'; | |||||
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; | import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; | ||||
import 'package:zhiying_comm/util/base_bloc.dart'; | |||||
import ''; | |||||
class MineHeaderBgWidget extends StatefulWidget { | class MineHeaderBgWidget extends StatefulWidget { | ||||
final ScrollController controller; | |||||
ScrollController controller; | |||||
Widget bgWidget; | |||||
const MineHeaderBgWidget({Key key, this.controller}) : super(key: key); | |||||
MineHeaderBgWidget({Key key, this.controller, this.bgWidget}) : super(key: key); | |||||
@override | @override | ||||
_MineHeaderBgWidgetState createState() => _MineHeaderBgWidgetState(); | _MineHeaderBgWidgetState createState() => _MineHeaderBgWidgetState(); | ||||
@@ -15,12 +21,10 @@ class _MineHeaderBgWidgetState extends State<MineHeaderBgWidget> { | |||||
int zIndex = 0; | int zIndex = 0; | ||||
double _offsetY = 0; | double _offsetY = 0; | ||||
double _height = 300; | double _height = 300; | ||||
_MineHeaderBgContainer _content; | |||||
@override | @override | ||||
void initState() { | void initState() { | ||||
super.initState(); | super.initState(); | ||||
_content = _MineHeaderBgContainer(); | |||||
if (widget.controller != null) { | if (widget.controller != null) { | ||||
widget.controller.addListener(() { | widget.controller.addListener(() { | ||||
@@ -41,20 +45,28 @@ class _MineHeaderBgWidgetState extends State<MineHeaderBgWidget> { | |||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
return Transform.translate( | return Transform.translate( | ||||
offset: Offset(0, _offsetY), | offset: Offset(0, _offsetY), | ||||
child: _content, | |||||
child: _MineHeaderBgContainer(bgWidget: widget?.bgWidget), | |||||
); | ); | ||||
} | } | ||||
} | } | ||||
class _MineHeaderBgContainer extends StatefulWidget { | class _MineHeaderBgContainer extends StatefulWidget { | ||||
Widget bgWidget; | |||||
_MineHeaderBgContainer({Key key, this.bgWidget}) : super(key: key); | |||||
@override | @override | ||||
_MineHeaderBgContainerState createState() => _MineHeaderBgContainerState(); | _MineHeaderBgContainerState createState() => _MineHeaderBgContainerState(); | ||||
} | } | ||||
class _MineHeaderBgContainerState extends State<_MineHeaderBgContainer> { | class _MineHeaderBgContainerState extends State<_MineHeaderBgContainer> { | ||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
print('_MineHeaderBgContainerState build'); | print('_MineHeaderBgContainerState build'); | ||||
if (widget.bgWidget != null) { | |||||
return widget.bgWidget; | |||||
} | |||||
return Consumer<MainPageBgNotifier>(builder: (context, model, widget) { | return Consumer<MainPageBgNotifier>(builder: (context, model, widget) { | ||||
return Stack( | return Stack( | ||||
fit: StackFit.passthrough, | fit: StackFit.passthrough, | ||||