Commit b3c0e34d authored by 朱璇's avatar 朱璇

Merge branch 'test' of git.wanmeizhensuo.com:linshengyu/gm_flutter into zx/gmFlutter

parents 67d281a1 90e676e5
......@@ -53,7 +53,7 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
screenWidth = MediaQuery.of(context).size.width;
return Scaffold(
appBar: baseAppBar(
title: "对比详情",
titleWidget: baseText("对比详情", 18, Color(0xff333333), bold: true),
centerTitle: true,
backClick: () {
if (RouterCenterImpl().findMainRouter().isWithNative()) {
......
......@@ -54,7 +54,7 @@ class _PlansCompareFeedState extends BaseState<PlansCompareFeedPage>
return Scaffold(
backgroundColor: Colors.white,
appBar: baseAppBar(
title: "方案对比",
titleWidget: baseText("方案对比", 18, Color(0xff333333), bold: true),
centerTitle: true,
backClick: () {
if (RouterCenterImpl().findMainRouter().isWithNative()) {
......
......@@ -47,7 +47,7 @@ class _ProjectDetailsState extends BaseState<ProjectDetailsPage> {
Widget buildItem(BuildContext context) {
return Scaffold(
appBar: baseAppBar(
title: "项目说明",
titleWidget: baseText("项目说明", 18, Color(0xff333333), bold: true),
centerTitle: true,
backClick: () {
if (RouterCenterImpl().findMainRouter().isWithNative()) {
......
......@@ -14,6 +14,8 @@ import 'package:gm_flutter/commonModel/util/DartUtil.dart';
import 'package:gm_flutter/commonModel/util/NumberUtil.dart';
import 'package:gm_flutter/main.mark.dart';
import '../../../main.dart';
class LevelOneItem extends StatelessWidget {
final Cards cards;
VoidCallback lowPrice;
......@@ -66,7 +68,7 @@ class LevelOneItem extends StatelessWidget {
}
Widget DoctorItem(BuildContext context) {
if (cards.doctor == null && isDebug) {
if (cards.doctor == null && !inProduction) {
throw new Exception();
}
var price =
......@@ -194,7 +196,7 @@ class LevelOneItem extends StatelessWidget {
}
Widget HospitalItem(BuildContext context) {
if (cards.hospital == null && isDebug) {
if (cards.hospital == null && !inProduction) {
throw new Exception();
}
var price =
......@@ -330,7 +332,7 @@ class LevelOneItem extends StatelessWidget {
}
Widget PlanItem(BuildContext context) {
if (cards.plan == null && isDebug) {
if (cards.plan == null && !inProduction) {
throw new Exception();
}
String price =
......@@ -477,7 +479,7 @@ class LevelOneItem extends StatelessWidget {
}
Widget DiaryItem(BuildContext context) {
if (cards.diary == null && isDebug) {
if (cards.diary == null && !inProduction) {
throw new Exception();
}
return Container(
......@@ -565,6 +567,7 @@ class LevelOneItem extends StatelessWidget {
Expanded(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
image: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(
......
......@@ -183,14 +183,14 @@ class LevelOneState extends BaseState<LevelOnePage>
child: newHome(),
)),
baseSliverTitle("${widget.title}", MediaQuery.of(context).size.width,
_model.textLive),
_model.textLive, context),
baseSliverBack(() {
if (RouterCenterImpl().findMainRouter().isWithNative()) {
FlutterBoost.singleton.closeCurrent();
} else {
Navigator.of(context).pop();
}
}),
}, context),
],
);
}
......@@ -221,7 +221,7 @@ class LevelOneState extends BaseState<LevelOnePage>
handle: extend.NestedScrollView.sliverOverlapAbsorberHandleFor(
context),
sliver: baseSliverAppBar(_model.imageUrl,
height: ScreenUtil().setHeight(200))),
height: 200)),
SliverList(
delegate: SliverChildBuilderDelegate((BuildContext c, int i) {
if (i == 0) {
......@@ -283,7 +283,7 @@ class LevelOneState extends BaseState<LevelOnePage>
return Container(
width: MediaQuery.of(context).size.width,
height: 54,
margin: EdgeInsets.only(top: 19, bottom: 12),
margin: EdgeInsets.only(top: 10, bottom: 12),
child: Stack(
children: <Widget>[
Positioned(
......
......@@ -174,14 +174,14 @@ class LevelTwoState extends BaseState<LevelTwoPage>
child: newHome(),
)),
baseSliverTitle("${_model.name}", MediaQuery.of(context).size.width,
_model.textLive),
_model.textLive, context),
baseSliverBack(() {
if (RouterCenterImpl().findMainRouter().isWithNative()) {
FlutterBoost.singleton.closeCurrent();
} else {
Navigator.of(context).pop();
}
}),
}, context),
],
);
}
......
......@@ -88,7 +88,6 @@ class MechanismBox implements IBottomPicker {
textController.dispose();
refreshController.dispose();
_model.dispose();
_model.dispose();
focusNode.dispose();
}
......
......@@ -12,6 +12,7 @@ import 'package:gm_flutter/ClueModel/page/plan/PlanModelInstance.dart';
import 'package:gm_flutter/ClueModel/server/api/ClueApi.serv.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanFeedBean.dart';
import 'package:gm_flutter/commonModel/App.dart';
import 'package:gm_flutter/commonModel/GMBase.dart';
import 'package:gm_flutter/commonModel/bean/Pair.dart';
import 'package:gm_flutter/commonModel/cache/CacheManager.dart';
......@@ -130,7 +131,6 @@ class PlanModel extends BaseModel {
})
.addToDispose(rxDispose)
.onError((err) {
print("ERROR12WCCCCCC ${err.toString()}");
PrintUtil.printBug(err);
stateLive.notifyView(FAIL);
});
......
......@@ -36,6 +36,7 @@ import 'package:gm_flutter/commonModel/view/baseRefreshIndicator.dart';
import 'package:gm_flutter/main.mark.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import '../../../main.dart';
import 'PlanModel.dart';
import 'ProjectView.dart';
......@@ -64,7 +65,9 @@ class PlanState extends BaseState<PlanPage> with TickerProviderStateMixin {
@override
void initState() {
if (RouterCenterImpl().findMainRouter().isWithNative() &&
super.initState();
if (inProduction&&
Platform.isIOS &&
CacheManager.getInstance().get(MEMORY_CACHE).get(BASE_URL) == null) {
func = (str) {
if (str == "init") {
......@@ -72,10 +75,8 @@ class PlanState extends BaseState<PlanPage> with TickerProviderStateMixin {
}
};
SimpleEventBus.instance().resignEvent("clueModel|Plan|PlanPage", func);
} else {
_model.init(needCache: true);
}
super.initState();
_model.init(needCache: true);
planBarView =
PlanBarView(_model.managerLive, clickIndex, hideAllMenuListener);
}
......
......@@ -148,9 +148,9 @@ class TopPageState extends BaseState<TopPage> with TickerProviderStateMixin {
} else {
Navigator.of(context).pop();
}
}),
}, context),
baseSliverTitle("${widget.title}", MediaQuery.of(context).size.width,
_model.textLive)
_model.textLive, context)
],
);
}
......
......@@ -326,13 +326,13 @@ class ClueApiImpl {
}
void _printHttpLog(Response response) {
if (!inProduction) {
try {
printRespond(response);
} catch (ex) {
print("Http Log" + " error......");
}
}
// if (!inProduction) {
// try {
// printRespond(response);
// } catch (ex) {
// print("Http Log" + " error......");
// }
// }
}
static void printRespond(Response response) {
......
......@@ -6,15 +6,10 @@
import 'dart:convert';
import 'dart:io';
import 'package:rxdart/rxdart.dart';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanOverViewBean.dart';
import 'package:rxdart/rxdart.dart';
const bool inProduction = const bool.fromEnvironment("dart.vm.product");
......@@ -130,13 +125,13 @@ class ClueTApiImpl {
}
void _printHttpLog(Response response) {
if (!inProduction) {
try {
printRespond(response);
} catch (ex) {
print("Http Log" + " error......");
}
}
// if (!inProduction) {
// try {
// printRespond(response);
// } catch (ex) {
// print("Http Log" + " error......");
// }
// }
}
static void printRespond(Response response) {
......
......@@ -16,6 +16,7 @@ import 'package:gm_flutter/commonModel/eventbus/SimpleEventBus.dart';
import 'package:gm_flutter/commonModel/util/DartUtil.dart';
import '../../commonModel/App.dart';
import '../../main.dart';
class MainManager {
MethodChannel flutterChannel;
......@@ -74,20 +75,20 @@ class MainManager {
innerSetData(map, USER_AGENT);
innerSetData(map, BASE_URL);
if (map[BASE_URL] != null) {
DioUtil.getInstance();
DioUtil.setDefOptions(
baseUrl: "${map[BASE_URL]}/", agent: map[USER_AGENT]);
DioUtil.getInstance().changeOpt();
DioUtil.getInstance();
if (inProduction) {
if (map[BASE_URL] != null &&
map[BASE_URL] != Api.getInstance().getBaseUrl()) {
CacheManager.getInstance().get(MEMORY_CACHE).save(URL_ISCHANE, "yes");
DioUtil.setDefOptions(
baseUrl: "${map[BASE_URL]}/", agent: map[USER_AGENT]);
DioUtil.getInstance().changeOpt();
SimpleEventBus.instance()
.notifyListener("clueModel|Plan|PlanPage", "init");
}
}
SimpleEventBus.instance().notifyListener("clueModel|Plan|PlanPage", "init");
// if (map[COOKIE] == null) {
// CacheManager.getInstance().get(MEMORY_CACHE).save(COOKIE,
// "_gm_token=1da6071594101423; csrftoken=rUrkkYYMOVZfIIQnU2IH09QIGmsfe8tE; sessionid=uz7f70uap76r6og48znci5l2hbr9vm5c; _gtid=5af9a5deba8511ea8d4082a085c393c93393");
// } else {
innerSetData(map, COOKIE);
// }
if (map[USER_ID] == null || "${map[USER_ID]}".isEmpty) {
CacheManager.getInstance().get(MEMORY_CACHE).save(USER_ID, null);
}
......
......@@ -27,9 +27,9 @@ class NetProxyState extends BaseState<NetProxyPage> {
appBar: baseAppBar(
centerTitle: true,
backClick: () {
if(RouterCenterImpl().findMainRouter().isWithNative()){
if (RouterCenterImpl().findMainRouter().isWithNative()) {
FlutterBoost.singleton.closeCurrent();
}else{
} else {
Navigator.of(context).pop();
}
},
......@@ -50,9 +50,10 @@ class NetProxyState extends BaseState<NetProxyPage> {
InkWell(
onTap: () {
MainApiImpl.getInstance()
.isOk(DioUtil.getInstance().getDio())
.listen((event) {}).onError((error){
print("LSYQQ ${error.toString()}");
.getCity(DioUtil.getInstance().getDio())
.listen((event) {})
.onError((error) {
print("LSYQQ ${error.toString()}");
});
},
child: Container(
......
......@@ -4,10 +4,14 @@
**/
import 'package:flutter_common/Annotations/anno/Get.dart';
import 'package:flutter_common/Annotations/anno/ServiceCenter.dart';
import 'package:gm_flutter/MainRouter/service/remote/entity/CityBean.dart';
import 'package:gm_flutter/MainRouter/service/remote/entity/TestBean.dart';
@ServiceCenter()
abstract class MainApi{
@Get("api/demo/test")
TestBean isOk();
@Get("api/city/located")
CityBean getCity();
}
\ No newline at end of file
......@@ -15,6 +15,7 @@ import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:gm_flutter/MainRouter/service/remote/entity/TestBean.dart';
import 'package:gm_flutter/MainRouter/service/remote/entity/CityBean.dart';
const bool inProduction = const bool.fromEnvironment("dart.vm.product");
......@@ -45,6 +46,19 @@ class MainApiImpl {
});
}
Stream<CityBean> getCity(
Dio _dio,
) {
return Stream.fromFuture(get(_dio, 'api/city/located')).flatMap((value) {
if (value != null &&
(value.statusCode >= 200 && value.statusCode < 300)) {
return Stream.fromFuture(compute(parseCityBean, value.toString()));
} else {
throw Exception("--未知网络错误--");
}
});
}
///==================base method==================
Future<Response> get(Dio _dio, url, {data, options, cancelToken}) async {
......@@ -185,3 +199,7 @@ class MainApiImpl {
TestBean parseTestBean(String value) {
return TestBean.fromJson(json.decode(value));
}
CityBean parseCityBean(String value) {
return CityBean.fromJson(json.decode(value));
}
/*
* @author lsy
* @date 2020/7/14
**/
class CityBean {
String message;
Extra extra;
Data data;
int error;
CityBean({this.message, this.extra, this.data, this.error});
CityBean.fromJson(Map<String, dynamic> json) {
message = json['message'];
extra = json['extra'] != null ? new Extra.fromJson(json['extra']) : null;
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
error = json['error'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['message'] = this.message;
if (this.extra != null) {
data['extra'] = this.extra.toJson();
}
if (this.data != null) {
data['data'] = this.data.toJson();
}
data['error'] = this.error;
return data;
}
}
class Extra {
Extra();
Extra.fromJson(Map<String, dynamic> json) {
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
return data;
}
}
class Data {
String cityId;
String cityName;
Data({this.cityId, this.cityName});
Data.fromJson(Map<String, dynamic> json) {
cityId = json['city_id'];
cityName = json['city_name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['city_id'] = this.cityId;
data['city_name'] = this.cityName;
return data;
}
}
......@@ -2,30 +2,31 @@
* @author lsy
* @date 2020/7/6
**/
const String APP_NAME="app_name";
const String VERSION="version";
const String PLATFORM="platform";
const String DEVICE_ID="device_id";
const String OS_VERSION="os_version";
const String MODEL="model";
const String SCREEN="screen";
const String LAT="lat";
const String LNG="lng";
const String CHANNEL="channel";
const String MANUFACTURER="manufacturer";
const String UUID="uuid";
const String ANDROID_DEVICE_ID="android_device_id";
const String CURRENT_CITY_ID="current_city_id";
const String RELEASE="release";
const String IDFA="idfa";
const String IDFV="idfv";
const String IS_WIFI="is_WiFi";
const String HARDWARE_MODEL="hardware_model";
const String APP_NAME = "app_name";
const String VERSION = "version";
const String PLATFORM = "platform";
const String DEVICE_ID = "device_id";
const String OS_VERSION = "os_version";
const String MODEL = "model";
const String SCREEN = "screen";
const String LAT = "lat";
const String LNG = "lng";
const String CHANNEL = "channel";
const String MANUFACTURER = "manufacturer";
const String UUID = "uuid";
const String ANDROID_DEVICE_ID = "android_device_id";
const String CURRENT_CITY_ID = "current_city_id";
const String RELEASE = "release";
const String IDFA = "idfa";
const String IDFV = "idfv";
const String IS_WIFI = "is_WiFi";
const String HARDWARE_MODEL = "hardware_model";
//head
const String USER_AGENT="User-Agent";
const String COOKIE="cookie";
const String USER_AGENT = "User-Agent";
const String COOKIE = "cookie";
//user
const String USER_ID="user_id";
const String BASE_URL="base_url";
const String USER_ID = "user_id";
const String BASE_URL = "base_url";
const String URL_ISCHANE = "URL_ISCHANE";
......@@ -3,6 +3,8 @@
* @date 2019-10-13
**/
import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
......@@ -96,7 +98,7 @@ Text baseText(String text, double fontSize, Color color,
fontSize: fontSize,
color: color,
fontStyle: FontStyle.normal,
fontWeight: bold ? FontWeight.w700 : FontWeight.w400),
fontWeight: bold ? FontWeight.w600 : FontWeight.w400),
maxLines: maxLines,
overflow: overflow == null ? TextOverflow.ellipsis : overflow,
);
......@@ -149,7 +151,7 @@ Widget netErrorItem() {}
Widget errorItem(double width, double height, VoidCallback retry,
{String errorText, String retryText, double paddingTop}) {
return Container(
color: Colors.white,
color: Colors.white,
width: width,
height: height,
padding: EdgeInsets.only(top: paddingTop ?? 0),
......@@ -502,20 +504,27 @@ Widget baseSliverAppBar(String url,
elevation: elevation ?? 0,
expandedHeight: height ?? 200,
automaticallyImplyLeading: false,
bottom: PreferredSize(
preferredSize: Size.fromHeight(Platform.isIOS ? -12 : -6),
child: SizedBox(
height: 0,
),
),
flexibleSpace: FlexibleSpaceBar(
background: needpic
? CachedNetworkImage(
imageUrl: url ?? '',
fit: BoxFit.cover,
fit: BoxFit.fitHeight,
)
: Container(),
),
);
}
Widget baseSliverBack(VoidCallback tap) {
Widget baseSliverBack(VoidCallback tap, context) {
final double topPadding = MediaQuery.of(context).padding.top;
return Positioned(
top: 45,
top: topPadding + 12,
left: 7,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
......@@ -536,9 +545,10 @@ Widget baseSliverBack(VoidCallback tap) {
);
}
Widget baseSliverTitle(String text, double width, LiveData liveData) {
Widget baseSliverTitle(String text, double width, LiveData liveData, context) {
final double topPadding = MediaQuery.of(context).padding.top;
return Positioned(
top: 46,
top: topPadding + 13,
child: StreamBuilder(
stream: liveData.stream,
initialData: liveData.data ?? 0.0,
......
......@@ -3,9 +3,3 @@
* @date 2019-10-14
**/
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
const bool isDebug = !const bool.fromEnvironment("dart.vm.product");
......@@ -7,6 +7,7 @@
import 'package:gm_flutter/commonModel/base/BaseUtil.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../main.dart';
import 'CacheManager.dart';
class ShareCache implements ICache {
......@@ -19,36 +20,36 @@ class ShareCache implements ICache {
void save(String key, value) {
if (value is String) {
sharedPreferences.setString(key, value).whenComplete(() {
if (isDebug) {
if (!inProduction) {
print("save String ${value} success");
}
});
} else if (value is bool) {
sharedPreferences.setBool(key, value).whenComplete(() {
if (isDebug) {
if (!inProduction) {
print("save bool ${value} success");
}
});
} else if (value is double) {
sharedPreferences.setDouble(key, value).whenComplete(() {
if (isDebug) {
if (!inProduction) {
print("save double ${value} success");
}
});
} else if (value is int) {
sharedPreferences.setInt(key, value).whenComplete(() {
if (isDebug) {
if (!inProduction) {
print("save int ${value} success");
}
});
} else if (value is List<String>) {
sharedPreferences.setStringList(key, value).whenComplete(() {
if (isDebug) {
if (!inProduction) {
print("save StringList ${value} success");
}
});
} else {
if (isDebug) {
if (!inProduction) {
throw Exception("save error type");
}
}
......
......@@ -8,6 +8,7 @@ import 'dart:math';
import 'package:dio/dio.dart';
import 'package:gm_flutter/commonModel/base/BaseUtil.dart';
import '../../main.dart';
import 'DioUtil.dart';
/**
......@@ -21,6 +22,7 @@ const String APP_HOST_RELEASE = "https://backend.igengmei.com";
//const String APP_HOST_DEBUG = "http://doctor.paas-merchant.env";
// const String APP_HOST_DEBUG = "https://x6cgr5y5-gengmei.mock.coding.io";
const String APP_HOST_DEBUG = "http://backend.paas-merchant.env";
//const String APP_HOST_DEBUG = "https://backend.igengmei.com";
//const String APP_HOST_DEBUG = "http://janus.paas-merchant.env";
/**
......@@ -41,7 +43,7 @@ class Api {
}
String getBaseUrl() {
if (!isDebug) {
if (inProduction) {
return APP_HOST_RELEASE;
} else {
return APP_HOST_DEBUG;
......
......@@ -17,9 +17,6 @@ class DioUtil {
static Map<String, dynamic> addHeadMap;
/// 是否是debug模式.
static bool _isDebug = isDebug;
static DioUtil getInstance() {
return _instance;
}
......@@ -72,7 +69,6 @@ class DioUtil {
headers['User-Agent'] = agent;
}
_options.headers = headers;
print("ISEMPTY ?? ${baseUrl}");
_options.baseUrl = baseUrl ?? "${Api.getInstance().getBaseUrl()}/";
}
}
......@@ -7,6 +7,7 @@ import 'package:flutter_common/commonModel/util/WindowUtil.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:gm_flutter/main.mark.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'commonModel/base/BaseComponent.dart';
import 'commonModel/base/BaseUtil.dart';
import 'commonModel/cache/CacheManager.dart';
......@@ -14,12 +15,14 @@ import 'commonModel/nav/NavigationService.dart';
import 'main.mark.dart';
NavigationService navigationService;
bool inProduction = true;
void main() {
inProduction = bool.fromEnvironment("dart.vm.product");
navigationService = NavigationService();
WidgetsFlutterBinding.ensureInitialized();
FlutterError.onError = (FlutterErrorDetails details) async {
if (isDebug) {
if (!inProduction) {
FlutterError.dumpErrorToConsole(details);
} else {
Zone.current.handleUncaughtError(details.exception, details.stack);
......@@ -121,7 +124,7 @@ class HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
ScreenUtil.init(context, width: 375, height: 667);
return isDebug
return !inProduction
? RouterCenterImpl().findMainRouter().getTestPage()
: Container(
color: Colors.white,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment