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 {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->


+ 1
- 1
example/pubspec.yaml View File

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

# 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;
} else {
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 ?? "");
if (widget?.model?.provider == 'taobao') {
TradeResult result;
if (Platform.isAndroid) {
result = await FlutterAlibc.openByUrl(
url: widget?.model?.couponUrl ?? "",
openType: AlibcOpenType.AlibcOpenTypeNative,
backUrl: "alisdk://");
} else if (Platform.isIOS) {
result = await FlutterAlibc.openByUrl(
url: widget?.model?.couponUrl ?? "",
openType: AlibcOpenType.AlibcOpenTypeNative,
url: widget?.model?.couponUrl ?? ""
);
}
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:ui';

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

Widget _createCenter() {
List<OrderStateModel> states = style.list.orderState;
OrderStateModel state = states.firstWhere((element) => element.type == model.state.toString());
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
@@ -147,21 +150,34 @@ class OrderItemWidget extends StatelessWidget {
],
),
_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>[
_cretePriceText('订单金额:${model?.itemPrice??''}'),
_cretePriceText('${state?.amountText}${model?.paidPrice ?? ''}'),
Spacer(),
Row(
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.ideographic,
textBaseline: TextBaseline.alphabetic,
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 == ''
? Container()
: 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() {
@@ -241,13 +257,59 @@ class OrderItemWidget extends StatelessWidget {
if (state == null || state.tips == null || state.tips == '') {
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(
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: Text(
state?.tips ?? '',
(state?.tips ?? ''),
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;

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

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

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

bool loading=false;

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

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

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



Loading…
Cancel
Save