Commit d4498ff3 authored by 朱璇's avatar 朱璇

一键授权接口调试

parent fedb5de6
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: zx * @Author: zx
* @Date: 2020-07-03 20:54:59 * @Date: 2020-07-03 20:54:59
* @Last Modified by: zx * @Last Modified by: zx
* @Last Modified time: 2020-07-04 11:38:20 * @Last Modified time: 2020-07-04 12:20:45
*/ */
import 'package:flutter_common/commonModel/live/BaseModel.dart'; import 'package:flutter_common/commonModel/live/BaseModel.dart';
import 'package:flutter_common/commonModel/live/LiveData.dart'; import 'package:flutter_common/commonModel/live/LiveData.dart';
...@@ -12,9 +12,12 @@ import 'package:gm_flutter/commonModel/rx/RxDispose.dart'; ...@@ -12,9 +12,12 @@ import 'package:gm_flutter/commonModel/rx/RxDispose.dart';
import 'package:flutter_common/commonModel/toast/NativeToast.dart'; import 'package:flutter_common/commonModel/toast/NativeToast.dart';
import 'package:gm_flutter/commonModel/bean/Pair.dart'; import 'package:gm_flutter/commonModel/bean/Pair.dart';
import 'package:gm_flutter/ClueModel/server/entity/DiscussLowPriceModelBean.dart'; import 'package:gm_flutter/ClueModel/server/entity/DiscussLowPriceModelBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/DiscussLowPriceAuthBean.dart';
class DiscussLowPriceModel extends BaseModel { class DiscussLowPriceModel extends BaseModel {
LiveData<Pair<int, DiscussLowPriceModelBean>> popViewLive = LiveData(); LiveData<Pair<int, DiscussLowPriceModelBean>> popViewLive = LiveData();
LiveData<bool> phoneAuthLive = LiveData();
RxDispose rxDispose = RxDispose(); RxDispose rxDispose = RxDispose();
fetchPopviewData(String planId, String hospitalId, String doctorId) { fetchPopviewData(String planId, String hospitalId, String doctorId) {
...@@ -40,6 +43,24 @@ class DiscussLowPriceModel extends BaseModel { ...@@ -40,6 +43,24 @@ class DiscussLowPriceModel extends BaseModel {
}); });
} }
givePhoneAuth(int leadPhoneRequestId) {
ClueApiImpl.getInstance()
.givePhoneAuth(DioUtil.getInstance().getDio(), leadPhoneRequestId)
.listen((event) {
if (event.error == 0) {
phoneAuthLive.notifyView(event.data.success);
} else {
NativeToast.showNativeToast(event.message);
phoneAuthLive.notifyView(false);
}
})
.addToDispose(rxDispose)
.onError((err) {
phoneAuthLive.notifyView(false);
NativeToast.showNativeToast(err.message);
});
}
@override @override
void dispose() { void dispose() {
popViewLive.dispost(); popViewLive.dispost();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: zx * @Author: zx
* @Date: 2020-07-03 13:53:16 * @Date: 2020-07-03 13:53:16
* @Last Modified by: zx * @Last Modified by: zx
* @Last Modified time: 2020-07-04 11:35:29 * @Last Modified time: 2020-07-04 12:48:35
*/ */
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_common/commonModel/picker/base/BaseCenterPicker.dart'; import 'package:flutter_common/commonModel/picker/base/BaseCenterPicker.dart';
...@@ -149,7 +149,9 @@ class _PopView implements ICenterPicker { ...@@ -149,7 +149,9 @@ class _PopView implements ICenterPicker {
), ),
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
// TODO 一键授权 // 一键授权
_model.givePhoneAuth(111);
dismissCallback();
}, },
child: Container( child: Container(
margin: EdgeInsets.only(bottom: 14), margin: EdgeInsets.only(bottom: 14),
......
...@@ -13,6 +13,7 @@ import 'package:gm_flutter/ClueModel/server/entity/ProjectDetailsItem.dart'; ...@@ -13,6 +13,7 @@ import 'package:gm_flutter/ClueModel/server/entity/ProjectDetailsItem.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanBean.dart'; import 'package:gm_flutter/ClueModel/server/entity/PlanBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanFeedBean.dart'; import 'package:gm_flutter/ClueModel/server/entity/PlanFeedBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/DiscussLowPriceModelBean.dart'; import 'package:gm_flutter/ClueModel/server/entity/DiscussLowPriceModelBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/DiscussLowPriceAuthBean.dart';
@ServiceCenter() @ServiceCenter()
abstract class ClueApi { abstract class ClueApi {
...@@ -53,4 +54,8 @@ abstract class ClueApi { ...@@ -53,4 +54,8 @@ abstract class ClueApi {
@Query("hospital_id") String hospitalId, @Query("hospital_id") String hospitalId,
@Query("doctor_id") String doctorId, @Query("doctor_id") String doctorId,
); );
@Get("api/janus/plans/agree_phone_authorize")
DiscussLowPriceAuthBean givePhoneAuth(
@Query("lead_phone_request_id") int leadPhoneRequestId);
} }
...@@ -22,6 +22,7 @@ import 'package:gm_flutter/ClueModel/server/entity/PlanBean.dart'; ...@@ -22,6 +22,7 @@ import 'package:gm_flutter/ClueModel/server/entity/PlanBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanFeedBean.dart'; import 'package:gm_flutter/ClueModel/server/entity/PlanFeedBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanBarBean.dart'; import 'package:gm_flutter/ClueModel/server/entity/PlanBarBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/DiscussLowPriceModelBean.dart'; import 'package:gm_flutter/ClueModel/server/entity/DiscussLowPriceModelBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/DiscussLowPriceAuthBean.dart';
const bool inProduction = const bool.fromEnvironment("dart.vm.product"); const bool inProduction = const bool.fromEnvironment("dart.vm.product");
...@@ -172,6 +173,22 @@ class ClueApiImpl { ...@@ -172,6 +173,22 @@ class ClueApiImpl {
}); });
} }
Stream<DiscussLowPriceAuthBean> givePhoneAuth(
Dio _dio, int leadPhoneRequestId) {
return Stream.fromFuture(
get(_dio, 'api/janus/plans/agree_phone_authorize', data: {
'lead_phone_request_id': leadPhoneRequestId,
})).flatMap((value) {
if (value != null &&
(value.statusCode >= 200 && value.statusCode < 300)) {
return Stream.fromFuture(
compute(parseDiscussLowPriceAuthBean, value.toString()));
} else {
throw Exception("--未知网络错误--");
}
});
}
///==================base method================== ///==================base method==================
Future<Response> get(Dio _dio, url, {data, options, cancelToken}) async { Future<Response> get(Dio _dio, url, {data, options, cancelToken}) async {
...@@ -340,3 +357,7 @@ PlanBarBean parsePlanBarBean(String value) { ...@@ -340,3 +357,7 @@ PlanBarBean parsePlanBarBean(String value) {
DiscussLowPriceModelBean parseDiscussLowPriceModelBean(String value) { DiscussLowPriceModelBean parseDiscussLowPriceModelBean(String value) {
return DiscussLowPriceModelBean.fromJson(json.decode(value)); return DiscussLowPriceModelBean.fromJson(json.decode(value));
} }
DiscussLowPriceAuthBean parseDiscussLowPriceAuthBean(String value) {
return DiscussLowPriceAuthBean.fromJson(json.decode(value));
}
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
// RouterCenterGenerator // RouterCenterGenerator
// ************************************************************************** // **************************************************************************
//MainRouterImpl is resign : true
//ClueRouterImpl is resign : true //ClueRouterImpl is resign : true
//MainRouterImpl is resign : true
import "package:gm_flutter/MainRouter/MainRouterImpl.dart";
import "package:gm_flutter/MainRouter/MainRouter.dart";
import "package:gm_flutter/ClueModel/ClueRouterImpl.dart"; import "package:gm_flutter/ClueModel/ClueRouterImpl.dart";
import "package:gm_flutter/ClueModel/ClueRouter.dart"; import "package:gm_flutter/ClueModel/ClueRouter.dart";
import "package:gm_flutter/MainRouter/MainRouterImpl.dart";
import "package:gm_flutter/MainRouter/MainRouter.dart";
import "package:flutter_common/Annotations/RouterBaser.dart"; import "package:flutter_common/Annotations/RouterBaser.dart";
...@@ -38,25 +38,25 @@ class RouterCenterImpl { ...@@ -38,25 +38,25 @@ class RouterCenterImpl {
} }
void init() { void init() {
map.putIfAbsent("MainRouter", () => MainRouterImpl());
map.putIfAbsent("ClueRouter", () => ClueRouterImpl()); map.putIfAbsent("ClueRouter", () => ClueRouterImpl());
map.putIfAbsent("MainRouter", () => MainRouterImpl());
} }
RouterBaser getModel(String modelName) { RouterBaser getModel(String modelName) {
return map[modelName]; return map[modelName];
} }
MainRouter findMainRouter() { ClueRouter findClueRouter() {
if (map["MainRouter"] == null) { if (map["ClueRouter"] == null) {
return null; return null;
} }
return map["MainRouter"] as MainRouter; return map["ClueRouter"] as ClueRouter;
} }
ClueRouter findClueRouter() { MainRouter findMainRouter() {
if (map["ClueRouter"] == null) { if (map["MainRouter"] == null) {
return null; return null;
} }
return map["ClueRouter"] as ClueRouter; return map["MainRouter"] as MainRouter;
} }
} }
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