From f22bb81d3a46a4ebd14cbc23d5856c71bd4ac9d2 Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Thu, 14 Oct 2021 11:28:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 2 +- lib/retrofit/min_api.dart | 136 --------------------------- lib/retrofit/min_api.g.dart | 88 ----------------- lib/store/store_view/settlement.dart | 2 +- 4 files changed, 2 insertions(+), 226 deletions(-) delete mode 100644 lib/retrofit/min_api.dart delete mode 100644 lib/retrofit/min_api.g.dart diff --git a/android/app/build.gradle b/android/app/build.gradle index 2856cd40..28c20a56 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -112,7 +112,7 @@ android { ndk { /// 选择要添加的对应.so 库。 - abiFilters 'armeabi-v7a', 'arm64-v8a' + abiFilters 'armeabi-v7a', 'arm64-v8a','x86' } manifestPlaceholders = mfph diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart deleted file mode 100644 index 8f3ce159..00000000 --- a/lib/retrofit/min_api.dart +++ /dev/null @@ -1,136 +0,0 @@ -import 'dart:convert'; - -import 'package:dio/dio.dart'; -import 'package:flare_flutter/flare_testing.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_easyloading/flutter_easyloading.dart'; -import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; -import 'package:huixiang/generated/l10n.dart'; -import 'package:huixiang/retrofit/data/base_data.dart'; -import 'package:huixiang/view_widget/login_tips_dialog.dart'; -import 'package:retrofit/retrofit.dart'; - -import 'data/findMiNiGroupList.dart'; -import 'data/miNiDetail.dart'; -import 'data/shoppingCart.dart'; -part 'min_api.g.dart'; - -// const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///正式 -// const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式 - -const base_url = "http://192.168.10.236:8765/app/"; ///费韬 -const baseUrl = "http://192.168.10.236:8765/app/"; ///费韬 - -// const base_url = "http://192.168.10.37:8766/app/"; -// const baseUrl = "http://192.168.10.37:8766/app/"; - -///调用小程序的接口 -@RestApi(baseUrl: baseUrl) -abstract class MinApiService { - factory MinApiService(Dio dio, { - String baseUrl, - BuildContext context, - String token, - String tenant, - bool showLoading = true, - bool pay = false, - }) { - Map headers = - (token == null || token == "") ? {} : {'token': "Bearer $token"}; - if (tenant != null && tenant != "") { - headers["tenant"] = tenant; - } - if (pay) { - headers["Environment"] = "app"; - } - dio.options = BaseOptions( - connectTimeout: 60000, - receiveTimeout: 60000, - headers: headers, - responseType: ResponseType.json, - ); - dio.interceptors.add( - InterceptorsWrapper(onRequest: (RequestOptions options) { - debugPrint("\n======================= Min_请求数据 ======================="); - debugPrint("method = ${options.method.toString()}"); - debugPrint("url = ${options.uri.toString()}"); - debugPrint("headers = ${options.headers}"); - if (showLoading && !EasyLoading.isShow) { - //是否显示loading - EasyLoading.show(status: S.of(context).zhengzaijiazai); - } - if (options.data is FormData) { - debugPrint("params data = FormData"); - } else { - debugPrint("params data = ${jsonEncode(options.data)}"); - } - debugPrint("params queryParameters = ${options.queryParameters}"); - }, onResponse: (Response response) { - debugPrint("\n======================= Min_响应数据开始 ======================="); - if (showLoading && EasyLoading.isShow) { - EasyLoading.dismiss(); - } - debugPrint("code = ${response.statusCode}"); - // p(jsonEncode(response.data)); - - debugPrint(jsonEncode(response.data), wrapWidth: response.data.toString().length); - - Map map = response.data; - if (map["code"] != 0) { - EasyLoading.dismiss(); - } - if (map["code"] == 40005 || map["code"] == 40001) { - if (!LoginTipsDialog().isShow) { - // print("show: ${LoginTipsDialog().isShow}"); - LoginTipsDialog().show(context); - } - } else if (map["code"] != 0 && response.request.baseUrl == baseUrl) { - ///高德地图的poi服务请求不需要toast - SmartDialog.showToast(map["msg"], alignment: Alignment.center); - } - debugPrint("======================= Min_响应数据结束 =======================\n"); - }, onError: (DioError e) { - if (EasyLoading.isShow) { - EasyLoading.dismiss(); - } - debugPrint("\n======================= Min_错误响应数据 ======================="); - debugPrint("type = ${e.type}"); - debugPrint("message = ${e.message}"); - debugPrint("\n"); - }), - ); - - if (kReleaseMode) { - baseUrl = base_url; - } - return _MinApiService(dio, baseUrl: baseUrl); - } - - static void p(String msg) { - int maxStrLength = 900; - while (msg.length > maxStrLength) { - debugPrint(msg.substring(0, maxStrLength)); - msg = msg.substring(maxStrLength); - } - debugPrint(msg); - } - - ///小程序查询分组及商品列表 - @POST("product/findMiNiGroupList") - Future>> findMiNiGroupList( - @Body() Map param); - - - ///小程序查询商品详情/規格选择 - @GET("/product/queryMiNiProductDetail?id={id}") - Future> miNiDetail(@Path("id") String id); - - ///添加购物车 - @POST("shoppingcart") - Future> shoppingCart( - @Body() Map param,Map header); - - - -} \ No newline at end of file diff --git a/lib/retrofit/min_api.g.dart b/lib/retrofit/min_api.g.dart deleted file mode 100644 index a7ede126..00000000 --- a/lib/retrofit/min_api.g.dart +++ /dev/null @@ -1,88 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'min_api.dart'; - -// ************************************************************************** -// RetrofitGenerator -// ************************************************************************** - -class _MinApiService implements MinApiService { - _MinApiService(this._dio, {this.baseUrl}) { - ArgumentError.checkNotNull(_dio, '_dio'); - baseUrl ??= 'http://192.168.10.236:8765/app/'; - } - - final Dio _dio; - - String baseUrl; - - @override - Future>> findMiNiGroupList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - 'product/findMiNiGroupList', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => (json as List) - .map( - (i) => FindMiNiGroupList.fromJson(i as Map)) - .toList()); - return value; - } - - @override - Future> miNiDetail(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/product/queryMiNiProductDetail?id=$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => MiNiDetail.fromJson(json), - ); - return value; - } - - @override - Future> shoppingCart(param, header) async { - ArgumentError.checkNotNull(param, 'param'); - ArgumentError.checkNotNull(header, 'header'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('shoppingcart', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson( - _result.data, - (json) => ShoppingCart.fromJson(json), - ); - return value; - } -} diff --git a/lib/store/store_view/settlement.dart b/lib/store/store_view/settlement.dart index 8a7f2ab8..81bc48af 100644 --- a/lib/store/store_view/settlement.dart +++ b/lib/store/store_view/settlement.dart @@ -40,7 +40,7 @@ class _Settlement extends State { super.initState(); SharedPreferences.getInstance().then((value) { - apiService = ApiService( + minService = MinApiService( Dio(), context: context, token: value.getString("token"),