Commit 353d5b11 authored by 林生雨's avatar 林生雨

Merge branch 'zx/gmFlutter' into 'test'

Zx/gm flutter

See merge request !6
parents c22fb1c0 65f6b83c
......@@ -2,7 +2,7 @@
* @Author: zx
* @Date: 2020-06-30 17:43:13
* @Last Modified by: zx
* @Last Modified time: 2020-07-01 20:04:23
* @Last Modified time: 2020-07-02 13:50:15
*/
import 'package:flutter_common/commonModel/live/BaseModel.dart';
import 'package:flutter_common/commonModel/live/LiveData.dart';
......@@ -10,25 +10,43 @@ import 'package:gm_flutter/ClueModel/server/api/ClueApi.serv.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanCompareDetail.dart';
import 'package:gm_flutter/commonModel/GMBase.dart';
import 'package:gm_flutter/commonModel/rx/RxDispose.dart';
import 'package:flutter_common/commonModel/toast/NativeToast.dart';
import 'package:gm_flutter/commonModel/util/PrintUtil.dart';
import 'package:gm_flutter/commonModel/bean/Pair.dart';
class PlanCompareDetailModel extends BaseModel {
LiveData<PlanCompareDetail> detailLive = LiveData();
LiveData<Pair<int, List<Groups>>> detailLive = LiveData();
LiveData<Pair<int, List<PlansInfo>>> headerLive = LiveData();
RxDispose rxDispose = RxDispose();
void init() {
void init(List<int> planIds) {
ClueApiImpl.getInstance()
.getPlanCompareDetail(DioUtil.getInstance().getDio(), [1,2])
.getPlanCompareDetail(DioUtil.getInstance().getDio(), planIds)
.listen((event) {
if (event.error == 0) {
detailLive.notifyView(event);
if (event.data.plansInfo == null || event.data.groups.isEmpty) {
headerLive.notifyView(Pair(ENDLOADING, []));
detailLive.notifyView(Pair(ENDLOADING, []));
} else {
detailLive.notifyView(Pair(ENDLOADING, event.data.groups));
}
} else {
NativeToast.showNativeToast(event.message);
headerLive.notifyView(Pair(FAIL, null));
detailLive.notifyView(Pair(FAIL, null));
}
})
.addToDispose(rxDispose)
.onError((err) {});
.onError((err) {
headerLive.notifyView(Pair(FAIL, null));
detailLive.notifyView(Pair(FAIL, null));
NativeToast.showNativeToast(err.message);
});
}
@override
void dispose() {
detailLive.dispost();
}
}
\ No newline at end of file
}
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