Browse Source

1.优化商品列表TabBar点击多次加载页数增加的问题

2.优化订单页面显示
tags/0.0.4+9
“yanghuaxuan” 3 years ago
parent
commit
2379305153
6 changed files with 131 additions and 55 deletions
  1. +27
    -27
      example/android/app/build.gradle
  2. +1
    -1
      example/pubspec.yaml
  3. +5
    -3
      lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart
  4. +80
    -18
      lib/pages/orders_page/views/order_item_widget.dart
  5. +17
    -6
      lib/widgets/home/home_goods/bloc/home_goods_bloc.dart
  6. +1
    -0
      lib/widgets/home/home_goods/home_goods.dart

+ 27
- 27
example/android/app/build.gradle View File

@@ -108,33 +108,33 @@ android {




// 应用信息配置 // 应用信息配置
// productFlavors {
// // 智夜生活
// zhiying {
// applicationId "cn.zhios.zhiying"
// versionCode 37
// dimension "app"
// versionName '1.2.37'
// // 签名信息
// signingConfig signingConfigs.zhiying
// }
// }
//
// // 打包脚本
// android.applicationVariants.all { variant ->
// if (variant.buildType.name != "debug") {
// variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/app/build/outputs/apk")
// }
//
// variant.outputs.all { output ->
// def outputFile = output.outputFile
// if (outputFile != null && outputFile.name.endsWith('.apk')) {
// //这里修改apk文件名
// def fileName = "${variant.productFlavors[0].name}_${releaseTime()}01_&V${variant.productFlavors[0].versionCode}.apk"
// outputFileName = fileName
// }
// }
// }
productFlavors {
// 智夜生活
zhiying {
applicationId "cn.zhios.zhiying"
versionCode 38
dimension "app"
versionName '1.2.38'
// 签名信息
signingConfig signingConfigs.zhiying
}
}
// 打包脚本
android.applicationVariants.all { variant ->
if (variant.buildType.name != "debug") {
variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/app/build/outputs/apk")
}
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
//这里修改apk文件名
def fileName = "${variant.productFlavors[0].name}_${releaseTime()}01_&V${variant.productFlavors[0].versionCode}.apk"
outputFileName = fileName
}
}
}


configurations.all { configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details -> resolutionStrategy.eachDependency { DependencyResolveDetails details ->


+ 1
- 1
example/pubspec.yaml View File

@@ -38,7 +38,7 @@ dev_dependencies:
zhiying_moments: zhiying_moments:
#path: ../zhiying_moments #path: ../zhiying_moments
git: git:
ref: 0.0.4
ref: 0.0.5
url: http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_moments.git url: http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_moments.git


# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the


+ 5
- 3
lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart View File

@@ -353,18 +353,20 @@ class _IntellectSearchGoodsDialogState
return; return;
} else { } else {
print("平台" + widget?.model?.provider ?? ""); print("平台" + widget?.model?.provider ?? "");
if(!widget?.model?.couponUrl.contains("http")){
widget?.model?.couponUrl="https:"+widget?.model?.couponUrl;
}
widget?.model?.couponUrl=widget?.model?.couponUrl.replaceAll("\\", "");
print("链接" + widget?.model?.couponUrl ?? ""); print("链接" + widget?.model?.couponUrl ?? "");
if (widget?.model?.provider == 'taobao') { if (widget?.model?.provider == 'taobao') {
TradeResult result; TradeResult result;
if (Platform.isAndroid) { if (Platform.isAndroid) {
result = await FlutterAlibc.openByUrl( result = await FlutterAlibc.openByUrl(
url: widget?.model?.couponUrl ?? "", url: widget?.model?.couponUrl ?? "",
openType: AlibcOpenType.AlibcOpenTypeNative,
backUrl: "alisdk://"); backUrl: "alisdk://");
} else if (Platform.isIOS) { } else if (Platform.isIOS) {
result = await FlutterAlibc.openByUrl( result = await FlutterAlibc.openByUrl(
url: widget?.model?.couponUrl ?? "",
openType: AlibcOpenType.AlibcOpenTypeNative,
url: widget?.model?.couponUrl ?? ""
); );
} }
Logger.debug('${result.errorCode} ${result.errorMessage} '); Logger.debug('${result.errorCode} ${result.errorMessage} ');


+ 80
- 18
lib/pages/orders_page/views/order_item_widget.dart View File

@@ -1,4 +1,5 @@
import 'dart:io'; import 'dart:io';
import 'dart:ui';


import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@@ -66,7 +67,7 @@ class OrderItemWidget extends StatelessWidget {
color: Color(0xff333333), color: Color(0xff333333),
), ),
), ),
(model?.priceName == null|| model?.priceName.length==0)
(model?.priceName == null || model?.priceName.length == 0)
? Container() ? Container()
: Container( : Container(
decoration: BoxDecoration(color: Colors.red, borderRadius: BorderRadius.circular(4)), decoration: BoxDecoration(color: Colors.red, borderRadius: BorderRadius.circular(4)),
@@ -95,6 +96,8 @@ class OrderItemWidget extends StatelessWidget {
} }


Widget _createCenter() { Widget _createCenter() {
List<OrderStateModel> states = style.list.orderState;
OrderStateModel state = states.firstWhere((element) => element.type == model.state.toString());
return Row( return Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
@@ -147,21 +150,34 @@ class OrderItemWidget extends StatelessWidget {
], ],
), ),
_creteText('${style?.list?.textOrderTime ?? ''}${model?.createAt ?? ''}'), _creteText('${style?.list?.textOrderTime ?? ''}${model?.createAt ?? ''}'),
_creteText('${style?.list?.textFinishTime ?? ''}${model?.confirmAt ?? ''}'),
Row(
_creteText('${style?.list?.textFinishTime ?? ''}${model?.confirmAt ?? '---'}'),
state.type!='4' ? Row(
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: <Widget>[ children: <Widget>[
_cretePriceText('订单金额:${model?.itemPrice??''}'),
_cretePriceText('${state?.amountText}${model?.paidPrice ?? ''}'),
Spacer(), Spacer(),
Row( Row(
crossAxisAlignment: CrossAxisAlignment.baseline, crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.ideographic,
textBaseline: TextBaseline.alphabetic,
children: <Widget>[ children: <Widget>[
Text("收益:¥",style: TextStyle(color: HexColor.fromHex("#FFFF4242"),fontSize: 10),),
Text(model?.userCommission??"",style: TextStyle(color: HexColor.fromHex("#FFFF4242"),fontSize: 18),)
Text(
'${state?.incomeText??""}',
style: TextStyle(color: HexColor.fromHex("#FFFF4242"), fontSize: 10),
),
Text(
model?.userCommission ?? "",
style: TextStyle(color: HexColor.fromHex("#FFFF4242"), fontSize: 18),
)
], ],
) )
], ],
)
):
Row(
children: <Widget>[
Text(state?.tips.replaceAll(state?.tipsReplaceKey, model?.reason??""),style: TextStyle(color: HexColor.fromHex("#FFFF4242"),fontSize: 12),)
],
)
], ],
), ),
) )
@@ -224,15 +240,15 @@ class OrderItemWidget extends StatelessWidget {
return text == null || text == '' return text == null || text == ''
? Container() ? Container()
: Padding( : Padding(
padding: EdgeInsets.only(top: 2, bottom: 2),
child: Text(
text,
style: TextStyle(
fontSize: 10,
color: HexColor.fromHex("#FF333333"),
),
),
);
padding: EdgeInsets.only(top: 2, bottom: 2),
child: Text(
text,
style: TextStyle(
fontSize: 10,
color: HexColor.fromHex("#FF333333"),
),
),
);
} }


Widget _createTips() { Widget _createTips() {
@@ -241,13 +257,59 @@ class OrderItemWidget extends StatelessWidget {
if (state == null || state.tips == null || state.tips == '') { if (state == null || state.tips == null || state.tips == '') {
return Container(); return Container();
} }
Widget centerWidget;
String str1;
String str2;
if (state.type == '3' || state.type == '4') {
// state?.tips=(state?.tips ?? '').replaceAll(state?.tipsReplaceKey,model?.reason);
// state?.tips=(state?.tips ?? '').replaceAll(state?.tipsReplaceKey,"2007-0808");

var strs = state.tips.split(state?.tipsReplaceKey);
if (strs.length >= 1) {
str1 = strs[0];
}
if (strs.length >= 2) {
str2 = strs[1];
}

///时间
if (state.type == '3') {
centerWidget = Text(
(model.settleAt ?? ''),
style: TextStyle(color: HexColor.fromHex(state?.tipsReplaceColor ?? ""), fontSize: 10),
);
}

///失效原因
if (state.type == '4') {
centerWidget = Text(
(model.reason ?? ''),
style: TextStyle(color: HexColor.fromHex(state?.tipsReplaceColor ?? ""), fontSize: 10),
);

}
}

if (centerWidget != null) {
return Container(
margin: EdgeInsets.only(top: 8),
padding: EdgeInsets.only(left: 8, right: 8, top: 2, bottom: 2),
width: double.infinity,
decoration: BoxDecoration(color: HexColor.fromHex(style.list.colorTipsBg ?? '#f5f5f5'), borderRadius: BorderRadius.circular(4)),
child: Row(children: [
Text(str1 ?? "", style: TextStyle(color: Color(0xff666666), fontSize: 10)),
centerWidget,
Text(str2 ?? "", style: TextStyle(color: Color(0xff666666), fontSize: 10)),
]));
}

return Container( return Container(
margin: EdgeInsets.only(top: 8), margin: EdgeInsets.only(top: 8),
padding: EdgeInsets.only(left: 8, right: 8, top: 2, bottom: 2), padding: EdgeInsets.only(left: 8, right: 8, top: 2, bottom: 2),
width: double.infinity, width: double.infinity,
decoration: BoxDecoration(color: HexColor.fromHex(style.list.colorTipsBg ?? '#f5f5f5'), borderRadius: BorderRadius.circular(4)), decoration: BoxDecoration(color: HexColor.fromHex(style.list.colorTipsBg ?? '#f5f5f5'), borderRadius: BorderRadius.circular(4)),
child: Text( child: Text(
state?.tips ?? '',
(state?.tips ?? ''),
style: TextStyle(color: Color(0xff666666), fontSize: 10), style: TextStyle(color: Color(0xff666666), fontSize: 10),
), ),
); );


+ 17
- 6
lib/widgets/home/home_goods/bloc/home_goods_bloc.dart View File

@@ -12,7 +12,7 @@ class HomeGoodsBloc extends BlocBase implements CategoryGoodsOnClickCallBack {
dynamic _provider; dynamic _provider;


String providerss = ''; String providerss = '';
int _page = 1;
int page = 1;


StreamController<List<HomeGoodsModel>> _goodsController = StreamController<List<HomeGoodsModel>>(); StreamController<List<HomeGoodsModel>> _goodsController = StreamController<List<HomeGoodsModel>>();


@@ -24,20 +24,30 @@ class HomeGoodsBloc extends BlocBase implements CategoryGoodsOnClickCallBack {
_goodsController = null; _goodsController = null;
} }


bool loading=false;

void loadMore(dynamic provider) { void loadMore(dynamic provider) {
///避免多次下拉刷新出现跳页加载的情况
if(loading){
return ;
}
loading=true;
Timer(Duration(milliseconds: 2000), (){
loading=false;
});
if (provider != _provider) { if (provider != _provider) {
_page = 1;
page = 1;
} }
_provider = provider; _provider = provider;


if (_page == 1) {
if (page == 1) {
_goods.clear(); _goods.clear();
} }


NetUtil.request('/api/v1/rec?page=${_page.toString()}',
NetUtil.request('/api/v1/rec?page=${page.toString()}',
queryParameters: _provider, queryParameters: _provider,
method: NetMethod.GET, method: NetMethod.GET,
onCache: _page == 1
onCache: page == 1
? (data) { ? (data) {
if (!EmptyUtil.isEmpty(data)) { if (!EmptyUtil.isEmpty(data)) {
if (data.containsKey('good')) { if (data.containsKey('good')) {
@@ -65,7 +75,7 @@ class HomeGoodsBloc extends BlocBase implements CategoryGoodsOnClickCallBack {
return HomeGoodsModel.fromJson(Map<String, dynamic>.from(item)); return HomeGoodsModel.fromJson(Map<String, dynamic>.from(item));
}).toList(); }).toList();
if (goods.length > 0) { if (goods.length > 0) {
_page++;
page++;
} }
_goods.addAll(goods); _goods.addAll(goods);
} }
@@ -78,6 +88,7 @@ class HomeGoodsBloc extends BlocBase implements CategoryGoodsOnClickCallBack {
void onTap(int index, String providerType) { void onTap(int index, String providerType) {
Logger.error('index = $index, providerType = $providerType'); Logger.error('index = $index, providerType = $providerType');
_provider = providerType; _provider = providerType;
page=1;
loadMore(providerType); loadMore(providerType);
} }
} }

+ 1
- 0
lib/widgets/home/home_goods/home_goods.dart View File

@@ -70,6 +70,7 @@ class _HomeGoodsContainerState extends State<_HomeGoodsContainer> {
// } // }
_isFirstLoading = false; _isFirstLoading = false;
_provider = data.provider; _provider = data.provider;
_bloc.page=1;
_bloc.loadMore(_provider); _bloc.loadMore(_provider);
}); });




Loading…
Cancel
Save