|
|
@@ -3,6 +3,8 @@ import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter_alibc/flutter_alibc.dart'; |
|
|
|
import 'package:jdsdk/jdsdk.dart'; |
|
|
|
import 'package:url_launcher/url_launcher.dart'; |
|
|
|
import 'package:zhiying_comm/pages/launch_page/launch_page.dart'; |
|
|
|
import 'package:zhiying_comm/register.dart'; |
|
|
|
import 'package:zhiying_comm/zhiying_comm.dart'; |
|
|
|
|
|
|
|
import 'taobao_image_viewer.dart'; |
|
|
@@ -17,26 +19,23 @@ class MyApp extends StatefulWidget { |
|
|
|
class _MyAppState extends State<MyApp> { |
|
|
|
@override |
|
|
|
void initState() { |
|
|
|
Jdsdk.init(appKey: '9fc3dec00b9b40cc950dfba5262cd6d3', |
|
|
|
appSecret: 'f785613e5fd54a129d0f0359a4e25c23').then((result) { |
|
|
|
BaseWidgetRegister.init(); |
|
|
|
Jdsdk.init( |
|
|
|
appKey: '9fc3dec00b9b40cc950dfba5262cd6d3', |
|
|
|
appSecret: 'f785613e5fd54a129d0f0359a4e25c23') |
|
|
|
.then((result) { |
|
|
|
Logger.debug('京东初始化:${result.toString()}'); |
|
|
|
}); |
|
|
|
FlutterAlibc.initAlibc(version: "", appName: "").then((result) { |
|
|
|
Logger.debug('${result.errorCode} ${result.errorMessage}'); |
|
|
|
}); |
|
|
|
|
|
|
|
super.initState(); |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
return MaterialApp( |
|
|
|
home: Scaffold( |
|
|
|
appBar: AppBar( |
|
|
|
title: const Text('智莺-基础库'), |
|
|
|
), |
|
|
|
body: HomePage(), |
|
|
|
), |
|
|
|
); |
|
|
|
return MaterialApp(home: LaunchPage(builder: (context) => HomePage(),),); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -49,71 +48,75 @@ class HomePage extends StatelessWidget { |
|
|
|
|
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
return SingleChildScrollView( |
|
|
|
child: Center( |
|
|
|
child: Wrap( |
|
|
|
spacing: 10, |
|
|
|
children: <Widget>[ |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
Navigator.push(context, MaterialPageRoute(builder: (_) { |
|
|
|
// return DeviceInfoPage(); |
|
|
|
})); |
|
|
|
}, |
|
|
|
child: Text('设备信息'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
Navigator.push(context, MaterialPageRoute(builder: (_) { |
|
|
|
// return PackageInfoPage(); |
|
|
|
})); |
|
|
|
}, |
|
|
|
child: Text('应用信息'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
NetUtil.post('/siteapi/v1/ucenter/login/', params: { |
|
|
|
'username': 'xiangguohui', |
|
|
|
'password': 'fnuo123com' |
|
|
|
}); |
|
|
|
}, |
|
|
|
child: Text('登录请求'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
NetUtil.request('/api/v1/rec/featured?page=1', params: null, |
|
|
|
onError: (msg) { |
|
|
|
print('onERROR = ${msg?.toString() ?? 'onError'}'); |
|
|
|
}, onSuccess: (json) { |
|
|
|
print('onSuccess = ${json?.toString() ?? 'onSuccess'}'); |
|
|
|
}, onCache: (json) { |
|
|
|
print('onCache = ${json?.toString() ?? 'onCache'}'); |
|
|
|
}); |
|
|
|
}, |
|
|
|
child: Text('网络异步请求(带缓存)'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
netPost(); |
|
|
|
}, |
|
|
|
child: Text('网络同步请求(无缓存)'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
// LogUtil.test(); |
|
|
|
}, |
|
|
|
child: Text('显示日志'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
Navigator.push(context, MaterialPageRoute(builder: (_) { |
|
|
|
return Logger(); |
|
|
|
})); |
|
|
|
}, |
|
|
|
child: Text('打开日志视图'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
return Scaffold( |
|
|
|
appBar: AppBar( |
|
|
|
title: const Text('智莺-基础库'), |
|
|
|
), |
|
|
|
body: SingleChildScrollView( |
|
|
|
child: Center( |
|
|
|
child: Wrap( |
|
|
|
spacing: 10, |
|
|
|
children: <Widget>[ |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
Navigator.push(context, MaterialPageRoute(builder: (_) { |
|
|
|
// return DeviceInfoPage(); |
|
|
|
})); |
|
|
|
}, |
|
|
|
child: Text('设备信息'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
Navigator.push(context, MaterialPageRoute(builder: (_) { |
|
|
|
// return PackageInfoPage(); |
|
|
|
})); |
|
|
|
}, |
|
|
|
child: Text('应用信息'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
NetUtil.post('/siteapi/v1/ucenter/login/', params: { |
|
|
|
'username': 'xiangguohui', |
|
|
|
'password': 'fnuo123com' |
|
|
|
}); |
|
|
|
}, |
|
|
|
child: Text('登录请求'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
NetUtil.request('/api/v1/rec/featured?page=1', params: null, |
|
|
|
onError: (msg) { |
|
|
|
print('onERROR = ${msg?.toString() ?? 'onError'}'); |
|
|
|
}, onSuccess: (json) { |
|
|
|
print('onSuccess = ${json?.toString() ?? 'onSuccess'}'); |
|
|
|
}, onCache: (json) { |
|
|
|
print('onCache = ${json?.toString() ?? 'onCache'}'); |
|
|
|
}); |
|
|
|
}, |
|
|
|
child: Text('网络异步请求(带缓存)'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
netPost(); |
|
|
|
}, |
|
|
|
child: Text('网络同步请求(无缓存)'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
// LogUtil.test(); |
|
|
|
}, |
|
|
|
child: Text('显示日志'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
Navigator.push(context, MaterialPageRoute(builder: (_) { |
|
|
|
return Logger(); |
|
|
|
})); |
|
|
|
}, |
|
|
|
child: Text('打开日志视图'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
// NetUtil.request('/api/v1/mod', params: {'ids': [6] } ,method: NetMethod.POST, |
|
|
|
// onSuccess: (params){ |
|
|
|
// Logger.log("onSuccess#$params"); |
|
|
@@ -122,74 +125,75 @@ class HomePage extends StatelessWidget { |
|
|
|
// Logger.log("onCache#$params"); |
|
|
|
// }); |
|
|
|
|
|
|
|
testPost(); |
|
|
|
}, |
|
|
|
child: Text('测试接口'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
Navigator.push(context, MaterialPageRoute(builder: (_) { |
|
|
|
return TaobaoImageView(); |
|
|
|
})); |
|
|
|
}, |
|
|
|
child: Text('抓淘宝图片'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
TaobaoAuth.auth(context); |
|
|
|
}, |
|
|
|
child: Text('淘宝授权'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
testPost(); |
|
|
|
}, |
|
|
|
child: Text('测试接口'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
Navigator.push(context, MaterialPageRoute(builder: (_) { |
|
|
|
return TaobaoImageView(); |
|
|
|
})); |
|
|
|
}, |
|
|
|
child: Text('抓淘宝图片'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
TaobaoAuth.auth(context); |
|
|
|
}, |
|
|
|
child: Text('淘宝授权'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
// |
|
|
|
Dio dio = Dio(); |
|
|
|
dio.get( |
|
|
|
'http://www.hairuyi.com/?mod=appapi&act=gotojingdong&gid=60291609161&yhq_url=http%3A%2F%2Fcoupon.m.jd.com%2Fcoupons%2Fshow.action%3Fkey%3Dd97e1472a8a24c39a9463dbe72b3fa32%26roleId%3D38088450%26to%3Ditem.jd.com%2F60291609161.html') |
|
|
|
.then((value) { |
|
|
|
Logger.debug(value.realUri.toString()); |
|
|
|
}); |
|
|
|
}, |
|
|
|
child: Text('获取重定向地址'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
Jdsdk.openUrl( |
|
|
|
url: 'http://www.hairuyi.com/?mod=appapi&act=gotojingdong&gid=60291609161&yhq_url=http%3A%2F%2Fcoupon.m.jd.com%2Fcoupons%2Fshow.action%3Fkey%3Dd97e1472a8a24c39a9463dbe72b3fa32%26roleId%3D38088450%26to%3Ditem.jd.com%2F60291609161.html'); |
|
|
|
}, |
|
|
|
child: Text('打开京东详情'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () async { |
|
|
|
String detailUrl = 'http://www.hairuyi.com/?mod=appapi&act=gotojingdong&gid=60291609161&yhq_url=http%3A%2F%2Fcoupon.m.jd.com%2Fcoupons%2Fshow.action%3Fkey%3Dd97e1472a8a24c39a9463dbe72b3fa32%26roleId%3D38088450%26to%3Ditem.jd.com%2F60291609161.html'; |
|
|
|
String baseUrl = detailUrl.getBaseUrl(); |
|
|
|
if (!baseUrl.contains('jd.com')) { |
|
|
|
Dio dio = Dio(); |
|
|
|
var responds = await dio.get(detailUrl); |
|
|
|
detailUrl = responds.realUri.toString(); |
|
|
|
} |
|
|
|
Logger.debug(detailUrl); |
|
|
|
Jdsdk.openUrl( |
|
|
|
url |
|
|
|
: |
|
|
|
detailUrl |
|
|
|
); |
|
|
|
}, |
|
|
|
child: Text('嗨如意转链打开京东'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () async { |
|
|
|
const url = 'weixin://'; |
|
|
|
dio.get( |
|
|
|
'http://www.hairuyi.com/?mod=appapi&act=gotojingdong&gid=60291609161&yhq_url=http%3A%2F%2Fcoupon.m.jd.com%2Fcoupons%2Fshow.action%3Fkey%3Dd97e1472a8a24c39a9463dbe72b3fa32%26roleId%3D38088450%26to%3Ditem.jd.com%2F60291609161.html') |
|
|
|
.then((value) { |
|
|
|
Logger.debug(value.realUri.toString()); |
|
|
|
}); |
|
|
|
}, |
|
|
|
child: Text('获取重定向地址'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () { |
|
|
|
Jdsdk.openUrl( |
|
|
|
url: 'http://www.hairuyi.com/?mod=appapi&act=gotojingdong&gid=60291609161&yhq_url=http%3A%2F%2Fcoupon.m.jd.com%2Fcoupons%2Fshow.action%3Fkey%3Dd97e1472a8a24c39a9463dbe72b3fa32%26roleId%3D38088450%26to%3Ditem.jd.com%2F60291609161.html'); |
|
|
|
}, |
|
|
|
child: Text('打开京东详情'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () async { |
|
|
|
String detailUrl = 'http://www.hairuyi.com/?mod=appapi&act=gotojingdong&gid=60291609161&yhq_url=http%3A%2F%2Fcoupon.m.jd.com%2Fcoupons%2Fshow.action%3Fkey%3Dd97e1472a8a24c39a9463dbe72b3fa32%26roleId%3D38088450%26to%3Ditem.jd.com%2F60291609161.html'; |
|
|
|
String baseUrl = detailUrl.getBaseUrl(); |
|
|
|
if (!baseUrl.contains('jd.com')) { |
|
|
|
Dio dio = Dio(); |
|
|
|
var responds = await dio.get(detailUrl); |
|
|
|
detailUrl = responds.realUri.toString(); |
|
|
|
} |
|
|
|
Logger.debug(detailUrl); |
|
|
|
Jdsdk.openUrl( |
|
|
|
url |
|
|
|
: |
|
|
|
detailUrl |
|
|
|
); |
|
|
|
}, |
|
|
|
child: Text('嗨如意转链打开京东'), |
|
|
|
), |
|
|
|
RaisedButton( |
|
|
|
onPressed: () async { |
|
|
|
const url = 'weixin://'; |
|
|
|
|
|
|
|
if (await canLaunch(url)) { |
|
|
|
await launch(url); |
|
|
|
} else { |
|
|
|
throw 'Could not launch $url'; |
|
|
|
} |
|
|
|
}, |
|
|
|
child: Text('url scheme打开app'), |
|
|
|
), |
|
|
|
], |
|
|
|
if (await canLaunch(url)) { |
|
|
|
await launch(url); |
|
|
|
} else { |
|
|
|
throw 'Could not launch $url'; |
|
|
|
} |
|
|
|
}, |
|
|
|
child: Text('url scheme打开app'), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|