diff --git a/.idea/encodings.xml b/.idea/encodings.xml index 97626ba..15a15b2 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -1,6 +1,4 @@ - - - + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 682e5c4..0a98a5e 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -10,14 +10,15 @@ diff --git a/app/build.gradle b/app/build.gradle index 1e37422..bd22a56 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,3 @@ - - apply plugin: 'com.android.application' android { signingConfigs { @@ -17,7 +15,7 @@ android { targetSdkVersion 28 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" signingConfig signingConfigs.config multiDexEnabled true } @@ -46,17 +44,18 @@ android { dependencies { implementation project(':flutter') implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.android.support:multidex:1.0.3' - implementation 'com.android.support:appcompat-v7:28.0.0' - implementation 'com.android.support.constraint:constraint-layout:1.1.3' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + implementation 'androidx.multidex:multidex:2.0.0' + implementation 'androidx.appcompat:appcompat:1.0.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + androidTestImplementation 'androidx.test:runner:1.1.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' //系统全局配置模块 implementation 'com.bristua.framework:appconfig:2.0.0-SNAPHOST' implementation 'com.bristua.framework:component_manager:2.0.0-SNAPHOST' //https模块 implementation 'com.bristua.framework:https:2.0.1-SNAPHOST' //路由模块 + implementation 'com.bristua.framework:brouter:2.0.0-SNAPHOST' //配置通用api 能力 implementation 'com.bristua.framework:common_api:2.0.0-SNAPHOST' @@ -64,23 +63,23 @@ dependencies { implementation 'com.bristua.framework:sp_manager:1.0.4-SNAPHOST' //全局APP Context implementation 'com.bristua.framework:context:2.0.0-SNAPHOST' - implementation 'com.ft.business.interceptor:response:1.1.2-SNAPHOST' - implementation 'com.ft.business.component:user_login:6.1.1-SNAPHOST' + implementation 'com.ft.business.interceptor:response:1.2.2-SNAPHOST' + implementation 'com.ft.business.component:user_login:6.1.4-SNAPHOST' implementation 'com.ft.business.component:invite:1.0.0-SNAPHOST' implementation 'com.ft.business.component:user_pay:1.1.2-SNAPHOST' implementation 'com.ft.business.component:enviroment:1.0.8-SNAPHOST' - implementation 'com.ft.business.component:shop_cart:1.2.6-SNAPHOST' - implementation 'com.ft.business.component:shop_sku:1.0.5-SNAPHOST' - implementation 'com.ft.business.component:address:1.1.1-SNAPHOST' - implementation 'com.ft.business.component:order:1.0.9-SNAPHOST' - implementation 'com.ft.business.component:order_list:1.0.0-SNAPHOST' + implementation 'com.ft.business.component:shop_cart:1.4.6-SNAPHOST' + implementation 'com.ft.business.component:shop_sku:1.0.6-SNAPHOST' + implementation 'com.ft.business.component:address:1.1.4-SNAPHOST' + implementation 'com.ft.business.component:order:1.3.4-SNAPHOST' + implementation 'com.ft.business.component:order_list:1.0.3-SNAPHOST' implementation 'com.ft.business.component:evaluate:1.0.1-SNAPHOST' - implementation 'com.ft.business.component:collection:1.0.1-SNAPHOST' - implementation 'com.ft.business.component:product:1.0.5-SNAPHOST' - implementation 'com.ft.business.component:rebate:1.0.8-SNAPHOST' + implementation 'com.ft.business.component:collection:1.0.2-SNAPHOST' + implementation 'com.ft.business.component:product:1.1.1-SNAPHOST' + implementation 'com.ft.business.component:rebate:1.0.9-SNAPHOST' implementation 'com.bristua.framework:logger:1.0.4-SNAPHOST' implementation 'com.bristua.framework:ssl_cert:1.0.5-SNAPHOST' - implementation 'com.ft.business.component:category:1.0.8-SNAPHOST' + implementation 'com.ft.business.component:category:1.0.9-SNAPHOST' implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.3.1' annotationProcessor 'com.nd.sdp.android.serviceloader:service-loader-compiler-app:1.0.9' implementation 'com.nd.sdp.android.serviceloader:service-loader:1.0.9' diff --git a/app/src/androidTest/java/com/ym/flutter/ftshop/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/ym/flutter/ftshop/ExampleInstrumentedTest.java index e2f2cf5..b72e564 100644 --- a/app/src/androidTest/java/com/ym/flutter/ftshop/ExampleInstrumentedTest.java +++ b/app/src/androidTest/java/com/ym/flutter/ftshop/ExampleInstrumentedTest.java @@ -1,8 +1,8 @@ package com.ym.flutter.ftshop; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 27eb3aa..e368dc0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,20 +1,26 @@ - - + android:theme="@style/AppTheme" + > + + + + @@ -26,17 +32,15 @@ android:host="video" android:scheme="flutterhost" /> - - - + - - + android:theme="@android:style/Theme.Translucent.NoTitleBar" /> result.confirm()) + .setCancelable(false) + .show(); + return true; + } + + @Override + public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) { + new AlertDialog.Builder(WebActivity.this) + .setTitle("JsConfirm") + .setMessage(message) + .setPositiveButton("OK", (dialog, which) -> result.confirm()) + .setNegativeButton("Cancel", (dialog, which) -> result.cancel()) + .setCancelable(false) + .show(); +// 返回布尔值:判断点击时确认还是取消 +// true表示点击了确认;false表示点击了取消; + return true; + } + + + }); + webView.loadUrl(url); + + } + + @Override + protected void onDestroy() { + if (webView != null) { + webView.loadDataWithBaseURL(null, "", "text/html", "utf-8", null); + webView.clearHistory(); + + ((ViewGroup) webView.getParent()).removeView(webView); + webView.destroy(); + webView = null; + } + super.onDestroy(); + } +} diff --git a/app/src/main/java/com/bristua/flutter/ftshop/app/AppVMachine.java b/app/src/main/java/com/bristua/flutter/ftshop/app/AppVMachine.java index 7bd8967..edbc12b 100644 --- a/app/src/main/java/com/bristua/flutter/ftshop/app/AppVMachine.java +++ b/app/src/main/java/com/bristua/flutter/ftshop/app/AppVMachine.java @@ -1,9 +1,8 @@ package com.bristua.flutter.ftshop.app; -import android.app.Application; import android.content.Context; import android.os.Handler; -import android.support.annotation.Nullable; +import androidx.annotation.Nullable; import com.bristua.bristua.sp.ShareprefenseImpl; import com.bristua.flutter.ftshop.R; diff --git a/app/src/main/java/com/bristua/flutter/ftshop/exception/VMachineException.java b/app/src/main/java/com/bristua/flutter/ftshop/exception/VMachineException.java index 3b358bd..775004d 100644 --- a/app/src/main/java/com/bristua/flutter/ftshop/exception/VMachineException.java +++ b/app/src/main/java/com/bristua/flutter/ftshop/exception/VMachineException.java @@ -1,6 +1,6 @@ package com.bristua.flutter.ftshop.exception; -import android.support.annotation.Nullable; +import androidx.annotation.Nullable; /** * 虚拟机异常 diff --git a/app/src/main/java/com/bristua/flutter/ftshop/plugin/PluginDelegate.java b/app/src/main/java/com/bristua/flutter/ftshop/plugin/PluginDelegate.java index 81fc43c..031ba8e 100644 --- a/app/src/main/java/com/bristua/flutter/ftshop/plugin/PluginDelegate.java +++ b/app/src/main/java/com/bristua/flutter/ftshop/plugin/PluginDelegate.java @@ -1,18 +1,40 @@ package com.bristua.flutter.ftshop.plugin; import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.net.Uri; import android.text.TextUtils; import android.widget.Toast; +import com.bristua.flutter.ftshop.WebActivity; import com.bristua.framework.define.IFlutterResult; import com.bristua.framework.router.BRouter; import org.json.JSONObject; +import java.util.List; + import io.flutter.plugin.common.MethodCall; public class PluginDelegate { + public static boolean isQQClientAvailable(Context context) { + final PackageManager packageManager = context.getPackageManager(); + List pinfo = packageManager.getInstalledPackages(0); + if (pinfo != null) { + for (int i = 0; i < pinfo.size(); i++) { + String pn = pinfo.get(i).packageName; + if (pn.equals("com.tencent.mobileqq")) { + return true; + } + } + } + return false; + } + + public void call(Context context, MethodCall methodCall, String params, IFlutterResult result) throws Exception { JSONObject jsonObject = null; if (!TextUtils.isEmpty(params)) { @@ -20,6 +42,27 @@ public void call(Context context, MethodCall methodCall, String params, IFlutter } switch (methodCall.method) { + case "openQQ": + if (jsonObject != null) { + String qq = jsonObject.optString("qq"); + if (isQQClientAvailable(context)) { + final String qqUrl = "mqqwpa://im/chat?chat_type=wpa&uin=" + qq + "&version=1"; + context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(qqUrl))); + } else { + Toast.makeText(context, "请安装QQ客户端", Toast.LENGTH_SHORT).show(); + } + } + break; + case "webview": + if (jsonObject != null) { + String url = jsonObject.optString("url"); + Intent intent = new Intent(context, WebActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.putExtra("url", url); + context.startActivity(intent); + } + + break; case "showShortToast": if (jsonObject != null) Toast.makeText(context, jsonObject.optString("message"), Toast.LENGTH_SHORT).show(); diff --git a/app/src/main/java/com/bristua/flutter/ftshop/plugin/PluginProvider.java b/app/src/main/java/com/bristua/flutter/ftshop/plugin/PluginProvider.java index 45a7a99..acb534f 100644 --- a/app/src/main/java/com/bristua/flutter/ftshop/plugin/PluginProvider.java +++ b/app/src/main/java/com/bristua/flutter/ftshop/plugin/PluginProvider.java @@ -1,9 +1,7 @@ package com.bristua.flutter.ftshop.plugin; import android.content.Context; -import android.support.annotation.Nullable; -import android.text.TextUtils; -import android.util.Log; +import androidx.annotation.Nullable; import com.bristua.framework.define.IFlutterResult; import com.bristua.framework.logger.Logger; diff --git a/app/src/main/java/com/bristua/flutter/ftshop/wxapi/WXEntryActivity.java b/app/src/main/java/com/bristua/flutter/ftshop/wxapi/WXEntryActivity.java index be51412..2802cef 100644 --- a/app/src/main/java/com/bristua/flutter/ftshop/wxapi/WXEntryActivity.java +++ b/app/src/main/java/com/bristua/flutter/ftshop/wxapi/WXEntryActivity.java @@ -10,8 +10,8 @@ import android.content.Intent; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v7.app.AppCompatActivity; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import android.util.Log; import android.widget.Toast; diff --git a/app/src/main/java/com/bristua/flutter/ftshop/wxapi/WXPayEntryActivity.java b/app/src/main/java/com/bristua/flutter/ftshop/wxapi/WXPayEntryActivity.java index 4caaa8a..678fc81 100644 --- a/app/src/main/java/com/bristua/flutter/ftshop/wxapi/WXPayEntryActivity.java +++ b/app/src/main/java/com/bristua/flutter/ftshop/wxapi/WXPayEntryActivity.java @@ -52,9 +52,11 @@ public void onResp(BaseResp resp) { break; case BaseResp.ErrCode.ERR_COMM:// 支付失败 Log.e(TAG, "微信支付 ------ 支付失败"); + PluginProvider.resultCallBack(403,"微信支付失败"); break; case BaseResp.ErrCode.ERR_USER_CANCEL:// 支付取消 Log.e(TAG, "微信支付 ------ 支付取消"); + PluginProvider.resultCallBack(406,"支付取消"); break; } finish(); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 70b5947..72bb3d6 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,5 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_video.xml b/app/src/main/res/layout/activity_video.xml index 638c062..93f277f 100644 --- a/app/src/main/res/layout/activity_video.xml +++ b/app/src/main/res/layout/activity_video.xml @@ -1,5 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_web.xml b/app/src/main/res/layout/activity_web.xml new file mode 100644 index 0000000..df8dfe7 --- /dev/null +++ b/app/src/main/res/layout/activity_web.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 49e3202..338443c 100644 --- a/build.gradle +++ b/build.gradle @@ -2,9 +2,9 @@ buildscript { repositories { + maven { url 'http://47.244.0.128:8081/nexus/content/groups/android-public/'} google() jcenter() - maven { url 'http://47.244.0.128:8081/nexus/content/groups/android-public/'} } dependencies { classpath 'com.android.tools.build:gradle:3.4.0' @@ -16,9 +16,9 @@ buildscript { allprojects { repositories { + maven { url 'http://47.244.0.128:8081/nexus/content/groups/android-public/'} google() jcenter() - maven { url 'http://47.244.0.128:8081/nexus/content/groups/android-public/'} } } diff --git a/flutter_lib/.android/.gitignore b/flutter_lib/.android/.gitignore new file mode 100644 index 0000000..9721358 --- /dev/null +++ b/flutter_lib/.android/.gitignore @@ -0,0 +1,56 @@ +.DS_Store +.dart_tool/ + +.packages +.pub/ + +.idea/ +.vagrant/ +.sconsign.dblite +.svn/ + +*.swp +profile + +DerivedData/ + +.generated/ + +*.pbxuser +*.mode1v3 +*.mode2v3 +*.perspectivev3 + +!default.pbxuser +!default.mode1v3 +!default.mode2v3 +!default.perspectivev3 + +xcuserdata + +*.moved-aside + +*.pyc +*sync/ +Icon? +.tags* + +build/ +#.android/ +#.ios/ +.flutter-plugins + +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild + diff --git a/flutter_lib/.android/Flutter/build.gradle b/flutter_lib/.android/Flutter/build.gradle index 40fdf33..969e0ee 100644 --- a/flutter_lib/.android/Flutter/build.gradle +++ b/flutter_lib/.android/Flutter/build.gradle @@ -34,7 +34,7 @@ android { targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } } @@ -44,6 +44,6 @@ flutter { dependencies { testImplementation 'junit:junit:4.12' - implementation 'com.android.support:support-v13:27.1.1' - implementation 'com.android.support:support-annotations:27.1.1' + implementation 'androidx.legacy:legacy-support-v13:1.0.0' + implementation 'androidx.annotation:annotation:1.0.0' } diff --git a/flutter_lib/.android/Flutter/src/main/java/io/flutter/facade/Flutter.java b/flutter_lib/.android/Flutter/src/main/java/io/flutter/facade/Flutter.java index 54d717e..7bc97ef 100644 --- a/flutter_lib/.android/Flutter/src/main/java/io/flutter/facade/Flutter.java +++ b/flutter_lib/.android/Flutter/src/main/java/io/flutter/facade/Flutter.java @@ -1,12 +1,12 @@ package io.flutter.facade; import android.app.Activity; -import android.arch.lifecycle.Lifecycle; -import android.arch.lifecycle.LifecycleObserver; -import android.arch.lifecycle.OnLifecycleEvent; +import androidx.lifecycle.Lifecycle; +import androidx.lifecycle.LifecycleObserver; +import androidx.lifecycle.OnLifecycleEvent; import android.content.Context; import android.os.Bundle; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import io.flutter.plugin.common.BasicMessageChannel; import io.flutter.plugin.common.StringCodec; diff --git a/flutter_lib/.android/Flutter/src/main/java/io/flutter/facade/FlutterFragment.java b/flutter_lib/.android/Flutter/src/main/java/io/flutter/facade/FlutterFragment.java index fdca660..998dfd5 100644 --- a/flutter_lib/.android/Flutter/src/main/java/io/flutter/facade/FlutterFragment.java +++ b/flutter_lib/.android/Flutter/src/main/java/io/flutter/facade/FlutterFragment.java @@ -2,8 +2,8 @@ import android.content.Context; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.app.Fragment; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.ViewGroup; diff --git a/flutter_lib/.android/Flutter/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java b/flutter_lib/.android/Flutter/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java index 0618751..815cf98 100644 --- a/flutter_lib/.android/Flutter/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java +++ b/flutter_lib/.android/Flutter/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java @@ -2,7 +2,9 @@ import io.flutter.plugin.common.PluginRegistry; import io.flutter.plugins.pathprovider.PathProviderPlugin; -import io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin; +import com.tekartik.sqflite.SqflitePlugin; +import io.flutter.plugins.urllauncher.UrlLauncherPlugin; +import io.flutter.plugins.webviewflutter.WebViewFlutterPlugin; /** * Generated file. Do not edit. @@ -13,7 +15,9 @@ public static void registerWith(PluginRegistry registry) { return; } PathProviderPlugin.registerWith(registry.registrarFor("io.flutter.plugins.pathprovider.PathProviderPlugin")); - SharedPreferencesPlugin.registerWith(registry.registrarFor("io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin")); + SqflitePlugin.registerWith(registry.registrarFor("com.tekartik.sqflite.SqflitePlugin")); + UrlLauncherPlugin.registerWith(registry.registrarFor("io.flutter.plugins.urllauncher.UrlLauncherPlugin")); + WebViewFlutterPlugin.registerWith(registry.registrarFor("io.flutter.plugins.webviewflutter.WebViewFlutterPlugin")); } private static boolean alreadyRegisteredWith(PluginRegistry registry) { diff --git a/flutter_lib/.android/build.gradle b/flutter_lib/.android/build.gradle index 3dbab77..6cdcf39 100644 --- a/flutter_lib/.android/build.gradle +++ b/flutter_lib/.android/build.gradle @@ -7,7 +7,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.4.0' + classpath 'com.android.tools.build:gradle:3.2.1' } } diff --git a/flutter_lib/.android/gradlew b/flutter_lib/.android/gradlew old mode 100755 new mode 100644 diff --git a/flutter_lib/.android/local.properties b/flutter_lib/.android/local.properties deleted file mode 100644 index b22e6da..0000000 --- a/flutter_lib/.android/local.properties +++ /dev/null @@ -1,2 +0,0 @@ -sdk.dir=/Users/richsjeson/Library/Android/sdk -flutter.sdk=/Users/richsjeson/compile/env/flutter_sdk \ No newline at end of file diff --git a/flutter_lib/.gitignore b/flutter_lib/.gitignore index 7427217..9721358 100644 --- a/flutter_lib/.gitignore +++ b/flutter_lib/.gitignore @@ -39,3 +39,18 @@ build/ #.android/ #.ios/ .flutter-plugins + +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild + diff --git a/flutter_lib/.ios/Flutter/FlutterPluginRegistrant/Classes/GeneratedPluginRegistrant.m b/flutter_lib/.ios/Flutter/FlutterPluginRegistrant/Classes/GeneratedPluginRegistrant.m index 4adb0ff..bbe0d8a 100644 --- a/flutter_lib/.ios/Flutter/FlutterPluginRegistrant/Classes/GeneratedPluginRegistrant.m +++ b/flutter_lib/.ios/Flutter/FlutterPluginRegistrant/Classes/GeneratedPluginRegistrant.m @@ -4,13 +4,17 @@ #import "GeneratedPluginRegistrant.h" #import -#import +#import +#import +#import @implementation GeneratedPluginRegistrant + (void)registerWithRegistry:(NSObject*)registry { [FLTPathProviderPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTPathProviderPlugin"]]; - [FLTSharedPreferencesPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTSharedPreferencesPlugin"]]; + [SqflitePlugin registerWithRegistrar:[registry registrarForPlugin:@"SqflitePlugin"]]; + [FLTUrlLauncherPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTUrlLauncherPlugin"]]; + [FLTWebViewFlutterPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTWebViewFlutterPlugin"]]; } @end diff --git a/flutter_lib/.ios/Flutter/FlutterPluginRegistrant/FlutterPluginRegistrant.podspec b/flutter_lib/.ios/Flutter/FlutterPluginRegistrant/FlutterPluginRegistrant.podspec index c29a8de..0f426de 100644 --- a/flutter_lib/.ios/Flutter/FlutterPluginRegistrant/FlutterPluginRegistrant.podspec +++ b/flutter_lib/.ios/Flutter/FlutterPluginRegistrant/FlutterPluginRegistrant.podspec @@ -18,5 +18,7 @@ Depends on all your plugins, and provides a function to register them. s.public_header_files = './Classes/**/*.h' s.dependency 'Flutter' s.dependency 'path_provider' - s.dependency 'shared_preferences' + s.dependency 'sqflite' + s.dependency 'url_launcher' + s.dependency 'webview_flutter' end diff --git a/flutter_lib/.ios/Flutter/Generated.xcconfig b/flutter_lib/.ios/Flutter/Generated.xcconfig index 013b6a6..b8eac05 100644 --- a/flutter_lib/.ios/Flutter/Generated.xcconfig +++ b/flutter_lib/.ios/Flutter/Generated.xcconfig @@ -1,6 +1,6 @@ // This is a generated file; do not edit or check into version control. FLUTTER_ROOT=C:\workspace\flutter -FLUTTER_APPLICATION_PATH=C:\workspace\github\bristuaftshop\flutter_lib +FLUTTER_APPLICATION_PATH=C:\workspace\github\flutter_shop\flutter_lib FLUTTER_TARGET=lib/main.dart FLUTTER_BUILD_DIR=build SYMROOT=${SOURCE_ROOT}/../build\ios diff --git a/flutter_lib/images/btn_settings.png b/flutter_lib/images/btn_settings.png new file mode 100644 index 0000000..e7a31ad Binary files /dev/null and b/flutter_lib/images/btn_settings.png differ diff --git a/flutter_lib/images/icon_bottom_navigation_active.png b/flutter_lib/images/icon_bottom_navigation_active.png new file mode 100644 index 0000000..9e6cf08 Binary files /dev/null and b/flutter_lib/images/icon_bottom_navigation_active.png differ diff --git a/flutter_lib/images/icon_bottom_navigation_car.png b/flutter_lib/images/icon_bottom_navigation_car.png new file mode 100644 index 0000000..95b9e5c Binary files /dev/null and b/flutter_lib/images/icon_bottom_navigation_car.png differ diff --git a/flutter_lib/images/icon_bottom_navigation_home.png b/flutter_lib/images/icon_bottom_navigation_home.png new file mode 100644 index 0000000..e2a1882 Binary files /dev/null and b/flutter_lib/images/icon_bottom_navigation_home.png differ diff --git a/flutter_lib/images/icon_bottom_navigation_mine.png b/flutter_lib/images/icon_bottom_navigation_mine.png new file mode 100644 index 0000000..be989dd Binary files /dev/null and b/flutter_lib/images/icon_bottom_navigation_mine.png differ diff --git a/flutter_lib/images/icon_collection.png b/flutter_lib/images/icon_collection.png new file mode 100644 index 0000000..d35893e Binary files /dev/null and b/flutter_lib/images/icon_collection.png differ diff --git a/flutter_lib/images/icon_exit.png b/flutter_lib/images/icon_exit.png new file mode 100644 index 0000000..8084d54 Binary files /dev/null and b/flutter_lib/images/icon_exit.png differ diff --git a/flutter_lib/images/icon_inputnumber.png b/flutter_lib/images/icon_inputnumber.png new file mode 100644 index 0000000..bcfabff Binary files /dev/null and b/flutter_lib/images/icon_inputnumber.png differ diff --git a/flutter_lib/images/icon_kehu.png b/flutter_lib/images/icon_kehu.png new file mode 100644 index 0000000..b7f9d23 Binary files /dev/null and b/flutter_lib/images/icon_kehu.png differ diff --git a/flutter_lib/images/icon_mine_bg.png b/flutter_lib/images/icon_mine_bg.png new file mode 100644 index 0000000..46ece7d Binary files /dev/null and b/flutter_lib/images/icon_mine_bg.png differ diff --git a/flutter_lib/images/icon_ranking.png b/flutter_lib/images/icon_ranking.png new file mode 100644 index 0000000..be2d205 Binary files /dev/null and b/flutter_lib/images/icon_ranking.png differ diff --git a/flutter_lib/images/icon_setting.png b/flutter_lib/images/icon_setting.png new file mode 100644 index 0000000..d471b4c Binary files /dev/null and b/flutter_lib/images/icon_setting.png differ diff --git a/flutter_lib/images/icon_shop_car.png b/flutter_lib/images/icon_shop_car.png new file mode 100644 index 0000000..95b9e5c Binary files /dev/null and b/flutter_lib/images/icon_shop_car.png differ diff --git a/flutter_lib/images/icon_shoucang.png b/flutter_lib/images/icon_shoucang.png new file mode 100644 index 0000000..f6c9dfa Binary files /dev/null and b/flutter_lib/images/icon_shoucang.png differ diff --git a/flutter_lib/images/icon_vip.png b/flutter_lib/images/icon_vip.png new file mode 100644 index 0000000..fec474b Binary files /dev/null and b/flutter_lib/images/icon_vip.png differ diff --git a/flutter_lib/images/icon_vip_bg.png b/flutter_lib/images/icon_vip_bg.png new file mode 100644 index 0000000..2bbd7b2 Binary files /dev/null and b/flutter_lib/images/icon_vip_bg.png differ diff --git a/flutter_lib/images/icon_vip_crown.png b/flutter_lib/images/icon_vip_crown.png new file mode 100644 index 0000000..5a70e1b Binary files /dev/null and b/flutter_lib/images/icon_vip_crown.png differ diff --git a/flutter_lib/images/net_error.png b/flutter_lib/images/net_error.png new file mode 100644 index 0000000..892cc45 Binary files /dev/null and b/flutter_lib/images/net_error.png differ diff --git a/flutter_lib/images/no_cart.png b/flutter_lib/images/no_cart.png new file mode 100644 index 0000000..92c04f4 Binary files /dev/null and b/flutter_lib/images/no_cart.png differ diff --git a/flutter_lib/images/no_msg.png b/flutter_lib/images/no_msg.png new file mode 100644 index 0000000..2fcd916 Binary files /dev/null and b/flutter_lib/images/no_msg.png differ diff --git a/flutter_lib/images/no_order.png b/flutter_lib/images/no_order.png new file mode 100644 index 0000000..b0b0107 Binary files /dev/null and b/flutter_lib/images/no_order.png differ diff --git a/flutter_lib/images/no_search_result.png b/flutter_lib/images/no_search_result.png new file mode 100644 index 0000000..17c6d79 Binary files /dev/null and b/flutter_lib/images/no_search_result.png differ diff --git a/flutter_lib/images/placeholder.png b/flutter_lib/images/placeholder.png new file mode 100644 index 0000000..af99fc7 Binary files /dev/null and b/flutter_lib/images/placeholder.png differ diff --git a/flutter_lib/images/user_icon.png b/flutter_lib/images/user_icon.png old mode 100755 new mode 100644 diff --git a/flutter_lib/lib/bridge/account_bridge.dart b/flutter_lib/lib/bridge/account_bridge.dart index 2821b2b..f225eae 100644 --- a/flutter_lib/lib/bridge/account_bridge.dart +++ b/flutter_lib/lib/bridge/account_bridge.dart @@ -101,4 +101,23 @@ class AccountBridge { } }); } + + + /* + * 绑定用户信息 + */ + static Future logout() { + return Bridge.dispenser({ + "method": "logout", + "params": { + "action": component, + "arguments": { + "method": "logout", + "data": { + "token":"token" + }, + } + } + }); + } } diff --git a/flutter_lib/lib/bridge/address_bridge.dart b/flutter_lib/lib/bridge/address_bridge.dart index 6fbd716..2c046d9 100644 --- a/flutter_lib/lib/bridge/address_bridge.dart +++ b/flutter_lib/lib/bridge/address_bridge.dart @@ -1,5 +1,8 @@ +import 'dart:convert'; + import 'package:flutter_lib/bridge/common_bridge.dart'; import 'package:flutter_lib/model/Result.dart'; +import 'package:flutter_lib/model/address.dart'; class AddressBridge { static const String component = "address"; @@ -13,18 +16,19 @@ class AddressBridge { */ static Future addAddress(String receivePhone, String receiveGoodsName, String receiveAddressName, int status) { + Address adss = new Address(); + adss.phone = receivePhone; + adss.name = receiveGoodsName; + adss.address = receiveAddressName; + adss.status = status; + return Bridge.dispenser({ "method": "address_add", "params": { "action": component, "arguments": { "method": "address_add", - "data": { - "receivePhone": receivePhone, - "receiveGoodsName": receiveGoodsName, - "receiveAddressName": receiveAddressName, - "status": status - }, + "data": json.encode(adss), } } }); diff --git a/flutter_lib/lib/bridge/cart_bridge.dart b/flutter_lib/lib/bridge/cart_bridge.dart index 291de88..8a99642 100644 --- a/flutter_lib/lib/bridge/cart_bridge.dart +++ b/flutter_lib/lib/bridge/cart_bridge.dart @@ -86,7 +86,8 @@ class CartBridge { * *从购物车移除 */ - static Future delSku(String productId,String skuId, int amount) async { + static Future delSku( + String productId, String skuId, int amount) async { // return Result.fromJson(await getCart()); return Bridge.dispenser({ "method": "shop_cart_del", @@ -94,7 +95,7 @@ class CartBridge { "action": component, "arguments": { "method": "shop_cart_del", - "data": {"productId":productId,"skuId": skuId, "distinct": amount} + "data": {"productId": productId, "skuId": skuId, "distinct": amount} } } }); @@ -104,7 +105,8 @@ class CartBridge { * *从购物车数量添加 */ - static Future addSkuAmount(String productId,String skuId, int amount) async { + static Future addSkuAmount( + String productId, String skuId, int amount) async { // return Result.fromJson(await getCart()); return Bridge.dispenser({ "method": "shop_cart_addAmount", @@ -112,7 +114,7 @@ class CartBridge { "action": component, "arguments": { "method": "shop_cart_addAmount", - "data": {"productId":productId,"skuId": skuId, "distinct": amount} + "data": {"productId": productId, "skuId": skuId, "distinct": amount} } } }); @@ -131,7 +133,100 @@ class CartBridge { "action": component, "arguments": { "method": "shop_cart_findCart", - "data": {"productId":"xxx",} + "data": { + "productId": "xxx", + } + } + } + }); + } + + /* + * + *添加数据至下单列表 + */ + static Future addSkuOrder( + int productId, + String skuId, + int amount, + double price, + double freight, + String norms, + String name, + String url) async { +// //todo "data": json.encode 待测试 +// String data = await getCart(); +// return Result.fromJson(data); + return Bridge.dispenser({ + "method": "shop_cart_order_add", + "params": { + "action": component, + "arguments": { + "method": "shop_cart_order_add", + "data": json.encode({ + "productId": productId, + "goodsId": skuId, + "amount": amount, + "price": price, + "freight": freight, + "norms": norms, + "name": name, + "img": url, + }), + }, + } + }); + } + + /* + * + *获取购物车信息 + */ + static Future findOrderNow() async { +// return Result.fromJson(await getCart()); + + return Bridge.dispenser({ + "method": "shop_cart_order_find", + "params": { + "action": component, + "arguments": { + "method": "shop_cart_order_find", + "data": { + "productId": "xxx", + } + } + } + }); + } + + /* + * + *获取购物车信息 + */ + static Future syschrizonCart(String cardJson) async { + return Bridge.dispenser({ + "method": "shop_cart_order_sys", + "params": { + "action": component, + "arguments": {"method": "shop_cart_order_sys", "data": cardJson} + } + }); + } + + /* + * + *获取购物车信息 + */ + static Future clearOrderNow() async { + return Bridge.dispenser({ + "method": "shop_cart_order_clear", + "params": { + "action": component, + "arguments": { + "method": "shop_cart_order_clear", + "data": { + "productId": "xxx", + } } } }); diff --git a/flutter_lib/lib/bridge/category_bridge.dart b/flutter_lib/lib/bridge/category_bridge.dart index 7186949..9f69174 100644 --- a/flutter_lib/lib/bridge/category_bridge.dart +++ b/flutter_lib/lib/bridge/category_bridge.dart @@ -1,8 +1,6 @@ import 'dart:async' show Future; -import 'dart:convert'; import 'package:flutter_lib/bridge/common_bridge.dart'; -import 'package:flutter_lib/logic/viewmodel/category_view_model.dart'; import 'package:flutter_lib/model/Result.dart'; class CategoryBridge { @@ -12,13 +10,6 @@ class CategoryBridge { *获取产品列表 */ static Future getCategories() async { -// String data = await CategoryViewModel.distest(); -// if (data != null) { -// print("bridge result:" + data); -// return Result.fromJson(data); -// } -// return Result.fromJson(json.encode({"code": -1, "msg": "无结果"})); -// todo 接口通了后使用下面的方法替换上面的假数据 return Bridge.dispenser({ "method": "root", "params": { @@ -37,12 +28,6 @@ class CategoryBridge { *获取产品列表 */ static Future getSubCategories( categoryId) async { -// String data = await CategoryViewModel.distest1(); -// if (data != null) { -// print("bridge result:" + data); -// return Result.fromJson(data); -// } -// return Result.fromJson(json.encode({"code": -1, "msg": "无结果"})); return Bridge.dispenser({ "method": "sub", "params": { diff --git a/flutter_lib/lib/bridge/common_bridge.dart b/flutter_lib/lib/bridge/common_bridge.dart index 4ac9b35..c3fab5f 100644 --- a/flutter_lib/lib/bridge/common_bridge.dart +++ b/flutter_lib/lib/bridge/common_bridge.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_lib/model/Result.dart'; @@ -7,19 +8,62 @@ class Bridge { static const _bridgePlatform = const MethodChannel("com.ym.framework.plugins/bridge"); + static BuildContext context; + static Future dispenser(var dispenser) async { String method = dispenser['method']; var params = dispenser['params']; print(method); print(params); - String data = await _bridgePlatform.invokeMethod(method, params); - if (data != null) { - print("bridge result:" + data); - return Result.fromJson(data); + Result result; + try { + String data = await _bridgePlatform.invokeMethod(method, params); + + if (data != null) { + print("bridge result:" + data); + result = Result.fromJson(data); + } else { + result = Result.fromJson(json.encode({"code": -1, "msg": "无结果"})); + } + } catch (e) { + result = Result.fromJson(json.encode({"code": -1, "msg": e.toString()})); + } + return result; + } + + static webview(String url) { + if (url == null || url.isEmpty) { + return; } - return Result.fromJson(json.encode({"code": -1, "msg": "无结果"})); + url = "" + url; + url = url.replaceAll(" ", ""); + dispenser({ + "method": "webview", + "params": json.encode({ + "url": url, + }), + }); } + + static openQQ(String url) { + if (url == null || url.isEmpty) { + return; + } + url = "" + url; + url = url.replaceAll(" ", ""); + dispenser({ + "method": "openQQ", + "params": json.encode({ + "qq": url, + }), + }); + } + + + + + static showShortToast(String message) { if (message == null || message.isEmpty) { return; diff --git a/flutter_lib/lib/bridge/order_bridge.dart b/flutter_lib/lib/bridge/order_bridge.dart index df61b50..a20bf55 100644 --- a/flutter_lib/lib/bridge/order_bridge.dart +++ b/flutter_lib/lib/bridge/order_bridge.dart @@ -2,25 +2,38 @@ import 'dart:async' show Future; import 'dart:convert'; import 'package:flutter_lib/bridge/common_bridge.dart'; +import 'package:flutter_lib/model/OrderComment.dart'; import 'package:flutter_lib/model/Result.dart'; class OrderBridge { static const String component = "order"; + /* + * + *vip下单 + */ + static Future orderVip(int chargeType) async { + return Bridge.dispenser({ + "method": "order_vip", + "params": { + "action": component, + "arguments": { + "method": "order_vip", + "data": { + "chargeType": chargeType, + } + } + } + }); + } + + /* * *获取产品列表 */ static Future submitOrder( String userAddressId, bool freight, dynamic orderGoods) async { -// String data = await CategoryViewModel.distest(); -// if (data != null) { -// print("bridge result:" + data); -// return Result.fromJson(data); -// } -// return Result.fromJson(json.encode({"code": -1, "msg": "无结果"})); - print(orderGoods); - print(json.encode(orderGoods)); return Bridge.dispenser({ "method": "order_submit", "params": { @@ -36,4 +49,65 @@ class OrderBridge { } }); } + + static Future cancelOrder(String orderId) async { + return Bridge.dispenser({ + "method": "order_cancel", + "params": { + "action": component, + "arguments": { + "method": "order_cancel", + "data": { + "orderId": orderId, + } + } + } + }); + } + + + static Future confirmOrder(String orderId) async { + return Bridge.dispenser({ + "method": "order_confirm", + "params": { + "action": component, + "arguments": { + "method": "order_confirm", + "data": { + "orderId": orderId, + } + } + } + }); + } + + static Future submitComment(OrderComment order) async { + return Bridge.dispenser({ + "method": "order_comment", + "params": { + "action": component, + "arguments": { + "method": "order_comment", + "data": json.encode(order), + } + } + }); + } + + static Future orderDetail(String orderId) async { + return Bridge.dispenser({ + "method": "order_detail", + "params": { + "action": component, + "arguments": { + "method": "order_detail", + "data": { + "orderId": orderId, + } + } + } + }); + } + + } diff --git a/flutter_lib/lib/bridge/product_bridge.dart b/flutter_lib/lib/bridge/product_bridge.dart index e409382..27ef8d1 100644 --- a/flutter_lib/lib/bridge/product_bridge.dart +++ b/flutter_lib/lib/bridge/product_bridge.dart @@ -1,5 +1,3 @@ -import 'dart:convert'; - import 'package:flutter_lib/bridge/common_bridge.dart'; import 'package:flutter_lib/logic/viewmodel/product_view_model.dart'; import 'package:flutter_lib/model/Result.dart'; @@ -10,21 +8,14 @@ class ProductBridge { * *获取产品列表 */ - static Future getProducts(int categoryId, bool orderBy) async { -// String data = await distest(); -// if (data != null) { -// print("bridge result:" + data); -// return Result.fromJson(data); -// } -// return Result.fromJson(json.encode({"code": -1, "msg": "无结果"})); - //todo 接口通了后使用下面的方法替换上面的假数据 + static Future getProducts(int categoryId, int orderBy) async { return Bridge.dispenser({ - "method": "findAll", + "method": "product_findAll", "params": { "action": component, "arguments": { - "method": "findAll", - "data": {"categoryId": categoryId,"orderBy":orderBy} + "method": "product_findAll", + "data": {"categoryId": categoryId, "orderBy": orderBy} } } }); @@ -39,42 +30,51 @@ class ProductBridge { * *获取产品列表 */ - static Future queryProduct(String query, bool orderBy) async { -// String data = await distest(); -// if (data != null) { -// print("bridge result:" + data); -// return Result.fromJson(data); -// } -// return Result.fromJson(json.encode({"code": -1, "msg": "无结果"})); - //todo 接口通了后使用下面的方法替换上面的假数据 + static Future queryProduct( + String query, int orderBy, int pageNo, int pageSize) async { + String searchQuery = (query == null ? "" : query); return Bridge.dispenser({ - "method": "queryProduct", + "method": "product_search_list", "params": { "action": component, "arguments": { - "method": "queryProduct", - "data": {"query": query,"orderBy":orderBy} + "method": "product_search_list", + "data": { + "keywold": searchQuery, + "pageNo": pageNo, + "pageSize": pageSize + } } } }); } static Future getProduct(int productId) async { -// String data = await distest(); -// if (data != null) { -// print("bridge result:" + data); -// return Result.fromJson(data); -// } - return Bridge.dispenser({ - "method": "detail", + "method": "product_detail", "params": { "action": component, "arguments": { - "method": "detail", + "method": "product_detail", "data": {"productId": productId} } } }); } + + /* + * 获取feature模块 + */ + static Future getFeature(int pageNo, int pageSize) async { + return Bridge.dispenser({ + "method": "product_search_list", + "params": { + "action": component, + "arguments": { + "method": "product_feature_search", + "data": {"pageNo": pageNo, "pageSize": pageSize} + } + } + }); + } } diff --git a/flutter_lib/lib/logic/bloc/address_bloc.dart b/flutter_lib/lib/logic/bloc/address_bloc.dart index 0088f7d..cafb364 100644 --- a/flutter_lib/lib/logic/bloc/address_bloc.dart +++ b/flutter_lib/lib/logic/bloc/address_bloc.dart @@ -1,9 +1,10 @@ import 'dart:async'; +import 'package:flutter/widgets.dart'; import 'package:flutter_lib/bridge/address_bridge.dart'; -import 'package:flutter_lib/bridge/common_bridge.dart'; import 'package:flutter_lib/model/address.dart'; import 'package:flutter_lib/model/addresslist.dart'; +import 'package:flutter_lib/utils/BristuaRouter.dart'; class AddressBloc { final addressController = StreamController>(); @@ -14,13 +15,16 @@ class AddressBloc { AddressBloc(); - getAddressList() { + getAddressList(BuildContext context) { AddressBridge.findAddress(1, 2000).then((result) { if (result.code == 200) { AddressList categoryList = AddressList.fromJson(result.data); addressController.add(categoryList.list); } else { - Bridge.showLongToast(result.msg == null ? "未返回错误信息" : result.msg); + print(result.msg == null ? "未返回错误信息" : result.msg); + if (result.code == 401) { + BristuaRouter.routerUserLogin(context); + } addressController.add(List()); } }); diff --git a/flutter_lib/lib/logic/bloc/cart_bloc.dart b/flutter_lib/lib/logic/bloc/cart_bloc.dart index 29ffa01..22ae225 100644 --- a/flutter_lib/lib/logic/bloc/cart_bloc.dart +++ b/flutter_lib/lib/logic/bloc/cart_bloc.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:flutter_lib/bridge/cart_bridge.dart'; -import 'package:flutter_lib/bridge/common_bridge.dart'; import 'package:flutter_lib/model/Result.dart'; import 'package:flutter_lib/model/cart.dart'; @@ -23,7 +22,8 @@ class CartBloc { Cart categoryList = Cart.fromJson(result.data); cartController.add(categoryList); } else { - Bridge.showLongToast(result.msg); + cartController.add(null); + print(result.msg == null ? "未返回错误信息" : result.msg); } }); } @@ -40,7 +40,36 @@ class CartBloc { cartController.add(categoryList); } } else { - Bridge.showLongToast(result.msg); + cartController.addError(result); + print(result.msg == null ? "未返回错误信息" : result.msg); + } + }); + } + + findOrderNow() { + Future future = CartBridge.findOrderNow(); + future.then((result) { + if (result.code == 200) { + if (result.data != null && result.data is Map) { + Cart categoryList = Cart.fromJson(result.data); + cartController.add(categoryList); + } else { + Cart categoryList = new Cart(totalCounts: 0); + cartController.add(categoryList); + } + } else { + cartController.addError(result); + print(result.msg == null ? "未返回错误信息" : result.msg); + } + }); + } + + clearOrderNow() { + Future future = CartBridge.clearOrderNow(); + future.then((result) { + if (result.code == 200) { + } else { + print(result.msg == null ? "未返回错误信息" : result.msg); } }); } @@ -53,20 +82,20 @@ class CartBloc { Cart categoryList = Cart.fromJson(result.data); cartController.add(categoryList); } else { - Bridge.showLongToast(result.msg); + print(result.msg == null ? "未返回错误信息" : result.msg); } }); } addSkuAmount(SkuWapper sku, int amount) { Future future = - CartBridge.delSku(sku.sku.productId, sku.goodsId, amount); + CartBridge.addSkuAmount(sku.sku.productId, sku.goodsId, amount); future.then((result) { if (result.code == 200) { Cart categoryList = Cart.fromJson(result.data); cartController.add(categoryList); } else { - Bridge.showLongToast(result.msg); + print(result.msg == null ? "未返回错误信息" : result.msg); } }); } diff --git a/flutter_lib/lib/logic/bloc/category_bloc.dart b/flutter_lib/lib/logic/bloc/category_bloc.dart index 9a6ca29..db7193a 100644 --- a/flutter_lib/lib/logic/bloc/category_bloc.dart +++ b/flutter_lib/lib/logic/bloc/category_bloc.dart @@ -34,11 +34,11 @@ class CategoryBloc { categoryController.add(categoryViewModel.categorysItems); print("getCategories add"); } else { - Bridge.showLongToast(result.msg == null ? "未返回错误信息" : result.msg); + print(result.msg == null ? "未返回错误信息" : result.msg); if (categoryController.isClosed || categoryController.isPaused) { return; } - categoryController.add(List()); + categoryController.addError(result); } }); } @@ -51,11 +51,11 @@ class CategoryBloc { subCategoryController.add(subCategoryList.list); print("getSubCategories add"); } else { - Bridge.showLongToast(result.msg == null ? "未返回错误信息" : result.msg); + print(result.msg == null ? "未返回错误信息" : result.msg); if (subCategoryController.isClosed || subCategoryController.isPaused) { return; } - subCategoryController.add(List()); + subCategoryController.addError(result); } }); } diff --git a/flutter_lib/lib/logic/bloc/home_bloc.dart b/flutter_lib/lib/logic/bloc/home_bloc.dart new file mode 100644 index 0000000..fa2f46a --- /dev/null +++ b/flutter_lib/lib/logic/bloc/home_bloc.dart @@ -0,0 +1,101 @@ +import 'dart:async'; + +import 'package:flutter_lib/model/Banner.dart'; +import 'package:flutter_lib/model/HomeCategory.dart'; +import 'package:flutter_lib/model/Result.dart'; +import 'package:flutter_lib/model/promotion.dart'; +import 'package:flutter_lib/model/special.dart'; +import 'package:flutter_lib/utils/http.dart'; + +class HomeBloc { + final tabController = StreamController>.broadcast(); + final homeCategoryController = + StreamController>.broadcast(); + + Stream> get tabItems => tabController.stream; + + Stream> get homeCategory => homeCategoryController.stream; + + HomeBloc() {} + + List v; + getImages() async { + if (v != null && v.isNotEmpty) { + tabController.add(v); + } else { + Result result = await Http.getBanner(); + if (result != null && result.code == 0) { + dynamic data = result.data; + List l = data["list"]; + List c = l.map((f) { + return DataListBean.fromJson(f); + }).toList(); + print(data); + if (v == null || v.isEmpty) { + v = c; + } + tabController.add(v); + } else { + tabController.addError(result); + } + } + } + + getHomeCategoryList() async { + Result result = await Http.getHomeCategoryList(); + if (result != null && result.code == 0) { + dynamic data = result.data; + List l = data["list"]; + List c = l.map((f) { + return HomeCategory.fromJson(f); + }).toList(); + print(data); + homeCategoryController.add(c); + } else { + homeCategoryController.addError(result); + } + } + + final promotionController = StreamController>.broadcast(); + Stream> get promotions => promotionController.stream; + + getPromotion() async { + Result result = await Http.getPromotion(); + if (result != null && result.code == 0) { + dynamic data = result.data; + List l = data["list"]; + List c = l.map((f) { + return Promotion.fromJson(f); + }).toList(); + print(data); + promotionController.add(c); + } else { + promotionController.addError(result); + } + } + + final specialController = StreamController>.broadcast(); + Stream> get specials => specialController.stream; + + getSpecial() async { + Result result = await Http.getSpecial(); + if (result != null && result.code == 0) { + dynamic data = result.data; + List l = data["list"]; + List c = l.map((f) { + return Special.fromJson(f); + }).toList(); + print(data); + specialController.add(c); + } else { + specialController.addError(result); + } + } + + getHomeAll() { + getImages(); + getHomeCategoryList(); + getPromotion(); + getSpecial(); + } +} diff --git a/flutter_lib/lib/logic/bloc/oder_list_bloc.dart b/flutter_lib/lib/logic/bloc/oder_list_bloc.dart index 0f4735d..a7ed994 100644 --- a/flutter_lib/lib/logic/bloc/oder_list_bloc.dart +++ b/flutter_lib/lib/logic/bloc/oder_list_bloc.dart @@ -1,9 +1,12 @@ import 'dart:async'; -import 'package:flutter_lib/bridge/common_bridge.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_lib/bridge/order_bridge.dart'; import 'package:flutter_lib/bridge/order_list_bridge.dart'; import 'package:flutter_lib/model/orderListItem.dart'; +import 'package:flutter_lib/model/orderdetail.dart'; import 'package:flutter_lib/model/orderlist.dart'; +import 'package:flutter_lib/utils/BristuaRouter.dart'; class OrderListBloc { final orderListController = StreamController>.broadcast(); @@ -12,19 +15,45 @@ class OrderListBloc { return orderListController.stream; } + final orderDetailController = StreamController.broadcast(); + Stream get orderDetail { + return orderDetailController.stream; + } OrderListBloc(); - getOrderListList(int type) { + getOrderListList(BuildContext context, int type) { OrderListBridge.getOrderList(1, 50, type).then((result) { if (result.code == 200) { OrderList orderList = OrderList.fromJson(result.data); orderListController.add(orderList.list); } else { - Bridge.showLongToast(result.msg == null ? "未返回错误信息" : result.msg); - orderListController.add(List()); + print(result.msg == null ? "未返回错误信息" : result.msg); + if (result.code == 401) { + //此处需要判断啊,不要认为很简单的 + //Navigator.pushNamed(context, UIData.login); + // + BristuaRouter.routerUserLogin(context); + } + orderListController.addError(result); } }); } + + getOrderDetail(String orderId) { + OrderBridge.orderDetail(orderId).then((result) { + if (result.code == 200) { + OrderDetail orderDetail = OrderDetail.fromJson(result.data); + orderDetailController.add(orderDetail); + } else { + print(result.msg == null ? "未返回错误信息" : result.msg); + orderDetailController.addError(result); + } + }); + } + + void close() { + orderListController?.close(); + } } diff --git a/flutter_lib/lib/logic/bloc/product_bloc.dart b/flutter_lib/lib/logic/bloc/product_bloc.dart index 67e35bf..693edd7 100644 --- a/flutter_lib/lib/logic/bloc/product_bloc.dart +++ b/flutter_lib/lib/logic/bloc/product_bloc.dart @@ -1,19 +1,17 @@ import 'dart:async'; -import 'package:flutter_lib/bridge/common_bridge.dart'; import 'package:flutter_lib/bridge/product_bridge.dart'; import 'package:flutter_lib/bridge/sku_bridge.dart'; import 'package:flutter_lib/logic/viewmodel/product_view_model.dart'; import 'package:flutter_lib/model/Result.dart'; import 'package:flutter_lib/model/productdetail.dart'; - import 'package:flutter_lib/model/productitem.dart'; import 'package:flutter_lib/model/skuinfo.dart'; class ProductBloc { final ProductViewModel productViewModel = ProductViewModel(); - final productController = StreamController>(); - final productDetaailController = StreamController(); + final productController = StreamController>.broadcast(); + final productDetailController = StreamController.broadcast(); final skuInfoController = StreamController.broadcast(); Stream> get productItems { @@ -21,7 +19,7 @@ class ProductBloc { } Stream get productDetail { - return productDetaailController.stream; + return productDetailController.stream; } Stream get skuInfo { @@ -30,26 +28,44 @@ class ProductBloc { ProductBloc(); - getProducts(int categoryId, bool orderByAes) { + getProducts(int categoryId, int orderByAes) { + productController.add(null); ProductBridge.getProducts(categoryId, orderByAes).then((result) { if (result.code == 200) { ProductList productList = ProductList.fromJson(result.data); productController.add(productList.list); } else { - Bridge.showLongToast(result.msg); + print(result.msg); + productController.add(List()); + } + }); + } + + /* + * 获取精选列表的商品 + */ + getFeatures(int pageNo, int pageSize) { + ProductBridge.getFeature(pageNo, pageSize).then((result) { + if (result.code == 200) { + ProductList productList = ProductList.fromJson(result.data); + productController.add(productList.list); + } else { + print(result.msg); + productController.addError(result); } }); } - queryProducts(String query, bool orderByAes) { - ProductBridge.queryProduct(query, orderByAes).then((result) { + queryProducts(String query, int orderByAes) { + ProductBridge.queryProduct(query, orderByAes, 1, 1000).then((result) { if (result.code == 200) { productController.add(null); ProductList productList = ProductList.fromJson(result.data); productController.add(productList.list); } else { - Bridge.showLongToast(result.msg); + print(result.msg); + productController.addError(result); } }); } @@ -59,12 +75,11 @@ class ProductBloc { Result result = await ProductBridge.getProduct(productId); if (result.code == 200) { Productdetail productList = Productdetail.fromJson(result.data); - productDetaailController.add(productList.list[0]); + productDetailController.add(productList.list[0]); print("getProduct add"); - } else { - Bridge.showLongToast(result.msg); - productDetaailController.add(null); + print(result.msg); + productDetailController.add(ProductDetail.N("")); } } @@ -77,8 +92,8 @@ class ProductBloc { skuInfoController.add(productList); print("getProduct sku add"); } else { - Bridge.showLongToast(result.msg); - skuInfoController.add(null); + print(result.msg); + skuInfoController.addError(result); } }); } diff --git a/flutter_lib/lib/logic/bloc/rebate_bloc.dart b/flutter_lib/lib/logic/bloc/rebate_bloc.dart index 21ce39b..ac6235b 100644 --- a/flutter_lib/lib/logic/bloc/rebate_bloc.dart +++ b/flutter_lib/lib/logic/bloc/rebate_bloc.dart @@ -1,5 +1,5 @@ import 'dart:async'; -import 'package:flutter_lib/bridge/common_bridge.dart'; + import 'package:flutter_lib/bridge/rebate_bridge.dart'; import 'package:flutter_lib/model/rebateList.dart'; @@ -17,7 +17,8 @@ class RebateBloc { RebateList rebateList = RebateList.fromJson(result.data); rebateStream.add(rebateList.list); } else { - Bridge.showLongToast(result.msg == null ? "未返回错误信息" : result.msg); + print(result.msg); + rebateStream.add(List()); } }); } diff --git a/flutter_lib/lib/logic/bloc/userinfo_bloc.dart b/flutter_lib/lib/logic/bloc/userinfo_bloc.dart index d5e5b3f..cf79035 100644 --- a/flutter_lib/lib/logic/bloc/userinfo_bloc.dart +++ b/flutter_lib/lib/logic/bloc/userinfo_bloc.dart @@ -18,7 +18,8 @@ class UserInfoBloc { Userinfo userinfo = Userinfo.fromJson(result.data); userInfoStream.add(userinfo); } else { -// Bridge.showLongToast(result.msg == null ? "未返回错误信息" : result.msg); + print(result.msg); + userInfoStream.add(Userinfo()); } }); } diff --git a/flutter_lib/lib/logic/viewmodel/homeitem_view_model.dart b/flutter_lib/lib/logic/viewmodel/homeitem_view_model.dart index b04d8cb..23ca8c2 100644 --- a/flutter_lib/lib/logic/viewmodel/homeitem_view_model.dart +++ b/flutter_lib/lib/logic/viewmodel/homeitem_view_model.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_lib/model/homeitem.dart'; -import 'package:flutter_lib/utils/uidata.dart'; import 'package:flutter_lib/model/userinfo.dart'; +import 'package:flutter_lib/utils/uidata.dart'; class HomeItemViewModel { List rankList; @@ -9,52 +9,55 @@ class HomeItemViewModel { HomeItemViewModel({this.rankList}); getMenuItems(Userinfo userInfo) { - return rankList = [ +// HomeItem( +// icon: "images/vip.png", +// title: "成为VIP", +// subTitle: "邀请返利不限量", +// arrowIcon:Icons.arrow_forward_ios, +// action: UIData.OrderDetailPage), HomeItem( - icon: "images/vip.png", - title: "成为VIP", - subTitle: "邀请返利不限量", - arrowIcon:Icons.arrow_forward_ios, - action: UIData.OrderDetailPage), + icon: "images/invite.png", + title: "邀请好友赢返利 ", + subTitle: "邀请好友赢返利 ", + arrowIcon: Icons.arrow_forward_ios, + action: UIData.IviteFriendsPage, + ), HomeItem( - icon: "images/invite.png", - title: "邀请好友赢返利 ", - subTitle: "邀请好友赢返利 ", - arrowIcon:Icons.arrow_forward_ios, - action: UIData.IviteFriendsPage, - ), - HomeItem( - icon: "images/coin.png", - title: "我的金币", - subTitle: "累计"+(userInfo==null?"0":userInfo.balanceAmt)+"个", - arrowIcon:Icons.arrow_forward_ios,), + icon: "images/coin.png", + title: "我的金币", + subTitle: "累计" + + (userInfo == null || userInfo.balanceAmt == null + ? "0" + : userInfo.balanceAmt) + + "个", + arrowIcon: Icons.arrow_forward_ios, + ), HomeItem( - icon: "images/invite_code.png", + icon: "images/invite_code.png", title: "输入邀请码", subTitle: "", - arrowIcon:Icons.arrow_forward_ios, + arrowIcon: Icons.arrow_forward_ios, action: UIData.InviteInputPage), HomeItem( - icon: "images/favor.png", + icon: "images/favor.png", title: "我的收藏", subTitle: "", - arrowIcon:Icons.arrow_forward_ios, + arrowIcon: Icons.arrow_forward_ios, action: UIData.MineCollectionPage), HomeItem( - icon: "images/setting.png", + icon: "images/setting.png", title: "设置中心", subTitle: "", - arrowIcon:Icons.arrow_forward_ios), + arrowIcon: Icons.arrow_forward_ios), HomeItem( - icon: "images/logout.png", + icon: "images/logout.png", title: "退出登录", subTitle: "", - arrowIcon:Icons.arrow_forward_ios), - + arrowIcon: Icons.arrow_forward_ios), ]; } } diff --git a/flutter_lib/lib/logic/viewmodel/product_view_model.dart b/flutter_lib/lib/logic/viewmodel/product_view_model.dart index bb163f7..14e135b 100644 --- a/flutter_lib/lib/logic/viewmodel/product_view_model.dart +++ b/flutter_lib/lib/logic/viewmodel/product_view_model.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_lib/bridge/product_bridge.dart'; import 'package:flutter_lib/model/Result.dart'; import 'package:flutter_lib/model/address.dart'; -import 'package:flutter_lib/model/orderDetail.dart'; +import 'package:flutter_lib/model/orderdetail.dart'; import 'package:flutter_lib/model/product.dart'; import 'dart:convert'; @@ -435,139 +435,139 @@ class ProductViewModel { size: [37, 40, 41], color: ["红色", "黑色", "蓝色"]) ]; - - List getOrderDetailList() { - List orderList = new List(); - OrderDetail orderDetail = new OrderDetail(); - orderDetail.status = 2; - orderDetail.express = "离开【太原中心】,下一站【广州中心】"; - Address address = new Address(); - address.name = "王大锤"; - address.phone = "12345678901"; - address.address = "四川省成都市金牛区西雅图"; - orderDetail.address = address; - orderDetail.products = ProductViewModel().getOderDetailProducts(); - orderDetail.orderNumber = "2539129895"; - orderDetail.orderTime = "2018.12.22 09:32"; - orderDetail.payMode = "支付宝"; - orderDetail.productTotal = 195.00; - orderDetail.freight = 12.00; - orderDetail.payPrice = 165.00; - orderList.add(orderDetail); - OrderDetail orderDetail1 = new OrderDetail(); - orderDetail1.status = 1; - orderDetail1.express = "离开【太原中心】,下一站【广州中心】"; - address = new Address(); - address.name = "王大锤"; - address.phone = "12345678901"; - address.address = "四川省成都市金牛区西雅图"; - orderDetail1.address = address; - orderDetail1.products = [ - new Product( - name: "大moss 露肩性感裹胸内衣打底韩版外穿针织黑色抹胸上衣女无肩带", - image: - "https://gd1.alicdn.com/imgextra/i1/173752284/O1CN01a8IsUi1Sk774g4TgD_!!173752284.jpg", - price: "¥59.00", - brand: "MAI PIÙ SENZA", - description: "Awesome Heels", - rating: 4.1, - totalReviews: 22, - size: [37, 40, 41], - color: ["红色", "黑色", "蓝色"]) - ]; - orderDetail1.orderNumber = "2539129895"; - orderDetail1.orderTime = "2018.12.22 09:32"; - orderDetail1.payMode = "支付宝"; - orderDetail1.productTotal = 195.00; - orderDetail1.freight = 12.00; - orderDetail1.payPrice = 165.00; - orderList.add(orderDetail1); - OrderDetail orderDetail2 = new OrderDetail(); - orderDetail2.status = 0; - orderDetail2.express = "离开【太原中心】,下一站【广州中心】"; - address = new Address(); - address.name = "王大锤"; - address.phone = "12345678901"; - address.address = "四川省成都市金牛区西雅图"; - orderDetail2.address = address; - orderDetail2.products = [ - new Product( - name: "大moss 露肩性感裹胸内衣打底韩版外穿针织黑色抹胸上衣女无肩带", - image: - "https://gd1.alicdn.com/imgextra/i1/173752284/O1CN01a8IsUi1Sk774g4TgD_!!173752284.jpg", - price: "¥59.00", - brand: "MAI PIÙ SENZA", - description: "Awesome Heels", - rating: 4.1, - totalReviews: 22, - size: [37, 40, 41], - color: ["红色", "黑色", "蓝色"]) - ]; - orderDetail2.orderNumber = "2539129895"; - orderDetail2.orderTime = "2018.12.22 09:32"; - orderDetail2.payMode = "支付宝"; - orderDetail2.productTotal = 195.00; - orderDetail2.freight = 12.00; - orderDetail2.payPrice = 165.00; - orderList.add(orderDetail2); - OrderDetail orderDetail3 = new OrderDetail(); - orderDetail3.status = 3; - orderDetail3.express = "离开【太原中心】,下一站【广州中心】"; - address = new Address(); - address.name = "王大锤"; - address.phone = "12345678901"; - address.address = "四川省成都市金牛区西雅图"; - orderDetail3.address = address; - orderDetail3.products = [ - new Product( - name: "性感女仆情趣内衣服小胸激情套装血滴子透视开档紧身夜店制服诱惑", - image: - "https://gd3.alicdn.com/imgextra/i3/2873137436/TB2R7juDeySBuNjy1zdXXXPxFXa_!!2873137436.jpg", - price: "¥38.00", - brand: "MAI PIÙ SENZA", - description: "Awesome Heels", - rating: 4.1, - totalReviews: 22, - size: [37, 40, 41], - color: ["红色", "黑色", "蓝色"]) - ]; - orderDetail3.orderNumber = "2539129895"; - orderDetail3.orderTime = "2018.12.22 09:32"; - orderDetail3.payMode = "支付宝"; - orderDetail3.productTotal = 195.00; - orderDetail3.freight = 12.00; - orderDetail3.payPrice = 165.00; - orderList.add(orderDetail3); - OrderDetail orderDetail4 = new OrderDetail(); - orderDetail4.status = 4; - orderDetail4.express = "离开【太原中心】,下一站【广州中心】"; - address = new Address(); - address.name = "王大锤"; - address.phone = "12345678901"; - address.address = "四川省成都市金牛区西雅图"; - orderDetail4.address = address; - orderDetail4.products = [ - new Product( - name: "jk学生制服女套装软妹服装内衣情趣水手服性感骚短可爱学生妹女装", - image: - "https://gd1.alicdn.com/imgextra/i4/842112630/TB2HDRvjb1YBuNjSszeXXablFXa_!!842112630.jpg", - price: "¥89.00", - brand: "MAI PIÙ SENZA", - description: "Awesome Heels", - rating: 4.1, - totalReviews: 22, - size: [37, 40, 41], - color: ["红色", "黑色", "蓝色"]) - ]; - orderDetail4.orderNumber = "2539129895"; - orderDetail4.orderTime = "2018.12.22 09:32"; - orderDetail4.payMode = "支付宝"; - orderDetail4.productTotal = 195.00; - orderDetail4.freight = 12.00; - orderDetail4.payPrice = 165.00; - orderList.add(orderDetail4); - return orderList; - } +// +// List getOrderDetailList() { +// List orderList = new List(); +// OrderDetail orderDetail = new OrderDetail(); +// orderDetail.status = 2; +// orderDetail.express = "离开【太原中心】,下一站【广州中心】"; +// Address address = new Address(); +// address.name = "王大锤"; +// address.phone = "12345678901"; +// address.address = "四川省成都市金牛区西雅图"; +// orderDetail.address = address; +// orderDetail.products = ProductViewModel().getOderDetailProducts(); +// orderDetail.orderNumber = "2539129895"; +// orderDetail.orderTime = "2018.12.22 09:32"; +// orderDetail.payMode = "支付宝"; +// orderDetail.productTotal = 195.00; +// orderDetail.freight = 12.00; +// orderDetail.payPrice = 165.00; +// orderList.add(orderDetail); +// OrderDetail orderDetail1 = new OrderDetail(); +// orderDetail1.status = 1; +// orderDetail1.express = "离开【太原中心】,下一站【广州中心】"; +// address = new Address(); +// address.name = "王大锤"; +// address.phone = "12345678901"; +// address.address = "四川省成都市金牛区西雅图"; +// orderDetail1.address = address; +// orderDetail1.products = [ +// new Product( +// name: "大moss 露肩性感裹胸内衣打底韩版外穿针织黑色抹胸上衣女无肩带", +// image: +// "https://gd1.alicdn.com/imgextra/i1/173752284/O1CN01a8IsUi1Sk774g4TgD_!!173752284.jpg", +// price: "¥59.00", +// brand: "MAI PIÙ SENZA", +// description: "Awesome Heels", +// rating: 4.1, +// totalReviews: 22, +// size: [37, 40, 41], +// color: ["红色", "黑色", "蓝色"]) +// ]; +// orderDetail1.orderNumber = "2539129895"; +// orderDetail1.orderTime = "2018.12.22 09:32"; +// orderDetail1.payMode = "支付宝"; +// orderDetail1.productTotal = 195.00; +// orderDetail1.freight = 12.00; +// orderDetail1.payPrice = 165.00; +// orderList.add(orderDetail1); +// OrderDetail orderDetail2 = new OrderDetail(); +// orderDetail2.status = 0; +// orderDetail2.express = "离开【太原中心】,下一站【广州中心】"; +// address = new Address(); +// address.name = "王大锤"; +// address.phone = "12345678901"; +// address.address = "四川省成都市金牛区西雅图"; +// orderDetail2.address = address; +// orderDetail2.products = [ +// new Product( +// name: "大moss 露肩性感裹胸内衣打底韩版外穿针织黑色抹胸上衣女无肩带", +// image: +// "https://gd1.alicdn.com/imgextra/i1/173752284/O1CN01a8IsUi1Sk774g4TgD_!!173752284.jpg", +// price: "¥59.00", +// brand: "MAI PIÙ SENZA", +// description: "Awesome Heels", +// rating: 4.1, +// totalReviews: 22, +// size: [37, 40, 41], +// color: ["红色", "黑色", "蓝色"]) +// ]; +// orderDetail2.orderNumber = "2539129895"; +// orderDetail2.orderTime = "2018.12.22 09:32"; +// orderDetail2.payMode = "支付宝"; +// orderDetail2.productTotal = 195.00; +// orderDetail2.freight = 12.00; +// orderDetail2.payPrice = 165.00; +// orderList.add(orderDetail2); +// OrderDetail orderDetail3 = new OrderDetail(); +// orderDetail3.status = 3; +// orderDetail3.express = "离开【太原中心】,下一站【广州中心】"; +// address = new Address(); +// address.name = "王大锤"; +// address.phone = "12345678901"; +// address.address = "四川省成都市金牛区西雅图"; +// orderDetail3.address = address; +// orderDetail3.products = [ +// new Product( +// name: "性感女仆情趣内衣服小胸激情套装血滴子透视开档紧身夜店制服诱惑", +// image: +// "https://gd3.alicdn.com/imgextra/i3/2873137436/TB2R7juDeySBuNjy1zdXXXPxFXa_!!2873137436.jpg", +// price: "¥38.00", +// brand: "MAI PIÙ SENZA", +// description: "Awesome Heels", +// rating: 4.1, +// totalReviews: 22, +// size: [37, 40, 41], +// color: ["红色", "黑色", "蓝色"]) +// ]; +// orderDetail3.orderNumber = "2539129895"; +// orderDetail3.orderTime = "2018.12.22 09:32"; +// orderDetail3.payMode = "支付宝"; +// orderDetail3.productTotal = 195.00; +// orderDetail3.freight = 12.00; +// orderDetail3.payPrice = 165.00; +// orderList.add(orderDetail3); +// OrderDetail orderDetail4 = new OrderDetail(); +// orderDetail4.status = 4; +// orderDetail4.express = "离开【太原中心】,下一站【广州中心】"; +// address = new Address(); +// address.name = "王大锤"; +// address.phone = "12345678901"; +// address.address = "四川省成都市金牛区西雅图"; +// orderDetail4.address = address; +// orderDetail4.products = [ +// new Product( +// name: "jk学生制服女套装软妹服装内衣情趣水手服性感骚短可爱学生妹女装", +// image: +// "https://gd1.alicdn.com/imgextra/i4/842112630/TB2HDRvjb1YBuNjSszeXXablFXa_!!842112630.jpg", +// price: "¥89.00", +// brand: "MAI PIÙ SENZA", +// description: "Awesome Heels", +// rating: 4.1, +// totalReviews: 22, +// size: [37, 40, 41], +// color: ["红色", "黑色", "蓝色"]) +// ]; +// orderDetail4.orderNumber = "2539129895"; +// orderDetail4.orderTime = "2018.12.22 09:32"; +// orderDetail4.payMode = "支付宝"; +// orderDetail4.productTotal = 195.00; +// orderDetail4.freight = 12.00; +// orderDetail4.payPrice = 165.00; +// orderList.add(orderDetail4); +// return orderList; +// } getDiscountList() => [ new Product( diff --git a/flutter_lib/lib/model/Banner.dart b/flutter_lib/lib/model/Banner.dart new file mode 100644 index 0000000..691a023 --- /dev/null +++ b/flutter_lib/lib/model/Banner.dart @@ -0,0 +1,35 @@ +import 'package:flutter_lib/ui/widgets/banner/banner_evalutor.dart'; + +class DataListBean implements BannerWithEval{ + String indexImgUrlId; + int status; + String createTime; + String title; + int sortNum; + String indexImgUrl; + + DataListBean({this.indexImgUrlId, this.status, this.createTime, this.title, this.sortNum, this.indexImgUrl}); + + DataListBean.fromJson(Map json) { + this.indexImgUrlId = json['indexImgUrlId']; + this.status = json['status']; + this.createTime = json['createTime']; + this.title = json['title']; + this.sortNum = json['sortNum']; + this.indexImgUrl = json['indexImgUrl']; + } + + Map toJson() { + final Map data = new Map(); + data['indexImgUrlId'] = this.indexImgUrlId; + data['status'] = this.status; + data['createTime'] = this.createTime; + data['title'] = this.title; + data['sortNum'] = this.sortNum; + data['indexImgUrl'] = this.indexImgUrl; + return data; + } + + @override + get bannerUrl => indexImgUrl; +} diff --git a/flutter_lib/lib/model/HomeCategory.dart b/flutter_lib/lib/model/HomeCategory.dart new file mode 100644 index 0000000..8dba774 --- /dev/null +++ b/flutter_lib/lib/model/HomeCategory.dart @@ -0,0 +1,27 @@ + +import 'package:json_annotation/json_annotation.dart'; +//flutter packages pub run build_runner build +part 'HomeCategory.g.dart'; + +@JsonSerializable() +class HomeCategory { + String categoryName; + + String categoryImgUrl; + + int sortNum; + String categoryId; + + HomeCategory( + this.categoryName, this.categoryImgUrl, this.sortNum, this.categoryId); + + /// + factory HomeCategory.fromJson(Map json) => _$HomeCategoryFromJson(json); + + /// `toJson` is the convention for a class to declare support for serialization + /// to JSON. The implementation simply calls the private, generated + /// helper method `_$CategoryToJson`. + Map toJson() => _$HomeCategoryToJson(this); + + +} diff --git a/flutter_lib/lib/model/HomeCategory.g.dart b/flutter_lib/lib/model/HomeCategory.g.dart new file mode 100644 index 0000000..d77b05d --- /dev/null +++ b/flutter_lib/lib/model/HomeCategory.g.dart @@ -0,0 +1,23 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'HomeCategory.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +HomeCategory _$HomeCategoryFromJson(Map json) { + return HomeCategory( + json['categoryName'] as String, + json['categoryImgUrl'] as String, + json['sortNum'] as int, + json['categoryId'] as String); +} + +Map _$HomeCategoryToJson(HomeCategory instance) => + { + 'categoryName': instance.categoryName, + 'categoryImgUrl': instance.categoryImgUrl, + 'sortNum': instance.sortNum, + 'categoryId': instance.categoryId + }; diff --git a/flutter_lib/lib/model/OrderComment.dart b/flutter_lib/lib/model/OrderComment.dart new file mode 100644 index 0000000..3d0ec5b --- /dev/null +++ b/flutter_lib/lib/model/OrderComment.dart @@ -0,0 +1,45 @@ +import 'package:json_annotation/json_annotation.dart'; +part 'OrderComment.g.dart'; +//flutter packages pub run build_runner build +@JsonSerializable() +class OrderComment { + String orderId; + + List goodsEvaluates; + + OrderComment(this.orderId, this.goodsEvaluates); + + + /// A necessary factory constructor for creating a new Category instance + /// from a map. Pass the map to the generated `_$CategoryFromJson()` constructor. + /// The constructor is named after the source class, in this case Category. + /// + factory OrderComment.fromJson(Map json) => _$OrderCommentFromJson(json); + + /// `toJson` is the convention for a class to declare support for serialization + /// to JSON. The implementation simply calls the private, generated + /// helper method `_$CategoryToJson`. + Map toJson() => _$OrderCommentToJson(this); + + +} + +@JsonSerializable() +class Goods { + String productId; + String content; + String level; + + Goods(this.productId, this.content, this.level); + + /// A necessary factory constructor for creating a new Category instance + /// from a map. Pass the map to the generated `_$CategoryFromJson()` constructor. + /// The constructor is named after the source class, in this case Category. + /// + factory Goods.fromJson(Map json) => _$GoodsFromJson(json); + + /// `toJson` is the convention for a class to declare support for serialization + /// to JSON. The implementation simply calls the private, generated + /// helper method `_$CategoryToJson`. + Map toJson() => _$GoodsToJson(this); +} diff --git a/flutter_lib/lib/model/OrderComment.g.dart b/flutter_lib/lib/model/OrderComment.g.dart new file mode 100644 index 0000000..6aa3834 --- /dev/null +++ b/flutter_lib/lib/model/OrderComment.g.dart @@ -0,0 +1,33 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'OrderComment.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +OrderComment _$OrderCommentFromJson(Map json) { + return OrderComment( + json['orderId'] as String, + (json['goodsEvaluates'] as List) + ?.map((e) => + e == null ? null : Goods.fromJson(e as Map)) + ?.toList()); +} + +Map _$OrderCommentToJson(OrderComment instance) => + { + 'orderId': instance.orderId, + 'goodsEvaluates': instance.goodsEvaluates + }; + +Goods _$GoodsFromJson(Map json) { + return Goods(json['productId'] as String, json['content'] as String, + json['level'] as String); +} + +Map _$GoodsToJson(Goods instance) => { + 'productId': instance.productId, + 'content': instance.content, + 'level': instance.level + }; diff --git a/flutter_lib/lib/model/orderDetail.dart b/flutter_lib/lib/model/orderDetail.dart deleted file mode 100644 index 09947f2..0000000 --- a/flutter_lib/lib/model/orderDetail.dart +++ /dev/null @@ -1,75 +0,0 @@ -import 'package:flutter_lib/model/address.dart'; -import 'package:flutter_lib/model/product.dart'; - -class OrderDetail { - int status; //状态 0已取消,1等待发货,2已发货,3已收货,4交易完成 - Address address; //收货地址 - String express; //最新一条物流信息 - List products; //商品信息 - String orderNumber; //订单编号 - String orderTime; //下单时间 - String payMode; //支付方式 - double productTotal; //商品合计(价格) - double freight; //运费 - double payPrice; //实付款 - - String getStatusName(){ - switch(status){ - case 0: - return "已取消"; - case 1: - return "等待发货"; - case 2: - return "已发货"; - case 3: - return "已收货"; - case 4: - return "交易完成"; - } - } - - String getListStatusName(){ - switch(status){ - case 0: - return "已取消"; - case 1: - return "待发货"; - case 2: - return "已发货"; - case 3: - return "待评价"; - case 4: - return "待评价"; - } - } - - String getStatusButtonName(){ - switch(status){ - case 0: - return "已取消"; - case 1: - return "取消订单"; - case 2: - return "查看物流"; - case 3: - return "申请售后"; - case 4: - return "申请售后"; - } - } - - String getListStatusButtonName(){ - switch(status){ - case 0: - return "已取消"; - case 1: - return "取消订单"; - case 2: - return "查看物流"; - case 3: - return "退换货"; - case 4: - return "退换货"; - } - } -} diff --git a/flutter_lib/lib/model/orderListItem.dart b/flutter_lib/lib/model/orderListItem.dart index 445e63d..21c135d 100644 --- a/flutter_lib/lib/model/orderListItem.dart +++ b/flutter_lib/lib/model/orderListItem.dart @@ -6,7 +6,8 @@ part 'orderListItem.g.dart'; @JsonSerializable() class OrderItem { - int status; //1:待付款,2:待发货,3:待收货,4:待评价,0:全部 +// //1:待付款,2:待发货,3:待收货,4:待评价,0:全部 + int status; Address address; //收货地址 String express; //最新一条物流信息 @JsonKey(name: 'goodsList') @@ -53,11 +54,14 @@ class Good { String goodsId; String goodsName; String goodsPrice; + String goodsImgUrl; + String specMsg; Good({ this.buyNum, this.goodsId, this.goodsName, this.goodsPrice, //商品信息 + this.specMsg, }); factory Good.fromJson(Map json) => diff --git a/flutter_lib/lib/model/orderListItem.g.dart b/flutter_lib/lib/model/orderListItem.g.dart index b8db51c..c687c2e 100644 --- a/flutter_lib/lib/model/orderListItem.g.dart +++ b/flutter_lib/lib/model/orderListItem.g.dart @@ -43,12 +43,16 @@ Good _$GoodFromJson(Map json) { buyNum: json['buyNum'] as String, goodsId: json['goodsId'] as String, goodsName: json['goodsName'] as String, - goodsPrice: json['goodsPrice'] as String); + goodsPrice: json['goodsPrice'] as String, + specMsg: json['specMsg'] as String) + ..goodsImgUrl = json['goodsImgUrl'] as String; } Map _$GoodToJson(Good instance) => { 'buyNum': instance.buyNum, 'goodsId': instance.goodsId, 'goodsName': instance.goodsName, - 'goodsPrice': instance.goodsPrice + 'goodsPrice': instance.goodsPrice, + 'goodsImgUrl': instance.goodsImgUrl, + 'specMsg': instance.specMsg }; diff --git a/flutter_lib/lib/model/orderdetail.dart b/flutter_lib/lib/model/orderdetail.dart new file mode 100644 index 0000000..ea16983 --- /dev/null +++ b/flutter_lib/lib/model/orderdetail.dart @@ -0,0 +1,169 @@ +import 'package:flutter_lib/bridge/common_bridge.dart'; +import 'package:flutter_lib/bridge/order_bridge.dart'; +import 'package:flutter_lib/model/OrderComment.dart'; +import 'package:flutter_lib/model/Result.dart'; +import 'package:flutter_lib/model/address.dart'; +import 'package:flutter_lib/model/orderListItem.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'orderdetail.g.dart'; + +//{createTime: 2019-04-30 16:46:33, +// freight: 0, +// goods: [{allGoodsPrice: 1, +// buyNum: 1, +// goodsId: 100, +// goodsName: Hawt Like a Habanero Shirt (Men's), +// goodsPrice: 1, +// specMsg: SIZE:S}], +// orderId: 1556642793767000, +// orderPrice: 1, +// payFee: 0, payType: 0, +// receiveGoods: { +// receiveAddressName: 上海, +// receiveGoodsName: 一明, +// receivePhone: 18612341234, +// status: 0, +// userAddressId: +// 1556616203528004}, +// status: 0} + +//flutter packages pub run build_runner build +@JsonSerializable() +class OrderDetail { + String orderId; //订单编号 + int status; //状态 1:待付款,2:待发货,3:待收货,4:待评价,5:完成,6:已取消 + Address receiveGoods; //收货地址 + String express; //最新一条物流信息 + + List goods; //商品信息 + String createTime; //下单时间 + + String payType; //支付方式 + String orderPrice; //订单金额 + String freight; //运费 + String payFee; + + + OrderDetail.O(this.orderId); + + OrderDetail( + this.orderId, + this.status, + this.receiveGoods, + this.express, + this.goods, + this.createTime, + this.payType, + this.orderPrice, + this.freight, + this.payFee); //实付款 + + factory OrderDetail.fromJson(Map json) => + _$OrderDetailFromJson(json); + + /// `toJson` is the convention for a class to declare support for serialization + /// to JSON. The implementation simply calls the private, generated + /// helper method `_$CategoryToJson`. + Map toJson() => _$OrderDetailToJson(this); + + String getStatusName() { + switch (status) { + case 0: + return "已取消"; + case 1: + return "待付款"; + case 2: + return "待发货"; + case 3: + return "待收货"; + case 4: + return "待评价"; + default: + return ""; + } + } +// 1:待付款,2:待发货,3:待收货,4:待评价,0:全部 + String getListStatusName() { + switch (status) { + case 0: + return "已取消"; + case 1: + return "待付款"; + case 2: + return "待发货"; + case 3: + return "待收货"; + case 4: + return "待评价"; + default: + return ""; + } + } + + String getStatusButtonName() { + switch (status) { + case 0: + return "已取消"; + case 1: + return "取消订单"; + case 2: + return "查看物流"; + case 3: + return "申请售后"; + case 4: + return "申请售后"; + default: + return ""; + } + } + + doWithOrder(){ + switch (status) { + case 0: + Future future = + OrderBridge.cancelOrder(orderId); + future.then((r) { + if (r.code == 200) { + Bridge.showLongToast("取消成功"); + } else { + Bridge.showLongToast(r.msg); + } + }); + break; + case 2: + + Bridge.webview("https://www.kuaidi100.com/chaxun?com=[]&nu=[]"); + break; + case 3: + Bridge.webview("https://www.kuaidi100.com/chaxun?com=[]&nu=[]"); + break; + case 4: + Bridge.webview("https://www.kuaidi100.com/chaxun?com=[]&nu=[]"); + break; + default: + return ""; + } + } +} +// +//@JsonSerializable() +//class Goods { +// String goodsName; +// String goodsPrice; +// String buyNum; +// String allGoodsPrice; +// String goodsImgUrl; +// String goodsId; +// String specMsg; +// +// Goods(this.goodsName, this.goodsPrice, this.buyNum, this.allGoodsPrice, +// this.goodsImgUrl, this.goodsId, this.specMsg); +// +// factory Goods.fromJson(Map json) => _$GoodsFromJson(json); +// +// /// `toJson` is the convention for a class to declare support for serialization +// /// to JSON. The implementation simply calls the private, generated +// /// helper method `_$CategoryToJson`. +// Map toJson() => _$GoodsToJson(this); +//} diff --git a/flutter_lib/lib/model/orderdetail.g.dart b/flutter_lib/lib/model/orderdetail.g.dart new file mode 100644 index 0000000..e05126f --- /dev/null +++ b/flutter_lib/lib/model/orderdetail.g.dart @@ -0,0 +1,40 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'orderdetail.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +OrderDetail _$OrderDetailFromJson(Map json) { + return OrderDetail( + json['orderId'] as String, + json['status'] as int, + json['receiveGoods'] == null + ? null + : Address.fromJson(json['receiveGoods'] as Map), + json['express'] as String, + (json['goods'] as List) + ?.map((e) => + e == null ? null : Good.fromJson(e as Map)) + ?.toList(), + json['createTime'] as String, + json['payType'] as String, + json['orderPrice'] as String, + json['freight'] as String, + json['payFee'] as String); +} + +Map _$OrderDetailToJson(OrderDetail instance) => + { + 'orderId': instance.orderId, + 'status': instance.status, + 'receiveGoods': instance.receiveGoods, + 'express': instance.express, + 'goods': instance.goods, + 'createTime': instance.createTime, + 'payType': instance.payType, + 'orderPrice': instance.orderPrice, + 'freight': instance.freight, + 'payFee': instance.payFee + }; diff --git a/flutter_lib/lib/model/ordergoods.dart b/flutter_lib/lib/model/ordergoods.dart index fad15d2..697709b 100644 --- a/flutter_lib/lib/model/ordergoods.dart +++ b/flutter_lib/lib/model/ordergoods.dart @@ -6,8 +6,11 @@ part 'ordergoods.g.dart'; class OrderGoods { String goodsId; String buyNum; + String productId; - OrderGoods(this.goodsId, this.buyNum); + + + OrderGoods(this.goodsId, this.buyNum, this.productId); factory OrderGoods.fromJson(Map json) => _$OrderGoodsFromJson(json); diff --git a/flutter_lib/lib/model/ordergoods.g.dart b/flutter_lib/lib/model/ordergoods.g.dart index b6a357e..8b0df65 100644 --- a/flutter_lib/lib/model/ordergoods.g.dart +++ b/flutter_lib/lib/model/ordergoods.g.dart @@ -7,8 +7,13 @@ part of 'ordergoods.dart'; // ************************************************************************** OrderGoods _$OrderGoodsFromJson(Map json) { - return OrderGoods(json['goodsId'] as String, json['buyNum'] as String); + return OrderGoods(json['goodsId'] as String, json['buyNum'] as String, + json['productId'] as String); } Map _$OrderGoodsToJson(OrderGoods instance) => - {'goodsId': instance.goodsId, 'buyNum': instance.buyNum}; + { + 'goodsId': instance.goodsId, + 'buyNum': instance.buyNum, + 'productId': instance.productId + }; diff --git a/flutter_lib/lib/model/productdetail.dart b/flutter_lib/lib/model/productdetail.dart index 8c00984..c92c2af 100644 --- a/flutter_lib/lib/model/productdetail.dart +++ b/flutter_lib/lib/model/productdetail.dart @@ -1,59 +1,92 @@ class Productdetail { - String totalCount; + String totalCount = "0"; List list; Productdetail({this.totalCount, this.list}); - Productdetail.fromJson(Map json) { + Productdetail.fromJson(Map json) { this.totalCount = json['totalCount']; - this.list = (json['list'] as List)!=null?(json['list'] as List).map((i) => ProductDetail.fromJson(i)).toList():null; + this.list = (json['list'] as List) != null + ? (json['list'] as List).map((i) => ProductDetail.fromJson(i)).toList() + : null; } Map toJson() { final Map data = new Map(); data['totalCount'] = this.totalCount; - data['list'] = this.list != null?this.list.map((i) => i.toJson()).toList():null; + data['list'] = + this.list != null ? this.list.map((i) => i.toJson()).toList() : null; return data; } - } class ProductDetail { - String activeStartDate; - String name; - String detail; - double salePrice; - double retailPrice; - int inventory; - int id; - List attributes; - List medias; - - ProductDetail({this.activeStartDate, this.name, this.detail, this.salePrice, this.retailPrice, this.inventory, this.id, this.attributes, this.medias}); + String activeStartDate = ""; + String name = ""; + double salePrice = 0; + double retailPrice = 0; + int inventory = 0; + String description; + String metaTitle; + int id = 0; + int skuId = 0; + List attributes = List(); + List medias = List(); + + ProductDetail( + this.activeStartDate, + this.name, + this.salePrice, + this.retailPrice, + this.inventory, + this.id, + this.metaTitle, + this.skuId, + this.attributes, + this.medias); + + ProductDetail.N(this.name); ProductDetail.fromJson(Map json) { this.activeStartDate = json['activeStartDate']; this.name = json['name']; - this.detail = json['detail']; this.salePrice = json['salePrice']; this.retailPrice = json['retailPrice']; this.inventory = json['inventory']; this.id = json['id']; - this.attributes = (json['attributes'] as List)!=null?(json['attributes'] as List).map((i) => AttributesListBean.fromJson(i)).toList():null; - this.medias = (json['medias'] as List)!=null?(json['medias'] as List).map((i) => MediasListBean.fromJson(i)).toList():null; + this.metaTitle = json['metaTitle']; + this.description = json['description']; + + this.skuId = json['skuId']; + this.attributes = (json['attributes'] as List) != null + ? (json['attributes'] as List) + .map((i) => AttributesListBean.fromJson(i)) + .toList() + : null; + this.medias = (json['medias'] as List) != null + ? (json['medias'] as List) + .map((i) => MediasListBean.fromJson(i)) + .toList() + : null; } Map toJson() { final Map data = new Map(); data['activeStartDate'] = this.activeStartDate; data['name'] = this.name; - data['detail'] = this.detail; data['salePrice'] = this.salePrice; data['retailPrice'] = this.retailPrice; data['inventory'] = this.inventory; data['id'] = this.id; - data['attributes'] = this.attributes != null?this.attributes.map((i) => i.toJson()).toList():null; - data['medias'] = this.medias != null?this.medias.map((i) => i.toJson()).toList():null; + data['metaTitle'] = this.metaTitle; + data['description'] = this.description; + data['skuId'] = this.skuId; + data['attributes'] = this.attributes != null + ? this.attributes.map((i) => i.toJson()).toList() + : null; + data['medias'] = this.medias != null + ? this.medias.map((i) => i.toJson()).toList() + : null; return data; } } @@ -66,7 +99,7 @@ class AttributesListBean { AttributesListBean({this.value, this.option, this.valueId, this.optionId}); - AttributesListBean.fromJson(Map json) { + AttributesListBean.fromJson(Map json) { this.value = json['value']; this.option = json['option']; this.valueId = json['valueId']; @@ -90,7 +123,7 @@ class MediasListBean { MediasListBean({this.name, this.url, this.id}); - MediasListBean.fromJson(Map json) { + MediasListBean.fromJson(Map json) { this.name = json['name']; this.url = json['url']; this.id = json['id']; diff --git a/flutter_lib/lib/model/promotion.dart b/flutter_lib/lib/model/promotion.dart new file mode 100644 index 0000000..3581bd5 --- /dev/null +++ b/flutter_lib/lib/model/promotion.dart @@ -0,0 +1,26 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'promotion.g.dart'; +//flutter packages pub run build_runner build + +@JsonSerializable() +class Promotion{ + String promotionTitle; + String promotionDesc; + String productId; + String sellPrice; + String promotionPrice; + String imgUrl; + + Promotion(this.promotionTitle, this.promotionDesc, this.productId, + this.sellPrice, this.promotionPrice, this.imgUrl); + + + factory Promotion.fromJson(Map json) => _$PromotionFromJson(json); + + /// `toJson` is the convention for a class to declare support for serialization + /// to JSON. The implementation simply calls the private, generated + /// helper method `_$CategoryToJson`. + Map toJson() => _$PromotionToJson(this); + +} \ No newline at end of file diff --git a/flutter_lib/lib/model/promotion.g.dart b/flutter_lib/lib/model/promotion.g.dart new file mode 100644 index 0000000..68cf65d --- /dev/null +++ b/flutter_lib/lib/model/promotion.g.dart @@ -0,0 +1,26 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'promotion.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Promotion _$PromotionFromJson(Map json) { + return Promotion( + json['promotionTitle'] as String, + json['promotionDesc'] as String, + json['productId'] as String, + json['sellPrice'] as String, + json['promotionPrice'] as String, + json['imgUrl'] as String); +} + +Map _$PromotionToJson(Promotion instance) => { + 'promotionTitle': instance.promotionTitle, + 'promotionDesc': instance.promotionDesc, + 'productId': instance.productId, + 'sellPrice': instance.sellPrice, + 'promotionPrice': instance.promotionPrice, + 'imgUrl': instance.imgUrl + }; diff --git a/flutter_lib/lib/model/record.dart b/flutter_lib/lib/model/record.dart new file mode 100644 index 0000000..430d91e --- /dev/null +++ b/flutter_lib/lib/model/record.dart @@ -0,0 +1,11 @@ +class Record { + String name; + String status; + String time; + + Record({ + this.name, + this.status, + this.time, + }); +} diff --git a/flutter_lib/lib/model/searchinfo.dart b/flutter_lib/lib/model/searchinfo.dart new file mode 100644 index 0000000..ed8ac54 --- /dev/null +++ b/flutter_lib/lib/model/searchinfo.dart @@ -0,0 +1,25 @@ +class SearchInfo { + String keywold; + int pageNo; + int pageSzie; + + SearchInfo( + this.keywold, + this.pageNo, + this.pageSzie, + ); + + SearchInfo.fromJson(Map json) { + this.keywold = json['keywold']; + this.pageNo = json['pageNo']; + this.pageSzie = json['pageSize']; + } + + Map toJson() { + final Map data = new Map(); + data['keywold'] = this.keywold; + data['pageNo'] = this.pageNo; + data['pageSzie'] = this.pageSzie; + return data; + } +} diff --git a/flutter_lib/lib/model/skuinfo.dart b/flutter_lib/lib/model/skuinfo.dart index 008ef80..31893aa 100644 --- a/flutter_lib/lib/model/skuinfo.dart +++ b/flutter_lib/lib/model/skuinfo.dart @@ -12,6 +12,8 @@ class SkuInfo { data['options'] = this.options != null?this.options.map((i) => i.toJson()).toList():null; return data; } + + } class OptionsListBean { diff --git a/flutter_lib/lib/model/special.dart b/flutter_lib/lib/model/special.dart new file mode 100644 index 0000000..fb954e3 --- /dev/null +++ b/flutter_lib/lib/model/special.dart @@ -0,0 +1,26 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'special.g.dart'; +//flutter packages pub run build_runner build + +@JsonSerializable() +class Special{ + String titleName;//标题 + String specialDesc;//描述 + String productId;//商品ID + String imgUrl; + + Special(this.titleName, this.specialDesc, this.productId, + this.imgUrl); //图片url + + + + + factory Special.fromJson(Map json) => _$SpecialFromJson(json); + + /// `toJson` is the convention for a class to declare support for serialization + /// to JSON. The implementation simply calls the private, generated + /// helper method `_$CategoryToJson`. + Map toJson() => _$SpecialToJson(this); + +} \ No newline at end of file diff --git a/flutter_lib/lib/model/special.g.dart b/flutter_lib/lib/model/special.g.dart new file mode 100644 index 0000000..1404724 --- /dev/null +++ b/flutter_lib/lib/model/special.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'special.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Special _$SpecialFromJson(Map json) { + return Special(json['titleName'] as String, json['specialDesc'] as String, + json['productId'] as String, json['imgUrl'] as String); +} + +Map _$SpecialToJson(Special instance) => { + 'titleName': instance.titleName, + 'specialDesc': instance.specialDesc, + 'productId': instance.productId, + 'imgUrl': instance.imgUrl + }; diff --git a/flutter_lib/lib/model/userinfo.dart b/flutter_lib/lib/model/userinfo.dart index b6b08c3..bd826b4 100644 --- a/flutter_lib/lib/model/userinfo.dart +++ b/flutter_lib/lib/model/userinfo.dart @@ -1,6 +1,19 @@ class Userinfo { + +// balanceAmt:金币 +//// totalConsumeAmt:总的消费额 +//// userCode:邀请码 +//// phone:手机号 +//// inviteNum:我的会员个数 +//// userSex:性别,1:男,2:女 +//// userImgUrl:用户头像 +//// openId:微信openid +//// nickName:昵称 +//// cityName:所在城市 +//// provinceName:所在省份 + String balanceAmt; - String totalConsumeAmt; + String totalConsume; String phone; String userCode; String status; @@ -18,11 +31,11 @@ class Userinfo { String inviteNum; - Userinfo({this.balanceAmt, this.totalConsumeAmt, this.phone, this.userCode, this.status, this.parentId, this.createTime, this.userLevel, this.userSex, this.userImgUrl, this.openId, this.nickName, this.cityName, this.countryName, this.provinceName, this.imgUrl, this.inviteNum}); + Userinfo({this.balanceAmt, this.totalConsume, this.phone, this.userCode, this.status, this.parentId, this.createTime, this.userLevel, this.userSex, this.userImgUrl, this.openId, this.nickName, this.cityName, this.countryName, this.provinceName, this.imgUrl, this.inviteNum}); Userinfo.fromJson(Map json) { this.balanceAmt = json['balanceAmt']; - this.totalConsumeAmt = json['totalConsumeAmt']; + this.totalConsume = json['totalConsume']; this.phone = json['phone']; this.userCode = json['userCode']; this.status = json['status']; @@ -43,7 +56,7 @@ class Userinfo { Map toJson() { final Map data = new Map(); data['balanceAmt'] = this.balanceAmt; - data['totalConsumeAmt'] = this.totalConsumeAmt; + data['totalConsume'] = this.totalConsume; data['phone'] = this.phone; data['userCode'] = this.userCode; data['status'] = this.status; diff --git a/flutter_lib/lib/myapp.dart b/flutter_lib/lib/myapp.dart index 6787dc3..065b31d 100644 --- a/flutter_lib/lib/myapp.dart +++ b/flutter_lib/lib/myapp.dart @@ -1,7 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:flutter_lib/bridge/common_bridge.dart'; +import 'package:flutter_lib/model/OrderComment.dart'; import 'package:flutter_lib/model/category.dart'; import 'package:flutter_lib/ui/page/account/login.dart'; +import 'package:flutter_lib/ui/page/account/mine_wallet.dart'; import 'package:flutter_lib/ui/page/account/register.dart'; +import 'package:flutter_lib/ui/page/account/vip_apply.dart'; import 'package:flutter_lib/ui/page/dashboard/dashboard.page.dart'; import 'package:flutter_lib/ui/page/dashboard/home_page.dart'; import 'package:flutter_lib/ui/page/dashboard/user_home_page.dart'; @@ -9,7 +13,6 @@ import 'package:flutter_lib/ui/page/invite/invite_friends.dart'; import 'package:flutter_lib/ui/page/invite/invite_input.dart'; import 'package:flutter_lib/ui/page/notfound/notfound_page.dart'; import 'package:flutter_lib/ui/page/order/all_shop_order_list.dart'; -import 'package:flutter_lib/ui/page/order/mine_order.dart'; import 'package:flutter_lib/ui/page/order/oder_comment.dart'; import 'package:flutter_lib/ui/page/order/order_comment_list.dart'; import 'package:flutter_lib/ui/page/order/order_detail.dart'; @@ -33,18 +36,7 @@ class MyApp extends StatelessWidget { debugShowCheckedModeBanner: true, showPerformanceOverlay: false, home: DashboardPage(), -// localizationsDelegates: [ -// const TranslationsDelegate(), -// GlobalMaterialLocalizations.delegate, -// GlobalWidgetsLocalizations.delegate, -// ], -// supportedLocales: [ -// const Locale("en", "US"), -// const Locale("hi", "IN"), -// ], initialRoute: UIData.notFoundRoute, - - //routes routes: { UIData.ShopCartListPage: (BuildContext context) => ShopCartListPage(true), @@ -54,12 +46,11 @@ class MyApp extends StatelessWidget { UIData.notFoundRoute: (BuildContext context) => NotFoundPage(), UIData.IviteFriendsPage: (BuildContext context) => InviteFriendsPage(), UIData.InviteInputPage: (BuildContext context) => InviteInputPage(), + UIData.VipApplyPage: (BuildContext context) => VipApplyPage(), + UIData.MineWalletPage: (BuildContext context) => MineWalletPage(), UIData.UserHomeListPage: (BuildContext context) => UserHomeListPage(), - UIData.AllShopOrderPage: (BuildContext context) => AllShopOrderPage(), UIData.MineCollectionPage: (BuildContext context) => MineCollectionPage(), - UIData.OrderDetailPage: (BuildContext context) => OrderDetailPage(), - UIData.OrderCommentPage: (BuildContext context) => OrderCommentPage(), UIData.OrderCommentListPage: (BuildContext context) => OrderCommentListPage(), UIData.Register: (BuildContext context) => RegisterPage() @@ -94,24 +85,47 @@ class MyApp extends StatelessWidget { ); } break; - case UIData.MineOrderPage: + case UIData.OrderCommentPage: + if (arguments is OrderComment) { + return new MaterialPageRoute( + settings: settings, + builder: (BuildContext context) => OrderCommentPage(arguments), + ); + } + break; + case UIData.OrderDetailPage: + if (arguments is String) { + return new MaterialPageRoute( + settings: settings, + builder: (BuildContext context) => OrderDetailPage(arguments), + ); + } + break; + case UIData.AllShopOrderPage: if (arguments is int) { return new MaterialPageRoute( settings: settings, - builder: (BuildContext context) => MineOrderPage(arguments), + builder: (BuildContext context) => AllShopOrderPage(arguments), ); } break; } }, - onUnknownRoute: (RouteSettings rs) => new MaterialPageRoute( - builder: (context) => new NotFoundPage( - appTitle: UIData.coming_soon, -// icon: FontAwesomeIcons.solidSmile, - title: UIData.coming_soon, - message: "Under Development", - iconColor: Colors.grey, - ))); + onUnknownRoute: (RouteSettings settings) { +// final arguments = settings.arguments; +// switch (settings.name) { +// case UIData.ShopDetailPage: +// +// break; +// } + new MaterialPageRoute( + builder: (context) => new NotFoundPage( + appTitle: UIData.coming_soon, + title: UIData.coming_soon, + message: "Under Development", + iconColor: Colors.grey, + )); + }); @override Widget build(BuildContext context) { diff --git a/flutter_lib/lib/logic/inherited/category_provider.dart b/flutter_lib/lib/ui/inherited/category_provider.dart similarity index 89% rename from flutter_lib/lib/logic/inherited/category_provider.dart rename to flutter_lib/lib/ui/inherited/category_provider.dart index 3e35f83..d59fde9 100644 --- a/flutter_lib/lib/logic/inherited/category_provider.dart +++ b/flutter_lib/lib/ui/inherited/category_provider.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_lib/logic/bloc/category_bloc.dart'; -import 'package:flutter_lib/logic/bloc/product_bloc.dart'; class CategoryProvider extends InheritedWidget { final CategoryBloc categoryBloc; diff --git a/flutter_lib/lib/ui/inherited/home_provider.dart b/flutter_lib/lib/ui/inherited/home_provider.dart new file mode 100644 index 0000000..153f46d --- /dev/null +++ b/flutter_lib/lib/ui/inherited/home_provider.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_lib/logic/bloc/home_bloc.dart'; +import 'package:flutter_lib/logic/bloc/product_bloc.dart'; + +class HomeBlocProvider extends InheritedWidget { + final HomeBloc bloc; + final Widget child; + + HomeBlocProvider({this.bloc, this.child}) : super(child: child); + + static HomeBlocProvider of(BuildContext context) => + context.inheritFromWidgetOfExactType(HomeBlocProvider); + + @override + bool updateShouldNotify(HomeBlocProvider oldWidget) => + bloc != oldWidget.bloc; +} diff --git a/flutter_lib/lib/logic/inherited/product_provider.dart b/flutter_lib/lib/ui/inherited/product_provider.dart similarity index 100% rename from flutter_lib/lib/logic/inherited/product_provider.dart rename to flutter_lib/lib/ui/inherited/product_provider.dart diff --git a/flutter_lib/lib/ui/page/account/login.dart b/flutter_lib/lib/ui/page/account/login.dart index 7564e7e..aef1610 100644 --- a/flutter_lib/lib/ui/page/account/login.dart +++ b/flutter_lib/lib/ui/page/account/login.dart @@ -4,13 +4,25 @@ import 'package:flutter_lib/bridge/account_bridge.dart'; import 'package:flutter_lib/bridge/common_bridge.dart'; import 'package:flutter_lib/model/Result.dart'; import 'package:flutter_lib/ui/page/account/register.dart'; +import 'package:flutter_lib/ui/widgets/countdown.dart'; class LoginPage extends StatefulWidget { @override LoginState createState() => LoginState(); } -class LoginState extends State { +class LoginState extends State with TickerProviderStateMixin { + TextEditingController smsCodeEditingController = new TextEditingController(); + TextEditingController inviteCodeEditingController = + new TextEditingController(); + Color _verifycodecolor = Color(0xFF999999); + Color _verifybordercolor = Color(0xFFEEEEEE); + var _verifyborderwidth = 1.0; + + int time_cutdown = 60; + bool isGetingSms = false; + AnimationController _animationController; + var _scaffoldkey = new GlobalKey(); void showSnackBar(String message) { @@ -18,6 +30,23 @@ class LoginState extends State { _scaffoldkey.currentState.showSnackBar(snackBar); } + @override + void initState() { + _animationController = new AnimationController( + duration: new Duration(seconds: time_cutdown), + vsync: this, + ); + _animationController.addStatusListener((v) { + AnimationStatus a = v; + if (a == AnimationStatus.completed) { + setState(() { + isGetingSms = false; + }); + } + }); + super.initState(); + } + @override Widget build(BuildContext context) { return new DefaultTabController( @@ -152,12 +181,7 @@ class LoginState extends State { ); } - TextEditingController smsCodeEditingController = new TextEditingController(); - TextEditingController inviteCodeEditingController = - new TextEditingController(); - Color _verifycodecolor = Color(0xFF999999); - Color _verifybordercolor = Color(0xFFEEEEEE); - var _verifyborderwidth = 1.0; + Container buildGetSms() { return Container( @@ -190,10 +214,19 @@ class LoginState extends State { child: new Container( width: 71.0, height: 22.0, - child: new Text( - "获取验证码", - style: TextStyle(color: _verifybordercolor, fontSize: 10), - ), + child: isGetingSms + ? new Countdown( + color: Colors.white, + animation: new StepTween( + begin: time_cutdown, + end: 0, + ).animate(_animationController), + ) + : new Text( + "获取验证码", + style: TextStyle( + color: _verifybordercolor, fontSize: 10), + ), alignment: Alignment.center, ), //圆角大小,与BoxDecoration保持一致,更美观 @@ -207,6 +240,10 @@ class LoginState extends State { future.then((v) { if (v.code == 200) { Bridge.showShortToast("短信发送成功"); + _animationController.forward(from: 0.0); + this.setState(() { + isGetingSms = true; + }); } else { Bridge.showShortToast(v.msg); } diff --git a/flutter_lib/lib/ui/page/account/mine_wallet.dart b/flutter_lib/lib/ui/page/account/mine_wallet.dart new file mode 100644 index 0000000..8b9f7b9 --- /dev/null +++ b/flutter_lib/lib/ui/page/account/mine_wallet.dart @@ -0,0 +1,171 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_lib/bridge/common_bridge.dart'; +import 'package:flutter_lib/bridge/invite_bridge.dart'; +import 'package:flutter_lib/model/Result.dart'; +import 'package:flutter_lib/model/record.dart'; +import 'package:flutter_lib/utils/uidata.dart'; + +class MineWalletPage extends StatefulWidget { + MineWalletPage({Key key}) : super(key: key); + + @override + MineWalletPageState createState() => new MineWalletPageState(); +} + +class MineWalletPageState extends State { + List list = new List(); + + @override + Widget build(BuildContext context) { + //测试数据 + list.add(new Record(name: "某某交易", status: "已提现", time: "2019-01-01 12:35")); + list.add(new Record(name: "某某交易", status: "已提现", time: "2019-01-01 12:35")); + list.add(new Record(name: "某某交易", status: "已提现", time: "2019-01-01 12:35")); + list.add(new Record(name: "某某交易", status: "已提现", time: "2019-01-01 12:35")); + list.add(new Record(name: "某某交易", status: "已提现", time: "2019-01-01 12:35")); + + return new Scaffold( + appBar: UIData.getCenterTitleAppBar("我的钱包", context), + body: Stack( + children: [ + Container( + color: Color(0xFFF5F5F5), + ), + CustomScrollView( + slivers: [ + SliverList( + delegate: SliverChildListDelegate( + [ + buildHeader(), + Container( + height: 10.0, + ), + ], + ), + ), + SliverList( + delegate: SliverChildBuilderDelegate( + (context, index) => RecordItem(item: list[index]), + childCount: list.length, + ), + ), + ], + ), + ], + )); + } + + Container buildHeader() { + return Container( + color: Colors.white, + width: double.infinity, + height: 269.0, + child: Stack( + children: [ + Positioned( + top: 67.0, + left: 0.0, + right: 0.0, + child: Text( + "1356", + style: TextStyle(color: Color(0xFFFA4848), fontSize: 50.0), + textAlign: TextAlign.center, + ), + ), + Positioned( + top: 124.0, + left: 0.0, + right: 0.0, + child: Text( + "我的余额", + style: TextStyle(color: Color(0xFF666666), fontSize: 15.0), + textAlign: TextAlign.center, + ), + ), + Positioned( + top: 208.0, + left: 15.0, + right: 15.0, + child: InkWell( + child: Container( + alignment: Alignment.center, + height: 45.0, + child: Text( + "全部提现", + style: TextStyle(color: Colors.white, fontSize: 20.0), + ), + decoration: new BoxDecoration( + borderRadius: new BorderRadius.circular(8.0), + color: Color(0xFFFA4848))), + onTap: () {}, + )), + ], + ), + ); + } + + _navigateToPerfectInfo(BuildContext context, String inviteCode) async { + Future future = InviteBridge.invitedParent(inviteCode); + future.then((result) { + if (result.code == 200) { + Navigator.pop(context, false); + } else { + Bridge.showLongToast(result.msg == null ? "未返回错误信息" : result.msg); + } + }); + } +} + +class RecordItem extends StatelessWidget { + final Record item; + + RecordItem({Key key, @required this.item}) : super(key: key); + + @override + Widget build(BuildContext context) { + return GestureDetector( + child: Column( + children: [ + Container( + color: Colors.white, + padding: EdgeInsets.fromLTRB(15, 12, 15, 12), + child: Row( + children: [ + Expanded( + child: Text( + item.name, + style: TextStyle(color: Color(0xFF353535), fontSize: 15.0), + ), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + item.status, + style: + TextStyle(color: Color(0xFF353535), fontSize: 12.0), + ), + Padding( + padding: EdgeInsets.fromLTRB(0, 3, 0, 0), + child: Text( + item.time, + style: + TextStyle(color: Color(0xFFCCCCCC), fontSize: 12.0), + ), + ), + ], + ) + ], + ), + ), + Container( + width: double.infinity, + height: 1.0, + color: Color(0xFFEEEEEE), + ) + ], + ), + onTap: () {}, + ); + } +} diff --git a/flutter_lib/lib/ui/page/account/register.dart b/flutter_lib/lib/ui/page/account/register.dart index 5f87f0c..f89eed9 100644 --- a/flutter_lib/lib/ui/page/account/register.dart +++ b/flutter_lib/lib/ui/page/account/register.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_lib/bridge/account_bridge.dart'; import 'package:flutter_lib/bridge/common_bridge.dart'; import 'package:flutter_lib/model/Result.dart'; +import 'package:flutter_lib/ui/widgets/countdown.dart'; import 'package:flutter_lib/utils/uidata.dart'; class Register extends StatelessWidget { @@ -28,7 +29,28 @@ class RegisterPage extends StatefulWidget { RegisterState createState() => RegisterState(); } -class RegisterState extends State { +class RegisterState extends State with TickerProviderStateMixin { + int time_cutdown = 60; + bool isGetingSms = false; + AnimationController _animationController; + + @override + void initState() { + _animationController = new AnimationController( + duration: new Duration(seconds: time_cutdown), + vsync: this, + ); + _animationController.addStatusListener((v) { + AnimationStatus a = v; + if (a == AnimationStatus.completed) { + setState(() { + isGetingSms = false; + }); + } + }); + super.initState(); + } + final TextEditingController _controller = new TextEditingController(); Color _registercolor = Color(0xFFFF7B7B); Color _verifycodecolor = Color(0xFF999999); @@ -52,7 +74,7 @@ class RegisterState extends State { if (_registercolor.value != 0xFFFF7B7B) { setState(() { _registercolor = Color(0xFFFF7B7B); - _verifycodecolor = Color(0xFF999999); + _verifycodecolor = UIData.ff666666; _verifybordercolor = Color(0xFFEEEEEE); _verifyborderwidth = 1.0; }); @@ -260,10 +282,19 @@ class RegisterState extends State { child: new Container( width: 71.0, height: 22.0, - child: new Text( - "获取验证码", - style: TextStyle(color: _verifycodecolor, fontSize: 10), - ), + child: isGetingSms + ? new Countdown( + color: UIData.ff353535, + animation: new StepTween( + begin: time_cutdown, + end: 0, + ).animate(_animationController), + ) + : new Text( + "获取验证码", + style: TextStyle( + color: UIData.fff, fontSize: 10), + ), alignment: Alignment.center, ), //圆角大小,与BoxDecoration保持一致,更美观 @@ -277,6 +308,10 @@ class RegisterState extends State { future.then((v) { if (v.code == 200) { Bridge.showShortToast("短信发送成功"); + _animationController.forward(from: 0.0); + this.setState(() { + isGetingSms = true; + }); } else { Bridge.showShortToast(v.msg); } diff --git a/flutter_lib/lib/ui/page/account/vip_apply.dart b/flutter_lib/lib/ui/page/account/vip_apply.dart new file mode 100644 index 0000000..9da8c44 --- /dev/null +++ b/flutter_lib/lib/ui/page/account/vip_apply.dart @@ -0,0 +1,224 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_lib/bridge/common_bridge.dart'; +import 'package:flutter_lib/bridge/invite_bridge.dart'; +import 'package:flutter_lib/bridge/order_bridge.dart'; +import 'package:flutter_lib/model/Result.dart'; +import 'package:flutter_lib/model/order_result.dart'; +import 'package:flutter_lib/ui/widgets/common_dialogs.dart'; +import 'package:flutter_lib/utils/BristuaRouter.dart'; +import 'package:flutter_lib/utils/uidata.dart'; + +class VipApplyPage extends StatefulWidget { + VipApplyPage({Key key}) : super(key: key); + + @override + VipApplyPageState createState() => new VipApplyPageState(); +} + +class VipApplyPageState extends State { + bool _isVip = false; + + @override + Widget build(BuildContext context) { + return new Scaffold( + appBar: + UIData.getCenterTitleAppBar(!_isVip ? "申请VIP" : "我的VIP", context), + body: !_isVip ? buildApplyVipBody() : buildMineVipBody()); + } + + Stack buildApplyVipBody() { + return Stack( + children: [ + Container( + color: Color(0xFFF5F5F5), + ), + Image.asset( + 'images/icon_vip_bg.png', + width: double.infinity, + height: 197.0, + fit: BoxFit.cover, + ), + Positioned( + top: 37.0, + left: 0.0, + right: 0.0, + child: Text( + "成为VIP", + style: TextStyle(color: Colors.white, fontSize: 24.0), + textAlign: TextAlign.center, + ), + ), + Positioned( + top: 75.0, + left: 0.0, + right: 0.0, + child: Text( + "立享好友消费返积分", + style: TextStyle(color: Colors.white, fontSize: 18.0), + textAlign: TextAlign.center, + ), + ), + Positioned( + top: 122.0, + left: 15.0, + right: 15.0, + child: Container( + alignment: Alignment.center, + width: 346.0, + height: 169.0, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + 'images/icon_vip_crown.png', + width: 80.0, + height: 66.0, + ), + Padding( + padding: EdgeInsets.fromLTRB(0, 15, 0, 0), + child: RichText( + text: TextSpan( + text: '389.00', + style: TextStyle(color: Colors.white, fontSize: 30.0), + children: [ + TextSpan( + text: ' 元/年', + style: + TextStyle(color: Colors.white, fontSize: 15.0), + ), + ], + ), + ), + ), + ], + ), + decoration: new BoxDecoration( + borderRadius: new BorderRadius.circular(8.0), + gradient: LinearGradient(colors: [ + Color(0xFFDABC86), + Color(0xFF937C54), + ], begin: FractionalOffset(1, 0), end: FractionalOffset(0, 1)), + )), + ), + Positioned( + top: 305.0, + left: 15.0, + right: 15.0, + child: InkWell( + child: Container( + alignment: Alignment.center, + height: 45.0, + child: Text( + "立即开通", + style: TextStyle(color: Colors.white, fontSize: 18.0), + ), + decoration: new BoxDecoration( + borderRadius: new BorderRadius.circular(8.0), + color: Color(0xFF9E8B69))), + onTap: () { + Future future = OrderBridge.orderVip(1); + future.then((result) { + if (result.code == 200) { + if (result.data == null) { + Bridge.showLongToast("订单号获取失败"); + return; + } + showPayDialog(context, 389.00, + OrderResult.fromJson(result.data).orderId,"vip"); + } else { + if (result.code == 401) { + BristuaRouter.routerUserLogin(context); + } else { + Bridge.showLongToast(result.msg); + } + } + }); + }, + )), + ], + ); + } + + Stack buildMineVipBody() { + return Stack( + children: [ + Container( + color: Color(0xFFF5F5F5), + ), + Image.asset( + 'images/icon_vip_bg.png', + width: double.infinity, + height: 197.0, + fit: BoxFit.cover, + ), + Positioned( + top: 45.0, + left: 0.0, + right: 0.0, + child: Row( + children: [ + Padding( + padding: EdgeInsets.fromLTRB(64, 0, 18, 0), + child: Image.asset( + 'images/icon_vip_crown.png', + width: 67.0, + height: 54.0, + ), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + "您已是VIP", + style: TextStyle(color: Colors.white, fontSize: 20.0), + ), + Padding( + padding: EdgeInsets.fromLTRB(0, 2, 0, 4), + child: Text( + "用户立享自己/好友消费返积分", + style: TextStyle(color: Colors.white, fontSize: 12.0), + ), + ), + Text( + "VIP有效期:2019.01.01-2019.12.31", + style: TextStyle(color: Color(0xFF948F85), fontSize: 12.0), + ), + ], + ), + ], + ), + ), + Positioned( + top: 130.0, + left: 15.0, + right: 15.0, + child: InkWell( + child: Container( + alignment: Alignment.center, + height: 45.0, + child: Text( + "立即体验特权", + style: TextStyle(color: Colors.white, fontSize: 18.0), + ), + decoration: new BoxDecoration( + borderRadius: new BorderRadius.circular(8.0), + color: Color(0xFF9E8B69))), + onTap: () {}, + )), + ], + ); + } + + _navigateToPerfectInfo(BuildContext context, String inviteCode) async { + Future future = InviteBridge.invitedParent(inviteCode); + future.then((result) { + if (result.code == 200) { + Navigator.pop(context, false); + } else { + Bridge.showLongToast(result.msg == null ? "未返回错误信息" : result.msg); + } + }); + } +} diff --git a/flutter_lib/lib/ui/page/address/address_list.dart b/flutter_lib/lib/ui/page/address/address_list.dart index 490bc0b..c227165 100644 --- a/flutter_lib/lib/ui/page/address/address_list.dart +++ b/flutter_lib/lib/ui/page/address/address_list.dart @@ -43,7 +43,7 @@ class _AddressListState extends State { } Widget bodyData() { - addressBloc.getAddressList(); + addressBloc.getAddressList(context); return StreamBuilder>( stream: addressBloc.productItems, builder: (context, snapshot) { diff --git a/flutter_lib/lib/ui/page/dashboard/dashboard.page.dart b/flutter_lib/lib/ui/page/dashboard/dashboard.page.dart index 8e5a40c..94af5d8 100644 --- a/flutter_lib/lib/ui/page/dashboard/dashboard.page.dart +++ b/flutter_lib/lib/ui/page/dashboard/dashboard.page.dart @@ -1,48 +1,24 @@ import 'dart:ui'; import 'package:flutter/material.dart'; -import 'package:flutter_lib/bridge/common_bridge.dart'; import 'package:flutter_lib/ui/page/dashboard/home_page.dart'; import 'package:flutter_lib/ui/page/dashboard/user_home_page.dart'; import 'package:flutter_lib/ui/page/shop/shop_cart_list.dart'; import 'package:flutter_lib/ui/page/shop/shop_category_list.dart'; -import 'package:flutter_lib/ui/widgets/banner/banner_evalutor.dart'; import 'package:flutter_lib/utils/uidata.dart'; -import 'package:flutter_test/flutter_test.dart'; class DashboardPage extends StatefulWidget { @override DashboardPageState createState() => DashboardPageState(); } -class Model extends Object with BannerWithEval { - final String imgUrl; - - Model({this.imgUrl}); - - @override - get bannerUrl => imgUrl; -} - -class Choice { - const Choice({this.title, this.icon}); - final String title; - final IconData icon; -} - -const List choices = const [ - const Choice(title: '热销精品', icon: Icons.directions_car), - const Choice(title: '上新好货', icon: Icons.directions_bike), - const Choice(title: '全部分类', icon: Icons.directions_boat), - const Choice(title: '邀请返利', icon: Icons.directions_bus) -]; - class DashboardPageState extends State { MyHomePage myHomePage = MyHomePage(); ShopCategoryListPage shopCategoryListPage = ShopCategoryListPage(title: "全部分类", showBackBtn: false); ShopCartListPage shopCartListPage = ShopCartListPage(false); UserHomeListPage userHomeListPage = UserHomeListPage(); + @override void initState() { super.initState(); @@ -67,36 +43,40 @@ class DashboardPageState extends State { bottomNavigationBar: BottomNavigationBar( items: [ BottomNavigationBarItem( - icon: Icon( - Icons.home, - color: UIData.ff353535, + icon: Image.asset( + 'images/icon_bottom_navigation_home.png', + width: 22.0, + height: 22.0, ), title: Text( '首页', style: TextStyle(color: UIData.ff353535, fontSize: 10), )), BottomNavigationBarItem( - icon: Icon( - Icons.category, - color: UIData.ff353535, + icon: Image.asset( + 'images/icon_bottom_navigation_active.png', + width: 22.0, + height: 22.0, ), title: Text( '分类', style: TextStyle(color: UIData.ff353535, fontSize: 10), )), BottomNavigationBarItem( - icon: Icon( - Icons.add_shopping_cart, - color: UIData.ff353535, + icon: Image.asset( + 'images/icon_bottom_navigation_car.png', + width: 22.0, + height: 22.0, ), title: Text( '购物车', style: TextStyle(color: UIData.ff353535, fontSize: 10), )), BottomNavigationBarItem( - icon: Icon( - Icons.person, - color: UIData.ff353535, + icon: Image.asset( + 'images/icon_bottom_navigation_mine.png', + width: 22.0, + height: 22.0, ), title: Text( '我的', diff --git a/flutter_lib/lib/ui/page/dashboard/home_page.dart b/flutter_lib/lib/ui/page/dashboard/home_page.dart index 6c96425..8cfb759 100644 --- a/flutter_lib/lib/ui/page/dashboard/home_page.dart +++ b/flutter_lib/lib/ui/page/dashboard/home_page.dart @@ -1,29 +1,26 @@ -import 'package:flutter/material.dart'; import 'dart:ui'; -import 'package:flutter_lib/logic/viewmodel/product_view_model.dart'; -import 'package:flutter_lib/model/product.dart'; - -import 'package:flutter_lib/ui/page/shop/search_shop_list.dart'; -import 'package:flutter_lib/utils/uidata.dart'; -import 'package:flutter_test/flutter_test.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_lib/logic/bloc/home_bloc.dart'; +import 'package:flutter_lib/logic/bloc/product_bloc.dart'; +import 'package:flutter_lib/model/Banner.dart'; +import 'package:flutter_lib/model/HomeCategory.dart'; +import 'package:flutter_lib/model/Result.dart'; +import 'package:flutter_lib/model/category.dart'; +import 'package:flutter_lib/model/productitem.dart'; +import 'package:flutter_lib/model/promotion.dart'; +import 'package:flutter_lib/model/special.dart'; +import 'package:flutter_lib/ui/inherited/home_provider.dart'; +import 'package:flutter_lib/ui/inherited/product_provider.dart'; import 'package:flutter_lib/ui/widgets/banner/banner_widget.dart'; -import 'package:flutter_lib/ui/widgets/banner/banner_evalutor.dart'; +import 'package:flutter_lib/ui/widgets/error_status_widget.dart'; +import 'package:flutter_lib/utils/uidata.dart'; class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } -class Model extends Object with BannerWithEval { - final String imgUrl; - - Model({this.imgUrl}); - - @override - get bannerUrl => imgUrl; -} - class Choice { const Choice({this.title, this.icon, this.action}); @@ -48,26 +45,9 @@ const List choices = const [ ]; class _MyHomePageState extends State { - final List data = [ - new Model( - imgUrl: - 'https://img1.360buyimg.com/da/jfs/t1/26933/21/15251/101018/5cae9e2fEb2d18145/ce92ccee53fc3e62.jpg'), - new Model( - imgUrl: - 'https://img1.360buyimg.com/pop/jfs/t1/33615/26/2942/67787/5cb2db16E190d1438/f87d36b439a01bb4.jpg'), - new Model( - imgUrl: - 'https://m.360buyimg.com/babel/jfs/t1/32943/39/11194/86395/5cb44a60Eacbc1baf/d15986655530b38a.jpg'), - new Model( - imgUrl: - 'https://m.360buyimg.com/babel/jfs/t1/35770/34/1817/46457/5cb43c53E9c28780e/b05442df5d5ba2c3.jpg'), - new Model( - imgUrl: - 'https://m.360buyimg.com/babel/jfs/t1/25888/33/15004/99699/5caca583E85bc0c4b/0144e355305c5946.jpg'), - ]; + ProductBloc productBloc = ProductBloc(); - final List discountList = ProductViewModel().getDiscountList(); - final List hotShopList = ProductViewModel().getProductTests(); + HomeBloc homeBloc = HomeBloc(); @override void initState() { @@ -88,93 +68,150 @@ class _MyHomePageState extends State { top: true, child: buildCustomScrollView(), ); -// return Scaffold( -// body: Container( -// child: buildCustomScrollView(), -// ), -//// floatingActionButton: FloatingActionButton( -//// tooltip: 'Increment', -//// child: Icon(Icons.add), -//// onPressed: () { -//// final navigator = Navigator.of(context); -//// navigator.push(new MaterialPageRoute( -//// builder: (context) => new SearchShopList())); -//// }, -//// ), -// // This trailing comma makes auto-formatting nicer for build methods. -// ); } CustomScrollView buildCustomScrollView() { + homeBloc.getPromotion(); + homeBloc.getSpecial(); return CustomScrollView(slivers: [ SliverList( delegate: SliverChildListDelegate( [ buildHeader(), - buildBanner(), - buildType(), - buildAdvertisement( - "https://img20.360buyimg.com/mobilecms/s350x128_jfs/t8554/10/1668315357/28454/82af77f0/59be2c79Ne4502dcf.jpg!q90!cc_350x128.webp"), - buildDiscount(), - Container( - height: 1.0, - width: double.infinity, - ), ], ), ), - SliverGrid( - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 1.0, - mainAxisSpacing: 1.0, - childAspectRatio: 1.88, - ), - delegate: SliverChildBuilderDelegate( - (BuildContext context, int index) { - return Container( - color: Colors.white, - child: buildDiscountItem(index, discountList[index]), - ); - }, - childCount: discountList.length, - ), - ), + buildBanner(), SliverList( delegate: SliverChildListDelegate( [ Container( - height: 10.0, - width: double.infinity, - ), - buildMustBay( - "https://img11.360buyimg.com/mobilecms/s350x250_jfs/t1/23441/6/14922/36622/5cac1223Edaf540b0/7df256141224531d.jpg!q90!cc_350x250.webp", - "https://img11.360buyimg.com/mobilecms/s350x250_jfs/t1/30730/6/10877/44332/5cb34d0cE9e0fcea6/9c3cde5807ab4186.jpg!q90!cc_350x250.webp"), - buildActivity(), - buildHotShop(), + child: Padding(padding: EdgeInsets.fromLTRB(0, 5, 0, 5)), + ) ], ), ), - SliverGrid( - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 0.0, - mainAxisSpacing: 0.0, - childAspectRatio: 0.74, - ), - delegate: SliverChildBuilderDelegate( - (BuildContext context, int index) { - return Container( - color: Color(0xFFF6F6F6), - child: buildHotShopItem(index, hotShopList[index]), + buildType(), + StreamBuilder>( + stream: homeBloc.promotions, + builder: (context, snapshot) { + if (snapshot.hasData && snapshot.data.isNotEmpty) { + return SliverList( + delegate: SliverChildListDelegate( + [ + buildDiscount(), + Container( + height: 1.0, + width: double.infinity, + ), + ], + ), ); - }, - childCount: hotShopList.length, - ), + } else { + return getNone(); + } + }, ), + StreamBuilder>( + stream: homeBloc.promotions, + builder: (context, snapshot) { + if (snapshot.hasData && snapshot.data.isNotEmpty) { + return SliverGrid( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + crossAxisSpacing: 1.0, + mainAxisSpacing: 1.0, + childAspectRatio: 1.88, + ), + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Container( + color: Colors.white, + child: buildDiscountItem(index, snapshot.data[index]), + ); + }, + childCount: snapshot.data.length, + ), + ); + } else { + return getNone(); + } + }, + ), + StreamBuilder>( + stream: homeBloc.specials, + builder: (context, snapshot) { + if (snapshot.hasData && snapshot.data.isNotEmpty) { + return SliverGrid( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 4, + crossAxisSpacing: 1.0, + mainAxisSpacing: 1.0, + childAspectRatio: 0.73, + ), + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + Special special = snapshot.data[index]; + return Center( + child: GestureDetector( + onTap: () { + Navigator.pushNamed(context, UIData.ShopDetailPage, + arguments: special.productId); + }, + child: buildActivityBottom( + index, + special.titleName == null ? "?" : special.titleName, + special.specialDesc == null + ? "" + : special.specialDesc, + special.imgUrl), + ), + ); + }, + childCount: snapshot.data.length, + ), + ); + } else { + return getNone(); + } + }, + ), + StreamBuilder>( + stream: productBloc.productItems, + builder: (context, snapshot) { + if (snapshot.hasData) { + if (snapshot.data.isNotEmpty) { + return SliverList( + delegate: SliverChildListDelegate( + [ + buildHotShop(), + ], + ), + ); + } else { + return getNone(); + } + } else { + return getNone(); + } + }), + getFeatureGrid(), ]); } + SliverList getNone() { + return SliverList( + delegate: SliverChildListDelegate( + [ + Container( + height: 0, + width: 0, + ) + ], + ), + ); + } + DefaultTabController buildDefaultTabController() { return DefaultTabController( length: choices.length, @@ -198,7 +235,7 @@ class _MyHomePageState extends State { ); } - Container buildHeader() { + buildHeader() { return Container( height: 44.0, color: Colors.white, @@ -232,6 +269,7 @@ class _MyHomePageState extends State { alignment: Alignment.center, height: 30.0, decoration: BoxDecoration( + color: Colors.white, border: Border.all(color: Color(0xFFF5F5F5), width: 15.0), borderRadius: new BorderRadius.all(new Radius.circular(15.0)), @@ -281,68 +319,86 @@ class _MyHomePageState extends State { ); } - BannerWidget buildBanner() { - return BannerWidget( - data: data, - curve: Curves.linear, - onClick: (position, bannerWithEval) { - print(position); - }); + Widget buildBanner() { + homeBloc.getImages(); + return SliverList( + delegate: SliverChildListDelegate( + [ + StreamBuilder>( + stream: homeBloc.tabItems, + builder: (context, snapshot) { + if (snapshot.hasError) { + Result result = snapshot.error; + return ErrorStatusWidget.order( + result.code, result.msg, "点击重试", () { + homeBloc.getHomeAll(); + }); + } else if (snapshot.hasData) { + if (snapshot.data.isNotEmpty) { + return BannerWidget( + data: snapshot.data, + curve: Curves.linear, + onClick: (position, bannerWithEval) { + print(position); + }); + } else { + return ErrorStatusWidget.order(0, "暂无数据", "点击重试", () { + homeBloc.getHomeAll(); + }); + } + } else { + return Center(child: CircularProgressIndicator()); + } + }) + ], + ), + ); } - Container buildType() { - return Container( - padding: EdgeInsets.fromLTRB(10.0, 15.0, 10.0, 4.0), - color: Colors.white, - child: Column( - children: [ - Row( - children: [ - Expanded( - child: buildTypeChild( - 0, - "服饰", - "images/shop_type_hat.png", + Widget buildType() { + homeBloc.getHomeCategoryList(); + return HomeBlocProvider( + bloc: homeBloc, + child: StreamBuilder>( + stream: homeBloc.homeCategory, + builder: (context, snapshot) { + if (snapshot.hasError) { + print(snapshot.error); + return SliverList( + delegate: SliverChildListDelegate( + [ + Container( + width: 0, + height: 0, + ), + ], ), - ), - Expanded( - child: buildTypeChild(1, "鞋帽箱包", "images/shop_type_hat.png"), - ), - Expanded( - child: buildTypeChild(2, "丽人", "images/shop_type_beauty.png"), - ), - Expanded( - child: - buildTypeChild(3, "家具家装", "images/shop_type_furniture.png"), - ), - Expanded( - child: buildTypeChild(4, "生活服务", "images/shop_type_life.png"), - ), - ], - ), - Row( - children: [ - Expanded( - child: buildTypeChild(5, "数码", "images/shop_type_hat.png"), - ), - Expanded( - child: buildTypeChild(6, "办公", "images/shop_type_office.png"), - ), - Expanded( - child: buildTypeChild(7, "百货超市", "images/shop_type_store.png"), - ), - Expanded( - child: - buildTypeChild(8, "教育培训", "images/shop_type_education.png"), - ), - Expanded( - child: buildTypeChild( - 9, "分类", "images/shop_type_classification.png"), - ), - ], - ), - ], - ), + ); + } else if (snapshot.hasData) { + List list = snapshot.data; + return SliverGrid( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 5, + childAspectRatio: 0.9, //item长宽比 + crossAxisSpacing: 5.0, + mainAxisSpacing: 5.0, + ), + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + HomeCategory item = list[index]; + + return Container( + child: buildTypeChild(int.parse(item.categoryId), + item.categoryName, item.categoryImgUrl), + ); + }, + childCount: list.length, + ), + ); + } else { + return getNone(); + } + }), ); } @@ -374,6 +430,7 @@ class _MyHomePageState extends State { style: TextStyle(color: Colors.white, fontSize: 12), ), decoration: new BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.only( topRight: Radius.circular(15.0), bottomRight: Radius.circular(15.0)), @@ -385,22 +442,26 @@ class _MyHomePageState extends State { Expanded( child: Container(), ), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Text( - "更多", - style: TextStyle(color: UIData.ff999999, fontSize: 12), - ), - Padding( - child: Icon( - Icons.arrow_forward_ios, - color: UIData.ff999999, - size: 9, + Container( + width: 0, + height: 0, + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Text( + "更多", + style: TextStyle(color: UIData.ff999999, fontSize: 12), ), - padding: EdgeInsets.fromLTRB(2, 0, 12, 0), - ), - ], + Padding( + child: Icon( + Icons.arrow_forward_ios, + color: UIData.ff999999, + size: 9, + ), + padding: EdgeInsets.fromLTRB(2, 0, 12, 0), + ), + ], + ), ), ], ), @@ -409,56 +470,74 @@ class _MyHomePageState extends State { ); } - Container buildTypeChild(int type, String typeName, String typeImg) { - return Container( - child: InkWell( + Widget getFeatureGrid() { + productBloc.getFeatures(1, 10); + return ProductProvider( + productBloc: productBloc, + child: StreamBuilder>( + stream: productBloc.productItems, + builder: (context, snapshot) { + if (snapshot.hasData) { + if (snapshot.data.isNotEmpty) { + return getFeatursGrid(snapshot.data); + } else { + return ErrorStatusWidget.sliver(0, "暂无数据", "点击重试", () { + productBloc.getFeatures(1, 10); + }); + } + } else if (snapshot.hasError) { + return getNone(); + } else { + return getNone(); + } + }), + ); + } + + SliverGrid getFeatursGrid(List items) { + return SliverGrid( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + childAspectRatio: (0.7), //item长宽比 + mainAxisSpacing: 5.0, + crossAxisSpacing: 5.0, + ), + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Padding( + padding: const EdgeInsets.all(2.0), + child: Container( + child: productGrid(items[index], index), + ), + ); + }, + childCount: items.length, + ), + ); + } + + Widget buildTypeChild(int type, String typeName, String typeImg) { + return InkWell( child: Column( children: [ - Image.asset( - typeImg, - width: 43.0, - height: 43.0, - ), - Padding( - padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 16.0), - child: Text( - typeName, - style: TextStyle(color: Color(0xFF666666), fontSize: 11), - ), + UIData.getImageWithWH(typeName, 56, 56), + Text( + typeName, + style: TextStyle(color: Color(0xFF666666), fontSize: 11), ), ], ), //每一个类别点击事件 onTap: () { - switch (type) { - case 0: - break; - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - case 5: - break; - case 6: - break; - case 7: - break; - case 8: - break; - case 9: - Navigator.pushNamed(context, UIData.ShopCategoryList, - arguments: "全部分类"); - break; - } + Category category = new Category(); + category.id = type; + category.name = typeName; + Navigator.pushNamed(context, UIData.ShopListPage, arguments: category); }, - )); + ); } - Container buildDiscountItem(int index, Product product) { + Container buildDiscountItem(int index, Promotion product) { return Container( child: InkWell( child: Row( @@ -471,7 +550,9 @@ class _MyHomePageState extends State { Padding( padding: EdgeInsets.fromLTRB(12.0, 16.0, 0.0, 4.0), child: Text( - product.name, + product.promotionTitle == null + ? "拜托 名字都不取一个?" + : product.promotionTitle, maxLines: 1, style: TextStyle(color: Color(0xFF353535), fontSize: 13), ), @@ -479,16 +560,53 @@ class _MyHomePageState extends State { Padding( padding: EdgeInsets.fromLTRB(12.0, 0.0, 0.0, 0.0), child: Text( - product.description, + product.promotionDesc == null + ? "" + : product.promotionDesc, maxLines: 1, style: TextStyle(color: Color(0xFF999999), fontSize: 11), ), ), Padding( padding: EdgeInsets.fromLTRB(12.0, 8.0, 0.0, 0.0), - child: Text( - product.price, - style: TextStyle(color: Color(0xFFEF2F2F), fontSize: 15), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Center( + child: Text( + "¥" + + (product.promotionPrice == null + ? "?" + : product.promotionPrice), + style: TextStyle( + color: Color(0xFFEF2F2F), fontSize: 13), + ), + ), + ), + Padding( + padding: EdgeInsets.fromLTRB(0, 0.0, 12.0, 0.0), + child: Center( + child: RichText( + text: new TextSpan( + children: [ + new TextSpan( + text: product.sellPrice == null + ? "" + : product.sellPrice, + style: TextStyle( + color: Color(0xFF999999), + fontSize: 11, + decoration: TextDecoration.lineThrough, + ), + ), + ], + ), + ), + ), + ) + ], ), ), ], @@ -497,23 +615,17 @@ class _MyHomePageState extends State { Padding( padding: EdgeInsets.fromLTRB(3.0, 12.0, 6.0, 0.0), child: UIData.getImageWithWHFit( - product.image, + product.imgUrl, BoxFit.cover, 75.0, 75.0, ), ), -// index % 2 == 0 -// ? Container() -// : Container( -// width: 1.0, -// color: Color(0xFFEEEEEE), -// ), ], ), onTap: () { Navigator.pushNamed(context, UIData.ShopDetailPage, - arguments: product.skuId); + arguments: product.productId); }, ), ); @@ -557,78 +669,9 @@ class _MyHomePageState extends State { padding: EdgeInsets.fromLTRB(2.0, 0.0, 0.0, 0.0), child: UIData.getImageWithWHFit( rightImage, - BoxFit.cover, - 166.0, - 130.0, - ), - ), - ], - ), - ); - } - - Container buildActivity() { - return Container( - color: Colors.white, - height: 270.0, - child: Column( - children: [ - Expanded( - child: Row( - children: [ - Expanded( - child: InkWell( - child: buildActivityTopLeft(), - //天天特价栏点击事件 - onTap: () {}, - ), - ), - Container( - width: 1.0, - color: Color(0xFFEEEEEE), - ), - Expanded( - child: InkWell( - child: buildActivityTopRight(), - //品牌闪购点击事件 - onTap: () {}, - ), - ), - ], - ), - ), - Expanded( - child: Row( - children: [ - Expanded( - child: buildActivityBottom(0, "天猫Outlets", "大品牌79元购", - "https://img11.360buyimg.com/mobilecms/s110x110_jfs/t1/22034/24/5708/134994/5c41416cE61e9ab02/358c89e09077ac5c.png!q90!cc_110x110.webp"), - ), - Container( - width: 1.0, - color: Color(0xFFEEEEEE), - ), - Expanded( - child: buildActivityBottom(1, "量贩优选", "1分钱疯抢", - "https://img11.360buyimg.com/mobilecms/s110x110_jfs/t1/14748/13/13064/114779/5c9dc90fEcd69f15a/9a3ae485e894bf66.jpg!q90!cc_110x110.webp"), - ), - Container( - width: 1.0, - color: Color(0xFFEEEEEE), - ), - Expanded( - child: buildActivityBottom(2, "淘宝心选", "官方自营品牌", - "https://img11.360buyimg.com/mobilecms/s110x110_jfs/t1/23443/5/10735/27836/5c88a96aE59ff0726/5f43bec36e308837.jpg!q90!cc_110x110.webp"), - ), - Container( - width: 1.0, - color: Color(0xFFEEEEEE), - ), - Expanded( - child: buildActivityBottom(3, "聚名品", "轻奢限量抢", - "https://img11.360buyimg.com/mobilecms/s110x110_jfs/t1/29836/32/1174/55982/5c0fbfe7E5d0a5db9/3226b9a61def3bb3.jpg!q90!cc_110x110.webp"), - ), - ], + BoxFit.cover, + 166.0, + 130.0, ), ), ], @@ -636,113 +679,12 @@ class _MyHomePageState extends State { ); } - Column buildActivityTopLeft() { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.fromLTRB(10.0, 10.0, 0.0, 4.0), - child: Text( - "天天特价", - style: TextStyle(color: Color(0xFFFF3507), fontSize: 14), - ), - ), - Padding( - padding: EdgeInsets.fromLTRB(10.0, 0.0, 0.0, 4.0), - child: Text( - "9.9元包邮好货随心抢", - style: TextStyle(color: Color(0xFF999999), fontSize: 11), - ), - ), - Padding( - padding: EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0), - child: Row( - children: [ - UIData.getImageWithWHFit( - "https://img13.360buyimg.com/mobilecms/s140x140_jfs/t1/5542/25/10695/184499/5bcc0adcE903a8a97/c43423eedf3039cf.jpg!q90.webp", - BoxFit.cover, - 70.0, - 70.0, - ), - Expanded( - child: Container(), - ), - UIData.getImageWithWHFit( - "https://img12.360buyimg.com/mobilecms/s140x140_jfs/t28132/336/144040487/125605/531bc317/5be9427dN7a38cc7f.jpg!q90.webp", - BoxFit.cover, - 70.0, - 70.0, - ), - ], - ), - ), - Expanded( - child: Container(), - ), - Container( - height: 1.0, - color: Color(0xFFEEEEEE), - ) - ], - ); - } - - Column buildActivityTopRight() { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.fromLTRB(10.0, 10.0, 0.0, 4.0), - child: Text( - "品牌闪购", - style: TextStyle(color: Color(0xFF333333), fontSize: 14), - ), - ), - Padding( - padding: EdgeInsets.fromLTRB(10.0, 0.0, 0.0, 4.0), - child: Text( - "每日签到 可抢5折卷", - style: TextStyle(color: Color(0xFF999999), fontSize: 11), - ), - ), - Padding( - padding: EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0), - child: Row( - children: [ - UIData.getImageWithWHFit( - "https://img11.360buyimg.com/mobilecms/s140x140_jfs/t1/36973/38/1895/117319/5cb453e9E93fc31a1/6edd54fcfd32ce9c.png!q90.webp", - BoxFit.cover, - 70.0, - 70.0, - ), - Expanded( - child: Container(), - ), - UIData.getImageWithWHFit( - "https://img11.360buyimg.com/mobilecms/s140x140_jfs/t1/9339/14/3383/296696/5bd69f43E5078db49/40af3283649c059e.jpg!q90.webp", - BoxFit.cover, - 70.0, - 70.0, - ), - ], - ), - ), - Expanded( - child: Container(), - ), - Container( - height: 1.0, - color: Color(0xFFEEEEEE), - ) - ], - ); - } - InkWell buildActivityBottom( int type, String title, String subTitle, String imageUrl) { return InkWell( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( padding: EdgeInsets.fromLTRB(10.0, 10.0, 0.0, 4.0), @@ -762,101 +704,97 @@ class _MyHomePageState extends State { alignment: Alignment.center, child: UIData.getImageWithWHFit( imageUrl, - BoxFit.cover, - 70.0, - 70.0, + BoxFit.cover, + 70.0, + 70.0, ), ), ], ), - onTap: () { - switch (type) { - case 0: - break; - case 1: - break; - case 2: - break; - case 3: - break; - } - }, ); } - Container buildHotShop() { - return Container( - color: Color(0xFFF6F6F6), - alignment: Alignment.center, - height: 62.0, - child: Image.asset( - "images/icon_home_hot_shop.png", - height: 15.0, + Widget buildHotShop() { + return Center( + child: Container( + color: Color(0xFFF6F6F6), + alignment: Alignment.center, + child: Padding( + padding: const EdgeInsets.fromLTRB(0, 20, 0, 16), + child: Image.asset( + "images/icon_home_hot_shop.png", + height: 15.0, + ), + ), ), ); } - Container buildHotShopItem(int index, Product product) { - return Container( + Widget productGrid(ProductItem product, int index) { + String imageUrl = ""; + if (product.medias.length > 0) { + imageUrl = product.medias[0].toString(); + } + return Padding( padding: EdgeInsets.fromLTRB( - index % 2 == 0 ? 4.0 : 0.0, 0.0, index % 2 == 0 ? 0.0 : 4.0, 0.0), - child: InkWell( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - width: 170.0, - height: 170.0, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(5.0), - topRight: Radius.circular(5.0)), - image: DecorationImage( - image: NetworkImage(product.image), fit: BoxFit.cover), - ), - ), - Expanded( - child: Container( - width: 170.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.fromLTRB(14.0, 12.0, 12.0, 10.0), - child: Text( - product.name, - maxLines: 1, - style: - TextStyle(color: Color(0xFF353535), fontSize: 12.0), - ), - ), - Padding( - padding: EdgeInsets.fromLTRB(14.0, 0.0, 0.0, 0.0), - child: Text( - product.price, - style: - TextStyle(color: Color(0xFFFA4848), fontSize: 16.0), - ), - ), - ], - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(5.0), - bottomRight: Radius.circular(5.0)), + index % 2 == 0 ? 5.0 : 0.0, 0.0, index % 2 == 0 ? 0.0 : 5.0, 0.0), + child: new GestureDetector( + child: new Card( + elevation: 5.0, + child: new Container( + child: new Stack( + children: [ + Positioned( + top: 0, + left: 0, + right: 0, + child: UIData.getImage( + imageUrl, + ), ), - ), - ), - Container( - height: 6.0, + Positioned( + bottom: 0, + left: 0, + right: 0, + child: new Container( + width: 140, + color: Colors.white, + child: new Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + new Padding( + padding: EdgeInsets.fromLTRB(5, 0, 5, 4), + child: Container( + width: 140, + child: new Text( + product.name, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 12, color: UIData.ff353535), + ), + ), + ), + new Padding( + padding: EdgeInsets.fromLTRB(5, 4, 5, 4), + child: new Text( + "¥" + product.price.toString(), + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle(color: Colors.red, fontSize: 16), + ), + ), + ], + ), + )), + ], ), - ], + ), ), onTap: () { Navigator.pushNamed(context, UIData.ShopDetailPage, - arguments: product.skuId); + arguments: product.id.toString()); }, ), ); diff --git a/flutter_lib/lib/ui/page/dashboard/user_home_page.dart b/flutter_lib/lib/ui/page/dashboard/user_home_page.dart index 62bb1ab..48a6133 100644 --- a/flutter_lib/lib/ui/page/dashboard/user_home_page.dart +++ b/flutter_lib/lib/ui/page/dashboard/user_home_page.dart @@ -1,6 +1,8 @@ import 'dart:ui'; import 'package:flutter/material.dart'; +import 'package:flutter_lib/bridge/account_bridge.dart'; +import 'package:flutter_lib/bridge/common_bridge.dart'; import 'package:flutter_lib/logic//bloc/userinfo_bloc.dart'; import 'package:flutter_lib/logic/viewmodel/homeitem_view_model.dart'; import 'package:flutter_lib/model/homeitem.dart'; @@ -25,103 +27,401 @@ class _UserHomeState extends State { // statusBarColor: UIData.fffa4848, //or set color with: Color(0xFF0000FF) // )); //InfoBridge.wxInfo(); - return Scaffold( - body: buildBody(), - ); +// return Scaffold( +// body: getContent(), +// ); + return getContent(); } - Container buildBody() { + Container buildBody(Userinfo userInfo) { return Container( child: Stack( + alignment: Alignment.topCenter, + fit: StackFit.loose, + //子Widgets溢出的处理方式 + overflow: Overflow.visible, children: [ Positioned( top: 0, bottom: 0, left: 0, right: 0, - child: new Scaffold(body: bodyData())), + child: new Scaffold(body: bodyData(userInfo))), + //充值成VIP + Positioned( + top: 152, + left: 10, + right: 10, + child: buildBannerVipHeader(userInfo), + ) ], ), ); } /* - * 创建头部布局 + * 创建邀请成为vip */ - Widget buildHeader(Userinfo userInfo) { - return Padding( - padding: EdgeInsets.all(10), - child: Container( - child: Card( - child: Column( - children: [ - Row( + Widget buildBannerVipHeader(Userinfo userInfo) { + print("创建邀请成为vip"); + return Container( + padding: EdgeInsets.fromLTRB(0, 0, 0, 0), + child: Container( + child: GestureDetector( + onTap: () { + Navigator.pushNamed(context, UIData.VipApplyPage, + arguments: 0); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + child: Row(children: [ + Padding( + padding: EdgeInsets.fromLTRB(17, 13, 0, 12), + child: Image.asset( + //图片地址 + "images/icon_vip.png", + width: 36, + height: 35, + )), + Padding( + padding: EdgeInsets.fromLTRB(15, 13, 0, 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + //文本区域 + "福利来袭! 会员首冲享7折优惠", + style: TextStyle( + color: Color(0xFFF0E6B8), + fontSize: 12.0), + ), + RichText( + text: TextSpan( + text: '原价', + style: TextStyle( + color: Color(0xFFF0E6B8), + fontSize: 12.0), + children: [ + TextSpan( + text: '20元', + style: TextStyle( + color: Color(0xFFFB5149), + fontSize: 12.0, + decoration: + TextDecoration.lineThrough, + decorationStyle: + TextDecorationStyle.solid, + decorationColor: + Color(0xFFFB5149)), + ), + TextSpan( + text: '现在只需要', + style: TextStyle( + color: Color(0xFFF0E6B8), + fontSize: 12.0), + ), + TextSpan( + text: '10元', + style: TextStyle( + color: Color(0xFFFB5149), + fontSize: 15.0), + ), + ], + ), + ) + ], + )) + ]), + flex: 2, + ), + Padding( + padding: EdgeInsets.fromLTRB(0, 0, 12, 0), + child: InkWell( + child: Container( + height: 25.0, + width: 70.0, + alignment: Alignment.center, + child: Text( + '立即开通', + style: TextStyle( + color: Color(0xFF827125), fontSize: 12.0), + ), + decoration: BoxDecoration( + color: Color(0xFFE6CF66), + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(12.5)), + ), + onTap: () { + //如果用户信息为空 + if (userInfo == null || + userInfo.userLevel == "" || + userInfo.userLevel == "-" || + int.parse(userInfo.userLevel) == 0) { + Navigator.pushNamed(context, UIData.VipApplyPage, + arguments: 0); + } + }, + ), + ), + ]))), + decoration: new BoxDecoration( + borderRadius: new BorderRadius.circular(8.0), + gradient: LinearGradient(colors: [ + Color(0xFF615B50), + Color(0xFF444039), + ], begin: FractionalOffset(1, 0), end: FractionalOffset(0, 1)), + )); + } + + /* + * 生成 build Common Tools + */ + Widget buildCommonTools(Userinfo userInfo) { + print("常用工具"); + homeItems = homeItemViewModel.getMenuItems(userInfo); + return Container( + padding: EdgeInsets.fromLTRB(10, 5, 10, 10), + child: Card( + child: Column( + children: [ + GestureDetector( + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.fromLTRB(15, 10, 15, 5), + child: Text( + "常用工具", + style: TextStyle(color: UIData.ff353535, fontSize: 15), + )), + ], + ), + ), + Container( + margin: EdgeInsets.fromLTRB(15, 0, 15, 0), + child: Divider(), + ), + Padding( + padding: EdgeInsets.fromLTRB(0, 0, 8, 22), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + GestureDetector( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + child: Image.asset( + "images/icon_inputnumber.png", + width: 35.0, + height: 35.0, + ), + padding: EdgeInsets.fromLTRB(0, 12, 0, 8), + ), + Text( + "输入邀请码", + style: + TextStyle(color: UIData.ff353535, fontSize: 12), + ), + ], + ), + onTap: () { + if (userInfo.phone == null) { + Navigator.pushNamed(context, UIData.Login); + } else { + Navigator.pushNamed( + context, + UIData.InviteInputPage, + ); + } + }, + ), +// GestureDetector( +// onTap: () { +// Navigator.pushNamed(context, UIData.MineCollectionPage); +// }, +// child: Column( +// mainAxisAlignment: MainAxisAlignment.center, +// children: [ +// Padding( +// child: Image.asset( +// "images/icon_shoucang.png", +// width: 35.0, +// height: 35.0, +// ), +// padding: EdgeInsets.fromLTRB(0, 12, 0, 8), +// ), +// Text( +// "我的收藏", +// style: +// TextStyle(color: UIData.ff353535, fontSize: 12), +// ), +// ], +// ), +// ), + GestureDetector( + onTap: () { + Bridge.openQQ("3346767433"); + }, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + child: Image.asset( + "images/icon_kehu.png", + width: 35.0, + height: 35.0, + ), + padding: EdgeInsets.fromLTRB(0, 12, 0, 8), + ), + GestureDetector( + onTap: () { + Bridge.openQQ("3346767433"); + }, + child: Text( + "客服中心", + style: + TextStyle(color: UIData.ff353535, fontSize: 12), + ), + ), + ], + ), + ), + GestureDetector( + onTap: () { + AccountBridge.logout().then((result) { + Navigator.pushNamed(context, UIData.Login); + }); + }, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + child: Image.asset( + "images/icon_exit.png", + width: 35.0, + height: 35.0, + ), + padding: EdgeInsets.fromLTRB(0, 12, 0, 8), + ), + Text( + "退出登录", + style: + TextStyle(color: UIData.ff353535, fontSize: 12), + ), + ], + ), + ), + ], + ), + ), + ], + ), + ), + ); + } + + /* + * 创建订单条目 + */ + Widget buildOrdlerHeader(Userinfo userInfo) { + print("创建订单条目"); + return Container( + padding: EdgeInsets.fromLTRB(10, 25, 10, 0), + child: Card( + child: Column( + children: [ + GestureDetector( + onTap: () { + if (userInfo.phone == null) { + Navigator.pushNamed(context, UIData.Login); + } else { + Navigator.pushNamed(context, UIData.AllShopOrderPage, + arguments: 0); + } + }, + child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Padding( - padding: EdgeInsets.all(15), + padding: EdgeInsets.fromLTRB(15, 16, 15, 5), child: Text( "我的订单", style: TextStyle(color: UIData.ff353535, fontSize: 15), ), ), Expanded( - child: GestureDetector( - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Text( - "查看全部订单", - style: - TextStyle(color: UIData.ff999999, fontSize: 15), - ), - Padding( - child: Icon( - Icons.arrow_forward_ios, - color: UIData.ff999999, - size: 9, - ), - padding: EdgeInsets.fromLTRB(5, 0, 15, 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Text( + "查看全部订单", + style: + TextStyle(color: Color(0xFF999999), fontSize: 12), + ), + Padding( + child: Icon( + Icons.arrow_forward_ios, + color: Color(0xFF999999), + size: 12, ), - ], - ), - onTap: () { - Navigator.pushNamed(context, UIData.AllShopOrderPage); - }, + padding: EdgeInsets.fromLTRB(5, 0, 15, 0), + ), + ], ), ), ], ), - Divider(), - Padding( - padding: EdgeInsets.fromLTRB(0, 8, 8, 22), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - GestureDetector( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - child: Image.asset( - "images/order1.png", - width: 22.0, - height: 22.0, - ), - padding: EdgeInsets.fromLTRB(0, 12, 0, 8), - ), - Text( - "待付款", - style: - TextStyle(color: UIData.ff353535, fontSize: 12), + ), + Container( + margin: EdgeInsets.fromLTRB(15, 0, 15, 0), + child: Divider(), + ), + Padding( + padding: EdgeInsets.fromLTRB(0, 0, 8, 22), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + GestureDetector( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + child: Image.asset( + "images/order1.png", + width: 22.0, + height: 22.0, ), - ], - ), - onTap: () { - Navigator.pushNamed(context, UIData.AllShopOrderPage); - }, + padding: EdgeInsets.fromLTRB(0, 12, 0, 8), + ), + Text( + "待付款", + style: + TextStyle(color: UIData.ff353535, fontSize: 12), + ), + ], ), - Column( + onTap: () { + if (userInfo.phone == null) { + Navigator.pushNamed(context, UIData.Login); + } else { + Navigator.pushNamed(context, UIData.AllShopOrderPage, + arguments: 1); + } + }, + ), + GestureDetector( + onTap: () { + if (userInfo.phone == null) { + Navigator.pushNamed(context, UIData.Login); + } else { + Navigator.pushNamed(context, UIData.AllShopOrderPage, + arguments: 2); + } + }, + child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( @@ -139,7 +439,17 @@ class _UserHomeState extends State { ), ], ), - Column( + ), + GestureDetector( + onTap: () { + if (userInfo.phone == null) { + Navigator.pushNamed(context, UIData.Login); + } else { + Navigator.pushNamed(context, UIData.AllShopOrderPage, + arguments: 3); + } + }, + child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( @@ -157,7 +467,17 @@ class _UserHomeState extends State { ), ], ), - Column( + ), + GestureDetector( + onTap: () { + if (userInfo.phone == null) { + Navigator.pushNamed(context, UIData.Login); + } else { + Navigator.pushNamed(context, UIData.AllShopOrderPage, + arguments: 4); + } + }, + child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( @@ -175,12 +495,320 @@ class _UserHomeState extends State { ), ], ), - ], - ), + ), + ], ), - ], + ), + ], + ), + ), + ); + } + +// /* +// * 创建头部布局 +// */ +// Widget buildHeader(Userinfo userInfo) { +// return Padding( +// padding: EdgeInsets.all(10), +// child: Container( +// child: Card( +// child: Column( +// children: [ +// GestureDetector( +// onTap: () { +// Navigator.pushNamed(context, UIData.AllShopOrderPage, +// arguments: 0); +// }, +// child: Row( +// mainAxisAlignment: MainAxisAlignment.spaceEvenly, +// children: [ +// Padding( +// padding: EdgeInsets.all(15), +// child: Text( +// "我的订单", +// style: TextStyle(color: UIData.ff353535, fontSize: 15), +// ), +// ), +// Expanded( +// child: Row( +// mainAxisAlignment: MainAxisAlignment.end, +// children: [ +// Text( +// "查看全部订单", +// style: +// TextStyle(color: UIData.ff999999, fontSize: 15), +// ), +// Padding( +// child: Icon( +// Icons.arrow_forward_ios, +// color: UIData.ff999999, +// size: 9, +// ), +// padding: EdgeInsets.fromLTRB(5, 0, 15, 0), +// ), +// ], +// ), +// ), +// ], +// ), +// ), +// Divider(), +// Padding( +// padding: EdgeInsets.fromLTRB(0, 8, 8, 22), +// child: Row( +// mainAxisAlignment: MainAxisAlignment.spaceEvenly, +// children: [ +// GestureDetector( +// child: Column( +// mainAxisAlignment: MainAxisAlignment.center, +// children: [ +// Padding( +// child: Image.asset( +// "images/order1.png", +// width: 22.0, +// height: 22.0, +// ), +// padding: EdgeInsets.fromLTRB(0, 12, 0, 8), +// ), +// Text( +// "待付款", +// style: +// TextStyle(color: UIData.ff353535, fontSize: 12), +// ), +// ], +// ), +// onTap: () { +// Navigator.pushNamed(context, UIData.AllShopOrderPage, +// arguments: 1); +// }, +// ), +// GestureDetector( +// onTap: () { +// Navigator.pushNamed(context, UIData.AllShopOrderPage, +// arguments: 2); +// }, +// child: Column( +// mainAxisAlignment: MainAxisAlignment.center, +// children: [ +// Padding( +// child: Image.asset( +// "images/order2.png", +// width: 22.0, +// height: 22.0, +// ), +// padding: EdgeInsets.fromLTRB(0, 12, 0, 8), +// ), +// Text( +// "待发货", +// style: +// TextStyle(color: UIData.ff353535, fontSize: 12), +// ), +// ], +// ), +// ), +// GestureDetector( +// onTap: () { +// Navigator.pushNamed(context, UIData.AllShopOrderPage, +// arguments: 3); +// }, +// child: Column( +// mainAxisAlignment: MainAxisAlignment.center, +// children: [ +// Padding( +// child: Image.asset( +// "images/order3.png", +// width: 22.0, +// height: 22.0, +// ), +// padding: EdgeInsets.fromLTRB(0, 12, 0, 8), +// ), +// Text( +// "待收货", +// style: +// TextStyle(color: UIData.ff353535, fontSize: 12), +// ), +// ], +// ), +// ), +// GestureDetector( +// onTap: () { +// Navigator.pushNamed(context, UIData.AllShopOrderPage, +// arguments: 4); +// }, +// child: Column( +// mainAxisAlignment: MainAxisAlignment.center, +// children: [ +// Padding( +// child: Image.asset( +// "images/order4.png", +// width: 22.0, +// height: 22.0, +// ), +// padding: EdgeInsets.fromLTRB(0, 12, 0, 8), +// ), +// Text( +// "待评价", +// style: +// TextStyle(color: UIData.ff353535, fontSize: 12), +// ), +// ], +// ), +// ), +// ], +// ), +// ), +// ], +// ), +// ), +// ), +// ); +// } + + /* + * 头部的用户昵称排版 + */ + Row getUserNickNameWidget(Userinfo userInfo) { + print("getUserNickNameWidget:" + (userInfo == null ? "true" : "false")); + return Row( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + //头像 + Padding( + child: CircleAvatar(radius: 30, backgroundImage: getImage(userInfo)), + padding: EdgeInsets.fromLTRB(22, 10, 0, 0), + ), + //用户数据 + Expanded( + child: Padding( + padding: EdgeInsets.fromLTRB(20, 15, 8, 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Padding( + child: Text( + userInfo == null || userInfo.nickName == null + ? "点此登录" + : userInfo.nickName, + style: TextStyle(color: UIData.fff, fontSize: 18)), + padding: EdgeInsets.fromLTRB(0, 0, 0, 0), + ), + Padding( + child: Text( + userInfo == null || userInfo.phone == null + ? "登录后获取更多精彩内容" + : userInfo.phone, + style: TextStyle(color: UIData.fff, fontSize: 12)), + padding: EdgeInsets.fromLTRB(0, 7, 0, 0), + ) + ], + ), ), ), + //设置按钮 +// Padding( +// child: FlatButton( +// child: +// Image.asset('images/btn_settings.png', width: 23, height: 23), +// ), +// padding: EdgeInsets.fromLTRB(0, 23, 15, 0), +// ), + ], + ); + } + + /* + * 注释 + */ + Padding getMoneyWidget(Userinfo userInfo) { + return Padding( + padding: EdgeInsets.fromLTRB(0, 15, 8, 16), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Padding( + child: Column( + children: [ + //金额 + Text( + userInfo == null || userInfo.balanceAmt == null + ? "0" + : userInfo.balanceAmt, + style: TextStyle(color: Colors.white, fontSize: 15.0), + ), + //返现余额 + Text( + "返现余额", + style: TextStyle(color: Colors.white, fontSize: 11.0), + ), + ], + ), + padding: EdgeInsets.fromLTRB(22, 0, 0, 0), + ), + flex: 1, + ), + Container( + color: Colors.white, + width: 0.5, + height: 30.0, + ), + Expanded( + child: GestureDetector( + onTap: () { + //如果用户信息为空,那么我们就要去登录了,如果用户信息不为空,这时候,就要验证下 + Navigator.pushNamed(context, UIData.IviteFriendsPage, + arguments: 0); + }, + child: Padding( + child: Column( + children: [ + //金额 + Text( + userInfo == null || userInfo.inviteNum == null + ? "0" + : userInfo.inviteNum, + style: TextStyle(color: Colors.white, fontSize: 15.0), + ), + //返现余额 + Text( + "邀请好友", + style: TextStyle(color: Colors.white, fontSize: 11.0), + ), + ], + ), + padding: EdgeInsets.fromLTRB(22, 0, 0, 0), + ), + ), + flex: 1), + Container( + color: Colors.white, + width: 0.5, + height: 30.0, + ), + Expanded( + child: Padding( + child: Column( + children: [ + //金额 + Text( + "0", + style: TextStyle(color: Colors.white, fontSize: 15.0), + ), + //返现余额 + Text( + "优惠券", + style: TextStyle(color: Colors.white, fontSize: 11.0), + ), + ], + ), + padding: EdgeInsets.fromLTRB(22, 0, 0, 0), + ), + flex: 1, + ), + ], ), ); } @@ -251,15 +879,34 @@ class _UserHomeState extends State { ); } - Widget bodyData() { + Widget bodyData(Userinfo userInfo) { + return getWidget(userInfo); + } + + Widget getContent() { userInfoBloc.getUserInfo(); return StreamBuilder( - stream: userInfoBloc.userInfoStream.stream, + stream: userInfoBloc.userInfo, builder: (context, snapshot) { - return getWidget(snapshot.data); + return buildBody(snapshot.data); }); } + /* + * 头部 + */ + Padding getHeaderWidget(Userinfo userInfo) { + return Padding( + padding: EdgeInsets.fromLTRB(0, 15, 8, 16), + child: Column( + children: [ + getUserNickNameWidget(userInfo), + getMoneyWidget(userInfo) + ], + ), + ); + } + /* * 获取配置信息 */ @@ -268,7 +915,7 @@ class _UserHomeState extends State { slivers: [ SliverAppBar( centerTitle: false, - expandedHeight: 155.0, + expandedHeight: 198.0, floating: false, pinned: false, //固定在顶部 @@ -276,49 +923,30 @@ class _UserHomeState extends State { flexibleSpace: FlexibleSpaceBar( centerTitle: false, background: GestureDetector( - child: Container( - color: UIData.fffa4848, - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - child: CircleAvatar( - radius: 30, backgroundImage: getImage(userInfo)), - padding: EdgeInsets.fromLTRB(22, 0, 0, 0), - ), - Expanded( - child: Padding( - padding: EdgeInsets.fromLTRB(20, 50, 8, 16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Padding( - child: Text( - userInfo == null - ? "点此登录" - : userInfo.nickName, - style: TextStyle( - color: UIData.fff, fontSize: 18)), - padding: EdgeInsets.fromLTRB(0, 0, 0, 0), - ), - Padding( - child: Text( - userInfo == null - ? "登录后获取更多精彩内容" - : userInfo.phone, - style: TextStyle( - color: UIData.fff, fontSize: 12)), - padding: EdgeInsets.fromLTRB(0, 7, 0, 0), - ) - ], - ), + child: Stack( + children: [ + Image.asset( + 'images/icon_mine_bg.png', + fit: BoxFit.cover, + width: double.infinity, + ), + Positioned( + right: 0, + top: 0, + child: Padding( + padding: EdgeInsets.fromLTRB(8, 8, 15, 8), + child: InkWell( + child: Image.asset( + 'images/icon_setting.png', + width: 23.0, + height: 23.0, ), + onTap: () {}, ), - ], + ), ), - ), + getHeaderWidget(userInfo), + ], ), onTap: () { //如果用户信息为空,那么我们就要去登录了,如果用户信息不为空,这时候,就要验证下 @@ -330,23 +958,19 @@ class _UserHomeState extends State { SliverList( delegate: SliverChildListDelegate( [ - buildHeader(userInfo), + //订单列表 + buildOrdlerHeader(userInfo), + //常用工具 + buildCommonTools(userInfo), ], ), - ), - SliverFixedExtentList( - itemExtent: 60, - delegate: SliverChildBuilderDelegate( - (context, index) => buildListIItem(index, userInfo), - childCount: 6, - ), - ), + ) ], ); } ImageProvider getImage(Userinfo userInfo) { - if (userInfo == null) { + if (userInfo == null || userInfo.userImgUrl == null) { return new AssetImage("images/user_icon.png"); } return new NetworkImage(userInfo.userImgUrl); @@ -357,7 +981,7 @@ class _UserHomeState extends State { */ void gotoLogin(Userinfo userInfo) { print("跳转至登录页面"); - if (userInfo == null) { + if (userInfo == null || userInfo.phone == null) { Navigator.pushNamed(context, UIData.Login); return; } diff --git a/flutter_lib/lib/ui/page/home_page.dart b/flutter_lib/lib/ui/page/home_page.dart deleted file mode 100644 index ff29fb7..0000000 --- a/flutter_lib/lib/ui/page/home_page.dart +++ /dev/null @@ -1,345 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_lib/logic/bloc/menu_bloc.dart'; -import 'package:flutter_lib/model/menu.dart'; -import 'package:flutter_lib/ui/widgets/about_tile.dart'; -import 'package:flutter_lib/ui/widgets/profile_tile.dart'; -import 'package:flutter_lib/utils/uidata.dart'; - -// ignore: must_be_immutable -class HomePage extends StatelessWidget { - final _scaffoldState = GlobalKey(); - Size deviceSize; - BuildContext _context; - //menuStack - Widget menuStack(BuildContext context, Menu menu) => InkWell( - onTap: () => _showModalBottomSheet(context, menu), - splashColor: Colors.orange, - child: Card( - clipBehavior: Clip.antiAlias, - elevation: 2.0, - child: Stack( - fit: StackFit.expand, - children: [ - menuImage(menu), - menuColor(), - menuData(menu), - ], - ), - ), - ); - - //stack 1/3 - Widget menuImage(Menu menu) => Image.asset( - menu.image, - fit: BoxFit.cover, - ); - - //stack 2/3 - Widget menuColor() => new Container( - decoration: BoxDecoration(boxShadow: [ - BoxShadow( - color: Colors.white.withOpacity(0.8), - blurRadius: 5.0, - ), - ]), - ); - - //stack 3/3 - Widget menuData(Menu menu) => Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - menu.icon, - color: Colors.white, - ), - SizedBox( - height: 10.0, - ), - Text( - menu.title, - style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold), - ) - ], - ); - - //appbar - Widget appBar() => SliverAppBar( - backgroundColor: Colors.white, - pinned: true, - elevation: 10.0, - forceElevated: true, - expandedHeight: 150.0, - flexibleSpace: FlexibleSpaceBar( - centerTitle: false, - background: Container( - decoration: BoxDecoration( - gradient: LinearGradient(colors: UIData.kitGradients)), - ), - title: Row( - children: [ - FlutterLogo( - colors: Colors.yellow, - textColor: Colors.white, - ), - SizedBox( - width: 10.0, - ), - Text(UIData.appName) - ], - ), - ), - ); - - //bodygrid - Widget bodyGrid(List menu) => SliverGrid( - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: - MediaQuery.of(_context).orientation == Orientation.portrait - ? 2 - : 3, - mainAxisSpacing: 0.0, - crossAxisSpacing: 0.0, - childAspectRatio: 1.0, - ), - delegate: SliverChildBuilderDelegate((BuildContext context, int index) { - return menuStack(context, menu[index]); - }, childCount: menu.length), - ); - - Widget homeScaffold(BuildContext context) => Theme( - data: Theme.of(context).copyWith( - canvasColor: Colors.transparent, - ), - child: Scaffold(key: _scaffoldState, body: bodySliverList()), - ); - - Widget bodySliverList() { - MenuBloc menuBloc = MenuBloc(); - return StreamBuilder>( - stream: menuBloc.menuItems, - builder: (context, snapshot) { - return snapshot.hasData - ? CustomScrollView( - slivers: [ - appBar(), - bodyGrid(snapshot.data), - ], - ) - : Center(child: CircularProgressIndicator()); - }); - } - - Widget header() => Ink( - decoration: BoxDecoration( - gradient: LinearGradient(colors: UIData.kitGradients2)), - child: Padding( - padding: const EdgeInsets.all(16.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - CircleAvatar( - radius: 25.0, - backgroundImage: AssetImage(UIData.pkImage), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: ProfileTile( - title: "Pawan Kumar", - subtitle: "mtechviral@gmail.com", - textColor: Colors.white, - ), - ) - ], - ), - ), - ); - - void _showModalBottomSheet(BuildContext context, Menu menu) { - showModalBottomSheet( - context: context, - builder: (context) => Material( - clipBehavior: Clip.antiAlias, - color: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: new BorderRadius.only( - topLeft: new Radius.circular(15.0), - topRight: new Radius.circular(15.0))), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - mainAxisSize: MainAxisSize.max, - children: [ - header(), - Expanded( - child: ListView.builder( - shrinkWrap: false, - itemCount: menu.items.length, - itemBuilder: (context, i) => Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), - child: ListTile( - title: Text( - menu.items[i], - ), - onTap: () { - Navigator.pop(context); - Navigator.pushNamed( - context, "/${menu.items[i]}"); - }), - ), - ), - ), - MyAboutTile() - ], - ))); - } - - Widget iosCardBottom(Menu menu, BuildContext context) => Padding( - padding: const EdgeInsets.all(12.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container( - width: 40.0, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10.0), - border: Border.all(width: 3.0, color: Colors.white), - image: DecorationImage( - fit: BoxFit.cover, - image: AssetImage( - menu.image, - ))), - ), - SizedBox( - width: 20.0, - ), - Text( - menu.title, - textAlign: TextAlign.start, - style: TextStyle(color: Colors.white), - ), - SizedBox( - width: 20.0, - ), - FittedBox( - child: CupertinoButton( - onPressed: () => _showModalBottomSheet(context, menu), - borderRadius: BorderRadius.circular(50.0), - child: Text( - "Go", - textAlign: TextAlign.left, - style: TextStyle(color: CupertinoColors.activeBlue), - ), - color: Colors.white, - ), - ) - ], - ), - ); - - Widget menuIOS(Menu menu, BuildContext context) { - return Container( - height: deviceSize.height / 2, - decoration: ShapeDecoration( - shape: - RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), - ), - child: Card( - clipBehavior: Clip.antiAlias, - elevation: 3.0, - margin: EdgeInsets.all(16.0), - child: Stack( - fit: StackFit.expand, - children: [ - menuImage(menu), - Padding( - padding: const EdgeInsets.all(16.0), - child: Text( - menu.title, - style: TextStyle( - color: Colors.white, - fontSize: 28.0, - fontWeight: FontWeight.bold, - ), - ), - ), - Positioned( - bottom: 0.0, - left: 0.0, - right: 0.0, - height: 60.0, - child: Container( - width: double.infinity, - color: menu.menuColor, - child: iosCardBottom(menu, context), - ), - ) - ], - ), - ), - ); - } - - Widget bodyDataIOS(List data, BuildContext context) => SliverList( - delegate: SliverChildListDelegate( - data.map((menu) => menuIOS(menu, context)).toList()), - ); - - Widget homeBodyIOS(BuildContext context) { - MenuBloc menuBloc = MenuBloc(); - return StreamBuilder>( - stream: menuBloc.menuItems, - initialData: List(), - builder: (context, snapshot) { - return snapshot.hasData - ? bodyDataIOS(snapshot.data, context) - : Center( - child: CircularProgressIndicator(), - ); - }); - } - - Widget homeIOS(BuildContext context) => Theme( - data: ThemeData( - fontFamily: '.SF Pro Text', - ).copyWith(canvasColor: Colors.transparent), - child: CupertinoPageScaffold( - child: CustomScrollView( - slivers: [ - CupertinoSliverNavigationBar( - border: Border(bottom: BorderSide.none), - backgroundColor: CupertinoColors.white, - largeTitle: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(UIData.appName), - Padding( - padding: const EdgeInsets.only(right: 16.0), - child: CircleAvatar( - radius: 15.0, - backgroundColor: CupertinoColors.black, - child: FlutterLogo( - size: 15.0, - colors: Colors.yellow, - ), - ), - ) - ], - ), - ), - homeBodyIOS(context) - ], - ), - ), - ); - - @override - Widget build(BuildContext context) { - _context = context; - deviceSize = MediaQuery.of(context).size; - return defaultTargetPlatform == TargetPlatform.iOS - ? homeIOS(context) - : homeScaffold(context); - } -} diff --git a/flutter_lib/lib/ui/page/invite/invite_friends.dart b/flutter_lib/lib/ui/page/invite/invite_friends.dart index f99cb80..537d366 100644 --- a/flutter_lib/lib/ui/page/invite/invite_friends.dart +++ b/flutter_lib/lib/ui/page/invite/invite_friends.dart @@ -1,25 +1,23 @@ import 'package:flutter/material.dart'; import 'package:flutter_lib/logic/bloc/rebate_bloc.dart'; import 'package:flutter_lib/logic/bloc/userinfo_bloc.dart'; +import 'package:flutter_lib/model/Result.dart'; import 'package:flutter_lib/model/rebateList.dart'; import 'package:flutter_lib/model/userinfo.dart'; +import 'package:flutter_lib/ui/widgets/error_status_widget.dart'; import 'package:flutter_lib/utils/uidata.dart'; class InviteFriendsPage extends StatefulWidget { - InviteFriendsPage({Key key}) : super(key: key); - @override InviteFriendsPageState createState() => new InviteFriendsPageState(); } class InviteFriendsPageState extends State { - BuildContext _context; UserInfoBloc userInfoBloc = new UserInfoBloc(); RebateBloc rebateBloc = new RebateBloc(); @override Widget build(BuildContext context) { - _context = context; return new Scaffold( appBar: UIData.getCenterTitleAppBar("邀请好友下单", context), body: bodyData()); @@ -31,9 +29,24 @@ class InviteFriendsPageState extends State { Widget bodyData() { userInfoBloc.getUserInfo(); return StreamBuilder( - stream: userInfoBloc.userInfoStream.stream, + stream: userInfoBloc.userInfo, builder: (context, snapshot) { - return getCustomScroll(snapshot.data); + if (snapshot.hasData) { + if (snapshot.data != null) { + return getCustomScroll(snapshot.data); + } else { + return ErrorStatusWidget.order(0, "暂无数据", "点击重试", () { + userInfoBloc.getUserInfo(); + }); + } + } else if (snapshot.hasError) { + Result result = snapshot.error; + return ErrorStatusWidget.order(result.code, result.msg, "点击重试", () { + userInfoBloc.getUserInfo(); + }); + } else { + return Center(child: CircularProgressIndicator()); + } }); } @@ -43,33 +56,49 @@ class InviteFriendsPageState extends State { Widget getSliverDelegate() { rebateBloc.getRebatList(); return StreamBuilder>( - stream: rebateBloc.rebateStream.stream, + stream: rebateBloc.rebateInfo, builder: (context, snapshot) { if (snapshot.hasData) { - print("又要进来了吧"); - empty2("hello"); - } else if (snapshot.hasError) { - empty(snapshot.error); +// if (snapshot.data == null || snapshot.data.isEmpty) { +// return EmptyWidget.WithSliverList(snapshot.error, () { +// userInfoBloc.getUserInfo(); +// }); +// } else { +// return getSliverChild(snapshot.data); +// } +// } else if (snapshot.hasError) { +// return EmptyWidget.WithSliverList(snapshot.error, () { +// rebateBloc.getRebatList(); +// }); +// } else { +// return progress(); +// } + return getSliverChild(snapshot.data); } else { - return Center(child: CircularProgressIndicator()); + return getNone(); } }); } - Widget empty2(Object error) { - return SliverFixedExtentList(itemExtent: 120.0); + SliverList getNone() { + return SliverList( + delegate: SliverChildListDelegate( + [ + Container( + height: 0, + width: 0, + ) + ], + ), + ); } - Widget empty(Object error) { - return Center( - child: GestureDetector( - child: Padding( - padding: const EdgeInsets.all(32.0), - child: Text(error == null ? error.toString() : "點擊重試"), - ), - onTap: () { -// todo try again? - }, + Widget progress() { + return SliverList( + delegate: SliverChildListDelegate( + [ + Center(child: CircularProgressIndicator()), + ], ), ); } @@ -82,10 +111,12 @@ class InviteFriendsPageState extends State { return Text("123"); } - Widget getSliverChild() { + Widget getSliverChild(List data) { // print("rankList:" + rankList.length.toString()); + return SliverFixedExtentList( itemExtent: 77, // I'm forcing item heights + delegate: SliverChildBuilderDelegate( (context, index) => Container( color: UIData.fff, @@ -99,7 +130,8 @@ class InviteFriendsPageState extends State { width: 25, height: 25, child: Center( - child: UIData.getTextWidget("1231", UIData.fff, 15), + child: UIData.getTextWidget( + data[index].userName, UIData.fff, 15), ), decoration: new BoxDecoration( color: UIData.fffa4848, @@ -113,12 +145,12 @@ class InviteFriendsPageState extends State { children: [ Padding( child: UIData.getTextWidget( - "121", UIData.ff353535, 12), + data[index].iegralNum, UIData.ff353535, 12), padding: EdgeInsets.fromLTRB(0, 0, 0, 5), ), Padding( child: UIData.getTextWidget( - "123", UIData.ff353535, 12), + data[index].consumeAmt, UIData.ff353535, 12), padding: EdgeInsets.fromLTRB(0, 0, 0, 0), ), ], @@ -129,7 +161,7 @@ class InviteFriendsPageState extends State { ], ), ), - childCount: 0, + childCount: data.length, ), ); } @@ -146,7 +178,7 @@ class InviteFriendsPageState extends State { buildHeader(userInfo), buildVipInfo(userInfo), buildPayInfo(userInfo), - buildFriendsPayInfoList(), + buildFriendsPayInfoList(userInfo), ], ), ), @@ -155,35 +187,42 @@ class InviteFriendsPageState extends State { ); } - Padding buildFriendsPayInfoList() { + Padding buildFriendsPayInfoList(Userinfo userInfo) { + bool isDIsplay = ((userInfo.inviteNum == "0") || (userInfo == null)); return Padding( - padding: EdgeInsets.fromLTRB(0, 0, 0, 10), - child: new Container( - child: new Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: EdgeInsets.fromLTRB(0, 13, 0, 15), - child: new Column( - children: [ - new Row( - mainAxisAlignment: MainAxisAlignment.center, + child: new Offstage( + offstage: isDIsplay, + child: new Container( + child: new Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: EdgeInsets.fromLTRB(0, 13, 0, 15), + child: new Column( children: [ - Icon(Icons.cloud_upload), - Padding( - padding: EdgeInsets.fromLTRB(7, 0, 0, 0), - child: UIData.getTextWidget( - "好友成功消费排行版", UIData.ff353535, 15), + new Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + 'images/icon_ranking.png', + width: 19.0, + height: 19.0, + ), + Padding( + padding: EdgeInsets.fromLTRB(7, 0, 0, 0), + child: UIData.getTextWidget( + "好友成功消费排行版", UIData.ff353535, 15), + ), + ], ), ], ), - ], - ), + ), + ], ), - ], - ), - ), + )), + padding: EdgeInsets.fromLTRB(0, 0, 0, 10), ); } @@ -205,7 +244,7 @@ class InviteFriendsPageState extends State { style: TextStyle(color: UIData.ff353535, fontSize: 15), ), Text( - "累计1560.0", + userInfo == null ? "" : userInfo.totalConsume, style: TextStyle(color: UIData.fffa4848, fontSize: 15), ) ], @@ -246,7 +285,7 @@ class InviteFriendsPageState extends State { style: TextStyle(color: UIData.ff353535, fontSize: 15), ), Text( - "0个", + userInfo == null ? "" : userInfo.balanceAmt, style: TextStyle(color: UIData.ff353535, fontSize: 15), ) ], @@ -265,7 +304,9 @@ class InviteFriendsPageState extends State { ), Padding( padding: EdgeInsets.fromLTRB(15, 8, 15, 10), - child: UIData.getMaxWidthButton("立即成为VIP", () {}), + child: UIData.getMaxWidthButton("立即成为VIP", () { + Navigator.pushNamed(context, UIData.VipApplyPage, arguments: 0); + }), ), ], ), @@ -292,12 +333,26 @@ class InviteFriendsPageState extends State { "专属邀请码", style: TextStyle(color: UIData.ffffa5a5, fontSize: 12), ), - new Padding( - padding: EdgeInsets.fromLTRB(0, 10, 0, 14), - child: Text( - userInfo == null ? "" : userInfo.userCode, - style: TextStyle(color: UIData.ffffe116, fontSize: 30), + GestureDetector( + child: new Padding( + padding: EdgeInsets.fromLTRB(0, 10, 0, 14), + child: Text( + userInfo == null ? "" : userInfo.userCode, + style: TextStyle(color: UIData.ffffe116, fontSize: 30), + ), ), + onTap: () { + if (userInfo != null && userInfo.userCode.isNotEmpty) { +// ClipboardManager.copyToClipBoard( +// userInfo == null ? "" : userInfo.userCode) +// .then((result) { +// final snackBar = SnackBar( +// content: Text('已复制到粘贴板'), +// ); +// Scaffold.of(context).showSnackBar(snackBar); +// }); + } + }, ), new Padding( padding: EdgeInsets.fromLTRB(0, 10, 0, 26), diff --git a/flutter_lib/lib/ui/page/order/all_shop_order_list.dart b/flutter_lib/lib/ui/page/order/all_shop_order_list.dart index 336da66..d14d776 100644 --- a/flutter_lib/lib/ui/page/order/all_shop_order_list.dart +++ b/flutter_lib/lib/ui/page/order/all_shop_order_list.dart @@ -1,12 +1,27 @@ import 'package:flutter/material.dart'; import 'package:flutter_lib/logic/bloc/oder_list_bloc.dart'; +import 'package:flutter_lib/model/Result.dart'; import 'package:flutter_lib/model/orderListItem.dart'; +import 'package:flutter_lib/ui/page/order/order_action_widget.dart'; +import 'package:flutter_lib/ui/widgets/error_status_widget.dart'; import 'package:flutter_lib/utils/uidata.dart'; class AllShopOrderPage extends StatefulWidget { + final int initialIndex; + + AllShopOrderPage(this.initialIndex); + @override State createState() { - return _ShopCartListState(); + List pages = List(); + + pages.add(Container(child: TagOrderPage(0))); + pages.add(Container(child: TagOrderPage(1))); + pages.add(Container(child: TagOrderPage(2))); + pages.add(Container(child: TagOrderPage(3))); + pages.add(Container(child: TagOrderPage(4))); + + return _ShopCartListState(pages); } } @@ -16,6 +31,8 @@ class TagOrderPage extends StatefulWidget { this.type = i; } + OrderListBloc orderListBloc; + @override State createState() { return TagState(); @@ -23,7 +40,18 @@ class TagOrderPage extends StatefulWidget { } class TagState extends State { - OrderListBloc orderListBloc = OrderListBloc(); + @override + void initState() { + super.initState(); + widget.orderListBloc = OrderListBloc(); + widget.orderListBloc.getOrderListList(context,widget.type); + } + + @override + void dispose() { + widget.orderListBloc?.close(); + super.dispose(); + } @override Widget build(BuildContext context) { @@ -31,58 +59,51 @@ class TagState extends State { } Widget getOrderList(int type) { -// todo type - orderListBloc.getOrderListList(type); return StreamBuilder>( - stream: orderListBloc.productItems, + stream: widget.orderListBloc.productItems, builder: (context, snapshot) { List list = snapshot.data; - return snapshot.hasData - ? ((list == null || list.isEmpty) - ? empty(type) - : buildListView(list)) - : Center(child: CircularProgressIndicator()); + if (snapshot.hasData) { + if (snapshot.data.isNotEmpty) { + return buildListView(type, list); + } else { + return ErrorStatusWidget.order(0,"暂无订单","去下单", () { + Navigator.pushNamed(context, UIData.ShopCategoryList, + arguments: "全部分类"); + }); + } + } else if (snapshot.hasError) { + Result result = snapshot.error; + return ErrorStatusWidget.order(result.code,result.msg,"去下单", () { + Navigator.pushNamed(context, UIData.ShopCategoryList, + arguments: "全部分类"); + }); + } else { + return center(); + } }); } - Widget empty(int type) { - return Center( - child: Padding( - padding: const EdgeInsets.all(32.0), - child: GestureDetector( - child: Padding( - padding: const EdgeInsets.all(32.0), - child: Text("无数据,点击重试"), - ), - onTap: () { - orderListBloc.getOrderListList(type); - }, - ), - ), - ); + Center center() { + widget.orderListBloc.getOrderListList(context,widget.type); + return Center(child: CircularProgressIndicator()); } - Widget buildListView(List orders) { + Widget buildListView(int type, List orders) { return ListView.builder( itemCount: orders == null ? 0 : orders.length, itemBuilder: (context, index) { - return buildOrderItem(orders, index); + return buildOrderItem(orders, index, type); }, ); } - GestureDetector buildOrderItem(List orders, int index) { + GestureDetector buildOrderItem(List orders, int index, int type) { OrderItem orderItem = orders[index]; List prducts = orderItem.products; String status = "无状态"; - String action = "无动作"; - // 1:待付款,2:待发货,3:待收货,4:待评价,0:全部 - switch (orderItem.status) { - case 0: - status = "已取消"; - break; case 1: status = "待付款"; break; @@ -95,6 +116,9 @@ class TagState extends State { case 4: status = "待评价"; break; + default: + status = "已取消"; + break; } return GestureDetector( @@ -134,20 +158,17 @@ class TagState extends State { Text( "共" + prducts.length.toString() + - "商品,已付款:" + + "商品,总价:¥" + orderItem.payPrice.toString(), style: TextStyle(color: UIData.ff353535, fontSize: 14), ), ], ), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Text( - action, - style: TextStyle(color: UIData.ff353535, fontSize: 14), - ), - ], + Padding( + padding: const EdgeInsets.fromLTRB(0, 16, 0, 0), + child: OrderActionWidget(orderItem, type, () { + widget.orderListBloc.getOrderListList(context,type); + }), ), ], ), @@ -156,14 +177,14 @@ class TagState extends State { ), ), onTap: () { - Navigator.pushNamed(context, UIData.OrderDetailPage); + Navigator.pushNamed(context, UIData.OrderDetailPage, + arguments: orderItem.orderNumber); }, ); } GestureDetector buildListIItem(Good product) { - String img = ""; - String description = "没有"; + String img = product.goodsImgUrl; String price = product.goodsPrice; String count = product.buyNum; return GestureDetector( @@ -190,20 +211,6 @@ class TagState extends State { child: Text(product.goodsName, style: TextStyle(fontSize: 12, color: UIData.ff353535)), ), - Padding( - padding: EdgeInsets.fromLTRB(12, 0, 13, 0), - child: Container( - height: 18, - width: 92, - decoration: BoxDecoration( - color: UIData.fff7f7f7, - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(3)), - child: Center( - child: UIData.getTextWidget( - description, UIData.ff999999, 11), - )), - ), Padding( padding: EdgeInsets.fromLTRB(15, 6, 15, 17), child: Row( @@ -219,11 +226,14 @@ class TagState extends State { ), ), Container( - width: 20, + width: 100, height: 20, child: Center( - child: UIData.getTextWidget( - "x" + count.toString(), UIData.ff999999, 11), + child: Text("数量:x " + count.toString(), + style: TextStyle( + fontSize: 11, + color: UIData.ff999999, + )), ), decoration: BoxDecoration( border: @@ -249,15 +259,15 @@ class TagState extends State { } class _ShopCartListState extends State { - OrderListBloc orderListBloc = OrderListBloc(); + List pages; + _ShopCartListState(pages) { + this.pages = pages; + } @override Widget build(BuildContext context) { -// SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light.copyWith( -// statusBarColor: UIData.fffa4848, //or set color with: Color(0xFF0000FF) -// )); - return DefaultTabController( + initialIndex: widget.initialIndex, child: Scaffold( appBar: AppBar( backgroundColor: UIData.fff, @@ -286,7 +296,16 @@ class _ShopCartListState extends State { color: UIData.fff, child: Text( "全部", - style: TextStyle(color: UIData.ff666666, fontSize: 14), + style: TextStyle(color: UIData.ff666666, fontSize: 12), + ), + ), + ), + Tab( + child: Container( + color: UIData.fff, + child: Text( + "待付款", + style: TextStyle(color: UIData.ff666666, fontSize: 12), ), ), ), @@ -295,7 +314,16 @@ class _ShopCartListState extends State { color: UIData.fff, child: Text( "待发货", - style: TextStyle(color: UIData.ff666666, fontSize: 14), + style: TextStyle(color: UIData.ff666666, fontSize: 12), + ), + ), + ), + Tab( + child: Container( + color: UIData.fff, + child: Text( + "待收货", + style: TextStyle(color: UIData.ff666666, fontSize: 12), ), ), ), @@ -304,7 +332,7 @@ class _ShopCartListState extends State { color: UIData.fff, child: Text( "待评价", - style: TextStyle(color: UIData.ff666666, fontSize: 14), + style: TextStyle(color: UIData.ff666666, fontSize: 12), ), ), ), @@ -312,15 +340,10 @@ class _ShopCartListState extends State { ), ), body: TabBarView( - children: [ - // 1:待付款,2:待发货,3:待收货,4:待评价,0:全部 - Container(child: TagOrderPage(0)), - Container(child: TagOrderPage(2)), - Container(child: TagOrderPage(4)), - ], + children: pages, ), ), - length: 3, + length: 5, ); } } diff --git a/flutter_lib/lib/ui/page/order/mine_order.dart b/flutter_lib/lib/ui/page/order/mine_order.dart deleted file mode 100644 index fa9ae7c..0000000 --- a/flutter_lib/lib/ui/page/order/mine_order.dart +++ /dev/null @@ -1,136 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_lib/model/mineOrderTab.dart'; -import 'package:flutter_lib/ui/page/order/mine_order_list.dart'; -import 'package:flutter_lib/utils/uidata.dart'; - -class MineOrderPage extends StatefulWidget { - int page; - - MineOrderPage(int page, {Key key}) : super(key: key) { - this.page = page; - } - - @override - MineOrderPageState createState() => new MineOrderPageState(page); -} - -//定义tab页基本数据结构 -final List mineOrderTabs = [ - new MineOrderTab('全部', 'all'), - new MineOrderTab('待发货', 'shipped'), - new MineOrderTab('待收货', 'received'), - new MineOrderTab('待评价', 'evaluated'), -]; - -class MineOrderPageState extends State { - MineOrderTab _currenttab; //定义默认打开的Tab页 - MineOrderPageState(int page) { - _currenttab = mineOrderTabs[page]; - } - - void _selectTab(MineOrderTab tab) { - //修改状态值 - setState(() { - _currenttab = tab; - }); - } - - @override - Widget build(BuildContext context) { - return new Scaffold( - appBar: UIData.getCenterTitleAppBar("我的订单", context), - body: Stack( - children: [ - Positioned( - top: 0, - left: 0, - right: 0, - child: TabNavigation( - currentTab: _currenttab, - onSelectTab: _selectTab, - ), - ), - Positioned( - top: 45, - left: 0, - right: 0, - bottom: 0, - child: Container( - color: Color(0xFFF5F5F5), - child: Stack( - children: mineOrderTabs.map((item) { - return Offstage( - offstage: _currenttab != item, - child: MineOrderList( - pageKey: PageStorageKey(item), - orderType: item.tabDescribe), - ); - }).toList()), - ), - ), - ], - ), - ); - } -} - -class TabNavigation extends StatelessWidget { - TabNavigation({this.currentTab, this.onSelectTab}); - - final MineOrderTab currentTab; - final ValueChanged - onSelectTab; //这个参数比较关键,仔细理解下,省了setState()调用的环节 - - @override - Widget build(BuildContext context) { - return Row( - children: mineOrderTabs.map((item) { - return Expanded( - child: GestureDetector( - //手势监听控件,用于监听各种手势 - child: Container( - color: Color(0xFFFFFFFF), - height: 45.0, - //alignment: Alignment.center, - child: Stack( - alignment: AlignmentDirectional.center, - children: [ - Text( - item.tabName, - style: TextStyle( - color: _colorTabMatching(item: item), - fontSize: 14.0), - ), - Positioned( - bottom: 0.0, - child: Container( - alignment: Alignment.center, - width: 60.0, - height: 2.0, - decoration: BoxDecoration( - border: Border.all( - color: currentTab == item - ? Color(0xFFFA4848) - : Colors.transparent, - width: 1.0), - borderRadius: - new BorderRadius.all(new Radius.circular(1.0)), - ), - ), - ), - ], - )), - onTap: () => onSelectTab( - item, - ) - //onSelectTab函数的使用非常巧妙, - //相当于定义了一个接口,可操控当前控件以外的数据 - )); - }).toList()); - } - - //定义tab被选中和没被选中的颜色样式 - Color _colorTabMatching({MineOrderTab item}) { - return currentTab == item ? Color(0xffF94847) : Color(0xff666666); - } -} diff --git a/flutter_lib/lib/ui/page/order/mine_order_list.dart b/flutter_lib/lib/ui/page/order/mine_order_list.dart deleted file mode 100644 index 5063a2d..0000000 --- a/flutter_lib/lib/ui/page/order/mine_order_list.dart +++ /dev/null @@ -1,339 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_lib/logic/viewmodel/product_view_model.dart'; -import 'package:flutter_lib/model/mineOrderTab.dart'; -import 'package:flutter_lib/model/orderDetail.dart'; -import 'package:flutter_lib/model/product.dart'; -import 'package:flutter_lib/utils/uidata.dart'; - -class MineOrderList extends StatefulWidget { - @override - MineOrderList({this.orderType, this.pageKey}); - - final PageStorageKey pageKey; //当前控件唯一标识Key - final String orderType; - - MineOrderState createState() => new MineOrderState(orderType: orderType); -} - -class MineOrderState extends State { - final String orderType; - List items = new List(); - - _upItems(List items) { - setState(() { - this.items = items; - }); - } - - @override - MineOrderState({this.orderType}); - - @override - Widget build(BuildContext context) { - List list = ProductViewModel().getOrderDetailList(); - items.clear(); - switch (orderType) { - case "all": - items.addAll(list); - break; - case "shipped": - for (OrderDetail orderDetail in list) { - if (orderDetail.status == 1) { - items.add(orderDetail); - } - } - break; - case "received": - for (OrderDetail orderDetail in list) { - if (orderDetail.status == 2) { - items.add(orderDetail); - } - } - break; - case "evaluated": - for (OrderDetail orderDetail in list) { - if (orderDetail.status == 3 || orderDetail.status == 4) { - items.add(orderDetail); - } - } - break; - } - return ListView.builder( - itemCount: items.length, - itemBuilder: (context, index) { - return MineOrderListItem(item: items[index]); - }, - ); - } -} - -class MineOrderListItem extends StatelessWidget { - final OrderDetail item; - - MineOrderListItem({Key key, @required this.item}) : super(key: key); - - @override - Widget build(BuildContext context) { - return GestureDetector( - child: Container( - padding: EdgeInsets.fromLTRB(6.0, 1.0, 6.0, 1.0), - child: Card( - child: Column( - children: [ - Container( - height: 38.0, - padding: EdgeInsets.fromLTRB(15.0, 0.0, 15.0, 0.0), - child: Row( - children: [ - Expanded( - child: Text( - "订单号:" + item.orderNumber, - style: - TextStyle(color: Color(0xFF353535), fontSize: 13.0), - ), - ), - Text( - item.getListStatusName(), - style: - TextStyle(color: Color(0xFFF94847), fontSize: 13.0), - ), - ], - ), - ), - Container( - margin: EdgeInsets.fromLTRB(15.0, 0, 15.0, 0), - color: Color(0xFFEEEEEE), - height: 1.0, - ), - ListView.builder( - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemCount: item.products.length, - itemBuilder: (context, index) { - return ProductItem(item: item.products[index]); - }, - ), - Container( - alignment: Alignment.centerRight, - margin: EdgeInsets.fromLTRB(15.0, 14.0, 15.0, 0.0), - child: Text( - "共" + - item.products.length.toString() + - "件商品已付款:¥" + - item.payPrice.toStringAsFixed(2), - style: TextStyle(color: Color(0xFF353535), fontSize: 12.0), - ), - ), - Container( - alignment: Alignment.centerRight, - height: item.status == 0 ? 14.0 : 45.0, - child: Stack( - children: [buildBottomBar(context)], - ), - ) - ], - ), - ), - ), - onTap: () { - //Navigator.pushNamed(context, UIData.ShopDetailPage, arguments: item); - }, - ); - } - - Positioned buildBottomBar(BuildContext context) { - return item.status == 0 - ? Positioned( - bottom: 0, - left: 0, - right: 0, - child: Container(), - ) - : Positioned( - bottom: 0, - left: 0, - right: 0, - child: Container( - height: 45, - color: Colors.white, - child: Row( - children: [ - Expanded( - child: Container(), - ), - Container( - margin: EdgeInsets.fromLTRB(0, 0, 10.0, 0), - child: Stack( - alignment: Alignment.center, - children: [ - Container( - alignment: Alignment.center, - width: 85.0, - height: 25.0, - decoration: BoxDecoration( - border: Border.all( - color: Color(0xFFEEEEEE), width: 1.0), - borderRadius: - new BorderRadius.all(new Radius.circular(12.5)), - ), - ), - InkWell( - child: new Container( - width: 85.0, - height: 25.0, - child: new Text( - item.getListStatusButtonName(), - style: TextStyle( - color: Color(0xFF353535), fontSize: 13), - ), - alignment: Alignment.center, - ), - //圆角大小,与BoxDecoration保持一致,更美观 - onTap: () {}, - ), - ], - ), - ), - !(item.status == 2 || item.status == 3) - ? Container( - height: 0, - ) - : Container( - margin: EdgeInsets.fromLTRB(0, 0, 10.0, 0), - child: Stack( - alignment: Alignment.center, - children: [ - Container( - alignment: Alignment.center, - width: 85.0, - height: 25.0, - decoration: BoxDecoration( - border: Border.all( - color: Color(0xFFF94847), width: 1.0), - borderRadius: new BorderRadius.all( - new Radius.circular(12.5)), - ), - ), - InkWell( - child: new Container( - width: 85.0, - height: 25.0, - child: new Text( - item.status == 2 ? "确认收货" : "评价", - style: TextStyle( - color: Color(0xFFF94847), fontSize: 13), - ), - alignment: Alignment.center, - ), - //圆角大小,与BoxDecoration保持一致,更美观 - onTap: () { - if(item.status == 2){ - - }else{ - Navigator.pushNamed(context, UIData.OrderCommentPage); - } - }, - ), - ], - ), - ), - ], - ), - ), - ); - } -} - -class ProductItem extends StatelessWidget { - final Product item; - - ProductItem({Key key, @required this.item}) : super(key: key); - - @override - Widget build(BuildContext context) { - return GestureDetector( - child: Container( - child: Container( - padding: EdgeInsets.fromLTRB(15.0, 10.0, 15.0, 0.0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.fromLTRB(0.0, 0.0, 10.0, 0.0), - width: 88.0, - height: 88.0, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8.0), - image: DecorationImage( - image: NetworkImage(item.image), fit: BoxFit.cover), - ), - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - item.name, - style: - TextStyle(color: Color(0xFF353535), fontSize: 12.0), - ), - Padding( - padding: EdgeInsets.fromLTRB(0, 8, 0, 0), - child: Container( - height: 18, - width: 92, - decoration: BoxDecoration( - color: UIData.fff7f7f7, - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(3)), - child: Center( - child: UIData.getTextWidget( - "米白色, 36码", UIData.ff999999, 11), - )), - ), - Container( - margin: EdgeInsets.fromLTRB(0.0, 15.0, 0.0, 0.0), - child: Row( - children: [ - Expanded( - child: Text( - item.price, - style: TextStyle( - color: Color(0xFFFF2E2E), fontSize: 12.0), - ), - ), - Padding( - padding: EdgeInsets.fromLTRB(3, 0, 3, 0), - child: Container( - width: 50, - height: 20, - child: Center( - child: UIData.getTextWidget( - "x " + item.count.toString(), - UIData.ff999999, - 11), - ), - decoration: BoxDecoration( - border: Border.all( - color: UIData.fff7f7f7, width: 1.0), - shape: BoxShape.rectangle, - ), - ), - ), - ], - ), - ), - ], - ), - ), - ], - ), - ), - ), - onTap: () { - Navigator.pushNamed(context, UIData.ShopDetailPage, arguments: item.skuId); - }, - ); - } -} diff --git a/flutter_lib/lib/ui/page/order/oder_comment.dart b/flutter_lib/lib/ui/page/order/oder_comment.dart index a64dea2..5853de4 100644 --- a/flutter_lib/lib/ui/page/order/oder_comment.dart +++ b/flutter_lib/lib/ui/page/order/oder_comment.dart @@ -1,9 +1,15 @@ import 'package:flutter/material.dart'; +import 'package:flutter_lib/bridge/common_bridge.dart'; +import 'package:flutter_lib/bridge/order_bridge.dart'; +import 'package:flutter_lib/model/OrderComment.dart'; +import 'package:flutter_lib/model/Result.dart'; import 'package:flutter_lib/ui/widgets/rating_bar.dart'; import 'package:flutter_lib/utils/uidata.dart'; class OrderCommentPage extends StatefulWidget { - OrderCommentPage({Key key}) : super(key: key); + OrderComment orderComment; + + OrderCommentPage(this.orderComment); @override OrderCommentPageState createState() => new OrderCommentPageState(); @@ -46,6 +52,9 @@ class OrderCommentPageState extends State { onChange: (int value) { setState(() { _value = value; + widget.orderComment.goodsEvaluates.forEach((f) { + f.level = _value.toString(); + }); }); }, ), @@ -70,19 +79,19 @@ class OrderCommentPageState extends State { maxLength: 130, maxLines: 7, //最大行数 - style: TextStyle( - fontSize: 15.0, color: Color(0xFF333333)), + style: TextStyle(fontSize: 15.0, color: Color(0xFF333333)), //输入文本的样式 decoration: new InputDecoration( - //fillColor: Color(0xFFEEEEEE), + //fillColor: Color(0xFFEEEEEE), border: InputBorder.none, - counterStyle: - TextStyle(color: Colors.transparent), + counterStyle: TextStyle(color: Colors.transparent), hintText: '填写你要发表的评语', - hintStyle: TextStyle( - fontSize: 15.0, color: Color(0xFFCCCCCC))), + hintStyle: + TextStyle(fontSize: 15.0, color: Color(0xFFCCCCCC))), onChanged: (text) { - + widget.orderComment.goodsEvaluates.forEach((f) { + f.content = text; + }); }, onSubmitted: (text) { //内容提交(按回车)的回调 @@ -95,10 +104,15 @@ class OrderCommentPageState extends State { height: 50, child: UIData.getShapeButton( UIData.fffa4848, UIData.fff, 345, 45, "提交评价", 18, 5, () { - setState(() { - + Future future = + OrderBridge.submitComment(widget.orderComment); + future.then((r) { + if (r.code == 200) { + Navigator.of(context).pop(); + } else { + Bridge.showLongToast(r.msg); + } }); - Navigator.of(context).pop(); }), ) ], diff --git a/flutter_lib/lib/ui/page/order/order_action_widget.dart b/flutter_lib/lib/ui/page/order/order_action_widget.dart new file mode 100644 index 0000000..2049337 --- /dev/null +++ b/flutter_lib/lib/ui/page/order/order_action_widget.dart @@ -0,0 +1,209 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_lib/bridge/common_bridge.dart'; +import 'package:flutter_lib/bridge/order_bridge.dart'; +import 'package:flutter_lib/model/OrderComment.dart'; +import 'package:flutter_lib/model/Result.dart'; +import 'package:flutter_lib/model/orderListItem.dart'; +import 'package:flutter_lib/ui/widgets/common_dialogs.dart'; +import 'package:flutter_lib/utils/uidata.dart'; +class OrderActionWidget extends StatelessWidget{ + final orderItem; + final type; + final click; + + OrderActionWidget(this.orderItem, this.type, this.click); + + @override + Widget build(BuildContext context) { + return getActionBtn(context,orderItem,type,click); + } + + Widget getActionBtn(BuildContext context,OrderItem orderItem, int type,click) { + // 1:待付款,2:待发货,3:待收货,4:待评价,0:全部 + switch (orderItem.status) { + case 1: + return Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), + child: Container( + child: GestureDetector( + onTap: () { + Future future = + OrderBridge.cancelOrder(orderItem.orderNumber); + future.then((r) { + if (r.code == 200) { + Bridge.showLongToast("取消成功"); + click(); + } else { + Bridge.showLongToast(r.msg); + } + }); + }, + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), + child: Text( + "取消订单", + style: TextStyle(color: UIData.ff353535, fontSize: 13), + ), + )), + decoration: BoxDecoration( + border: Border.all(color: UIData.ff353535, width: 1), + borderRadius: BorderRadius.circular(13.0), + ), + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), + child: Container( + child: GestureDetector( + onTap: () { + showPayDialog(context, double.parse(orderItem.payPrice), + orderItem.orderNumber,""); + }, + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), + child: Text( + "立即付款", + style: TextStyle(color: UIData.ff353535, fontSize: 13), + ), + )), + decoration: BoxDecoration( + border: Border.all(color: UIData.ff353535, width: 1), + borderRadius: BorderRadius.circular(13.0), + ), + ), + ), + ], + ); + + case 2: + return Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), + child: Container( + child: GestureDetector( + onTap: () { + Future future = + OrderBridge.cancelOrder(orderItem.orderNumber); + future.then((r) { + if (r.code == 200) { + Bridge.showLongToast("取消成功"); + click(); + } else { + Bridge.showLongToast(r.msg); + } + }); + }, + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), + child: Text( + "取消订单", + style: TextStyle(color: UIData.ff353535, fontSize: 13), + ), + )), + decoration: BoxDecoration( + border: Border.all(color: UIData.ff353535, width: 1), + borderRadius: BorderRadius.circular(13.0), + ), + ), + ), + ], + ); + case 3: + return Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), + child: Container( + child: GestureDetector( + onTap: () { + Bridge.webview("http://www.baidu.com"); + }, + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), + child: Text( + "查看物流", + style: TextStyle(color: UIData.ff353535, fontSize: 13), + ), + )), + decoration: BoxDecoration( + border: Border.all(color: UIData.ff353535, width: 1), + borderRadius: BorderRadius.circular(13.0), + ), + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), + child: Container( + child: GestureDetector( + onTap: () { + Future future = + OrderBridge.confirmOrder(orderItem.orderNumber); + future.then((r) { + if (r.code == 200) { + Bridge.showLongToast("已确认收货"); + click(); + } else { + Bridge.showLongToast(r.msg); + } + }); + }, + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), + child: Text( + "确认收货", + style: TextStyle(color: UIData.fffa4848, fontSize: 13), + ), + )), + decoration: BoxDecoration( + border: Border.all(color: UIData.fffa4848, width: 1), + borderRadius: BorderRadius.circular(13.0), + ), + ), + ), + ], + ); + break; + case 4: + return Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), + child: Container( + child: GestureDetector( + onTap: () { + var goods = orderItem.products.map((f) { + return Goods(f.goodsId, "", ""); + }).toList(); + var orderComment = + OrderComment(orderItem.orderNumber, goods); + Navigator.pushNamed(context, UIData.OrderCommentPage, + arguments: orderComment); + }, + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), + child: Text( + "评价", + style: TextStyle(color: UIData.fffa4848, fontSize: 13), + ), + )), + decoration: BoxDecoration( + border: Border.all(color: UIData.fffa4848, width: 1), + borderRadius: BorderRadius.circular(13.0), + ), + ), + ), + ], + ); + default: + return Text(""); + } + } +} + diff --git a/flutter_lib/lib/ui/page/order/order_detail.dart b/flutter_lib/lib/ui/page/order/order_detail.dart index 55f02f9..06cda28 100644 --- a/flutter_lib/lib/ui/page/order/order_detail.dart +++ b/flutter_lib/lib/ui/page/order/order_detail.dart @@ -1,80 +1,109 @@ import 'package:flutter/material.dart'; -import 'package:flutter_lib/logic/viewmodel/product_view_model.dart'; -import 'package:flutter_lib/model/address.dart'; -import 'package:flutter_lib/model/orderDetail.dart'; -import 'package:flutter_lib/model/product.dart'; -import 'package:flutter_lib/ui/page/address/add_edit_address.dart'; -import 'package:flutter_lib/ui/page/address/address_list.dart'; +import 'package:flutter_lib/logic/bloc/oder_list_bloc.dart'; +import 'package:flutter_lib/model/Result.dart'; +import 'package:flutter_lib/model/orderListItem.dart'; +import 'package:flutter_lib/model/orderdetail.dart'; +import 'package:flutter_lib/ui/page/order/order_action_widget.dart'; +import 'package:flutter_lib/ui/widgets/error_status_widget.dart'; import 'package:flutter_lib/utils/uidata.dart'; class OrderDetailPage extends StatefulWidget { - OrderDetailPage({Key key}) : super(key: key); + String orderId; + + OrderDetailPage(this.orderId); @override OrderDetailPageState createState() => new OrderDetailPageState(); } class OrderDetailPageState extends State { - OrderDetail _orderDetail; + OrderListBloc orderListBloc = OrderListBloc(); @override Widget build(BuildContext context) { - _orderDetail = getOrderDetail(); - return new Scaffold( + return Scaffold( appBar: UIData.getCenterTitleAppBar("订单详情", context), body: Container( - child: Stack( - children: [ - Container( - color: Color(0xFFF5F5F5), - ), - buildHeader(), - Positioned( - top: 78.0, - left: 10.0, - right: 10.0, - bottom: _orderDetail.status == 0 ? 0 : 49.0, - child: CustomScrollView( - slivers: [ - SliverList( - delegate: SliverChildListDelegate( - [ - _orderDetail.status != 0 - ? buildLogistics() - : Container( - height: 0.0, - ), - buildAddress(), - ], - ), - ), - SliverList( - delegate: SliverChildBuilderDelegate( - (context, index) => - ProductItem(item: _orderDetail.products[index]), - childCount: _orderDetail.products.length, - ), - ), - SliverList( - delegate: SliverChildListDelegate( - [ - buildOrderInfo(), - buildPayInfo(), - buildServiceInfo(), - ], - ), - ), - ], + child: getDetail(), + ), + ); + } + + Widget getDetail() { + orderListBloc.getOrderDetail(widget.orderId); + return StreamBuilder( + stream: orderListBloc.orderDetail, + builder: (context, snapshot) { + if (snapshot.hasError) { + Result result = snapshot.error; + return ErrorStatusWidget.order(result.code, result.msg, "点击重试", () { + orderListBloc.getOrderDetail(widget.orderId); + }); + } else if (snapshot.hasData) { + if (snapshot.data != null && snapshot.data.orderId.isNotEmpty) { + return buildStack(snapshot.data); + } else { + return ErrorStatusWidget.order(0, "暂无数据", "点击重试", () { + orderListBloc.getOrderDetail(widget.orderId); + }); + } + } else { + return Center(child: CircularProgressIndicator()); + } + }); + } + + Stack buildStack(OrderDetail _orderDetail) { + return Stack( + children: [ + Container( + color: Color(0xFFF5F5F5), + ), + buildHeader(_orderDetail), + Positioned( + top: 78.0, + left: 10.0, + right: 10.0, + bottom: _orderDetail.status == 0 ? 0 : 49.0, + child: CustomScrollView( + slivers: [ + SliverList( + delegate: SliverChildListDelegate( + [ + _orderDetail.status != 0 + ? buildLogistics(_orderDetail) + : Container( + height: 0.0, + ), + buildAddress(_orderDetail), + ], + ), ), - ), - buildBottomBar(), - ], + SliverList( + delegate: SliverChildBuilderDelegate( + (context, index) => + ProductItem(item: _orderDetail.goods[index]), + childCount: _orderDetail.goods.length, + ), + ), + SliverList( + delegate: SliverChildListDelegate( + [ + buildOrderInfo(_orderDetail), + buildPayInfo(_orderDetail), + buildServiceInfo(), + ], + ), + ), + ], + ), ), - ), + buildBottomBar(_orderDetail), + ], ); } - Container buildHeader() { + Container buildHeader(OrderDetail _orderDetail) { return Container( color: Color(0xFFF33D3C), height: 100.0, @@ -84,7 +113,9 @@ class OrderDetailPageState extends State { top: 31.0, left: 26.0, child: Text( - _orderDetail.getStatusName(), + _orderDetail.getStatusName() == null + ? "名称不可为空" + : _orderDetail.getStatusName(), style: TextStyle(color: Colors.white, fontSize: 18.0), ), ), @@ -93,7 +124,7 @@ class OrderDetailPageState extends State { right: 26.0, child: InkWell( child: Text( - _orderDetail.status == 0 ? "" : "邀请好友下单返现金", + _orderDetail.status == 0 ? "名称不可为空" : "邀请好友下单返现金", style: TextStyle(color: Color(0xFFFF9796), fontSize: 12.0), ), onTap: () { @@ -106,7 +137,13 @@ class OrderDetailPageState extends State { ); } - Card buildLogistics() { + Widget buildLogistics(OrderDetail _orderDetail) { + if (_orderDetail.express == null) { + return Container( + width: 0, + height: 0, + ); + } return Card( child: Container( height: 45.0, @@ -121,7 +158,9 @@ class OrderDetailPageState extends State { child: Container( padding: EdgeInsets.fromLTRB(6.0, 0.0, 6.0, 0.0), child: Text( - _orderDetail.express, + _orderDetail.express == null + ? "名称不可为空" + : _orderDetail.express, style: TextStyle(color: Color(0xFF353535), fontSize: 12.0), maxLines: 1, ), @@ -137,7 +176,7 @@ class OrderDetailPageState extends State { ); } - Card buildAddress() { + Card buildAddress(OrderDetail _orderDetail) { return Card( child: Padding( padding: EdgeInsets.fromLTRB(10, 15, 10, 15), @@ -156,11 +195,12 @@ class OrderDetailPageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - _orderDetail.address.name + _orderDetail.address.phone, + _orderDetail.receiveGoods.name + + _orderDetail.receiveGoods.phone, style: TextStyle(color: UIData.ff353535, fontSize: 13), ), Text( - "地址:" + _orderDetail.address.address, + "地址:" + _orderDetail.receiveGoods.address, style: TextStyle(color: UIData.ff999999, fontSize: 12), ), ], @@ -176,7 +216,7 @@ class OrderDetailPageState extends State { ); } - Card buildOrderInfo() { + Card buildOrderInfo(OrderDetail _orderDetail) { return Card( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -206,7 +246,9 @@ class OrderDetailPageState extends State { Padding( padding: EdgeInsets.fromLTRB(16.0, 15.0, 0, 15.0), child: Text( - "订单编号:" + _orderDetail.orderNumber, + "订单编号:" + _orderDetail.orderId == null + ? "名称不可为空" + : _orderDetail.orderId, style: TextStyle(color: Color(0xFF777777), fontSize: 12.0), )), Container( @@ -217,7 +259,9 @@ class OrderDetailPageState extends State { Padding( padding: EdgeInsets.fromLTRB(16.0, 15.0, 0, 15.0), child: Text( - "下单时间:" + _orderDetail.orderTime, + "下单时间:" + _orderDetail.createTime == null + ? "名称不可为空" + : _orderDetail.createTime, style: TextStyle(color: Color(0xFF777777), fontSize: 12.0), )), Container( @@ -230,7 +274,7 @@ class OrderDetailPageState extends State { ); } - Card buildPayInfo() { + Card buildPayInfo(OrderDetail _orderDetail) { return Card( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -238,7 +282,10 @@ class OrderDetailPageState extends State { Padding( padding: EdgeInsets.fromLTRB(16.0, 15.0, 0, 15.0), child: Text( - "支付方式:" + _orderDetail.payMode, + "支付方式:" + + (_orderDetail.payType == null + ? "名称不可为空" + : _orderDetail.payType), style: TextStyle(color: Color(0xFF777777), fontSize: 12.0), )), Container( @@ -249,7 +296,10 @@ class OrderDetailPageState extends State { Padding( padding: EdgeInsets.fromLTRB(16.0, 15.0, 0, 15.0), child: Text( - "商品合计:¥" + _orderDetail.productTotal.toStringAsFixed(2), + "商品合计:¥" + + (_orderDetail.orderPrice == null + ? "名称不可为空" + : _orderDetail.orderPrice), style: TextStyle(color: Color(0xFF777777), fontSize: 12.0), )), Container( @@ -260,7 +310,10 @@ class OrderDetailPageState extends State { Padding( padding: EdgeInsets.fromLTRB(16.0, 15.0, 0, 15.0), child: Text( - "运费:¥" + _orderDetail.freight.toStringAsFixed(2), + "运费:¥" + + (_orderDetail.freight == null + ? "名称不可为空" + : _orderDetail.freight), style: TextStyle(color: Color(0xFF777777), fontSize: 12.0), )), Container( @@ -271,7 +324,10 @@ class OrderDetailPageState extends State { Padding( padding: EdgeInsets.fromLTRB(16.0, 15.0, 0, 15.0), child: Text( - "实付款:¥" + _orderDetail.payPrice.toStringAsFixed(2), + "实付款:¥" + + (_orderDetail.payFee == null + ? "名称不可为空" + : _orderDetail.payFee), style: TextStyle(color: Color(0xFFFF2E2E), fontSize: 12.0), )), Container( @@ -312,13 +368,22 @@ class OrderDetailPageState extends State { )); } - Positioned buildBottomBar() { + Positioned buildBottomBar(OrderDetail _orderDetail) { + OrderItem orderItem = OrderItem(); + orderItem.status = _orderDetail.status; + orderItem.payPrice = _orderDetail.orderPrice; + orderItem.orderNumber = _orderDetail.orderId; + orderItem.products = _orderDetail.goods; return _orderDetail.status == 0 ? Positioned( bottom: 0, left: 0, right: 0, height: 0, + child: Container( + width: 0, + height: 0, + ), ) : Positioned( bottom: 0, @@ -332,105 +397,16 @@ class OrderDetailPageState extends State { Expanded( child: Container(), ), - Container( - margin: EdgeInsets.fromLTRB(0, 0, 10.0, 0), - child: Stack( - alignment: Alignment.center, - children: [ - Container( - alignment: Alignment.center, - width: 90.0, - height: 30.0, - decoration: BoxDecoration( - border: Border.all( - color: Color(0xFFEEEEEE), width: 1.0), - borderRadius: - new BorderRadius.all(new Radius.circular(15.0)), - ), - ), - InkWell( - child: new Container( - width: 90.0, - height: 30.0, - child: new Text( - _orderDetail.getStatusButtonName(), - style: TextStyle( - color: Color(0xFF353535), fontSize: 14), - ), - alignment: Alignment.center, - ), - //圆角大小,与BoxDecoration保持一致,更美观 - onTap: () {}, - ), - ], - ), - ), - !(_orderDetail.status == 2 || _orderDetail.status == 3) - ? Container( - height: 0, - ) - : Container( - margin: EdgeInsets.fromLTRB(0, 0, 10.0, 0), - child: Stack( - alignment: Alignment.center, - children: [ - Container( - alignment: Alignment.center, - width: 90.0, - height: 30.0, - decoration: BoxDecoration( - border: Border.all( - color: Color(0xFFFF2E2E), width: 15.0), - borderRadius: new BorderRadius.all( - new Radius.circular(15.0)), - ), - ), - InkWell( - child: new Container( - width: 90.0, - height: 30.0, - child: new Text( - _orderDetail.status == 2 ? "确认收货" : "评价", - style: TextStyle( - color: Colors.white, fontSize: 14), - ), - alignment: Alignment.center, - ), - //圆角大小,与BoxDecoration保持一致,更美观 - onTap: () { - }, - ), - ], - ), - ), + OrderActionWidget(orderItem, _orderDetail.status, () {}), ], ), ), ); } - - OrderDetail getOrderDetail() { - OrderDetail orderDetail = new OrderDetail(); - orderDetail.status = 2; - orderDetail.express = "离开【太原中心】,下一站【广州中心】"; - Address address = new Address(); - address.name = "王大锤"; - address.phone = "12345678901"; - address.address = "四川省成都市金牛区西雅图"; - orderDetail.address = address; - orderDetail.products = ProductViewModel().getOderDetailProducts(); - orderDetail.orderNumber = "2539129895"; - orderDetail.orderTime = "2018.12.22 09:32"; - orderDetail.payMode = "支付宝"; - orderDetail.productTotal = 195.00; - orderDetail.freight = 12.00; - orderDetail.payPrice = 165.00; - return orderDetail; - } } class ProductItem extends StatelessWidget { - final Product item; + final Good item; ProductItem({Key key, @required this.item}) : super(key: key); @@ -446,21 +422,17 @@ class ProductItem extends StatelessWidget { children: [ Container( margin: EdgeInsets.fromLTRB(0.0, 0.0, 10.0, 0.0), - width: 88.0, - height: 88.0, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8.0), - image: DecorationImage( - image: NetworkImage(item.image), fit: BoxFit.cover), - ), + child: UIData.getImageWithWH( + item.goodsImgUrl == null ? "名称不可为空" : item.goodsImgUrl, + 88, + 88), ), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - item.name, + item.goodsName == null ? "名称不可为空" : item.goodsName, style: TextStyle(color: Color(0xFF353535), fontSize: 12.0), ), @@ -475,7 +447,11 @@ class ProductItem extends StatelessWidget { borderRadius: BorderRadius.circular(3)), child: Center( child: UIData.getTextWidget( - "米白色, 36码", UIData.ff999999, 11), + item.specMsg == null + ? "名称不可为空" + : item.specMsg, + UIData.ff999999, + 11), )), ), Container( @@ -484,7 +460,9 @@ class ProductItem extends StatelessWidget { children: [ Expanded( child: Text( - item.price, + item.goodsPrice == null + ? "名称不可为空" + : item.goodsPrice, style: TextStyle( color: Color(0xFFFF2E2E), fontSize: 12.0), ), @@ -496,7 +474,10 @@ class ProductItem extends StatelessWidget { height: 20, child: Center( child: UIData.getTextWidget( - "x " + item.count.toString(), + "x " + + (item.buyNum == null + ? "名称不可为空" + : item.buyNum), UIData.ff999999, 11), ), @@ -520,7 +501,7 @@ class ProductItem extends StatelessWidget { ), onTap: () { Navigator.pushNamed(context, UIData.ShopDetailPage, - arguments: item.skuId); + arguments: item.goodsId); }, ); } diff --git a/flutter_lib/lib/ui/page/order/shop_order.dart b/flutter_lib/lib/ui/page/order/shop_order.dart index 5c7b905..3bbf709 100644 --- a/flutter_lib/lib/ui/page/order/shop_order.dart +++ b/flutter_lib/lib/ui/page/order/shop_order.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_lib/bridge/common_bridge.dart'; import 'package:flutter_lib/bridge/order_bridge.dart'; -import 'package:flutter_lib/bridge/pay_bridge.dart'; import 'package:flutter_lib/logic/bloc/address_bloc.dart'; import 'package:flutter_lib/logic/bloc/cart_bloc.dart'; import 'package:flutter_lib/model/Result.dart'; @@ -11,6 +10,9 @@ import 'package:flutter_lib/model/order_result.dart'; import 'package:flutter_lib/model/ordergoods.dart'; import 'package:flutter_lib/ui/page/address/add_edit_address.dart'; import 'package:flutter_lib/ui/page/address/address_list.dart'; +import 'package:flutter_lib/ui/widgets/common_dialogs.dart'; +import 'package:flutter_lib/ui/widgets/error_status_widget.dart'; +import 'package:flutter_lib/utils/BristuaRouter.dart'; import 'package:flutter_lib/utils/uidata.dart'; class ShopOrderListPage extends StatefulWidget { @@ -25,7 +27,7 @@ class _ShopOrderListState extends State { CartBloc cartBloc = CartBloc(); AddressBloc addressBloc = AddressBloc(); - String userAddressId = "123123"; + String userAddressId; @override Widget build(BuildContext context) { @@ -52,34 +54,31 @@ class _ShopOrderListState extends State { } Widget bodyData() { - cartBloc.findCart(); + print("立即下单即加入购物车,之后从购物车中读取出来"); + cartBloc.findOrderNow(); return StreamBuilder( stream: cartBloc.productItems, builder: (context, snapshot) { Cart cart = snapshot.data; - return snapshot.hasData - ? (cart == null ? empty() : buildBody(cart)) - : Center(child: CircularProgressIndicator()); + if (snapshot.hasError) { + Result result = snapshot.error; + return ErrorStatusWidget.order(result.code, result.msg, "点击重试", () { + cartBloc.findOrderNow(); + }); + } else if (snapshot.hasData) { + if (cart == null) { + return ErrorStatusWidget.order(0, "没有数据", "点击重试", () { + cartBloc.findOrderNow(); + }); + } else { + return buildBody(cart); + } + } else { + return Center(child: CircularProgressIndicator()); + } }); } - Widget empty() { - return Center( - child: Padding( - padding: const EdgeInsets.all(32.0), - child: GestureDetector( - child: Padding( - padding: const EdgeInsets.all(32.0), - child: Text("无数据,点击重试"), - ), - onTap: () { - cartBloc.findCart(); - }, - ), - ), - ); - } - Container buildBody(Cart cart) { return Container( child: Stack( @@ -161,8 +160,9 @@ class _ShopOrderListState extends State { List orderGoodses = cart.products .map( (sku) => new OrderGoods( - sku.goodsId, + sku.sku.productId, sku.sku.amount.toString(), + sku.goodsId, ), ) .toList(); @@ -170,20 +170,33 @@ class _ShopOrderListState extends State { var orders = orderGoodses.map((f) => (f.toJson())).toList(); - Future future = - OrderBridge.submitOrder(userAddressId, true, orders); - future.then((result) { - if (result.code == 200) { - if (result.data == null) { - Bridge.showLongToast("订单号获取失败"); - return; + if (userAddressId != null && userAddressId.isNotEmpty) { + Future future = OrderBridge.submitOrder( + userAddressId, true, orders); + future.then((result) { + if (result.code == 200) { + if (result.data == null) { + Bridge.showLongToast("订单号获取失败"); + return; + } + //清除订单的下单数据 + cartBloc.clearOrderNow(); + showPayDialog(context, cart.totalMoney, + OrderResult.fromJson(result.data).orderId, ""); + } else { + if (result.code == 401) { + BristuaRouter.routerUserLogin(context); + } else { + Bridge.showLongToast(result.msg); + } } - showPayDialog( - context, cart, OrderResult.fromJson(result.data)); - } else { - Bridge.showLongToast(result.msg); - } - }); + }); + } else { + Navigator.push( + context, + new MaterialPageRoute( + builder: (context) => new AddressListPage())); + } }), ), ], @@ -201,103 +214,6 @@ class _ShopOrderListState extends State { ); } - showPayDialog(BuildContext context, Cart cart, OrderResult orderResult) { - if (orderResult == null) { - Bridge.showLongToast("订单信息生成失败"); - return; - } - showModalBottomSheet( - context: context, - builder: (context) => Center( - child: Material( - borderRadius: BorderRadius.circular(8.0), - color: Colors.white, - elevation: 5.0, - child: Padding( - padding: const EdgeInsets.all(32.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Center( - child: Text("确认付款", - style: TextStyle( - color: UIData.ff33333, fontSize: 18))), - Divider(), - Padding( - padding: const EdgeInsets.fromLTRB(0, 46, 0, 0), - child: Text( - "¥" + cart.totalMoney.toStringAsFixed(2), - style: - TextStyle(color: UIData.ff353535, fontSize: 33), - ), - ), - Divider(), - Padding( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - mainAxisSize: MainAxisSize.max, - children: [ - Text( - "订单信息", - style: TextStyle( - color: UIData.ff666666, fontSize: 15), - ), - Text( - "商品组合", - style: - TextStyle(color: Colors.black, fontSize: 15), - ) - ], - ), - padding: EdgeInsets.fromLTRB(14, 14, 14, 14), - ), - Divider(), - Padding( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "付款方式", - style: TextStyle( - color: UIData.ff666666, fontSize: 15), - ), - Text( - "支付宝", - style: - TextStyle(color: Colors.black, fontSize: 15), - ) - ], - ), - padding: EdgeInsets.fromLTRB(14, 14, 14, 0), - ), - Divider(), - UIData.getShapeButton( - UIData.fffa4848, - UIData.fff, - 345, - 45, - "立即付款", - 18, - 5, - () { - //"1555746236014000", - //"商品描述", - goToPay( - context, - orderResult.orderId, - "123.12.12.123", - "商品组合", - "附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据"); - }, - ) - ], - ), - ), - ), - )); - } - GestureDetector buildListIItem(SkuWapper sku) { CartProduct cartProduct = sku.sku; String name = (cartProduct.name != null) ? cartProduct.name : ""; @@ -331,22 +247,24 @@ class _ShopOrderListState extends State { padding: EdgeInsets.fromLTRB(12, 18, 12, 8), child: Text(name, style: - TextStyle(fontSize: 12, color: UIData.ff353535)), - ), - Padding( - padding: EdgeInsets.fromLTRB(12, 0, 13, 0), - child: Container( - height: 18, - width: 92, - decoration: BoxDecoration( - color: UIData.fff7f7f7, - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(3)), - child: Center( - child: - UIData.getTextWidget(name, UIData.ff999999, 11), - )), + TextStyle(fontSize: 12, color: UIData.ff353535), + softWrap: false, + overflow: TextOverflow.ellipsis), ), +// Padding( +// padding: EdgeInsets.fromLTRB(12, 0, 13, 0), +// child: Container( +// height: 18, +// width: 92, +// decoration: BoxDecoration( +// color: UIData.fff7f7f7, +// shape: BoxShape.rectangle, +// borderRadius: BorderRadius.circular(3)), +// child: Center( +// child: +// UIData.getTextWidget(name, UIData.ff999999, 11), +// )), +// ), Padding( padding: EdgeInsets.fromLTRB(15, 6, 15, 17), child: Row( @@ -382,7 +300,7 @@ class _ShopOrderListState extends State { Padding( padding: EdgeInsets.fromLTRB(3, 0, 3, 0), child: UIData.getTextWidget( - cartProduct.amount.toString(), + "x " + cartProduct.amount.toString(), UIData.ff999999, 11), ), @@ -419,7 +337,7 @@ class _ShopOrderListState extends State { } Widget buildHeaderBody() { - addressBloc.getAddressList(); + addressBloc.getAddressList(context); return StreamBuilder>( stream: addressBloc.productItems, builder: (context, snapshot) { @@ -548,17 +466,4 @@ class _ShopOrderListState extends State { ), ); } - - goToPay(BuildContext context, String tradeOrderId, String spbillCreateIp, - String goodsDesc, String attach) async { - Future future = - PayBridge.wxPay(tradeOrderId, spbillCreateIp, goodsDesc, attach); - future.then((v) { - if (v.code == 200) { - Navigator.pop(context, false); - } else { - Bridge.showShortToast(v.msg); - } - }); - } } diff --git a/flutter_lib/lib/ui/page/shop/mine_collection.dart b/flutter_lib/lib/ui/page/shop/mine_collection.dart index 9e708aa..d4b7daa 100644 --- a/flutter_lib/lib/ui/page/shop/mine_collection.dart +++ b/flutter_lib/lib/ui/page/shop/mine_collection.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_lib/bridge/collection_bridge.dart'; import 'package:flutter_lib/logic/viewmodel/product_view_model.dart'; import 'package:flutter_lib/model/product.dart'; import 'package:flutter_lib/utils/uidata.dart'; @@ -21,6 +22,7 @@ class MineCollectionPageState extends State { @override Widget build(BuildContext context) { + CollectionBridge.allCollection(1, 2000); return new Scaffold( appBar: UIData.getCenterTitleAppBar("我的收藏", context), body: Container( diff --git a/flutter_lib/lib/ui/page/shop/search_shop_list.dart b/flutter_lib/lib/ui/page/shop/search_shop_list.dart index 897ef0e..1a82c92 100644 --- a/flutter_lib/lib/ui/page/shop/search_shop_list.dart +++ b/flutter_lib/lib/ui/page/shop/search_shop_list.dart @@ -1,12 +1,14 @@ import 'package:flutter/material.dart'; +import 'package:flutter_lib/bridge/common_bridge.dart'; import 'package:flutter_lib/logic/bloc/product_bloc.dart'; import 'package:flutter_lib/logic/viewmodel/tab_view_model.dart'; +import 'package:flutter_lib/model/Result.dart'; import 'package:flutter_lib/model/productitem.dart'; import 'package:flutter_lib/ui/page/shop/shop_detail.dart'; +import 'package:flutter_lib/ui/widgets/error_status_widget.dart'; import 'package:flutter_lib/ui/widgets/shop_tab_item.dart'; import 'package:flutter_lib/utils/uidata.dart'; - class SearchShopListPage extends StatefulWidget { @override SearchShopListState createState() => SearchShopListState(); @@ -41,33 +43,30 @@ class SearchShopListState extends State { builder: (context, snapshot) { if (showHistory) { if (chips.isEmpty) { - return empty(); + return Container( + width: 0, + height: 0, + ); } else { return buildWrapChips(); } } else { - return snapshot.hasData - ? productGrid(snapshot.data) - : Center(child: CircularProgressIndicator()); + if (snapshot.hasError) { + Result result = snapshot.error; + return ErrorStatusWidget.search(result.code, result.msg,null, null); + } else if (snapshot.hasData) { + if (snapshot.data == null || snapshot.data.isEmpty) { + return ErrorStatusWidget.search(0, "暂无搜索结果\n换个搜索词试试",null, null); + } else { + return productGrid(snapshot.data); + } + } else { + return Center(child: CircularProgressIndicator()); + } } }); } - Widget empty() { - return Center( - child: Padding( - padding: const EdgeInsets.all(32.0), - child: GestureDetector( - child: Padding( - padding: const EdgeInsets.all(32.0), - child: Text("热门搜索,可以补充任何东西?"), - ), - onTap: () {}, - ), - ), - ); - } - Column buildWrapChips() { return Column( children: [ @@ -113,8 +112,10 @@ class SearchShopListState extends State { onTap: () { setState(() { _searchQuery.text = chip; - chips.add(_searchQuery.text); - _doSearch(); + if(_searchQuery.text.isNotEmpty) { + chips.add(_searchQuery.text); + _doSearch(); + } }); }, ); @@ -127,60 +128,70 @@ class SearchShopListState extends State { Widget productGrid(List data) { return new Padding( - padding: EdgeInsets.all(5), + padding: EdgeInsets.all(10), child: new GridView.builder( itemCount: data.length, gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: (0.7), //item长宽比 - mainAxisSpacing: 5.0, - crossAxisSpacing: 5.0, // add some space + mainAxisSpacing: 10.0, + crossAxisSpacing: 10.0, ), itemBuilder: (BuildContext context, int index) { - ProductItem prodcutItem = data[index]; + ProductItem product = data[index]; + String imgUrl; + if (product.medias.isNotEmpty) { + imgUrl = product.medias[0].url; + } return new GestureDetector( child: new Card( elevation: 5.0, child: new Container( - alignment: Alignment.center, - child: new Column( - crossAxisAlignment: CrossAxisAlignment.stretch, + child: new Stack( children: [ - new Stack( - children: [ - UIData.getImage( - prodcutItem.medias[0].url, - ), - Positioned( - bottom: 0, - left: 0, - right: 0, - child: new Container( - color: Colors.white, - child: new Column( - children: [ - new Padding( - padding: EdgeInsets.fromLTRB(0, 12, 0, 6), - child: new Text( - prodcutItem.name, - style: TextStyle( - fontSize: 12, - color: UIData.ff353535), - ), - ), - new Padding( - padding: EdgeInsets.fromLTRB(0, 6, 0, 12), - child: new Text( - prodcutItem.price.toString(), - style: TextStyle( - color: Colors.red, fontSize: 16), - ), + Positioned( + top: 0, + left: 0, + child: UIData.getImage( + imgUrl, + ), + ), + Positioned( + bottom: 0, + left: 0, + right: 0, + child: new Container( + color: Colors.white, + child: new Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + new Padding( + padding: EdgeInsets.fromLTRB(5, 5, 5, 4), + child: Container( + width: 140, + child: new Text( + product.name, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 12, color: UIData.ff353535), ), - ], + ), ), - )), - ], - ), + new Padding( + padding: EdgeInsets.fromLTRB(5, 4, 5, 4), + child: new Text( + "¥" + product.price.toString(), + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: Colors.red, fontSize: 16), + ), + ), + ], + ), + )), ], ), ), @@ -189,8 +200,7 @@ class SearchShopListState extends State { Navigator.push( context, new MaterialPageRoute( - builder: (context) => - new ShopDetailPage(prodcutItem.id))); + builder: (context) => new ShopDetailPage(product.id))); }, ); }), @@ -237,70 +247,76 @@ class SearchShopListState extends State { ), ), onTap: () { - chips.add(_searchQuery.text); - _doSearch(); + if (_searchQuery.text.isNotEmpty) { + chips.add(_searchQuery.text); + _doSearch(); + } else { + Bridge.showShortToast("请输入搜索内容"); + } }, ); } Widget buildTextField() { - return Center( - child: Stack( - children: [ - Center( - child: Container( - alignment: Alignment.center, - height: 30.0, - decoration: BoxDecoration( - border: Border.all(color: Color(0xFFF5F5F5), width: 15.0), - borderRadius: new BorderRadius.all(new Radius.circular(15.0)), - ), + return Stack( + children: [ + Center( + child: Container( + decoration: BoxDecoration( + color: Color(0xFFF5F5F5), + border: Border.all(color: Color(0xFFF5F5F5), width: 1), + borderRadius: BorderRadius.circular(13.0), ), - ), - Center( - child: Padding( - padding: const EdgeInsets.fromLTRB(10, 0, 0, 0), - child: TextField( - maxLines: 1, - controller: _searchQuery, - cursorColor: Colors.transparent, - style: new TextStyle(color: UIData.ff353535, fontSize: 12), - decoration: new InputDecoration( - focusedBorder: null, - errorBorder: null, - disabledBorder: null, - focusedErrorBorder: null, - border: null, - fillColor: Color(0xfff5f5f5), - suffixIcon: new IconButton( - color: UIData.ffcccccc, - icon: Icon(Icons.close), - onPressed: () { - _searchQuery.clear(); - }, - ), - hintText: "请输入搜索内容", - hintStyle: new TextStyle(color: UIData.ffcccccc)), + height: 30.0, + child: new TextField( + controller: _searchQuery, + cursorColor: Colors.transparent, + cursorWidth: 0, + decoration: new InputDecoration( + focusedBorder: UnderlineInputBorder( + borderSide: + BorderSide(color: Colors.transparent, width: 0)), + hintText: "请输入搜索内容", + fillColor: Colors.transparent, + contentPadding: EdgeInsets.fromLTRB(10, 0, 0, 0), + hintStyle: new TextStyle(color: UIData.ffcccccc, fontSize: 12), ), + maxLines: 1, + textAlign: TextAlign.left, ), - ) - ], - ), + alignment: Alignment.centerLeft, + ), + ), + Positioned( + top: 0, + bottom: 0, + right: 1, + child: new IconButton( + color: UIData.ffcccccc, + icon: Icon(Icons.close), + onPressed: () { + _searchQuery.clear(); + }, + ), + ), + ], ); } void _doSearch() { - if (_searchQuery.text.isEmpty) { + if (_searchQuery.text.isEmpty && chips.isNotEmpty) { setState(() { showHistory = true; print("showHistory:" + showHistory.toString()); }); } else { - productBloc.queryProducts(_searchQuery.text, true); - setState(() { - showHistory = false; - print("showHistory:" + showHistory.toString()); - }); + if(_searchQuery.text.isNotEmpty) { + productBloc.queryProducts(_searchQuery.text, 1); + setState(() { + showHistory = false; + print("showHistory:" + showHistory.toString()); + }); + } } } } diff --git a/flutter_lib/lib/ui/page/shop/shop_cart_list.dart b/flutter_lib/lib/ui/page/shop/shop_cart_list.dart index ba8ab22..4436718 100644 --- a/flutter_lib/lib/ui/page/shop/shop_cart_list.dart +++ b/flutter_lib/lib/ui/page/shop/shop_cart_list.dart @@ -1,8 +1,13 @@ +import 'dart:convert'; + import 'package:flutter/material.dart'; +import 'package:flutter_lib/bridge/cart_bridge.dart'; import 'package:flutter_lib/bridge/common_bridge.dart'; import 'package:flutter_lib/logic/bloc/cart_bloc.dart'; +import 'package:flutter_lib/model/Result.dart'; import 'package:flutter_lib/model/cart.dart'; import 'package:flutter_lib/ui/page/order/shop_order.dart'; +import 'package:flutter_lib/ui/widgets/error_status_widget.dart'; import 'package:flutter_lib/utils/uidata.dart'; class ShopCartListPage extends StatefulWidget { @@ -53,36 +58,36 @@ class _ShopCartListState extends State { stream: cartBloc.productItems, builder: (context, snapshot) { Cart cart = snapshot.data; - return snapshot.hasData - ? ((cart == null || - cart.products == null || - cart.products.isEmpty || - cart.totalCounts == 0) - ? empty() - : buildBody(cart)) - : Center(child: CircularProgressIndicator()); - }); - } - - Widget empty() { - return Center( - child: Padding( - padding: const EdgeInsets.all(32.0), - child: GestureDetector( - child: Padding( - padding: const EdgeInsets.all(32.0), - child: Text(widget.showBackBtn ? "快去添加商品" : "可前往首页选购商品"), - ), - onTap: () { - if (widget.showBackBtn) { - Navigator.pop(context, true); + if (snapshot.hasData) { + if ((cart == null || + cart.products == null || + cart.products.isEmpty || + cart.totalCounts == 0)) { + return ErrorStatusWidget.cart(0, "暂无购物记录~", "立即购物", () { + if (widget.showBackBtn) { + Navigator.pop(context, true); + } else { + Navigator.pushNamed(context, UIData.ShopCategoryList, + arguments: "全部分类"); + } + }); } else { - cartBloc.findCart(); + return buildBody(cart); } - }, - ), - ), - ); + } else if (snapshot.hasError) { + Result result = snapshot.error; + return ErrorStatusWidget.cart(result.code, result.msg, "立即购物", () { + if (widget.showBackBtn) { + Navigator.pop(context, true); + } else { + Navigator.pushNamed(context, UIData.ShopCategoryList, + arguments: "全部分类"); + } + }); + } else { + return Center(child: CircularProgressIndicator()); + } + }); } String userAddressId = "12"; @@ -142,10 +147,12 @@ class _ShopCartListState extends State { Bridge.showShortToast("请至少选择一个商品"); return; } - Navigator.push( - context, - new MaterialPageRoute( - builder: (context) => new ShopOrderListPage())); + //此处需要将cart数据同步到底层 + synchorizedCartList(cart); +// Navigator.push( +// context, +// new MaterialPageRoute( +// builder: (context) => new ShopOrderListPage())); }), ), ], @@ -175,6 +182,8 @@ class _ShopCartListState extends State { ? products[index].sku.price.toStringAsFixed(2) : "0.00"); + String skuInfo = + products[index].sku.norms == null ? "" : products[index].sku.norms; return GestureDetector( child: Container( child: Card( @@ -184,7 +193,7 @@ class _ShopCartListState extends State { Padding( padding: EdgeInsets.fromLTRB(14, 0, 12, 0), child: UIData.getImageWithWHFit( - products[index].sku.img, BoxFit.cover, 88, 88), + products[index].sku.img, BoxFit.cover, 44, 44), ), Expanded( child: Column( @@ -198,20 +207,25 @@ class _ShopCartListState extends State { style: TextStyle( fontSize: 12, color: UIData.ff353535)), ), - Padding( - padding: EdgeInsets.fromLTRB(12, 0, 13, 0), - child: Container( - height: 18, - width: 92, - decoration: BoxDecoration( - color: UIData.fff7f7f7, - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(3)), - child: Center( - child: UIData.getTextWidget( - name, UIData.ff999999, 11), - )), - ), + skuInfo.isEmpty + ? Container( + width: 0, + height: 0, + ) + : Padding( + padding: EdgeInsets.fromLTRB(12, 0, 13, 0), + child: Container( + height: 18, + width: 92, + decoration: BoxDecoration( + color: UIData.fff7f7f7, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(3)), + child: Center( + child: UIData.getTextWidget( + skuInfo, UIData.ff999999, 11), + )), + ), Padding( padding: EdgeInsets.fromLTRB(15, 6, 15, 17), child: Row( @@ -220,10 +234,15 @@ class _ShopCartListState extends State { crossAxisAlignment: CrossAxisAlignment.end, children: [ Expanded( - child: Text( - price, - style: TextStyle( - color: UIData.fffa4848, fontSize: 15), + child: Container( + width: 80, + child: Text( + price, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: UIData.fffa4848, fontSize: 12), + ), ), ), GestureDetector( @@ -297,4 +316,21 @@ class _ShopCartListState extends State { }, ); } + + /* + * 立即下单列表 + */ + void synchorizedCartList(Cart cart) { + Future future = CartBridge.syschrizonCart(json.encode(cart)); + future.then((result) { + if (result.code == 200) { + Navigator.push( + context, + new MaterialPageRoute( + builder: (context) => new ShopOrderListPage())); + } else { + Bridge.showLongToast(result.msg); + } + }); + } } diff --git a/flutter_lib/lib/ui/page/shop/shop_category_list.dart b/flutter_lib/lib/ui/page/shop/shop_category_list.dart index bbed365..67801fb 100644 --- a/flutter_lib/lib/ui/page/shop/shop_category_list.dart +++ b/flutter_lib/lib/ui/page/shop/shop_category_list.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_lib/logic/bloc/category_bloc.dart'; -import 'package:flutter_lib/logic/inherited/category_provider.dart'; +import 'package:flutter_lib/model/Result.dart'; import 'package:flutter_lib/model/category.dart'; -import 'package:flutter_lib/ui/page/shop/shop_list.dart'; +import 'package:flutter_lib/ui/inherited/category_provider.dart'; +import 'package:flutter_lib/ui/widgets/error_status_widget.dart'; import 'package:flutter_lib/utils/uidata.dart'; - class ShopCategoryListPage extends StatefulWidget { ShopCategoryListPage({Key key, this.title, this.showBackBtn}) : super(key: key); @@ -18,12 +18,12 @@ class ShopCategoryListPage extends StatefulWidget { class ShopCategoryListState extends State { Widget appBarTitle; - CategoryBloc categoryBloc = new CategoryBloc(); + CategoryBloc categoryBloc; @override void initState() { super.initState(); - + categoryBloc = new CategoryBloc(); } @override @@ -34,7 +34,6 @@ class ShopCategoryListState extends State { @override Widget build(BuildContext context) { - print("ShopCategoryListPage build"); return DefaultTabController( @@ -61,14 +60,28 @@ class ShopCategoryListState extends State { Widget bodyData() { print("shop category build"); - return CategoryProvider( + return CategoryProvider( categoryBloc: categoryBloc, child: StreamBuilder>( stream: categoryBloc.categoryItems, builder: (context, snapshot) { - return snapshot.hasData - ? (snapshot.data.isEmpty ? empty() : body(snapshot.data)) - : Center(child: CircularProgressIndicator()); + if (snapshot.hasError) { + Result result = snapshot.error; + return ErrorStatusWidget.order( + result.code, result.msg, "点击重试", () { + categoryBloc.getCategories(); + }); + } else if (snapshot.hasData) { + if (snapshot.data.isNotEmpty) { + return body(snapshot.data); + } else { + return ErrorStatusWidget.order(0, "暂无数据", "点击重试", () { + categoryBloc.getCategories(); + }); + } + } else { + return Center(child: CircularProgressIndicator()); + } }), ); } @@ -76,20 +89,6 @@ class ShopCategoryListState extends State { int selectIndex = 0; int categoryId = 0; - Widget empty() { - return Center( - child: GestureDetector( - child: Padding( - padding: const EdgeInsets.all(32.0), - child: Text("无数据,点击重试"), - ), - onTap: () { - categoryBloc.getCategories(); - }, - ), - ); - } - Widget body(List categories) { categoryId = categories[selectIndex].id; categoryBloc.getSubCategories(categoryId); @@ -170,86 +169,75 @@ class ShopCategoryListState extends State { child: StreamBuilder>( stream: categoryBloc.suCategoryItems, builder: (context, snapshot) { - return snapshot.hasData - ? (snapshot.data.isEmpty - ? emptySub() - : sliverGrid(snapshot.data)) - : SliverList( - delegate: SliverChildListDelegate( - [ - Center(child: CircularProgressIndicator()), - ], - ), - ); + if (snapshot.hasData) { + if (snapshot.data.isEmpty) { + return ErrorStatusWidget.order(0, "暂无数据", "点击重试", () { + categoryBloc.getCategories(); + }); + } else { + return sliverGrid(snapshot.data); + } + } else if (snapshot.hasError) { + Result result = snapshot.error; + return ErrorStatusWidget.order(result.code, result.msg, "点击重试", () { + categoryBloc.getCategories(); + }); + } else { + return SliverList( + delegate: SliverChildListDelegate( + [ + Center(child: CircularProgressIndicator()), + ], + ), + ); + } })); } - Widget emptySub() { - return SliverList( - delegate: SliverChildListDelegate( - [ - Center( - child: GestureDetector( - child: Padding( - padding: const EdgeInsets.all(32.0), - child: Text("无子分类数据,点击重试"), - ), - onTap: () { - categoryBloc.getSubCategories(categoryId); - }, - ), - ), - ], - ), - ); - } - SliverGrid sliverGrid(List data) { return SliverGrid( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3, crossAxisSpacing: 8.0, mainAxisSpacing: 8.0, - childAspectRatio: 0.66, + childAspectRatio: 0.7, ), delegate: SliverChildBuilderDelegate( (BuildContext context, int index) { return new GestureDetector( - child: new Container( - alignment: Alignment.center, - child: new Column( - children: [ - new Stack( - children: [ - UIData.getImage(data[index].image), - Positioned( - bottom: 0, - left: 0, - right: 0, - child: new Container( - color: Colors.white, - child: new Column( - children: [ - new Padding( - padding: EdgeInsets.fromLTRB(0, 12, 0, 6), - child: new Text( - data[index].name, - style: TextStyle( - fontSize: 11, color: UIData.ff353535), - maxLines: 1, - ), - ), - ], - ), - )), - ], - ), - ], - ), + child: new Stack( + children: [ + Positioned( + top: 0, + left: 0, + right: 0, + child: UIData.getImageWithWHFit( + data[index].image, BoxFit.contain, 90, 90), + ), + Positioned( + bottom: 0, + left: 0, + right: 0, + child: new Container( + alignment: Alignment.center, + color: Colors.white, + child: new Padding( + padding: EdgeInsets.fromLTRB(0, 12, 0, 6), + child: new Text( + data[index].name, + textAlign: TextAlign.center, + style: + TextStyle(fontSize: 11, color: UIData.ff353535), + maxLines: 1, + ), + ), + )), + ], ), onTap: () { print(data[index].toString()); - Navigator.pushNamed(context, UIData.ShopListPage,arguments:data[index]); + Navigator.pushNamed(context, UIData.ShopListPage, + arguments: data[index]); }, ); }, diff --git a/flutter_lib/lib/ui/page/shop/shop_detail.dart b/flutter_lib/lib/ui/page/shop/shop_detail.dart index d55651f..9d4b76a 100644 --- a/flutter_lib/lib/ui/page/shop/shop_detail.dart +++ b/flutter_lib/lib/ui/page/shop/shop_detail.dart @@ -5,18 +5,19 @@ import 'package:flutter_lib/bridge/cart_bridge.dart'; import 'package:flutter_lib/bridge/common_bridge.dart'; import 'package:flutter_lib/bridge/sku_bridge.dart'; import 'package:flutter_lib/logic/bloc/product_bloc.dart'; -import 'package:flutter_lib/logic/inherited/product_provider.dart'; import 'package:flutter_lib/logic/viewmodel/comment_view_model.dart'; import 'package:flutter_lib/model/Result.dart'; -import 'package:flutter_lib/model/productdetail.dart'; -import 'package:flutter_lib/model/skuresult.dart'; import 'package:flutter_lib/model/cart.dart'; import 'package:flutter_lib/model/comment.dart'; -import 'package:flutter_lib/model/productitem.dart'; +import 'package:flutter_lib/model/productdetail.dart'; import 'package:flutter_lib/model/skuinfo.dart'; +import 'package:flutter_lib/model/skuresult.dart'; +import 'package:flutter_lib/ui/inherited/product_provider.dart'; import 'package:flutter_lib/ui/page/order/shop_order.dart'; +import 'package:flutter_lib/ui/widgets/error_status_widget.dart'; import 'package:flutter_lib/ui/widgets/rating_bar.dart'; import 'package:flutter_lib/utils/uidata.dart'; +import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; class ShopDetailPage extends StatefulWidget { int productId; @@ -42,6 +43,7 @@ class ShopDetailPageState extends State { int chooseCount = 1; String chooseCountStr = "1"; int cartCount = 0; + String productName = ""; ShopDetailPageState(int productId) { this.productId = productId; @@ -50,34 +52,64 @@ class ShopDetailPageState extends State { @override void initState() { super.initState(); + productBloc = ProductBloc(); + productBloc.getProduct(productId); } @override void dispose() { -// productBloc.close(); + productBloc.close(); super.dispose(); } @override Widget build(BuildContext context) { print("ShopDetailPage build"); - productBloc = ProductBloc(); return ProductProvider( productBloc: productBloc, child: new Scaffold( - appBar: UIData.getCenterTitleAppBar("商品名称", context), + appBar: AppBar( + centerTitle: true, + title: StreamBuilder( + stream: productBloc.productDetail, + builder: (context, snapshot) { + if (snapshot.hasData) { + if (snapshot.data != null && + snapshot.data.name.isNotEmpty) { + productName = snapshot.data.name; + return Text(productName); + } + } else { + return Text(productName); + } + }), + leading: new IconButton( + icon: UIData.back, + onPressed: () => Navigator.pop(context, false), + ), + ), body: bodyData(), )); } Widget bodyData() { - productBloc.getProduct(productId); return StreamBuilder( stream: productBloc.productDetail, builder: (context, snapshot) { if (snapshot.hasData) { print("getProduct hasdata"); - return buidBody(snapshot.data); + if (snapshot.data != null && snapshot.data.name.isNotEmpty) { + return buidBody(snapshot.data); + } else { + return ErrorStatusWidget.order(0, "数据异常", "点击重试", () { + productBloc.getProduct(productId); + }); + } + } else if (snapshot.hasError) { + Result result = snapshot.error; + return ErrorStatusWidget.order(result.code, result.msg, "点击重试", () { + productBloc.getProduct(productId); + }); } else { return Center(child: CircularProgressIndicator()); } @@ -85,7 +117,6 @@ class ShopDetailPageState extends State { } Container buidBody(ProductDetail product) { - productBloc.getProductSkuInfo(productId); return Container( child: Stack( @@ -102,16 +133,20 @@ class ShopDetailPageState extends State { flex: 1, child: Stack( children: [ - Center( - child: IconButton( - icon: Icon( - Icons.shopping_cart, - color: Colors.black, - ), - onPressed: () { - Navigator.pushNamed( - context, UIData.ShopCartListPage); - })), + Container( + margin: const EdgeInsets.fromLTRB(10, 0, 5, 0), + child: Center( + child: IconButton( + icon: Image.asset( + 'images/icon_shop_car.png', + width: 22.0, + height: 22.0, + ), + onPressed: () { + Navigator.pushNamed( + context, UIData.ShopCartListPage); + })), + ), Positioned( right: 8, top: 8, @@ -130,17 +165,34 @@ class ShopDetailPageState extends State { ), Expanded( flex: 1, - child: IconButton( - icon: Icon(Icons.star, color: Colors.black), - onPressed: () {}, + child: Container( + margin: const EdgeInsets.fromLTRB(5, 0, 10, 0), + child: IconButton( + icon: Image.asset( + 'images/icon_collection.png', + width: 22.0, + height: 22.0, + ), + onPressed: () { + Navigator.pushNamed(context, UIData.MineCollectionPage); + }, + ), ), ), UIData.getShapeButton( - UIData.fffa4848, UIData.fff, 125, 50, "加入购物车", 16, 0, () { + UIData.fffa4848, UIData.fff, 100, 50, "加入购物车", 16, 0, () { + if (skuInfo == null) { + print("执行加入购物车"); + addCart(product, product.skuId.toString()); + return; + } getSkuResult(product); }), UIData.getShapeButton( - UIData.ffffa517, UIData.fff, 110, 50, "立即购买", 16, 0, () { + UIData.ffffa517, UIData.fff, 95, 50, "立即购买", 16, 0, () { + if (skuInfo == null) { + addOrderCart(product, product.skuId.toString()); + } Navigator.push( context, new MaterialPageRoute( @@ -162,6 +214,12 @@ class ShopDetailPageState extends State { } CustomScrollView buildCustomScrollView(ProductDetail product) { + String img = ""; + if (product != null && + product.medias != null && + product.medias.isNotEmpty) { + img = product.medias[0].url; + } return CustomScrollView( slivers: [ SliverList( @@ -192,16 +250,24 @@ class ShopDetailPageState extends State { delegate: SliverChildListDelegate( [ Container( - color: UIData.fff, - child: Padding( - padding: EdgeInsets.fromLTRB(15, 17, 15, 12), - child: Text( - "商品详情", - style: TextStyle(color: UIData.ff353535, fontSize: 15), - ), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(5.0), + bottomRight: Radius.circular(5.0)), ), ), - UIData.getImage(product.medias[0].url), + (product.description == null || product.description.isEmpty) + ? Container( + width: 0, + height: 0, + ) + : Container( + child: HtmlWidget( + product.description, + webView: true, + ), + ), ], ), ), @@ -213,16 +279,26 @@ class ShopDetailPageState extends State { return StreamBuilder( stream: productBloc.skuInfo, builder: (context, snapshot) { - if(snapshot.hasData){ - print("getProduct sku hasdata"); + if (snapshot.hasData) { return buildVipInfo(product, snapshot.data); - }else{ + } else if (snapshot.hasError) { + Result result = snapshot.error; + return ErrorStatusWidget.order(result.code, result.msg, "点击重试", () { + productBloc.getProductSkuInfo(productId); + }); + } else { return Center(child: CircularProgressIndicator()); } }); } Padding buildHeader(ProductDetail product) { + String img = ""; + if (product != null && + product.medias != null && + product.medias.isNotEmpty) { + img = product.medias[0].url; + } return Padding( padding: EdgeInsets.fromLTRB(0, 0, 0, 10), child: new Container( @@ -230,7 +306,15 @@ class ShopDetailPageState extends State { child: new Center( child: new Column( children: [ - UIData.getImage(product.medias[0].url), + Container( + child: UIData.getImage(img), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(5.0), + bottomRight: Radius.circular(5.0)), + ), + ), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, @@ -273,7 +357,10 @@ class ShopDetailPageState extends State { ), Expanded( child: GestureDetector( - onTap: () {}, + onTap: () { + Navigator.pushNamed( + context, UIData.IviteFriendsPage); + }, child: Container( width: 115, height: 20, @@ -295,14 +382,14 @@ class ShopDetailPageState extends State { Padding( padding: EdgeInsets.fromLTRB(15, 6, 15, 6), child: Text( - product.name, + product.name == null ? "" : product.name, style: TextStyle(color: UIData.ff353535, fontSize: 16), ), ), Padding( padding: EdgeInsets.fromLTRB(15, 6, 15, 15), child: Text( - product.detail, + product.metaTitle == null ? "" : product.metaTitle, style: TextStyle(color: UIData.ff999999, fontSize: 12), ), ), @@ -447,16 +534,21 @@ class ShopDetailPageState extends State { } Padding buildVipInfo(ProductDetail product, SkuInfo data) { - this.skuInfo = data; + print(data.toString()); String skuInfoSelect = ""; - for (int i = 0; i < this.skuInfo.options.length; i++) { - var o = this.skuInfo.options[i]; - List vs = this.skuInfo.options[i].values; - for (int j = 0; j < vs.length; j++) { - var v = vs[j]; - if (j == 0) { - widget.mapForUI[o.key] = v; - skuInfoSelect = skuInfoSelect + " " + o.key + ":" + v.name; + if (skuInfo != null && + skuInfo.options != null && + skuInfo.options.isNotEmpty) { + this.skuInfo = data; + for (int i = 0; i < this.skuInfo.options.length; i++) { + var o = this.skuInfo.options[i]; + List vs = this.skuInfo.options[i].values; + for (int j = 0; j < vs.length; j++) { + var v = vs[j]; + if (j == 0) { + widget.mapForUI[o.key] = v; + skuInfoSelect = skuInfoSelect + " " + o.key + ":" + v.name; + } } } } @@ -469,45 +561,58 @@ class ShopDetailPageState extends State { child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: EdgeInsets.all(15), - child: GestureDetector( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - widget.skuInfoSelect + " 数量:" + chooseCount.toString(), - style: TextStyle(color: UIData.ff353535, fontSize: 15), + widget.skuInfoSelect.isEmpty + ? Container( + width: 0, + height: 0, + ) + : Padding( + padding: EdgeInsets.all(15), + child: GestureDetector( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + widget.skuInfoSelect + + " 数量:" + + chooseCount.toString(), + style: + TextStyle(color: UIData.ff353535, fontSize: 15), + ), + Icon(Icons.arrow_forward_ios), + ], + ), + onTap: () { + if (skuInfo == null) { + getSkuResult(product); + return; + } + showChooseDialog(product); + }, ), - Icon(Icons.arrow_forward_ios), - ], - ), - onTap: () { - if (skuInfo == null) { - getSkuResult(product); - return; - } - showChooseDialog(product); - }, - ), - ), - Padding( - padding: EdgeInsets.fromLTRB(15, 0, 15, 0), - child: Divider(), - ), - Padding( - padding: EdgeInsets.all(15), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "在线支付运费0元", - style: TextStyle(color: UIData.ff353535, fontSize: 15), ), - Icon(Icons.arrow_forward_ios), - ], - ), - ), + widget.skuInfoSelect.isEmpty + ? Container( + width: 0, + height: 0, + ) + : Padding( + padding: EdgeInsets.fromLTRB(15, 0, 15, 0), + child: Divider(), + ), +// Padding( +// padding: EdgeInsets.all(15), +// child: Row( +// mainAxisAlignment: MainAxisAlignment.spaceBetween, +// children: [ +// Text( +// "在线支付运费0元", +// style: TextStyle(color: UIData.ff353535, fontSize: 15), +// ), +// Icon(Icons.arrow_forward_ios), +// ], +// ), +// ), ], ), ), @@ -554,10 +659,13 @@ class ShopDetailPageState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.min, children: [ - UIData.getImageWithWH( - product.medias[0].url, - 90, - 90, + Padding( + padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), + child: UIData.getImageWithWH( + product.medias[0].url, + 90, + 90, + ), ), Expanded( child: Column( @@ -605,6 +713,10 @@ class ShopDetailPageState extends State { 18, 5, () { + if (skuInfo == null) { + addCart(product, product.skuId.toString()); + return; + } getSkuResult(product); }, ), @@ -652,6 +764,7 @@ class ShopDetailPageState extends State { ).toList(), ); } + // // void getSkuList(int productId) { // Future skuFuture = SkuBridge.findGoodsSku(productId.toString()); @@ -685,21 +798,23 @@ class ShopDetailPageState extends State { print(int64list); Future skuFuture = SkuBridge.findGoodsSkuInfo(productId.toString(), int64list); - skuFuture.then((result) { if (result.code == 200) { SkuResult skuResult = SkuResult.fromJson(result.data); addCart(product, skuResult.id.toString()); } else { - Bridge.showLongToast(result.msg); + print("获取sku 加入购物车"); +// Bridge.showLongToast(result.msg); + addCart(product, product.skuId.toString()); } }); } else { - addCart(product, product.id.toString()); + addCart(product, product.skuId.toString()); } } void addCart(ProductDetail product, String skuId) { + print("skuId:=" + skuId); Future future = CartBridge.addSku( productId, product.id.toString(), @@ -708,7 +823,7 @@ class ShopDetailPageState extends State { 0, "规格", product.name, - product.medias[0].url); + product.medias.length == 0 ? "" : product.medias[0].url); future.then((result) { if (result.code == 200) { Cart categoryList = Cart.fromJson(result.data); @@ -721,4 +836,31 @@ class ShopDetailPageState extends State { } }); } + + /* + * 立即下单列表 + */ + void addOrderCart(ProductDetail product, String skuId) { + print("skuId:=" + skuId); + Future future = CartBridge.addSkuOrder( + productId, + product.id.toString(), + chooseCount, + product.retailPrice, + 0, + "规格", + product.name, + product.medias.length == 0 ? "" : product.medias[0].url); + future.then((result) { + if (result.code == 200) { +// Cart categoryList = Cart.fromJson(result.data); +// setState(() { +// print("setState" + categoryList.totalCounts.toString()); +// cartCount = categoryList.totalCounts; +// }); + } else { + Bridge.showLongToast(result.msg); + } + }); + } } diff --git a/flutter_lib/lib/ui/page/shop/shop_list.dart b/flutter_lib/lib/ui/page/shop/shop_list.dart index b0d1dd5..9775418 100644 --- a/flutter_lib/lib/ui/page/shop/shop_list.dart +++ b/flutter_lib/lib/ui/page/shop/shop_list.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_lib/logic/bloc/product_bloc.dart'; -import 'package:flutter_lib/model/product.dart'; +import 'package:flutter_lib/model/Result.dart'; import 'package:flutter_lib/model/productitem.dart'; import 'package:flutter_lib/ui/page/shop/shop_detail.dart'; +import 'package:flutter_lib/ui/widgets/error_status_widget.dart'; import 'package:flutter_lib/ui/widgets/shop_tab_item.dart'; import 'package:flutter_lib/utils/uidata.dart'; - //分页参考https://medium.com/saugo360/flutter-creating-a-listview-that-loads-one-page-at-a-time-c5c91b6fabd3 class ShopListPage extends StatefulWidget { ShopListPage({Key key, this.title, this.categoryId}) : super(key: key); @@ -48,88 +48,98 @@ class ShopListState extends State { } Widget bodyData() { - productBloc.getProducts(widget.categoryId, true); + productBloc.getProducts(widget.categoryId, 1); return StreamBuilder>( stream: productBloc.productItems, builder: (context, snapshot) { - return snapshot.hasData - ? (snapshot.data.isEmpty ? empty() : productGrid(snapshot.data)) - : Center(child: CircularProgressIndicator()); + if (snapshot.hasData) { + if (snapshot.data.isEmpty) { + return ErrorStatusWidget.order(0, "暂无数据", "点击重试", () { + productBloc.getProducts(widget.categoryId, 1); + }); + } else { + return productGrid(snapshot.data); + } + } else if (snapshot.hasError) { + Result result = snapshot.error; + return ErrorStatusWidget.order(result.code, result.msg, "点击重试", + () { + productBloc.getProducts(widget.categoryId, 1); + }); + } else { + return Center(child: CircularProgressIndicator()); + } }); } - Widget empty() { - return Center( - child: Padding( - padding: const EdgeInsets.all(32.0), - child: GestureDetector( - child: Padding( - padding: const EdgeInsets.all(32.0), - child: Text("无数据,点击重试"), - ), - onTap: () { - productBloc.getProducts(widget.categoryId, true); - }, - ), - ), - ); - } - Widget productGrid(List data) { return new Padding( - padding: EdgeInsets.all(5), + padding: EdgeInsets.all(10), child: new GridView.builder( itemCount: data.length, gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: (0.7), //item长宽比 - mainAxisSpacing: 5.0, - crossAxisSpacing: 5.0, // add some space + mainAxisSpacing: 10.0, + crossAxisSpacing: 10.0, ), itemBuilder: (BuildContext context, int index) { - ProductItem productItem = data[index]; + ProductItem product = data[index]; + String imgUrl; + if (product.medias.isNotEmpty) { + imgUrl = product.medias[0].url; + } return new GestureDetector( child: new Card( elevation: 5.0, child: new Container( - alignment: Alignment.center, - child: new Column( + child: new Stack( children: [ - new Stack( - children: [ - UIData.getImage( - productItem.medias[0].url, - ), - Positioned( - bottom: 0, - left: 0, - right: 0, - child: new Container( - color: Colors.white, - child: new Column( - children: [ - new Padding( - padding: EdgeInsets.fromLTRB(0, 12, 0, 6), - child: new Text( - data[index].name, - style: TextStyle( - fontSize: 12, - color: UIData.ff353535), - ), - ), - new Padding( - padding: EdgeInsets.fromLTRB(0, 6, 0, 12), - child: new Text( - productItem.price.toString(), - style: TextStyle( - color: Colors.red, fontSize: 16), - ), + Positioned( + top: 0, + left: 0, + right: 0, + child: UIData.getImage( + imgUrl, + ), + ), + Positioned( + bottom: 0, + left: 0, + right: 0, + child: new Container( + width: 140, + color: Colors.white, + child: new Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + new Padding( + padding: EdgeInsets.fromLTRB(5, 5, 5, 4), + child: Container( + width: 140, + child: new Text( + product.name, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 12, color: UIData.ff353535), ), - ], + ), ), - )), - ], - ), + new Padding( + padding: EdgeInsets.fromLTRB(5, 4, 5, 4), + child: new Text( + "¥" + product.price.toString(), + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: Colors.red, fontSize: 16), + ), + ), + ], + ), + )), ], ), ), @@ -138,8 +148,7 @@ class ShopListState extends State { Navigator.push( context, new MaterialPageRoute( - builder: (context) => - new ShopDetailPage(productItem.id))); + builder: (context) => new ShopDetailPage(product.id))); }, ); }), diff --git a/flutter_lib/lib/ui/widgets/banner/banner_widget.dart b/flutter_lib/lib/ui/widgets/banner/banner_widget.dart index 31271d0..274e06a 100644 --- a/flutter_lib/lib/ui/widgets/banner/banner_widget.dart +++ b/flutter_lib/lib/ui/widgets/banner/banner_widget.dart @@ -1,11 +1,12 @@ import 'package:flutter/material.dart'; +import 'package:flutter_lib/utils/uidata.dart'; import './banner_evalutor.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'dart:async'; -class BannerWidget extends StatefulWidget{ +class BannerWidget extends StatefulWidget { final List data; - final int height,delayTime,duration; + final int height, delayTime, duration; final Curve curve; final ItemBuild build; final IndicatorBuild indicator; @@ -21,7 +22,7 @@ class BannerWidget extends StatefulWidget{ this.height = 160, this.delayTime = 4000, this.duration = 1000, - }): super(key : key); + }) : super(key: key); createState() => BannerState(); } @@ -29,7 +30,7 @@ class BannerWidget extends StatefulWidget{ class BannerState extends State { Timer timer; PageController controller; - int position,currentPage; + int position, currentPage; List bannerList = []; bool isRoll = true; @@ -58,23 +59,24 @@ class BannerState extends State { Widget pageView() { return Listener( - onPointerMove: (event){ + onPointerMove: (event) { isRoll = true; }, - onPointerDown: (event){ + onPointerDown: (event) { isRoll = false; }, - onPointerUp: (event){ + onPointerUp: (event) { isRoll = true; }, - onPointerCancel: (event){ + onPointerCancel: (event) { isRoll = true; }, child: NotificationListener( - onNotification: (scrollNotification){ + onNotification: (scrollNotification) { if (currentPage == -1) { isRoll = true; - }else if (scrollNotification is ScrollEndNotification || scrollNotification is UserScrollNotification) { + } else if (scrollNotification is ScrollEndNotification || + scrollNotification is UserScrollNotification) { if (currentPage == 0) { setState(() { currentPage = getRealCount(); @@ -93,17 +95,21 @@ class BannerState extends State { position = index % getRealCount(); setState(() {}); }, - physics: const PageScrollPhysics(parent: const BouncingScrollPhysics()), - childrenDelegate: SliverChildBuilderDelegate((context, index){ - int current = index % getRealCount(); - BannerWithEval bannerWithEval = bannerList[current]; - return GestureDetector( - onTap: () => widget.onClick(current, bannerWithEval), - child: widget.build != null ? widget.build(current) : BannerItem( - url: bannerWithEval.bannerUrl, - ), - ); - }, + physics: + const PageScrollPhysics(parent: const BouncingScrollPhysics()), + childrenDelegate: SliverChildBuilderDelegate( + (context, index) { + int current = index % getRealCount(); + BannerWithEval bannerWithEval = bannerList[current]; + return GestureDetector( + onTap: () => widget.onClick(current, bannerWithEval), + child: widget.build != null + ? widget.build(current) + : BannerItem( + url: bannerWithEval.bannerUrl, + ), + ); + }, childCount: bannerList.length, ), ), @@ -112,16 +118,18 @@ class BannerState extends State { } Widget indicator() { - return widget.indicator == null ? Align( - alignment: Alignment.bottomCenter, - child: Container( - height: 20.0, - padding: EdgeInsets.all(2.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: circularPoint(getRealCount()), - ), - )) : widget.indicator(position,getRealCount()); + return widget.indicator == null + ? Align( + alignment: Alignment.bottomCenter, + child: Container( + height: 20.0, + padding: EdgeInsets.all(2.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: circularPoint(getRealCount()), + ), + )) + : widget.indicator(position, getRealCount()); } List circularPoint(int count) { @@ -130,7 +138,7 @@ class BannerState extends State { children.add(Container( width: 6.0, height: 6.0, - margin: EdgeInsets.only(left: 2.0,top: 0.0,right: 2.0,bottom: 0.0), + margin: EdgeInsets.only(left: 2.0, top: 0.0, right: 2.0, bottom: 0.0), decoration: BoxDecoration( shape: BoxShape.circle, color: position == i ? Colors.black38 : Colors.white, @@ -141,29 +149,30 @@ class BannerState extends State { } void restTime() { - if (timer == null){ + if (timer == null) { timer = Timer.periodic(Duration(milliseconds: widget.delayTime), (timer) { - if (isRoll){ - if (currentPage == -1){ + if (isRoll) { + if (currentPage == -1) { currentPage = 0; controller.jumpToPage(currentPage); return; } currentPage++; - controller.nextPage(duration: Duration(milliseconds: widget.duration), + controller.nextPage( + duration: Duration(milliseconds: widget.duration), curve: widget.curve); } }); } } - void cancelTime(){ + void cancelTime() { timer?.cancel(); timer = null; } - void restData(){ - for (int i = 0;i<2;i++){ + void restData() { + for (int i = 0; i < 2; i++) { bannerList.addAll(widget.data); } } @@ -179,12 +188,12 @@ class BannerState extends State { } } -class BannerItem extends StatefulWidget{ +class BannerItem extends StatefulWidget { final String url; BannerItem({ Key key, @required this.url, - }): super(key : key); + }) : super(key: key); @override createState() => ItemState(); @@ -194,18 +203,19 @@ class ItemState extends State { @override Widget build(BuildContext context) { return CachedNetworkImage( - placeholder: Container( - height: 160.0, - width: double.infinity, - color: Colors.black38, - child: Center( - widthFactor: 2.0, - heightFactor: 2.0, - child: CircularProgressIndicator(), - ) - ), - imageUrl: widget.url, - fit: BoxFit.cover); + imageUrl: widget.url, + placeholder: (context, url) => Container( + height: 160.0, + width: double.infinity, + color: Colors.black38, + child: Center( + widthFactor: 2.0, + heightFactor: 2.0, + child: CircularProgressIndicator(), + )), + fit: BoxFit.cover, + errorWidget: (context, url, error) => UIData.getImage(""), + ); } } @@ -213,7 +223,7 @@ class ItemState extends State { typedef Widget ItemBuild(int position); //在这添加自定义的指示器,指示器位置自定义请使用Align部件,默认圆点 -typedef Widget IndicatorBuild(int position,int counmt); +typedef Widget IndicatorBuild(int position, int counmt); //点击监听 -typedef void OnClick(int position, BannerWithEval bannerWithEval); \ No newline at end of file +typedef void OnClick(int position, BannerWithEval bannerWithEval); diff --git a/flutter_lib/lib/ui/widgets/common_dialogs.dart b/flutter_lib/lib/ui/widgets/common_dialogs.dart index 881a2e2..f46476c 100644 --- a/flutter_lib/lib/ui/widgets/common_dialogs.dart +++ b/flutter_lib/lib/ui/widgets/common_dialogs.dart @@ -1,4 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:flutter_lib/bridge/common_bridge.dart'; +import 'package:flutter_lib/bridge/pay_bridge.dart'; +import 'package:flutter_lib/model/Result.dart'; import 'package:flutter_lib/utils/uidata.dart'; fetchApiResult(BuildContext context, String snapshot) { @@ -6,7 +9,7 @@ fetchApiResult(BuildContext context, String snapshot) { context: context, builder: (context) => AlertDialog( title: Text(UIData.error), - content: Text("AlertDialog") , + content: Text("AlertDialog"), actions: [ FlatButton( child: Text(UIData.ok), @@ -64,3 +67,113 @@ showProgress(BuildContext context) { hideProgress(BuildContext context) { Navigator.pop(context); } + +showPayDialog(BuildContext context, double totalMoney, String tradeOrderId, + String attach) { + if (tradeOrderId == null) { + Bridge.showLongToast("订单id无效"); + return; + } + showModalBottomSheet( + context: context, + builder: (context) => Center( + child: Material( + borderRadius: BorderRadius.circular(8.0), + color: Colors.white, + child: Padding( + padding: const EdgeInsets.fromLTRB(32, 0, 32, 0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + Center( + child: Text("确认付款", + style: TextStyle( + color: UIData.ff33333, fontSize: 18))), + Padding( + padding: const EdgeInsets.fromLTRB(0, 46, 0, 0), + child: Text( + "¥" + totalMoney.toStringAsFixed(2), + style: TextStyle(color: UIData.ff353535, fontSize: 33), + ), + ), + Divider(), + Padding( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.max, + children: [ + Text( + "订单信息", + style: + TextStyle(color: UIData.ff666666, fontSize: 15), + ), + Text( + "商品组合", + style: TextStyle(color: Colors.black, fontSize: 15), + ) + ], + ), + padding: EdgeInsets.fromLTRB(14, 14, 14, 14), + ), + Divider(), + Padding( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "付款方式", + style: + TextStyle(color: UIData.ff666666, fontSize: 15), + ), + Text( + "微信", + style: TextStyle(color: Colors.black, fontSize: 15), + ) + ], + ), + padding: EdgeInsets.fromLTRB(14, 14, 14, 0), + ), + Divider(), + Padding( + padding: const EdgeInsets.fromLTRB(0, 10, 0, 0), + child: UIData.getShapeButton( + UIData.fffa4848, + UIData.fff, + 345, + 45, + "立即付款", + 18, + 5, + () { + //"1555746236014000", + //"商品描述", + Future future = PayBridge.wxPay( + tradeOrderId, + "123.12.12.123", + "商品组合", + attach == null + ? "附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据" + : attach); + future.then((v) { + if (v.code == 200) { + Navigator.pushNamed(context, UIData.homeRoute); + } else if (v.code == 403) { + //支付失败 + Navigator.pop(context, false); + Bridge.showShortToast(v.msg); + } else if (v.code == 406) { + //取消支付 + Navigator.pop(context, false); + Bridge.showShortToast(v.msg); + } + }); + }, + ), + ) + ], + ), + ), + ), + )); +} diff --git a/flutter_lib/lib/ui/widgets/countdown.dart b/flutter_lib/lib/ui/widgets/countdown.dart new file mode 100644 index 0000000..b7c4fee --- /dev/null +++ b/flutter_lib/lib/ui/widgets/countdown.dart @@ -0,0 +1,16 @@ +import 'package:flutter/material.dart'; + +class Countdown extends AnimatedWidget { + Countdown({Key key, this.animation,this.color}) : super(key: key, listenable: animation); + Animation animation; + Color color; + + + @override + build(BuildContext context) { + return new Text( + animation.value.toString() + "后重试", + style: new TextStyle(fontSize: 10.0,color: Colors.white), + ); + } +} diff --git a/flutter_lib/lib/ui/widgets/empty_widget.dart b/flutter_lib/lib/ui/widgets/empty_widget.dart new file mode 100644 index 0000000..ad80163 --- /dev/null +++ b/flutter_lib/lib/ui/widgets/empty_widget.dart @@ -0,0 +1,72 @@ +//import 'package:flutter/cupertino.dart'; +// +//class EmptyWidget extends StatelessWidget { +// var type = 0; +// var tab; +// String error; +// +// EmptyWidget( +// this.error, +// this.tab, +// ); +// +// EmptyWidget.WithSliverList(this.error,this.tab) { +// type = 1; +// } +// +// @override +// Widget build(BuildContext context) { +// if (type == 0) { +// return Center( +// child: Padding( +// padding: const EdgeInsets.all(32.0), +// child: GestureDetector( +// child: Padding( +// padding: const EdgeInsets.all(32.0), +// child: Text(error==null?"无数据,点击重试":error), +// ), +// onTap: tab, +// ), +// ), +// ); +// } else if (type == 1) { +// return SliverList( +// delegate: SliverChildListDelegate( +// [ +// Center( +// child: Padding( +// padding: const EdgeInsets.all(32.0), +// child: GestureDetector( +// child: Padding( +// padding: const EdgeInsets.all(32.0), +// child: Text(error==null?"无数据,点击重试":error), +// ), +// onTap: tab, +// ), +// ), +// ), +// ], +// ), +// ); +// } else if (type == 2) { +// return SliverList( +// delegate: SliverChildListDelegate( +// [ +// Center( +// child: Padding( +// padding: const EdgeInsets.all(32.0), +// child: GestureDetector( +// child: Padding( +// padding: const EdgeInsets.all(32.0), +// child: Text(error==null?"无数据,点击重试":error), +// ), +// onTap: tab, +// ), +// ), +// ), +// ], +// ), +// ); +// } +// } +//} diff --git a/flutter_lib/lib/ui/widgets/error_status_widget.dart b/flutter_lib/lib/ui/widgets/error_status_widget.dart new file mode 100644 index 0000000..242d109 --- /dev/null +++ b/flutter_lib/lib/ui/widgets/error_status_widget.dart @@ -0,0 +1,233 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_lib/utils/uidata.dart'; + +class ErrorStatusWidget extends StatelessWidget { + var type = 0; + var errorCode = 500; + //errorCode200:请求成功 +// 500:解析异常 +// 404:找不到服务地址或服务访问失败 +// 600:网络未开启 +// 601:连接超时 + var tab; + String error; + String actionTxt; + + ErrorStatusWidget( + this.errorCode, + this.error, + this.tab, + this.actionTxt, + ); + + ErrorStatusWidget.order( + this.errorCode, + this.error, + this.actionTxt, + this.tab, + ) { + type = 0; + } + + ErrorStatusWidget.sliver( + this.errorCode, + this.error, + this.actionTxt, + this.tab, + ) { + type = 3; + } + + ErrorStatusWidget.search( + this.errorCode, + this.error, + this.actionTxt, + this.tab, + ) { + type = 1; + } + + ErrorStatusWidget.cart( + this.errorCode, + this.error, + this.actionTxt, + this.tab, + ) { + type = 2; + } + + @override + Widget build(BuildContext context) { + Widget img = Image.asset( + UIData.net_error, + width: 196, + height: 196, + ); + if (type == 0) { + img = Image.asset( + UIData.no_order, + width: 196, + height: 196, + ); + } else if (type == 1) { + img = Image.asset( + UIData.no_search_result, + width: 196, + height: 196, + ); + } else if (type == 2) { + img = Image.asset( + UIData.no_cart, + width: 196, + height: 196, + ); + } + switch (errorCode) { + case 404: + case 600: + case 601: + case -1: + img = Image.asset( + UIData.net_error, + width: 196, + height: 196, + ); + break; + } + if (type == 0) { + return Center( + child: Padding( + padding: const EdgeInsets.all(32.0), + child: Column( + children: [ + img, + GestureDetector( + child: Padding( + padding: const EdgeInsets.all(32.0), + child: Text( + error == null ? "暂无数据" : error, + textAlign: TextAlign.center, + ), + ), + onTap: tab, + ), + Padding( + padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), + child: SizedBox( + width: 105, + height: 30, + child: FlatButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(15)), + side: BorderSide( + color: Color(0xFFF9F3FF), + style: BorderStyle.solid, + width: 2)), + onPressed: tab, + child: new Text(actionTxt), + ), + ), + ), + ], + ), + ), + ); + } else if (type == 1) { + return Center( + child: Padding( + padding: const EdgeInsets.all(32.0), + child: Padding( + padding: const EdgeInsets.all(32.0), + child: Column( + children: [ + img, + Text( + error == null ? "暂无搜索结果\n换个搜索词试试" : error, + textAlign: TextAlign.center, + ), + ], + ), + ), + ), + ); + } else if (type == 2) { + return Center( + child: Column( + children: [ + img, + GestureDetector( + child: Padding( + padding: const EdgeInsets.all(32.0), + child: Text( + error == null ? "暂无购物记录~" : error, + textAlign: TextAlign.center, + ), + ), + onTap: tab, + ), + SizedBox( + width: 105, + height: 30, + child: FlatButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(15)), + side: BorderSide( + color: Color(0xFFF9F3FF), + style: BorderStyle.solid, + width: 2)), + onPressed: tab, + child: new Text("立即购物"), + ), + ), + ], + ), + ); + } else { + return SliverList( + delegate: SliverChildListDelegate( + [ + Center( + child: Padding( + padding: const EdgeInsets.all(32.0), + child: Column( + children: [ + img, + GestureDetector( + child: Padding( + padding: const EdgeInsets.all(32.0), + child: Text( + error == null ? "暂无数据" : error, + textAlign: TextAlign.center, + ), + ), + onTap: tab, + ), + Padding( + padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), + child: SizedBox( + width: 105, + height: 30, + child: FlatButton( + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.all(Radius.circular(15)), + side: BorderSide( + color: Color(0xFFF9F3FF), + style: BorderStyle.solid, + width: 2)), + onPressed: tab, + child: new Text(actionTxt), + ), + ), + ), + ], + ), + ), + ), + ], + ), + ); + } + } +} diff --git a/flutter_lib/lib/ui/widgets/shop_tab_item.dart b/flutter_lib/lib/ui/widgets/shop_tab_item.dart index fd7b5d4..3f8970d 100644 --- a/flutter_lib/lib/ui/widgets/shop_tab_item.dart +++ b/flutter_lib/lib/ui/widgets/shop_tab_item.dart @@ -1,7 +1,8 @@ import 'package:flutter/material.dart'; +import 'package:flutter_lib/utils/uidata.dart'; class PreferreSizeWidget extends StatelessWidget implements PreferredSize { - final ValueChanged onChanged; + final ValueChanged onChanged; @override Size get preferredSize => new Size.fromHeight(48); @@ -19,7 +20,7 @@ class PreferreSizeWidget extends StatelessWidget implements PreferredSize { } class TabItemPage extends StatefulWidget { - final ValueChanged onChanged; + final ValueChanged onChanged; const TabItemPage({Key key, this.onChanged}) : super(key: key); @override @@ -28,13 +29,16 @@ class TabItemPage extends StatefulWidget { class TabItemState extends State { var isArrowDown = true; + var isArrowDown1 = true; + var isArrowDown2 = true; - final ValueChanged onChanged; + int lastSelectType = 1; + final ValueChanged onChanged; TabItemState(this.onChanged); - void _handleTap() { - onChanged(isArrowDown); + void _handleTap(int type) { + onChanged(type); } @override @@ -44,53 +48,84 @@ class TabItemState extends State { Container buildContainer() { return Container( - height: 50, child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - buildArrowDownUpText("综合"), - buildGestureDetector("销量"), - buildGestureDetector("价格"), + buildArrowDownUpText(1, "综合"), + buildArrowDownUpText(3, "销量"), + buildArrowDownUpText(5, "价格"), ], ), ); } - GestureDetector buildGestureDetector(String s) { + GestureDetector buildArrowDownUpText(int type, String s) { return new GestureDetector( - child: new Text( - s, - ), - ); - } - - GestureDetector buildArrowDownUpText(String s) { - return new GestureDetector( - child: new Row( - children: [ - new Text( - s, - style: TextStyle(color: Colors.red), - ), - isArrowDown - ? new Icon( - Icons.arrow_drop_down, - color: Colors.red, - ) - : new Icon( - Icons.arrow_drop_up, - color: Colors.red, - ) - ], + child: Padding( + padding: const EdgeInsets.all(8.0), + child: new Row( + children: [buildText(type,s), getIcon(type)], + ), ), onTap: () { this.setState(() { - print("点击前:" + isArrowDown.toString()); - isArrowDown = !this.isArrowDown; - print("点击后:" + isArrowDown.toString()); - _handleTap(); + lastSelectType = type; + if (type == 1) { + isArrowDown = !this.isArrowDown; + _handleTap(isArrowDown ? type : (type + 1)); + } else if (type == 3) { + isArrowDown1 = !this.isArrowDown1; + _handleTap(isArrowDown1 ? type : (type + 1)); + } else { + isArrowDown2 = !this.isArrowDown2; + _handleTap(isArrowDown2 ? type : (type + 1)); + } }); }, ); } + + Text buildText(int type, String s) { + Color color = UIData.ff353535; + if (lastSelectType == type) { + color = UIData.fffa4848; + } else { + color = UIData.ff353535; + } + return new Text( + s, + style: TextStyle(color: color), + ); + } + + Icon getIcon(int type) { + bool arrow = true; + Color color = UIData.ff353535; + + if (lastSelectType == type) { + color = UIData.fffa4848; + } else { + color = UIData.ff353535; + } + switch (type) { + case 1: + arrow = isArrowDown; + break; + case 3: + arrow = isArrowDown1; + break; + case 5: + arrow = isArrowDown2; + break; + } + return arrow + ? new Icon( + Icons.arrow_drop_down, + color: color, + ) + : new Icon( + Icons.arrow_drop_up, + color: color, + ); + } } diff --git a/flutter_lib/lib/utils/BristuaRouter.dart b/flutter_lib/lib/utils/BristuaRouter.dart new file mode 100644 index 0000000..592d44e --- /dev/null +++ b/flutter_lib/lib/utils/BristuaRouter.dart @@ -0,0 +1,14 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_lib/ui/page/account/login.dart'; + +class BristuaRouter { + /* + * 路由到主页面 + */ + static void routerUserLogin(BuildContext context) { + Navigator.pop(context, false); + Route route = MaterialPageRoute(builder: (context) => LoginPage()); + Navigator.push(context, route); + } +} diff --git a/flutter_lib/lib/utils/http.dart b/flutter_lib/lib/utils/http.dart new file mode 100644 index 0000000..ae730a4 --- /dev/null +++ b/flutter_lib/lib/utils/http.dart @@ -0,0 +1,63 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter_lib/model/Result.dart'; + +class Http { + static const baseUrl = "https://mall.bchun.com"; + + static const banner = "/mall/get/app/index/image"; + + static const homeCategory = "/mall/get/app/index/category"; + + static Future getResult(String url) async { + bool trustSelfSigned = true; + HttpClient httpClient = new HttpClient() + ..badCertificateCallback = + ((X509Certificate cert, String host, int port) => trustSelfSigned); + + String result; + try { + print(url); + var request = await httpClient.postUrl(Uri.parse(url)); + var response = await request.close(); + if (response.statusCode == HttpStatus.ok) { + var jsons = await response.transform(utf8.decoder).join(); + Result jsonResponse = Result.fromJson(jsons); + + print("http:response:"+jsonResponse.toString()); + return jsonResponse; + } else { + result = + 'Error getting IP address:\nHttp status ${response.statusCode}'; + return Result.fromJson( + json.encode({"code": response.statusCode, "msg": result})); + } + } catch (exception) { + result = exception.toString(); + return Result.fromJson(json.encode({"code": -1, "msg": "网络异常,请检查网络设置"})); + } + } + + static Future getBanner() async { + Result result = await getResult(baseUrl + banner); + + return result; + } + + static Future getHomeCategoryList() async { + Result result = await getResult(baseUrl + homeCategory); + return result; + } + + static getPromotion() async{ + Result result = await getResult(baseUrl + "/mall/get/app/index/promotion"); + return result; + } + + static getSpecial() async{ + Result result = await getResult(baseUrl + "/mall/get/app/index/special"); + return result; + } + +} diff --git a/flutter_lib/lib/utils/uidata.dart b/flutter_lib/lib/utils/uidata.dart index 1a9b3b6..6dfb3c0 100644 --- a/flutter_lib/lib/utils/uidata.dart +++ b/flutter_lib/lib/utils/uidata.dart @@ -27,6 +27,10 @@ class UIData { static const String ShopDetailPage = "/ShopDetailPage"; static const String ShopCartListPage = "/ShopCartListPage"; + static const String WebViewPage = "/WebViewPage"; + + static const String VipApplyPage = "/VipApplyPage"; + static const String MineWalletPage = "/MineWalletPage"; //strings static const String appName = "Flutter UIKit"; @@ -38,6 +42,7 @@ class UIData { static const String quickNormalFont = "Quicksand_Book.otf"; static const String quickLightFont = "Quicksand_Light.otf"; + //images static const String imageDir = "assets/images"; static const String pkImage = "$imageDir/pk.jpg"; @@ -51,6 +56,13 @@ class UIData { static const String timelineImage = "$imageDir/timeline.jpeg"; static const String verifyImage = "$imageDir/verification.jpg"; + static const String no_search_result = "images/no_search_result.png"; + static const String net_error = "images/net_error.png"; + static const String no_order = "images/no_order.png"; + static const String no_msg = "images/no_msg.png"; + static const String no_cart = "images/no_cart.png"; + + //login static const String enter_code_label = "Phone Number"; static const String enter_code_hint = "10 Digit Phone Number"; @@ -68,7 +80,7 @@ class UIData { static const String ok = "OK"; static const String forgot_password = "Forgot Password?"; static const String something_went_wrong = "Something went wrong"; - static const String coming_soon = "Coming Soon"; + static const String coming_soon = "未知领域"; static const MaterialColor ui_kit_color = Colors.grey; static const Color ffcccccc = Color(0xffcccccc); @@ -308,11 +320,11 @@ class UIData { static Widget getImage(String image) { if (image == null || !image.startsWith("http")) { - return Image.asset("images/shop_type_hat.png"); + return Image.asset("images/placeholder.png",fit: BoxFit.cover,); } else { return FadeInImage.assetNetwork( - placeholder: 'images/shop_type_hat.png', - fit: BoxFit.contain, + placeholder: 'images/placeholder.png', + fit: BoxFit.cover, image: image, ); } @@ -321,14 +333,14 @@ class UIData { static Widget getImageWithWH(String image, double w, double h) { if (image == null || !image.startsWith("http")) { return Image.asset( - "images/shop_type_hat.png", + "images/placeholder.png", width: w, height: h, ); } else { return FadeInImage.assetNetwork( - placeholder: 'images/shop_type_hat.png', - fit: BoxFit.contain, + placeholder: 'images/placeholder.png', + fit: BoxFit.cover, image: image, width: w, height: h, @@ -340,13 +352,13 @@ class UIData { String image, BoxFit fit, double w, double h) { if (image == null || !image.startsWith("http")) { return Image.asset( - "images/shop_type_hat.png", + "images/placeholder.png", width: w, height: h, ); } else { return FadeInImage.assetNetwork( - placeholder: 'images/shop_type_hat.png', + placeholder: 'images/placeholder.png', fit: fit, image: image, width: w, @@ -354,4 +366,36 @@ class UIData { ); } } + + static Widget getFlatButton(String txt,tab) { + return FlatButton( + child: Text(txt), + onPressed: tab, + textTheme: ButtonTextTheme.normal, + textColor: Colors.yellow, + disabledTextColor: Colors.red, + color: Color(0xFF82B1FF), + disabledColor: Colors.grey, + highlightColor: Colors.grey, + // 按下的背景色 + splashColor: Colors.transparent, + // 水波纹颜色 + colorBrightness: Brightness.light, + // 主题 +// elevation: 10, +// highlightElevation: 10, +// disabledElevation: 10, + padding: EdgeInsets.all(10), +// RaisedButton 才起效 + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(20)), + side: BorderSide( + color: Color(0xFFF9F3FF), style: BorderStyle.solid, width: 2)), + clipBehavior: Clip.antiAlias, + materialTapTargetSize: MaterialTapTargetSize.padded, +// animationDuration: Duration(seconds:1), +// minWidth: 200, +// height: 50, + ); + } } diff --git a/flutter_lib/pubspec.lock b/flutter_lib/pubspec.lock index 0edc5bf..c23e068 100644 --- a/flutter_lib/pubspec.lock +++ b/flutter_lib/pubspec.lock @@ -7,7 +7,7 @@ packages: name: analyzer url: "https://pub.flutter-io.cn" source: hosted - version: "0.36.0" + version: "0.36.3" args: dependency: transitive description: @@ -35,7 +35,7 @@ packages: name: build url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.3" + version: "1.1.4" build_config: dependency: transitive description: @@ -77,21 +77,21 @@ packages: name: built_collection url: "https://pub.flutter-io.cn" source: hosted - version: "4.2.0" + version: "4.2.2" built_value: dependency: transitive description: name: built_value url: "https://pub.flutter-io.cn" source: hosted - version: "6.4.0" + version: "6.5.0" cached_network_image: dependency: "direct main" description: name: cached_network_image url: "https://pub.flutter-io.cn" source: hosted - version: "0.4.2" + version: "0.7.0" charcode: dependency: transitive description: @@ -127,6 +127,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.0.6" + csslib: + dependency: transitive + description: + name: csslib + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.16.0" cupertino_icons: dependency: "direct main" description: @@ -141,6 +148,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.2.7" + fish_redux: + dependency: "direct main" + description: + name: fish_redux + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.1.7" fixnum: dependency: transitive description: @@ -159,19 +173,33 @@ packages: name: flutter_cache_manager url: "https://pub.flutter-io.cn" source: hosted - version: "0.1.2" + version: "0.3.2" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + flutter_widget_from_html: + dependency: "direct main" + description: + name: flutter_widget_from_html + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.2.0" + flutter_widget_from_html_core: + dependency: transitive + description: + name: flutter_widget_from_html_core + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.2.0" front_end: dependency: transitive description: name: front_end url: "https://pub.flutter-io.cn" source: hosted - version: "0.1.15" + version: "0.1.18" glob: dependency: transitive description: @@ -186,20 +214,27 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.2.0" + html: + dependency: transitive + description: + name: html + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.14.0+2" http: dependency: transitive description: name: http url: "https://pub.flutter-io.cn" source: hosted - version: "0.11.3+17" + version: "0.12.0+2" http_multi_server: dependency: transitive description: name: http_multi_server url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.5" + version: "2.0.6" http_parser: dependency: transitive description: @@ -241,7 +276,7 @@ packages: name: kernel url: "https://pub.flutter-io.cn" source: hosted - version: "0.3.15" + version: "0.3.18" logging: dependency: transitive description: @@ -297,7 +332,7 @@ packages: name: path_provider url: "https://pub.flutter-io.cn" source: hosted - version: "0.4.1" + version: "0.5.0+1" pedantic: dependency: transitive description: @@ -333,13 +368,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.0.1" - shared_preferences: - dependency: transitive - description: - name: shared_preferences - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.4.3" shelf: dependency: transitive description: @@ -373,6 +401,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.5.4" + sqflite: + dependency: transitive + description: + name: sqflite + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.5" stack_trace: dependency: transitive description: @@ -407,7 +442,7 @@ packages: name: synchronized url: "https://pub.flutter-io.cn" source: hosted - version: "1.5.3+2" + version: "2.1.0" term_glyph: dependency: transitive description: @@ -436,13 +471,20 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.1.6" + url_launcher: + dependency: transitive + description: + name: url_launcher + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.0.2" uuid: dependency: transitive description: name: uuid url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.3" + version: "2.0.1" vector_math: dependency: transitive description: @@ -464,6 +506,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.12" + webview_flutter: + dependency: transitive + description: + name: webview_flutter + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.3.6" yaml: dependency: transitive description: @@ -473,4 +522,4 @@ packages: version: "2.1.15" sdks: dart: ">=2.1.1 <3.0.0" - flutter: ">=0.1.4 <2.0.0" + flutter: ">=1.2.1 <2.0.0" diff --git a/flutter_lib/pubspec.yaml b/flutter_lib/pubspec.yaml index 5b876fa..21e4b06 100644 --- a/flutter_lib/pubspec.yaml +++ b/flutter_lib/pubspec.yaml @@ -20,13 +20,15 @@ dependencies: flutter: sdk: flutter - - cached_network_image: ^0.4.1 + fish_redux: ^0.1.7 + cached_network_image: ^0.7.0 +# clipboard_manager: ^0.0.4 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.2 json_annotation: ^2.0.0 + flutter_widget_from_html: ^0.2.0 dev_dependencies: flutter_test: @@ -53,6 +55,12 @@ flutter: - images/icon_login_wx.png - images/icon_back.png - images/icon_code.png + - images/icon_vip.png + - images/btn_settings.png + - images/icon_exit.png + - images/icon_kehu.png + - images/icon_inputnumber.png + - images/icon_shoucang.png - images/shop_type_hat.png - images/shop_type_beauty.png - images/shop_type_furniture.png @@ -74,6 +82,24 @@ flutter: - images/invite.png - images/favor.png - images/coin.png + - images/user_icon.png + - images/placeholder.png + - images/icon_bottom_navigation_active.png + - images/icon_bottom_navigation_car.png + - images/icon_bottom_navigation_home.png + - images/icon_bottom_navigation_mine.png + - images/icon_ranking.png + - images/icon_collection.png + - images/icon_shop_car.png + - images/no_search_result.png + - images/net_error.png + - images/no_order.png + - images/no_msg.png + - images/no_cart.png + - images/icon_vip_bg.png + - images/icon_vip_crown.png + - images/icon_mine_bg.png + - images/icon_setting.png # An image asset can refer to one or more resolution-specific "variants", see diff --git a/ftshop.jks b/ftshop.jks new file mode 100644 index 0000000..935ee5f Binary files /dev/null and b/ftshop.jks differ diff --git a/gradle.properties b/gradle.properties index 8376c63..fa9d621 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,4 +18,6 @@ POM_ARTIFACT_ID=user_info POM_NAME=user_info POM_PACKAGING=com.hua.yuan.provider POM_DESCRIPTION=user_info -VERSION_NAME=user_info \ No newline at end of file +VERSION_NAME=user_info +android.useAndroidX=true +android.enableJetifier=true \ No newline at end of file