Commit a3c1ac2a authored by 林生雨's avatar 林生雨

commit

parent 026a4810
......@@ -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,10 +64,12 @@ 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 if (call.method == "UPLOAD_IMG") {
result.success("2019/10/17/1156/44dbb13ac6d9");
} 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/" }
}
}
......
//
// 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>[
......
......@@ -27,9 +27,9 @@ class BuriedImpl implements BuriedRouter {
}
@override
void onEvent(String type, Map<String, String> params) {
print("lsy !! ON EVENT ");
BuriedCenter.getInstance().onEvent(type, params);
void onEvent(String type, Map<String, String> params) async{
await 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)));
......
......@@ -42,6 +42,7 @@ class ReputationsState extends BasePage<ReputationsPage> {
return WillPopScope(
child: Scaffold(
appBar: AppBar(
elevation: 0.0,
title: StreamBuilder<String>(
stream: _model.titleLive.stream,
initialData: _model.titleLive.data,
......
......@@ -12,6 +12,7 @@ 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 platform = const MethodChannel('flutter_bury_channel');
void jumpToH5(String jumpToName, Map params) {
......@@ -38,6 +39,10 @@ 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}));
}
void initParams(VoidCallback callback) {
platform.invokeMethod(INIT_PARAMS, null).then((value) {
print("lsy INITPARAMS !! $value");
......
......@@ -16,6 +16,7 @@ AppBar baseAppBar(
return AppBar(
title: title == null ? Container() : baseText(title, 16, ALColors.Color323232),
centerTitle: centerTitle,
elevation: 0.0,
leading: GestureDetector(
onTap: backClick,
child: Container(
......
......@@ -26,6 +26,15 @@ class _MyAppState extends State<MyApp> {
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 +61,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) ||
......@@ -73,17 +92,24 @@ class _MyAppState extends State<MyApp> {
FlutterBoost.handleOnStartPage();
}
bool isBuildMain = false;
var buildOnce = FlutterBoost.init();
@override
Widget build(BuildContext context) {
RouterCenterImpl().findBuriedRouter()?.onEvent("Test", null);
RouterCenterImpl().findBuriedRouter()?.onEvent("Test", null);
print("lsy BUILD!!");
return MaterialApp(
title: 'Flutter Boost example',
debugShowCheckedModeBanner: false,
routes: {
'/': (context) {
return TestPage();
},
},
builder: FlutterBoost.init(postPush: _onRoutePushed),
// routes: {
// '/': (context) {
// return TestPage();
// },
// },
builder: buildOnce,
theme: new ThemeData(
primaryColor: Colors.white,
backgroundColor: Color(0xFFEFEFEF),
......
......@@ -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.name, "countryName": country.name});
},
child: Container(
alignment: Alignment.centerLeft,
......
......@@ -3,6 +3,8 @@
* @date 2019-09-04
**/
import 'dart:math';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
......@@ -14,6 +16,7 @@ import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.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/UserEntity.user.dart' as prefix0;
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart';
import 'package:gmalpha_flutter/userModel/util/JumpUtil.dart';
......@@ -27,7 +30,7 @@ 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);
......@@ -42,11 +45,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);
});
} 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,7 +129,8 @@ class UserSettingModel extends BaseModel {
void jumpToCTY(BuildContext context, String pageName) {
jumpToCountry(context, pageName).then((value) {
if (value != null) {
cityLive.notifyView(value);
cityId = value["countryId"];
cityLive.notifyView(value["countryName"]);
detectUpdate();
}
}).catchError((error) {
......@@ -122,4 +142,56 @@ class UserSettingModel extends BaseModel {
void quit(BuildContext context, String pageName) {
clickEvent(pageName, "quit");
}
void save(BuildContext context) {
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) {
UserEntityImpl().saveage(data?.data?.age);
UserEntityImpl().saveprofilePic(head);
UserEntityImpl().savenickName(name);
UserEntityImpl().savecountryInfoId(countryId);
Toast.show(context, "保存成功");
Navigator.pop(context);
} else {
Toast.show(context, "保存失败");
}
}).onError((e) {
Toast.show(context, e.toString());
print(e);
});
}
}
......@@ -72,7 +72,9 @@ class UserState extends BasePage<UserSettingPage> {
);
} else {
return GestureDetector(
onTap: () {},
onTap: () {
_model.save(context);
},
child: Padding(
padding: EdgeInsets.only(
right: ScreenUtil.instance.setWidth(30)),
......
......@@ -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,14 @@ 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);
}
}
......@@ -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}");
......
......@@ -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,14 @@ 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);
}
}
......@@ -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,26 @@ 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);
}
......@@ -13,6 +13,8 @@ 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/DioUtil.dart';
......@@ -59,4 +61,31 @@ 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);
}
});
}
}
/*
* @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;
}
......@@ -298,4 +298,22 @@ class UserEntityImpl {
}
return Observable.fromFuture(spUtil.getStringKv("country_language"));
}
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"));
}
}
......@@ -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