Commit 1253304c authored by 杜欣's avatar 杜欣

Merge branch 'dev' into dx/message

# Conflicts:
#	lib/TestPage.dart
#	lib/commonModel/base/BaseComponent.dart
#	lib/res/value/ALColors.dart
parents b223e407 bb45d9f5
......@@ -84,10 +84,9 @@ flutter {
source '../..'
}
dependencies {
// implementation 'com.squareup.okhttp3:okhttp:3.7.0'
// implementation 'com.qiniu:qiniu-android-sdk:7.4.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
......@@ -64,11 +64,15 @@ class MainActivity : FlutterActivity() {
} else if (call.method == "INIT_PARAMS") {
val map = HashMap<String, String>()
map.put("buildConfig", "debug")
map.put("provider","com.example.gmalpha_flutter")
map.put("provider", "com.example.gmalpha_flutter")
//HERE
// map.put("proxy", "172.30.9.84:6666");
result.success(map)
} else {
} else if (call.method == "UPLOAD_IMG") {
result.success("2019/10/17/1156/44dbb13ac6d9");
} else if(call.method =="USER_LOGOUT"){
result.success(true)
}else {
result.notImplemented()
}
}
......
package com.example.gmalpha_flutter.util;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
public class UploadMD5Key {
private String myValue = "";
private String endValue = "";
private String myKey = "";
public static String getKey(){
SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd/HHmm");
String t=format.format(new Date());
long timeStamp = System.currentTimeMillis();
String str = timeStamp+getRandomString();
String myValue = "";
String endValue = "";
try {
myValue = md5(str);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
endValue = myValue.substring(0,12);
return t+"/"+endValue;
}
public static String getRandomString(){
String base = "abcdefghijklmnopqrstuvwxyz0123456789";
int randomNum;
char randomChar;
Random random = new Random();
// StringBuffer类型的可以append增加字符
StringBuffer str = new StringBuffer();
for (int i = 0; i < 32; i++) {
// 可生成[0,n)之间的整数,获得随机位置
randomNum = random.nextInt(base.length());
// 获得随机位置对应的字符
randomChar = base.charAt(randomNum);
// 组成一个随机字符串
str.append(randomChar);
}
return str.toString();
}
public static String md5(String data) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(data.getBytes());
StringBuffer buf = new StringBuffer();
byte[] bits = md.digest();
for(int i=0;i<bits.length;i++){
int a = bits[i];
if(a<0) a+=256;
if(a<16) buf.append("0");
buf.append(Integer.toHexString(a));
}
return buf.toString();
}
}
......@@ -4,6 +4,7 @@ buildscript {
google()
jcenter()
maven {url 'https://dl.google.com/dl/android/maven2'}
mavenCentral()
}
dependencies {
......@@ -17,6 +18,8 @@ allprojects {
maven {url 'https://dl.google.com/dl/android/maven2'}
google()
jcenter()
mavenCentral()
maven { url "https://dl.bintray.com/thelasterstar/maven/" }
}
}
......
......@@ -56,6 +56,7 @@ function android_apk(){
cd /Users/apple/lsy/gmalpha_flutter/build/app/outputs/apk/${suff}/
unzip /Users/apple/lsy/gmalpha_flutter/build/app/outputs/apk/${suff}/app-${suff}.zip
cp -r /Users/apple/lsy/gmalpha_flutter/build/app/outputs/apk/${suff}/lib/armeabi-v7a/libapp.so /Users/apple/lsy/gengmei_alpha/alpha/libs/armeabi-v7a
cp -r /Users/apple/lsy/gmalpha_flutter/build/app/outputs/apk/${suff}/lib/armeabi-v7a/libflutter.so /Users/apple/lsy/gengmei_alpha/alpha/libs/armeabi-v7a
rm -rf /Users/apple/lsy/gengmei_alpha/alpha/src/main/assets/flutter_assets
cp -r /Users/apple/lsy/gmalpha_flutter/build/app/outputs/apk/${suff}/assets/flutter_assets /Users/apple/lsy/gengmei_alpha/alpha/src/main/assets/
......@@ -127,8 +128,8 @@ function upload_android_aar(){
./gradlew clean
./gradlew assembleRelease
./gradlew uploadArchives
cp -r /Users/apple/lsy/MergeTest/app/build/outputs/aar/app.aar /Users/apple/lsy/Test/app/libs/
cp -r /Users/apple/lsy/MergeTest/app/build/outputs/aar/app.aar /Users/apple/lsy/gmalpha_flutter/build/
# cp -r /Users/apple/lsy/MergeTest/app/build/outputs/aar/app.aar /Users/apple/lsy/Test/app/libs/
# cp -r /Users/apple/lsy/MergeTest/app/build/outputs/aar/app.aar /Users/apple/lsy/gmalpha_flutter/build/
cd /Users/apple/lsy/flutter_aar
git add .
......@@ -142,6 +143,7 @@ function upload_android_aar(){
function ios(){
cd ${projectDir}
flutter build ios --release --no-codesign
lipo -remove x86_64 /Users/apple/lsy/gmalpha_flutter/ios/Flutter/Flutter.framework/Flutter -o /Users/apple/lsy/gmalpha_flutter/ios/Flutter/Flutter.framework/Flutter
cp -r /Users/apple/lsy/gmalpha_flutter/ios/Flutter/App.framework /Users/apple/lsy/aar_update/ios${message}/
rm -rf /Users/apple/lsy/GMAlpha/GMAlpha/Classes/APP/flutter_project/App.framework
rm -rf /Users/apple/lsy/GMAlpha/GMAlpha/Classes/APP/flutter_project/Flutter.framework
......@@ -234,11 +236,11 @@ mkdir /Users/apple/lsy/aar_update/androd${message}/
mkdir /Users/apple/lsy/aar_update/ios${message}/
clean
#android_apk
android_apk
#android
#android_publish
#upload_android_aar
ios
#ios
#ios_publish
#notifyDingDing
......
//
// ALUpLoadManager.h
// GMAlpha
//
// Created by zhouLiang on 2018/11/26.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef void(^returnImageUrlBlock)(NSString *path);
typedef void(^returnFailBlock)(NSString *message);
@interface ALUpLoadManager : NSObject
+ (instancetype)shareInstance;
@property (nonatomic, assign) NSString *fileSuffer;
- (void)setImage:(NSString *)filePath token:(NSString*)token block:(returnImageUrlBlock)block failBlock:(returnFailBlock)failBlock;
@end
//
// ALUpLoadManager.m
// GMAlpha
//
// Created by zhouLiang on 2018/11/26.
// Copyright © 2018 Gengmei. All rights reserved.
//
#import "ALUpLoadManager.h"
#import "QNUploadManager.h"
#import "QNResponseInfo.h"
#import "QNConfiguration.h"
#import <CommonCrypto/CommonDigest.h>
#import "QNConfiguration.h"
@interface ALUpLoadManager ()
@property (nonatomic, copy) NSString *token;
@end
@implementation ALUpLoadManager
+ (instancetype)shareInstance
{
static dispatch_once_t onceToken;
static id instance = nil;
dispatch_once(&onceToken, ^{
instance = [[[self class] alloc] init];
});
return instance;
}
/**
* 七牛上传文件
*/
- (void)setImage:(NSString *)filePath token:(NSString*)token block:(returnImageUrlBlock)block failBlock:(returnFailBlock)failBlock{
dispatch_group_t group = dispatch_group_create();
dispatch_group_enter(group);
dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
QNConfiguration *config = [QNConfiguration build:^(QNConfigurationBuilder *builder) {
builder.timeoutInterval = 60;
}];
QNUploadManager *upManager = [[QNUploadManager alloc] initWithConfiguration:config];
NSString *key = [self createImagePath];
[upManager putFile:filePath key:key token:token complete:^(QNResponseInfo *info, NSString *key,NSDictionary *resp) {
if (info.ok) {
// 上传成功
if (block != nil) {
block(key);
}
} else {
if (failBlock != nil) {
failBlock(@"上传失败");
}
}
dispatch_group_leave(group);
} option:nil];
});
};
// 生成图片或者文件的路径
- (NSString *)createImagePath {
NSString *imagePath = @"";
// 1、先取 当前时间 按照 "年/月/日/时分" 转换 作为图片路径的上半部分--> 2018/10/25/1821
NSDate* date = [NSDate dateWithTimeIntervalSinceNow:0];//获取当前时间0秒后的时间
NSTimeInterval timeNow = [date timeIntervalSince1970];
NSString *frontPart = [self getDateStringWithTimeStr:timeNow];
imagePath = [imagePath stringByAppendingString:frontPart];
// 2、取当前的时间戳 + 随机字符串(长度 32) 组成字符串,将该字符串 MD5哈希,取该哈希值的前 12位 作为图片路径的下半部分 --> caf8f8d86886
NSString *timeNowStr = [NSString stringWithFormat:@"%lld", timeNow];
NSString *radomStr = [self getRadomString];
NSString *secondPart = [timeNowStr stringByAppendingString:radomStr];
NSString *secondPartMD5 = [[self MD5ForLower32Bate:secondPart] substringToIndex:12];
return [NSString stringWithFormat:@"%@/%@", imagePath, secondPartMD5];
}
// 时间戳转字符串
- (NSString *)getDateStringWithTimeStr:(float )time{
NSDate *detailDate=[NSDate dateWithTimeIntervalSince1970:time];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; //实例化一个NSDateFormatter对象
//设定时间格式,这里可以设置成自己需要的格式
[dateFormatter setDateFormat:@"yyyy/MM/dd/HHmm"];
NSString *currentDateStr = [dateFormatter stringFromDate: detailDate];
return currentDateStr;
}
// 取随机字符串
- (NSString *)getRadomString {
NSArray *array = [[NSArray alloc] initWithObjects:@"a",@"b",@"c",@"d",@"e",@"f",@"g",@"h",@"i",@"j",@"k",@"l",@"m",@"n",@"o",@"p",@"q",@"r",@"s",@"t",@"u",@"v",@"w",@"x",@"y",@"z",@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",nil];
NSMutableArray *randomArray = [[NSMutableArray alloc] init];
while (randomArray.count < 32) {
int r = arc4random() % [array count];
[randomArray addObject:[array objectAtIndex:r]];
}
return [randomArray componentsJoinedByString:@""];
}
// MD5加密
-(NSString *)MD5ForLower32Bate:(NSString *)str{
//要进行UTF8的转码
const char* input = [str UTF8String];
unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5(input, (CC_LONG)strlen(input), result);
NSMutableString *digest = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
for (NSInteger i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
[digest appendFormat:@"%02x", result[i]];
}
return digest;
}
@end
#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
#include <flutter_boost/FlutterBoostPlugin.h>
#include "ALUpLoadManager.h"
@implementation AppDelegate
......@@ -67,6 +68,19 @@
//HERE
// [dict setObject:@"172.30.9.84:6666" forKey:@"proxy"];
result(dict);
}else if([call.method isEqualToString:@"UPLOAD_IMG"]){
// NSString* path=call.arguments[@"path"];
// NSString* token=call.arguments[@"token"];
// [[ALUpLoadManager shareInstance] setImage:path token:token block:^(NSString *url) {
// result(url);
// NSLog(@"!!!OKK %@",url);
// } failBlock:^(NSString *message) {
// NSLog(@"!!!ERROR %@",message);
// result([FlutterError errorWithCode:@"11" message:message details:message]);
// }];
// NSData *data = [NSData dataWithContentsOfFile:path];
// UIImage * printerImg = [UIImage imageWithData:data];
result(@"2019/10/17/1156/44dbb13ac6d9");
}
}];
}
......
......@@ -68,7 +68,7 @@ class ActivityReportState extends BasePage<ActivityReportPage> {
.findBuriedRouter()
?.onClick(pageName(), "test_again");
Navigator.pop(context, "");
jumpToH5("question", null);
jumpToH5("question", {"template_id": _model.type});
},
)
],
......@@ -502,15 +502,17 @@ class AnimationNumberState extends State<AnimationNumber>
}
clearState() {
_timer.dispose();
super.dispose();
_animationController.dispose();
_timer.dispose();
}
@override
Widget build(BuildContext context) {
_timer = Timer(Duration(seconds: 1), () {
_animationController.forward();
if (_animationController != null) {
_animationController.forward();
}
});
return widget.container(_animationController.value.toInt());
}
......@@ -561,8 +563,8 @@ class AnimationCharacterState extends State<AnimationCharacter>
];
final target = (widget.targetNmber / 10).ceil();
_animationController.addListener(() {
var value = _animationController.value;
_animationController?.addListener(() {
var value = _animationController?.value;
double percent = value / 10;
double frist = target / 10;
int nowValue;
......@@ -593,9 +595,9 @@ class AnimationCharacterState extends State<AnimationCharacter>
}
clearState() {
_timer.dispose();
super.dispose();
_animationController.dispose();
_timer.dispose();
}
Widget _peopleViewUI(BuildContext context, item) {
......@@ -612,7 +614,9 @@ class AnimationCharacterState extends State<AnimationCharacter>
@override
Widget build(BuildContext context) {
_timer = Timer(Duration(seconds: 1), () {
_animationController.forward();
if (_animationController != null) {
_animationController.forward();
}
});
return Column(
children: <Widget>[
......
......@@ -52,7 +52,12 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
if(_${fieldData.name}!=null){
return Observable.fromFuture(Future.value(_${fieldData.name}));
}
return Observable.fromFuture(spUtil.getStringKv("${key}"));
return Observable.fromFuture(spUtil.getStringKv("${key}")).map((value){
if(value==""){
return null;
}
return value;
});
}
""");
} else if (type == "int") {
......
......@@ -28,8 +28,8 @@ class BuriedImpl implements BuriedRouter {
@override
void onEvent(String type, Map<String, String> params) {
print("lsy !! ON EVENT ");
BuriedCenter.getInstance().onEvent(type, params);
print("lsy !! ON EVENT --> ");
}
@override
......
......@@ -29,16 +29,16 @@ class SendTask {
void _sendBuriedData(BuryingRequest request) {
getNetType().listen((value) {
_deviceInfo.netType = value;
_deviceInfo.netType = value??"";
request.device = _deviceInfo;
print("FLUTTER 埋点 --> $request");
_client
.dataReport(Stream.fromFuture(Future.value(request)))
.listen((data) {
print("埋点响应 --> $data");
}).onError((error) {
print(error);
});
.dataReport(Stream.fromFuture(Future.value(request)));
// .listen((data) {
// print("埋点响应 --> $data");
// }).onError((error) {
// print(error);
// });
}).onError((error) {
print("FLUTTER 埋点ERROR --> $error");
_client.dataReport(Stream.fromFuture(Future.value(request)));
......
......@@ -9,6 +9,7 @@ import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
import 'package:gmalpha_flutter/PrestigeModel/page/reputation/ReputationsModel.dart';
import 'package:gmalpha_flutter/PrestigeModel/service/remote/entity/PrestigeEntity.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:gmalpha_flutter/commonModel/base/BaseComponent.dart';
import 'package:gmalpha_flutter/commonModel/base/BasePage.dart';
import 'package:flutter_svg/flutter_svg.dart';
......@@ -41,35 +42,27 @@ class ReputationsState extends BasePage<ReputationsPage> {
screenWidth = MediaQuery.of(context).size.width;
return WillPopScope(
child: Scaffold(
appBar: AppBar(
title: StreamBuilder<String>(
stream: _model.titleLive.stream,
initialData: _model.titleLive.data,
builder: (context, data) {
if (data.data == null) {
return MyText(16, '我的专家声望', 0xff323232);
}
String titleWord = '${data.data}的专家声望';
if (titleWord.length > 10) {
titleWord = titleWord.substring(0, 10) + "...";
}
return MyText(16, titleWord, 0xff323232);
},
),
centerTitle: true,
leading: GestureDetector(
onTap: () {
_model.pop(context, pageName());
},
child: Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(left: 22),
width: 30,
height: double.maxFinite,
child: SvgPicture.asset("images/left_arrow.svg",
color: Color(0xff323232)),
),
)),
appBar:
baseAppBarChangeTitle(
title: StreamBuilder<String>(
stream: _model.titleLive.stream,
initialData: _model.titleLive.data,
builder: (context, data) {
if (data.data == null) {
return MyText(16, '我的专家声望', 0xff323232);
}
String titleWord = '${data.data}的专家声望';
if (titleWord.length > 10) {
titleWord = titleWord.substring(0, 10) + "...";
}
return MyText(16, titleWord, 0xff323232);
},
),
centerTitle: true,
backClick: () {
_model.pop(context, pageName());
},
),
body: StreamBuilder<PrestigeEntity>(
stream: _model.prestigeLive.stream,
initialData: _model.prestigeLive.data,
......
......@@ -13,7 +13,7 @@ class TestPage extends StatelessWidget {
TestPage() {
Api.getInstance().setDioCookie({
'Cookie':
'sessionid=k96qdzwb3bquf87g32kdfbn676jkfnmk; _gtid=6bcbb61eebf411e9bfa4525400e82fab7541; _gm_token=e0fc1c1570864112'
'sessionid=ley6ne6wdi3w4sapyqgwa5mtjberyaum;_gtid=d7fdc2def3b311e99a80525400e82fab3556;_gm_token=4ab9e41571629122'
});
}
......
......@@ -15,3 +15,5 @@ export 'net/Api.dart';
export 'net/DioUtil.dart';
export 'net/Responce/SimpleResponce.dart';
export 'net/ALNetWork.dart';
export 'picker/loadingPicker.dart';
export 'picker/base/BaseCenterPicker.dart';
......@@ -2,7 +2,10 @@
* @author lsy
* @date 2019-09-24
**/
import 'dart:async';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:gmalpha_flutter/commonModel/cache/CacheManager.dart';
import 'package:gmalpha_flutter/commonModel/net/Api.dart';
......@@ -12,6 +15,8 @@ import 'package:rxdart/rxdart.dart';
const BURIED_METHOD = "FLUTTER_BURIED";
const NET_TYPE = "GET_NET_TYPE";
const INIT_PARAMS = "INIT_PARAMS";
const UPLOAD_IMG = "UPLOAD_IMG";
const USER_LOGOUT = "USER_LOGOUT";
const platform = const MethodChannel('flutter_bury_channel');
void jumpToH5(String jumpToName, Map params) {
......@@ -38,6 +43,15 @@ Observable getNetType() {
return Observable.fromFuture(platform.invokeMethod(NET_TYPE, null));
}
Observable<String> uploadImg(String path, String token) {
return Observable.fromFuture(
platform.invokeMethod(UPLOAD_IMG, {"path": path, "token": token}));
}
Observable<bool> userLogout() {
return Observable.fromFuture(platform.invokeMethod(USER_LOGOUT));
}
void initParams(VoidCallback callback) {
platform.invokeMethod(INIT_PARAMS, null).then((value) {
print("lsy INITPARAMS !! $value");
......@@ -56,11 +70,43 @@ void initBuried(VoidCallback call) {
CacheManager.getInstance().get(MEMORY_CACHE).save(k, v);
});
call();
// catchAllError();
}).catchError((error) {
print(error);
});
}
void catchAllError(VoidCallback call) {
FlutterError.onError = (FlutterErrorDetails details) {
reportErrorAndLog(details);
};
runZoned(
() => call(),
zoneSpecification: ZoneSpecification(
print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
collectLog(line); // 收集日志
},
),
onError: (Object obj, StackTrace stack) {
var details = makeDetails(obj, stack);
reportErrorAndLog(details);
},
);
}
void collectLog(String line) {
//收集日志
}
void reportErrorAndLog(FlutterErrorDetails details) {
//上报错误和日志逻辑
}
FlutterErrorDetails makeDetails(Object obj, StackTrace stack) {
// 构建错误信息
}
String getNowTimeSecond() {
return "${DateTime.now().millisecondsSinceEpoch}";
// String year = "${DateTime.now().year}".length == 4
......
......@@ -13,9 +13,24 @@ AppBar baseAppBar(
List<Widget> action,
bool centerTitle,
VoidCallback backClick}) {
return baseAppBarChangeTitle(
title: title == null
? Container()
: baseText(title, 16, ALColors.Color323232),
action: action,
centerTitle: centerTitle,
backClick: backClick);
}
AppBar baseAppBarChangeTitle(
{Widget title,
List<Widget> action,
bool centerTitle,
VoidCallback backClick}) {
return AppBar(
title: title == null ? Container() : baseText(title, 16, ALColors.Color323232),
title: title,
centerTitle: centerTitle,
elevation: 0.0,
leading: GestureDetector(
onTap: backClick,
child: Container(
......@@ -23,10 +38,12 @@ AppBar baseAppBar(
padding: EdgeInsets.only(left: 22),
width: 30,
height: double.maxFinite,
child: SvgPicture.asset(
"images/left_arrow.svg",
color: Color(0xff323232),
)),
child: Hero(
tag: "left_arrow",
child: SvgPicture.asset(
"images/left_arrow.svg",
color: Color(0xff323232),
))),
),
actions: action == null ? List<Widget>() : action,
);
......@@ -39,6 +56,9 @@ Text baseText(String text, double fontSize, Color color) {
);
}
/**
* 基础的liveView分割线
*/
Widget baseDivide(double height, double padding, Color color) {
return Container(
height: height,
......
......@@ -2,6 +2,8 @@
* @author lsy
* @date 2019-10-08
**/
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
......@@ -9,6 +11,9 @@ import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
abstract class BasePage<T extends StatefulWidget> extends State<T> {
var startTime;
double screenWidth = window.physicalSize.width;
double screenHeight = window.physicalSize.height;
String pageName();
String referrer();
......
......@@ -8,8 +8,6 @@ import 'dart:ui';
import 'package:flutter/material.dart';
double screenWidth = window.physicalSize.width;
double screenHeight = window.physicalSize.height;
void jumpToPage(Widget page, BuildContext context) {
Navigator.push(context, MaterialPageRoute(builder: ((context) {
......
......@@ -3,23 +3,47 @@
* @date 2019-09-05
**/
class SimpleResponce {
Null data;
int errorCode;
String errorMsg;
int error;
String message;
Null extra;
Data data;
SimpleResponce({this.data, this.errorCode, this.errorMsg});
SimpleResponce({this.error, this.message, this.extra, this.data});
SimpleResponce.fromJson(Map<String, dynamic> json) {
data = json['data'];
errorCode = json['errorCode'];
errorMsg = json['errorMsg'];
error = json['error'];
message = json['message'];
extra = json['extra'];
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['data'] = this.data;
data['errorCode'] = this.errorCode;
data['errorMsg'] = this.errorMsg;
data['error'] = this.error;
data['message'] = this.message;
data['extra'] = this.extra;
if (this.data != null) {
data['data'] = this.data.toJson();
}
return data;
}
}
\ No newline at end of file
}
class Data {
int error;
String message;
Data({this.error, this.message});
Data.fromJson(Map<String, dynamic> json) {
error = json['error'];
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['error'] = this.error;
data['message'] = this.message;
return data;
}
}
/*
* @author lsy
* @date 2019-10-18
**/
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gmalpha_flutter/ActivityReportModel/page/ActivityReportPage.dart';
import 'package:gmalpha_flutter/commonModel/picker/base/DialogRouter.dart';
class BaseCenterPicker extends StatefulWidget {
BaseCenterPickerState centerState;
ICenterPicker picker;
bool cancelOutSide = true;
setPicker(ICenterPicker picker) {
this.picker = picker;
centerState?.setState(() {});
}
setCancelOutside(bool cancel) {
this.cancelOutSide = cancel;
centerState?.setState(() {});
}
show(BuildContext context) {
Navigator.push(context, DialogRouter(this));
}
dismiss(BuildContext context) {
Navigator.pop(context);
}
@override
State<StatefulWidget> createState() {
centerState = BaseCenterPickerState();
return centerState;
}
}
class BaseCenterPickerState extends State<BaseCenterPicker> {
@override
Widget build(BuildContext context) {
ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
return Container(
color: Colors.black54,
width: double.maxFinite,
height: double.maxFinite,
child: Stack(
children: <Widget>[
GestureDetector(
onTap: () {
if (widget.cancelOutSide) {
widget.dismiss(context);
}
},
),
Center(
child: Material(
color: Colors.transparent,
child: widget.picker.build(context),
))
],
),
);
}
}
abstract class ICenterPicker {
Widget build(BuildContext context);
}
/*
* @author lsy
* @date 2019-10-21
**/
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:gmalpha_flutter/commonModel/GMBase.dart';
class BaseLoadingItem implements ICenterPicker {
final String loadingText;
BaseLoadingItem(this.loadingText);
@override
Widget build(BuildContext context) {
return Center(
///弹框大小
child: new Container(
width: 120.0,
height: 120.0,
child: new Container(
///弹框背景和圆角
decoration: ShapeDecoration(
color: Color(0xffffffff),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0),
),
),
),
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new CircularProgressIndicator(),
new Padding(
padding: const EdgeInsets.only(
top: 20.0,
),
child: new Text(
loadingText,
style: new TextStyle(fontSize: 16.0),
),
),
],
),
),
),
);
}
}
/*
* @author lsy
* @date 2019-10-18
**/
import 'package:flutter/material.dart';
class DialogRouter extends PageRouteBuilder {
final Widget page;
DialogRouter(this.page)
: super(
opaque: false,
pageBuilder: (context, animation, secondaryAnimation) => page,
transitionsBuilder:
(context, animation, secondaryAnimation, child) {
return child;
});
}
/*
* @author lsy
* @date 2019-10-18
**/
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/commonModel/picker/base/DialogRouter.dart';
Future popLoadingDialog(
BuildContext context, bool canceledOnTouchOutside, String text) {
return Navigator.push(
context, DialogRouter(LoadingDialog(canceledOnTouchOutside, text)));
}
void dismissLoadingDialog(BuildContext context) {
Navigator.pop(context);
}
class LoadingDialog extends Dialog {
LoadingDialog(this.canceledOnTouchOutside, this.text) : super();
///点击背景是否能够退出
final bool canceledOnTouchOutside;
final String text;
@override
Widget build(BuildContext context) {
return Center(
child: new Material(
///背景透明
color: Colors.black54,
///保证控件居中效果
child: Stack(
children: <Widget>[
GestureDetector(
///点击事件
onTap: () {
if (canceledOnTouchOutside) {
Navigator.pop(context);
}
},
),
_dialog()
],
)),
);
}
Widget _dialog() {
return new Center(
///弹框大小
child: new Container(
width: 120.0,
height: 120.0,
child: new Container(
///弹框背景和圆角
decoration: ShapeDecoration(
color: Color(0xffffffff),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0),
),
),
),
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new CircularProgressIndicator(),
new Padding(
padding: const EdgeInsets.only(
top: 20.0,
),
child: new Text(
text,
style: new TextStyle(fontSize: 16.0),
),
),
],
),
),
),
);
}
}
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
......@@ -14,6 +15,7 @@ import 'commonModel/GMBase.dart';
void main() {
initParams(() => runApp(MyApp()));
}
class MyApp extends StatefulWidget {
......@@ -22,10 +24,26 @@ class MyApp extends StatefulWidget {
}
class _MyAppState extends State<MyApp> {
var buildOnce = FlutterBoost.init(
postPush: (String pageName, String uniqueId, Map params, Route route,
Future _) {
print("FLUTTER PUSHED $pageName");
});
@override
void initState() {
super.initState();
FlutterBoost.singleton.registerPageBuilders({
'comment_suggest': (pageName, params, _) {
if (!Api.getInstance().setDioCookie(params) ||
params["fromPage"] == null) {
return ErrorPage("出错:需要传递的参数为空");
}
return RouterCenterImpl()
.findUserRouter()
?.getCommentPage(params["fromPage"]);
},
'message_home': (pageName, params, _) => MessageHomePage(params),
'album': (pageName, params, _) {
if (params == null) {
......@@ -52,6 +70,16 @@ class _MyAppState extends State<MyApp> {
return RouterCenterImpl().findPrestigeRouter()?.getReputationsPage(
userId, params["userName"], params["fromPage"]);
},
"user_setting": (pageName, params, _) {
print("PARAMS!! ${params}");
if (!Api.getInstance().setDioCookie(params) ||
params["fromPage"] == null) {
return ErrorPage("出错:需要传递的参数为空");
}
return RouterCenterImpl()
.findUserRouter()
?.getUserSettingPage(params["userId"] ?? "", params["fromPage"]);
},
"activity_report": (pageName, params, _) {
print("PARAMS!! ${params}");
if (!Api.getInstance().setDioCookie(params) ||
......@@ -61,13 +89,13 @@ class _MyAppState extends State<MyApp> {
return RouterCenterImpl()
.findActivityReportRouter()
?.getActivityReportPage(
params["survey_record_id"] == null
? null
: int.parse(params["survey_record_id"]),
params["template_id"] == null
? null
: int.parse(params["template_id"]),
params["fromPage"]);
params["survey_record_id"] == null
? null
: int.parse(params["survey_record_id"]),
params["template_id"] == null
? null
: int.parse(params["template_id"]),
params["fromPage"]);
}
});
FlutterBoost.handleOnStartPage();
......@@ -83,7 +111,7 @@ class _MyAppState extends State<MyApp> {
return TestPage();
},
},
builder: FlutterBoost.init(postPush: _onRoutePushed),
builder: buildOnce,
theme: new ThemeData(
primaryColor: Colors.white,
backgroundColor: Color(0xFFEFEFEF),
......@@ -99,9 +127,4 @@ class _MyAppState extends State<MyApp> {
),
);
}
void _onRoutePushed(
String pageName, String uniqueId, Map params, Route route, Future _) {
print("PUSHED $pageName");
}
}
......@@ -5,52 +5,63 @@
import 'package:flutter/material.dart';
class CustomRoute extends PageRouteBuilder{
final Widget widget;
CustomRoute(this.widget)
:super(
// 设置过度时间
transitionDuration:Duration(milliseconds: 200),
// 构造器
pageBuilder:(
// 上下文和动画
BuildContext context,
Animation<double> animaton1,
Animation<double> animaton2,
){
return widget;
},
transitionsBuilder:(
BuildContext context,
Animation<double> animaton1,
Animation<double> animaton2,
Widget child,
){
enum RouteWay {
SCARE,
TRAN_RIGHT_TO_LEFT,
ALP,
}
// 需要什么效果把注释打开就行了
// 渐变效果
// return FadeTransition(
// // 从0开始到1
// opacity: Tween(begin: 0.0,end: 1.0)
// .animate(CurvedAnimation(
// // 传入设置的动画
// parent: animaton1,
// // 设置效果,快进漫出 这里有很多内置的效果
// curve: Curves.fastOutSlowIn,
// )),
// child: child,
// );
class CustomRoute extends PageRouteBuilder {
final Widget widget;
// 缩放动画效果
// return ScaleTransition(
// scale: Tween(begin: 0.0,end: 1.0).animate(CurvedAnimation(
// parent: animaton1,
// curve: Curves.fastOutSlowIn
// )),
// child: child,
// );
RouteWay routeWay;
CustomRoute(this.widget, {RouteWay routeWay = RouteWay.TRAN_RIGHT_TO_LEFT})
: super(
// 设置过度时间
transitionDuration: Duration(milliseconds: 200),
// 构造器
pageBuilder: (
// 上下文和动画
BuildContext context,
Animation<double> animaton1,
Animation<double> animaton2,
) {
return widget;
},
transitionsBuilder: (
BuildContext context,
Animation<double> animaton1,
Animation<double> animaton2,
Widget child,
) {
// 渐变效果
if (routeWay.index == 2) {
return FadeTransition(
// 从0开始到1
opacity: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
// 传入设置的动画
parent: animaton1,
// 设置效果,快进漫出 这里有很多内置的效果
curve: Curves.fastOutSlowIn,
)),
child: child,
);
} else if (routeWay.index == 1) {
return SlideTransition(
position: Tween<Offset>(
begin: Offset(1.0, 0.0), end: Offset(0.0, 0.0))
.animate(CurvedAnimation(
parent: animaton1, curve: Curves.fastOutSlowIn)),
child: child,
);
} else {
return ScaleTransition(
scale: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: animaton1, curve: Curves.fastOutSlowIn)),
child: child,
);
}
// 旋转加缩放动画效果
// return RotationTransition(
// turns: Tween(begin: 0.0,end: 1.0)
......@@ -67,19 +78,5 @@ class CustomRoute extends PageRouteBuilder{
// child: child,
// ),
// );
// 左右滑动动画效果
return SlideTransition(
position: Tween<Offset>(
// 设置滑动的 X , Y 轴
begin: Offset(1.0, 0.0),
end: Offset(0.0,0.0)
).animate(CurvedAnimation(
parent: animaton1,
curve: Curves.fastOutSlowIn
)),
child: child,
);
}
);
}
\ No newline at end of file
});
}
......@@ -23,5 +23,9 @@ class ALColors {
static const Color ColorF4F3F8 = Color(0xFFf4f3f8);
static const Color Color282828 = Color(0xFF282828);
static const Color ColorE5E5E5 = Color(0xFFe5e5e5);
static const Color Color5276F4 = Color(0xFF5276F4);
static const Color Color0093FF = Color(0xFF0093FF);
static const Color Color666666 = Color(0xFF666666);
}
......@@ -13,4 +13,6 @@ abstract class UserRouter implements RouterBaser {
Widget getUserPage();
Widget getUserSettingPage(String userID, String refer);
Widget getCommentPage(String refer);
}
......@@ -4,6 +4,7 @@
**/
import 'package:flutter/src/widgets/framework.dart';
import 'package:gmalpha_flutter/userModel/UserRouter.dart';
import 'package:gmalpha_flutter/userModel/page/comment/CommentSuggestPage.dart';
import 'package:gmalpha_flutter/userModel/page/userSetting/UserSettingPage.dart';
class UserRouterImpl implements UserRouter {
......@@ -15,4 +16,9 @@ class UserRouterImpl implements UserRouter {
Widget getUserSettingPage(String userID, String refer) {
return UserSettingPage(userID,refer);
}
@override
Widget getCommentPage(String refer) {
return CommentSuggestPage(refer);
}
}
......@@ -21,10 +21,10 @@ class CommentModel extends BaseModel {
.findBuriedRouter()
?.onEvent('click_comment_suggest', {'comment_id': '10086'});
UserRepository.getInstance().commentSuggest(content, phone).listen((value) {
Toast.show(context, "提交成功");
// Toast.show(context, "提交成功");
Navigator.pop(context);
}).onError((error) {
Toast.show(context, "提交失败");
// Toast.show(context, "提交失败");
Toast.debugShow(context, error.message);
print(error.message);
});
......
......@@ -93,7 +93,8 @@ class CountryState extends BasePage {
countryItem(Countries country) {
return GestureDetector(
onTap: () {
Navigator.pop(context, country.name);
Navigator.pop(context,
{"countryId": country.id, "countryName": country.name});
},
child: Container(
alignment: Alignment.centerLeft,
......
......@@ -3,18 +3,17 @@
* @date 2019-09-04
**/
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
import 'package:gmalpha_flutter/commonModel/GMBase.dart';
import 'package:gmalpha_flutter/commonModel/base/BaseUtil.dart';
import 'package:gmalpha_flutter/commonModel/live/BaseModel.dart';
import 'package:gmalpha_flutter/commonModel/net/Api.dart';
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/commonModel/picker/loadingPicker.dart';
import 'package:gmalpha_flutter/commonModel/toast/toast.dart';
import 'package:gmalpha_flutter/userModel/service/UserRepository.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.user.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart';
import 'package:gmalpha_flutter/userModel/util/JumpUtil.dart';
import '../../../commonModel/live/LiveData.dart';
......@@ -27,14 +26,14 @@ class UserSettingModel extends BaseModel {
final String userid;
final String refere;
String selectImgPath, defultName, defultCity;
String selectImgPath, defultName, defultCity, cityId, age;
UserSettingModel(this.userid, this.refere);
init(BuildContext context) {
UserEntityImpl().getuserId().listen((value) {
print("VALUEE $value");
if (value == null || value != userid) {
if (value == null || value != userid || value == "") {
UserRepository.getInstance().getUserInfo(userid).listen((data) {
print(data);
nameLive.notifyView(data?.data?.nickName);
......@@ -42,11 +41,27 @@ class UserSettingModel extends BaseModel {
headImgLive.notifyView(data?.data?.profilePic);
defultName = data?.data?.nickName;
defultCity = data?.data?.countryInfo?.name;
cityId = data?.data?.countryInfo?.id;
age = data?.data?.age;
}).onError((error) {
print(error);
Toast.show(context, error);
Toast.show(context, error.toString());
});
} else {
UserEntityImpl().getage().listen((data) {
print("AGE ${data}");
age = data;
}).onError((e) {
Toast.show(context, e);
print(e);
});
UserEntityImpl().getcityId().listen((data) {
print("CITY ID $data");
cityId = data;
}).onError((e) {
Toast.debugShow(context, e);
print(e);
});
UserEntityImpl().getnickName().listen((data) {
print("NICK $data");
defultName = data;
......@@ -110,16 +125,102 @@ class UserSettingModel extends BaseModel {
void jumpToCTY(BuildContext context, String pageName) {
jumpToCountry(context, pageName).then((value) {
if (value != null) {
cityLive.notifyView(value);
print("COUNTRY $value");
cityId = value["countryId"];
cityLive.notifyView(value["countryName"]);
detectUpdate();
}
}).catchError((error) {
Toast.debugShow(context, error);
Toast.debugShow(context, error.toString());
print(error);
});
}
void quit(BuildContext context, String pageName) {
void quit(BuildContext context, String pageName, VoidCallback dismiss) {
clickEvent(pageName, "quit");
UserRepository.getInstance().userLogout(userid).listen((value) {
if (value != null) {
quitNative(context, dismiss);
}
}).onError((error) {
Toast.debugShow(context, error);
print(error);
});
}
void quitNative(BuildContext context, VoidCallback dismiss) {
userLogout().listen((value) {
if (value) {
dismiss();
Navigator.pop(context);
}
}).onError((error) {
Toast.debugShow(context, error);
print(error);
});
}
void save(BuildContext context) {
popLoadingDialog(context, true, "加载中");
if (selectImgPath != null) {
UserRepository.getInstance().getUploadToken(1).listen((data) {
uploadImage(context, data.data?.token);
}).onError((error) {
Toast.show(context, "网络错误");
print(error);
});
} else {
settingInfo(context, headImgLive.data, nameLive.data, cityId);
}
}
void uploadImage(BuildContext context, String token) {
if (token == null) {
Toast.debugShow(context, " token is null");
} else {
uploadImg(selectImgPath, token).listen((value) {
print("UPLOAD --> $value");
if (value != null) {
settingInfo(context, "http://alpha.iyanzhi.com/${value}-w",
nameLive.data, cityId);
} else {
Toast.show(context, "上传失败");
}
}).onError((e) {
Toast.debugShow(context, e);
print(e);
});
}
}
void settingInfo(
BuildContext context, String head, String name, String countryId) {
UserRepository.getInstance()
.settingUserInfo(countryId, name, head, userid, age)
.listen((data) {
if (data != null) {
dismissLoadingDialog(context);
UserEntityImpl().saveage(data?.data?.age);
UserEntityImpl().saveprofilePic(head);
UserEntityImpl().savenickName(name);
UserEntityImpl().savecountryInfoId(countryId);
UserEntityImpl().savecountryInfoName(cityLive.data);
Timer(Duration(milliseconds: 390), () {
Navigator.pop(context);
});
} else {
Toast.show(context, "保存失败");
}
}).onError((e) {
Toast.show(context, e.toString());
print(e);
});
}
void onNameChange(String text) {
if (text != null && text.isNotEmpty) {
nameLive.data = text;
detectUpdate();
}
}
}
......@@ -3,6 +3,7 @@
* @date 2019-09-04
**/
import 'dart:async';
import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
......@@ -14,6 +15,7 @@ import 'package:gmalpha_flutter/commonModel/base/BaseBuried.dart';
import 'package:gmalpha_flutter/commonModel/base/BaseComponent.dart';
import 'package:gmalpha_flutter/commonModel/base/BasePage.dart';
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/commonModel/picker/base/BasePickerComponent.dart';
import 'package:gmalpha_flutter/res/GMRes.dart';
import 'package:gmalpha_flutter/userModel/page/userSetting/UserSettingModel.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
......@@ -33,6 +35,10 @@ class UserSettingPage extends StatefulWidget {
class UserState extends BasePage<UserSettingPage> {
final UserSettingModel _model;
TextEditingController _controller = new TextEditingController();
BaseCenterPicker logoutPicker;
BaseLoadingItem baseLoadingItem;
UserLogoutPicker userLogoutPicker;
UserState(this._model);
......@@ -40,12 +46,27 @@ class UserState extends BasePage<UserSettingPage> {
void initState() {
super.initState();
_model.init(context);
_controller.addListener(() {
_model.onNameChange(_controller.text);
});
logoutPicker = BaseCenterPicker();
baseLoadingItem = BaseLoadingItem("加载中");
userLogoutPicker = UserLogoutPicker(() {
logoutPicker.setPicker(baseLoadingItem);
_model.quit(context, pageName(), () {
logoutPicker.dismiss(context);
});
}, () {
logoutPicker.dismiss(context);
});
logoutPicker.setPicker(userLogoutPicker);
}
@override
void dispose() {
super.dispose();
_model.dispose();
_controller?.dispose();
}
@override
......@@ -72,7 +93,9 @@ class UserState extends BasePage<UserSettingPage> {
);
} else {
return GestureDetector(
onTap: () {},
onTap: () {
_model.save(context);
},
child: Padding(
padding: EdgeInsets.only(
right: ScreenUtil.instance.setWidth(30)),
......@@ -122,8 +145,17 @@ class UserState extends BasePage<UserSettingPage> {
height: ScreenUtil.instance.setWidth(127),
child: ClipOval(
child: _model.selectImgPath == null
? CachedNetworkImage(
imageUrl: data.data,
? SizedBox(
height: double.maxFinite,
width: double.maxFinite,
child: CachedNetworkImage(
imageUrl: data.data,
fit: BoxFit.cover,
placeholder: (con, str) {
return SvgPicture.asset(
"images/replace_head.svg");
},
),
)
: SizedBox(
height: double.maxFinite,
......@@ -150,9 +182,26 @@ class UserState extends BasePage<UserSettingPage> {
stream: _model.nameLive.stream,
initialData: _model.nameLive.data,
builder: (con, data) {
return Center(
child: baseText(data.data ?? "", 13, ALColors.Color323232),
);
// _controller.text = data.data;
return Container(
width: screenWidth / 4,
height: 60,
alignment: Alignment.center,
child: TextField(
autofocus: false,
textInputAction: TextInputAction.done,
style: TextStyle(
fontSize: 13, color: ALColors.Color323232),
controller: _controller,
textAlign: TextAlign.right,
maxLines: 1,
decoration: InputDecoration(
hintText: data.data,
// hintStyle: TextStyle(
// fontSize: 13, color: ALColors.Color323232),
border: InputBorder.none,
),
));
},
),
false),
......@@ -168,7 +217,8 @@ class UserState extends BasePage<UserSettingPage> {
return Container(
margin: EdgeInsets.only(
right: ScreenUtil.instance.setWidth(19)),
child: baseText(data.data ?? "", 13, ALColors.Color323232),
child:
baseText(data.data ?? "", 13, ALColors.Color323232),
);
},
),
......@@ -194,7 +244,7 @@ class UserState extends BasePage<UserSettingPage> {
right: ScreenUtil.instance.setWidth(30)),
child: OutlineButton(
onPressed: () {
_model.quit(context, pageName());
logoutPicker.show(context);
},
child: baseText("退出登入", 14, ALColors.Color323232),
borderSide: new BorderSide(color: Color(0xff323232)),
......@@ -218,7 +268,10 @@ class UserState extends BasePage<UserSettingPage> {
children: <Widget>[
baseText(left, 13, ALColors.Color323232),
Expanded(
child: Text(""),
child: SizedBox(
height: double.maxFinite,
child: Text(""),
),
),
center ?? Container(),
needRight
......@@ -245,3 +298,54 @@ class UserState extends BasePage<UserSettingPage> {
return _model.refere;
}
}
class UserLogoutPicker implements ICenterPicker {
VoidCallback sure;
VoidCallback cancel;
UserLogoutPicker(this.sure, this.cancel);
@override
Widget build(BuildContext context) {
return Container(
width: ScreenUtil.instance.setWidth(270),
height: ScreenUtil.instance.setHeight(200),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.0),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.only(
top: ScreenUtil.instance.setHeight(20),
bottom: ScreenUtil.instance.setHeight(20)),
child: baseText("提示", 22, ALColors.Color8E8E8E),
),
baseText("确定要退出当前账号", 13, ALColors.Color8E8E8E),
Expanded(
child: Container(),
),
baseDivide(1, 0, ALColors.ColorE4E4E4),
GestureDetector(
onTap: sure,
child: Container(
alignment: Alignment.center,
height: 50,
width: double.maxFinite,
child: baseText("确定", 16, ALColors.Color0093FF),
)),
baseDivide(1, 0, ALColors.ColorE4E4E4),
GestureDetector(
onTap: cancel,
child: Container(
height: 50,
alignment: Alignment.center,
width: double.maxFinite,
child: baseText("取消", 16, ALColors.Color999999),
)),
],
));
}
}
......@@ -7,7 +7,9 @@ import 'package:gmalpha_flutter/userModel/service/local/UserLocal.dart';
import 'package:gmalpha_flutter/userModel/service/remote/UserRemote.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/CommentBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/CountryBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/SetUserBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UploadTokenBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.user.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart';
......@@ -47,4 +49,23 @@ class UserRepository {
Observable<CountryBean> getCountries() {
return _remote.getCountrise();
}
Observable<UploadTokenBean> getUploadToken(int token_type) {
return _remote.getUploadToken(token_type);
}
Observable<SetUserBean> settingUserInfo(String country_id, String nick_name,
String profile_pic, String user_id, String age) {
return _remote.settingUserInfo(
country_id, nick_name, profile_pic, user_id, age);
}
Observable<SimpleResponce> userLogout(String userID) {
return _remote.userLogout(userID).map((value){
if(value!=null){
_local.clearData();
}
return value;
});
}
}
......@@ -5,6 +5,8 @@
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.user.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.user.dart'
as prefix0;
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart';
class UserLocal {
......@@ -21,6 +23,7 @@ class UserLocal {
void saveUserInfo(UserResultBean value) {
if (value != null) {
UserEntityImpl().saveage("${value.data.age}");
UserEntityImpl().saveuserId("${value.data.userId}");
UserEntityImpl().savebirth(value.data.birth);
UserEntityImpl().savecityId("${value.data.cityId}");
......@@ -39,4 +42,24 @@ class UserLocal {
UserEntityImpl().savequestionUrl(value.data.questionUrl);
}
}
void clearData() {
UserEntityImpl().saveage("");
UserEntityImpl().saveuserId("");
UserEntityImpl().savebirth(0);
UserEntityImpl().savecityId("");
UserEntityImpl().savecountryId("");
UserEntityImpl().savecountryInfoId("");
UserEntityImpl()
.savecountryInfoLanguage("");
UserEntityImpl().savegender("");
UserEntityImpl().savedetailSetted(false);
UserEntityImpl().savecountryInfoName("");
UserEntityImpl().savehasAnswered(false);
UserEntityImpl().savehasScanFace(false);
UserEntityImpl().saveisBind(false);
UserEntityImpl().savenickName("");
UserEntityImpl().saveprofilePic("");
UserEntityImpl().savequestionUrl("");
}
}
......@@ -5,7 +5,9 @@
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/userModel/service/remote/api/UserApi.serv.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/CommentBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/SetUserBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UploadTokenBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart';
import 'package:rxdart/rxdart.dart';
......@@ -35,4 +37,18 @@ class UserRemote {
Observable<CountryBean> getCountrise() {
return UserApiImpl().getCountrys();
}
Observable<UploadTokenBean> getUploadToken(int token_type) {
return UserApiImpl().getUploadToken(token_type);
}
Observable<SetUserBean> settingUserInfo(String country_id, String nick_name,
String profile_pic, String user_id, String age) {
return UserApiImpl()
.settingUserInfo(country_id, nick_name, profile_pic, user_id, age);
}
Observable<SimpleResponce> userLogout(String userId) {
return UserApiImpl().logout(userId);
}
}
......@@ -9,7 +9,9 @@ import 'package:gmalpha_flutter/Annotations/anno/ServiceCenter.dart';
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/CommentBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/CountryBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/SetUserBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UploadTokenBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart';
......@@ -19,8 +21,29 @@ abstract class UserApi {
UserResultBean getUserInfo(@Query("user_id") String userID);
@Post("api/v1/suggestion")
CommentBean comment(@Query("content") String content, @Query("phone") String phone);
CommentBean comment(
@Query("content") String content, @Query("phone") String phone);
@Get("api/v1/countries")
CountryBean getCountrys();
/**
* TODO not here!
* 获取token api/v1/app/upload_token
* <p>
* 1, '图片' 2, '视频文件'3, 'face扫脸相关文件'
*/
@Post("api/v1/app/upload_token")
UploadTokenBean getUploadToken(@Query("token_type") int token_type);
@Post("api/account/user_settle")
SetUserBean settingUserInfo(
@Query("country_id") String country_id,
@Query("nick_name") String nick_name,
@Query("profile_pic") String profile_pic,
@Query("user_id") String user_id,
@Query("age") String age);
@Post("api/account/logout/")
SimpleResponce logout(@Query("user_id") String user_id);
}
......@@ -13,6 +13,9 @@ import 'package:rxdart/rxdart.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/CommentBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/CountryBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UploadTokenBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/SetUserBean.dart';
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/commonModel/net/DioUtil.dart';
......@@ -59,4 +62,42 @@ class UserApiImpl {
}
});
}
Observable<UploadTokenBean> getUploadToken(int token_type) {
return Observable.fromFuture(DioUtil().post('api/v1/app/upload_token',
data: {'token_type': token_type})).map((value) {
if (value != null && value.statusCode == 200) {
Map map = json.decode(value.toString());
return UploadTokenBean.fromJson(map);
}
});
}
Observable<SetUserBean> settingUserInfo(String country_id, String nick_name,
String profile_pic, String user_id, String age) {
return Observable.fromFuture(
DioUtil().post('api/account/user_settle', data: {
'country_id': country_id,
'nick_name': nick_name,
'profile_pic': profile_pic,
'user_id': user_id,
'age': age
})).map((value) {
if (value != null && value.statusCode == 200) {
Map map = json.decode(value.toString());
return SetUserBean.fromJson(map);
}
});
}
Observable<SimpleResponce> logout(String user_id) {
return Observable.fromFuture(
DioUtil().post('api/account/logout/', data: {'user_id': user_id}))
.map((value) {
if (value != null && value.statusCode == 200) {
Map map = json.decode(value.toString());
return SimpleResponce.fromJson(map);
}
});
}
}
/*
* @author lsy
* @date 2019-10-16
**/
class SetUserBean {
int error;
String message;
Null extra;
Data data;
UserType userType;
SetUserBean({this.error, this.message, this.extra, this.data, this.userType});
SetUserBean.fromJson(Map<String, dynamic> json) {
error = json['error'];
message = json['message'];
extra = json['extra'];
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
userType = json['user_type'] != null
? new UserType.fromJson(json['user_type'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['error'] = this.error;
data['message'] = this.message;
data['extra'] = this.extra;
if (this.data != null) {
data['data'] = this.data.toJson();
}
if (this.userType != null) {
data['user_type'] = this.userType.toJson();
}
return data;
}
}
class Data {
int id;
bool isOnline;
int userId;
String nickName;
String profilePic;
int gender;
String age;
Null cityId;
String countryId;
double birth;
bool isBind;
Data(
{this.id,
this.isOnline,
this.userId,
this.nickName,
this.profilePic,
this.gender,
this.age,
this.cityId,
this.countryId,
this.birth,
this.isBind});
Data.fromJson(Map<String, dynamic> json) {
id = json['id'];
isOnline = json['is_online'];
userId = json['user_id'];
nickName = json['nick_name'];
profilePic = json['profile_pic'];
gender = json['gender'];
age = json['age'];
cityId = json['city_id'];
countryId = json['country_id'];
birth = json['birth'];
isBind = json['is_bind'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['is_online'] = this.isOnline;
data['user_id'] = this.userId;
data['nick_name'] = this.nickName;
data['profile_pic'] = this.profilePic;
data['gender'] = this.gender;
data['age'] = this.age;
data['city_id'] = this.cityId;
data['country_id'] = this.countryId;
data['birth'] = this.birth;
data['is_bind'] = this.isBind;
return data;
}
}
class UserType {
UserType();
UserType.fromJson(Map<String, dynamic> json) {}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
return data;
}
}
/*
* @author lsy
* @date 2019-10-16
**/
class UploadTokenBean {
int error;
String message;
Null extra;
Data data;
UserType userType;
UploadTokenBean(
{this.error, this.message, this.extra, this.data, this.userType});
UploadTokenBean.fromJson(Map<String, dynamic> json) {
error = json['error'];
message = json['message'];
extra = json['extra'];
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
userType = json['user_type'] != null
? new UserType.fromJson(json['user_type'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['error'] = this.error;
data['message'] = this.message;
data['extra'] = this.extra;
if (this.data != null) {
data['data'] = this.data.toJson();
}
if (this.userType != null) {
data['user_type'] = this.userType.toJson();
}
return data;
}
}
class Data {
String token;
int tokenType;
Data({this.token, this.tokenType});
Data.fromJson(Map<String, dynamic> json) {
token = json['token'];
tokenType = json['token_type'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['token'] = this.token;
data['token_type'] = this.tokenType;
return data;
}
}
class UserType {
UserType();
UserType.fromJson(Map<String, dynamic> json) {}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
return data;
}
}
......@@ -16,6 +16,7 @@ const String COUNTRY_ID = "country_id";
const String USER_BIND_MOBILE = "user_bind_mobile";
const String COUNTRY_LANGUAGE = "country_language";
const String COUNTRY_NAME = "country_name";
const String AGE = "user_age";
@UserCenter()
class UserEntity {
......@@ -90,73 +91,6 @@ class UserEntity {
String insBindId;
String registerTime;
UserEntity(
{this.userId,
this.nickName,
this.profilePic,
this.hasAnswered,
this.hasScanFace,
this.id,
this.gender,
this.cityId,
this.birth,
this.countryId,
this.logined,
this.detailSetted,
this.tagSetted,
this.questionUrl,
this.isBind,
this.countryInfoName,
this.countryInfoId,
this.countryInfoLanguage,
this.insBindId,
this.registerTime});
UserEntity.fromJson(Map<String, dynamic> json) {
userId = json['user_id'];
nickName = json['nick_name'];
profilePic = json['profile_pic'];
hasAnswered = json['has_answered'];
hasScanFace = json['has_scan_face'];
id = json['id'];
gender = json['gender'];
cityId = json['city_id'];
birth = json['birth'];
countryId = json['country_id'];
logined = json['logined'];
detailSetted = json['detail_setted'];
tagSetted = json['tag_setted'];
questionUrl = json['question_url'];
isBind = json['is_bind'];
countryInfoName = json['country_info_name'];
countryInfoId = json['country_info_id'];
countryInfoLanguage = json['country_info_language'];
insBindId = json['ins_bind_id'];
registerTime = json['register_time'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['user_id'] = this.userId;
data['nick_name'] = this.nickName;
data['profile_pic'] = this.profilePic;
data['has_answered'] = this.hasAnswered;
data['has_scan_face'] = this.hasScanFace;
data['id'] = this.id;
data['gender'] = this.gender;
data['city_id'] = this.cityId;
data['birth'] = this.birth;
data['country_id'] = this.countryId;
data['logined'] = this.logined;
data['detail_setted'] = this.detailSetted;
data['tag_setted'] = this.tagSetted;
data['question_url'] = this.questionUrl;
data['is_bind'] = this.isBind;
data['country_info_name'] = this.countryInfoName;
data['country_info_id'] = this.countryInfoId;
data['country_info_language'] = this.countryInfoLanguage;
data['ins_bind_id'] = this.insBindId;
data['register_time'] = this.registerTime;
return data;
}
@User(AGE, "")
String age;
}
......@@ -38,7 +38,12 @@ class UserEntityImpl {
if (_userId != null) {
return Observable.fromFuture(Future.value(_userId));
}
return Observable.fromFuture(spUtil.getStringKv("user_uid"));
return Observable.fromFuture(spUtil.getStringKv("user_uid")).map((value) {
if (value == "") {
return null;
}
return value;
});
}
String _nickName;
......@@ -56,7 +61,12 @@ class UserEntityImpl {
if (_nickName != null) {
return Observable.fromFuture(Future.value(_nickName));
}
return Observable.fromFuture(spUtil.getStringKv("username"));
return Observable.fromFuture(spUtil.getStringKv("username")).map((value) {
if (value == "") {
return null;
}
return value;
});
}
String _profilePic;
......@@ -74,7 +84,12 @@ class UserEntityImpl {
if (_profilePic != null) {
return Observable.fromFuture(Future.value(_profilePic));
}
return Observable.fromFuture(spUtil.getStringKv("potrait"));
return Observable.fromFuture(spUtil.getStringKv("potrait")).map((value) {
if (value == "") {
return null;
}
return value;
});
}
bool _hasAnswered;
......@@ -129,7 +144,12 @@ class UserEntityImpl {
if (_gender != null) {
return Observable.fromFuture(Future.value(_gender));
}
return Observable.fromFuture(spUtil.getStringKv("gender"));
return Observable.fromFuture(spUtil.getStringKv("gender")).map((value) {
if (value == "") {
return null;
}
return value;
});
}
String _cityId;
......@@ -147,7 +167,13 @@ class UserEntityImpl {
if (_cityId != null) {
return Observable.fromFuture(Future.value(_cityId));
}
return Observable.fromFuture(spUtil.getStringKv("current_city_id"));
return Observable.fromFuture(spUtil.getStringKv("current_city_id"))
.map((value) {
if (value == "") {
return null;
}
return value;
});
}
double _birth;
......@@ -183,7 +209,12 @@ class UserEntityImpl {
if (_countryId != null) {
return Observable.fromFuture(Future.value(_countryId));
}
return Observable.fromFuture(spUtil.getStringKv("country_id"));
return Observable.fromFuture(spUtil.getStringKv("country_id")).map((value) {
if (value == "") {
return null;
}
return value;
});
}
bool _detailSetted;
......@@ -221,7 +252,13 @@ class UserEntityImpl {
if (_questionUrl != null) {
return Observable.fromFuture(Future.value(_questionUrl));
}
return Observable.fromFuture(spUtil.getStringKv("question_url"));
return Observable.fromFuture(spUtil.getStringKv("question_url"))
.map((value) {
if (value == "") {
return null;
}
return value;
});
}
bool _isBind;
......@@ -258,7 +295,13 @@ class UserEntityImpl {
if (_countryInfoName != null) {
return Observable.fromFuture(Future.value(_countryInfoName));
}
return Observable.fromFuture(spUtil.getStringKv("country_name"));
return Observable.fromFuture(spUtil.getStringKv("country_name"))
.map((value) {
if (value == "") {
return null;
}
return value;
});
}
String _countryInfoId;
......@@ -277,7 +320,12 @@ class UserEntityImpl {
if (_countryInfoId != null) {
return Observable.fromFuture(Future.value(_countryInfoId));
}
return Observable.fromFuture(spUtil.getStringKv("country_id"));
return Observable.fromFuture(spUtil.getStringKv("country_id")).map((value) {
if (value == "") {
return null;
}
return value;
});
}
String _countryInfoLanguage;
......@@ -296,6 +344,35 @@ class UserEntityImpl {
if (_countryInfoLanguage != null) {
return Observable.fromFuture(Future.value(_countryInfoLanguage));
}
return Observable.fromFuture(spUtil.getStringKv("country_language"));
return Observable.fromFuture(spUtil.getStringKv("country_language"))
.map((value) {
if (value == "") {
return null;
}
return value;
});
}
String _age;
Observable<bool> saveage(String age) {
return Observable.fromFuture(spUtil.saveStringKv("user_age", age))
.map((value) {
if (value) {
this._age = age;
}
return value;
});
}
Observable<String> getage() {
if (_age != null) {
return Observable.fromFuture(Future.value(_age));
}
return Observable.fromFuture(spUtil.getStringKv("user_age")).map((value) {
if (value == "") {
return null;
}
return value;
});
}
}
......@@ -44,8 +44,8 @@ class Data {
String nickName;
String profilePic;
int gender;
Null age;
Null cityId;
String age;
String cityId;
double birth;
double registerTime;
bool isBind;
......@@ -146,9 +146,9 @@ class CountryInfo {
CountryInfo({this.name, this.id, this.language});
CountryInfo.fromJson(Map<String, dynamic> json) {
name = json['name'];
id = json['id'];
language = json['language'];
name = json['name']??"";
id = json['id']??"";
language = json['language']??"";
}
Map<String, dynamic> toJson() {
......
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