|
|
@@ -6,6 +6,7 @@ import 'package:flutter_redux/flutter_redux.dart';
|
|
|
import '../redux/AppState.dart';
|
|
|
import '../net/HttpManager.dart';
|
|
|
import '../net/Result.dart';
|
|
|
+import '../model/BindGameInfo.dart';
|
|
|
|
|
|
class BindGame extends StatefulWidget {
|
|
|
@override
|
|
|
@@ -15,21 +16,69 @@ class BindGame extends StatefulWidget {
|
|
|
class BindGameState extends State<BindGame> {
|
|
|
String bindName = '';
|
|
|
bool isBind = false;
|
|
|
+ BindGameInfo bindInfo;
|
|
|
|
|
|
- void bindEvent() async{
|
|
|
+ void getBindInfo() async {
|
|
|
+ Toast.show(context, '加载中', -1, 'loading');
|
|
|
+ Result res = await HttpManager.get("bindGame/all", data: {
|
|
|
+ "gameId": 1,
|
|
|
+ "userId": StoreProvider.of<AppState>(context).state.userInfo.id
|
|
|
+ });
|
|
|
+ Toast.hide();
|
|
|
+ if (res.success) {
|
|
|
+ if (res.data.length > 0) {
|
|
|
+ print(res.data[0]);
|
|
|
+ setState(() {
|
|
|
+ isBind = true;
|
|
|
+ bindInfo = BindGameInfo.fromJson(res.data[0]);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ setState(() {
|
|
|
+ isBind = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ void initState() {
|
|
|
+ super.initState();
|
|
|
+ Future.delayed(Duration(milliseconds: 50), () {
|
|
|
+ getBindInfo();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ void bindEvent() async {
|
|
|
if (bindName == '') {
|
|
|
Toast.show(context, '请输入绑定角色名称', 1500, 'info');
|
|
|
return;
|
|
|
}
|
|
|
-Toast.show(context, '加载中', -1, 'loading');
|
|
|
- Result res = await HttpManager.post("assets/uploadFile", data: {
|
|
|
-
|
|
|
+ Toast.show(context, '加载中', -1, 'loading');
|
|
|
+ Result res = await HttpManager.post("bindGame/save", data: {
|
|
|
+ "gameId": 1,
|
|
|
+ "userId": StoreProvider.of<AppState>(context).state.userInfo.id,
|
|
|
+ "nickName": bindName
|
|
|
});
|
|
|
Toast.hide();
|
|
|
if (res.success) {
|
|
|
-
|
|
|
+ Toast.show(context, '绑定成功', 1000, 'success');
|
|
|
+ Future.delayed(Duration(milliseconds: 1000), () {
|
|
|
+ getBindInfo();
|
|
|
+ });
|
|
|
} else {}
|
|
|
+ }
|
|
|
|
|
|
+ void cancelBind() async {
|
|
|
+ Toast.show(context, '加载中', -1, 'loading');
|
|
|
+ Result res =
|
|
|
+ await HttpManager.post("bindGame/del", data: {'id': bindInfo.id});
|
|
|
+ Toast.hide();
|
|
|
+ if (res.success) {
|
|
|
+ Toast.show(context, '解绑成功', 1000, 'success');
|
|
|
+ Future.delayed(Duration(milliseconds: 1000), () {
|
|
|
+ getBindInfo();
|
|
|
+ });
|
|
|
+ } else {}
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
@@ -50,7 +99,7 @@ Toast.show(context, '加载中', -1, 'loading');
|
|
|
Container(
|
|
|
height: 220,
|
|
|
width: double.infinity,
|
|
|
- padding: EdgeInsets.symmetric(vertical: 15, horizontal: 34),
|
|
|
+ // padding: EdgeInsets.symmetric(vertical: 15, horizontal: 34),
|
|
|
decoration: BoxDecoration(
|
|
|
image: DecorationImage(
|
|
|
image: AssetImage('images/img_chijizhanchang.png'),
|
|
|
@@ -68,10 +117,72 @@ Toast.show(context, '加载中', -1, 'loading');
|
|
|
List<Widget> _bindWidegt() {
|
|
|
List<Widget> widgetList = [];
|
|
|
if (isBind) {
|
|
|
+ widgetList.add(Container(
|
|
|
+ height: 78,
|
|
|
+ padding: EdgeInsets.all(15),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ gradient: LinearGradient(
|
|
|
+ colors: [Color(0xFF464B6A), Color(0xFF35395E)],
|
|
|
+ begin: Alignment.topCenter,
|
|
|
+ end: Alignment.bottomCenter)),
|
|
|
+ child: Row(
|
|
|
+ children: <Widget>[
|
|
|
+ Image.network(bindInfo.gameInfo.icon, width: 48),
|
|
|
+ Container(
|
|
|
+ width: 10,
|
|
|
+ ),
|
|
|
+ Expanded(
|
|
|
+ flex: 1,
|
|
|
+ child: Column(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: <Widget>[
|
|
|
+ Text(bindInfo.gameInfo.gameName,
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 14)),
|
|
|
+ Container(
|
|
|
+ height: 5,
|
|
|
+ ),
|
|
|
+ Row(
|
|
|
+ children: <Widget>[
|
|
|
+ Text(
|
|
|
+ "已绑定",
|
|
|
+ style: TextStyle(
|
|
|
+ color: Color(0xFF727785),
|
|
|
+ fontSize: 13,
|
|
|
+ fontWeight: FontWeight.w500),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ width: 10,
|
|
|
+ ),
|
|
|
+ Text(
|
|
|
+ bindInfo.nickName,
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontSize: 13,
|
|
|
+ fontWeight: FontWeight.w500),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ )),
|
|
|
+ Container(
|
|
|
+ width: 50,
|
|
|
+ height: 30,
|
|
|
+ child: OutlineButton(
|
|
|
+ padding: EdgeInsets.all(0),
|
|
|
+ borderSide: BorderSide(color: Color(0xFFC2524D), width: 1),
|
|
|
+ textColor: Color(0xFFC2524D),
|
|
|
+ highlightedBorderColor: Color(0xFF9B4040),
|
|
|
+ child: Text("解绑"),
|
|
|
+ onPressed: () => cancelBind(),
|
|
|
+ ))
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ));
|
|
|
} else {
|
|
|
widgetList = [
|
|
|
Container(
|
|
|
- margin: EdgeInsets.only(bottom: 10),
|
|
|
+ margin: EdgeInsets.only(bottom: 10, left: 45, right: 45),
|
|
|
decoration: BoxDecoration(
|
|
|
borderRadius: BorderRadius.all(Radius.circular(2)),
|
|
|
color: Colors.white,
|
|
|
@@ -93,6 +204,7 @@ Toast.show(context, '加载中', -1, 'loading');
|
|
|
),
|
|
|
),
|
|
|
Container(
|
|
|
+ margin: EdgeInsets.only(left: 45, right: 45, bottom: 15),
|
|
|
width: double.infinity,
|
|
|
height: 40,
|
|
|
child: RaisedButton(
|