You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

542 lines
17 KiB

import 'dart:convert';
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.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/activity.dart';
import 'package:huixiang/retrofit/data/article.dart';
import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/comunity_comment.dart';
import 'package:huixiang/retrofit/data/coupon.dart';
import 'package:huixiang/retrofit/data/login_info.dart';
import 'package:huixiang/retrofit/data/order_info.dart';
import 'package:huixiang/view_widget/login_tips_dialog.dart';
import 'package:retrofit/retrofit.dart';
import 'data/achievement_detail_list.dart';
import 'data/activity_pos.dart';
import 'data/address.dart';
import 'data/app_update.dart';
import 'data/banner.dart';
import 'data/brand_data.dart';
import 'data/category_select_list.dart';
import 'data/chapter.dart';
import 'data/collect_class_list.dart';
import 'data/coupon_detail.dart';
import 'data/course_details.dart';
import 'data/course_list.dart';
import 'data/exchange_order.dart';
import 'data/follow_list.dart';
import 'data/goods.dart';
import 'data/goods_category.dart';
import 'data/headlines_list.dart';
import 'data/headlines_list_details.dart';
import 'data/home_rank.dart';
import 'data/invitation_list.dart';
import 'data/logistics.dart';
import 'data/member_Infor.dart';
import 'data/member_comment_list.dart';
import 'data/message.dart';
import 'data/msg_stats.dart';
import 'data/page.dart';
import 'data/rank.dart';
import 'data/recharge_list.dart';
import 'data/second_card_list.dart';
import 'data/sign_info.dart';
import 'data/social_info.dart';
import 'data/store.dart';
import 'data/upload_result.dart';
import 'data/user_bill.dart';
import 'data/user_info.dart';
import 'data/vip_badges_list.dart';
import 'data/vip_benefit_list.dart';
import 'data/vip_card.dart';
import 'data/vip_rule_details.dart';
import 'data/wx_pay.dart';
part 'retrofit_api.g.dart';
// const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///正式
// const base_url = "http://platform.prod.kunqi.lotus-wallet.com/app/"; ///222
// const base_url = "http://192.168.10.236:8766/app/"; ///费韬
// const base_url = "http://192.168.10.37:8766/app/";
// const base_url = "http://192.168.10.132:8766/app/";///詹云久
const localBaseUrl = "http://192.168.10.236:8766/app/";///本地
const serviceBaseUrl = "https://pos.platform.lotus-wallet.com/app/";///线上
@RestApi(baseUrl: localBaseUrl)
abstract class ApiService {
factory ApiService(
Dio dio, {
String baseUrl,
BuildContext context,
String token,
bool showLoading = false,
bool pay = true,
}) {
Map<String, dynamic> headers =
(token == null || token == "") ? {} : {'token': "Bearer $token"};
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======================= 请求数据 =======================");
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======================= 响应数据开始 =======================");
if (showLoading && EasyLoading.isShow) {
EasyLoading.dismiss();
}
debugPrint("code = ${response.statusCode}");
p(jsonEncode(response.data));
// debugPrint(jsonEncode(response.data), wrapWidth: response.data.toString().length * 10);
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("======================= 响应数据结束 =======================\n");
}, onError: (DioError e) {
if (EasyLoading.isShow) {
EasyLoading.dismiss();
}
debugPrint("\n======================= 错误响应数据 =======================");
debugPrint("type = ${e.type}");
debugPrint("message = ${e.message}");
debugPrint("\n");
}),
);
if (kReleaseMode) {
baseUrl = serviceBaseUrl;
}
return _ApiService(dio, baseUrl: baseUrl);
}
static void p(String msg) {
//因为String的length是字符数量不是字节数量所以为了防止中文字符过多,
// 把4*1024的MAX字节打印长度改为1000字符数
int maxStrLength = 900;
//大于1000时
while (msg.length > maxStrLength) {
debugPrint(msg.substring(0, maxStrLength), wrapWidth: maxStrLength);
msg = msg.substring(maxStrLength);
}
//剩余部分
debugPrint(msg, wrapWidth: maxStrLength);
}
///文件上传
@POST("/file/upload")
@MultiPart()
Future<BaseData<UploadResult>> upload(
@Part(name: "file") File data, @Part(name: "folderId") int folderId,bool isVideo);
/// 周边搜索
@GET("https://restapi.amap.com/v3/place/around?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location={lat},{lng}&keywords={keywords}&offset={size}&page={page}&extensions=all")
Future<dynamic> searchPoi(@Path("lat") String lat, @Path("lng") String lng,
@Path("keywords") String keywords, int size, int page);
/// 用户登录
@POST("/auth/platform/memberLogin")
Future<BaseData> memberLogin(@Body() Map<String, dynamic> param);
///发送验证码
@GET("/auth/sendVerify/{areaCode}/{mobile}")
Future<BaseData> sendVerify(@Path("areaCode") String areaCode, @Path("mobile") String mobile);
///积分商城商品列表
@POST("/creditGoods/list")
Future<BaseData<PageInfo<Goods>>> creditGoods(
@Body() Map<String, dynamic> param);
///积分商城商品分類列表
@POST("/creditGoodsCategory/page")
Future<BaseData<PageInfo<GoodsCategory>>> goodsCategory(
@Body() Map<String, dynamic> param);
///积分商城商品详情
@GET("/creditGoods/{id}")
Future<BaseData<Goods>> creditGoodsById(@Path("id") String id);
///查询用户信息
@GET("/member/info")
Future<BaseData<UserInfo>> queryInfo();
///编辑用户信息
@POST("/member/editMemberInfo")
Future<BaseData> editInfo(@Body() Map<String, dynamic> param);
///用户签到信息
@GET("/member/signInInfo")
Future<BaseData<SignInfo>> signInInfo();
///用户签到
@GET("/member/signIn")
Future<BaseData> signIn();
///平台充值
@POST("/wallet/recharge")
Future<BaseData<dynamic>> recharge(@Body() Map<String, dynamic> param);
///充值活动列表
@GET("/wallet/rechargeAct")
Future<BaseData<List<RechargeList>>> rechargeAct();
///领取优惠券
@GET("/coupon/receive?couponId={couponId}")
Future<BaseData> receiveCoupon(@Path("couponId") String couponId);
///兑换订单列表
@POST("/creditOrder/list")
Future<BaseData<PageInfo<ExchangeOrder>>> creditOrderList(
@Body() Map<String, dynamic> param);
///创建积分订单
@POST("/creditOrder/create")
Future<BaseData> creditOrder(@Body() Map<String, dynamic> param);
///保存收货地址
@POST("/address/add")
Future<BaseData> addAddress(@Body() Map<String, dynamic> param);
///删除收货地址
@POST("/address/delete")
Future<BaseData> deleteAddress(@Body() Map<String, dynamic> param);
///查询收货地址
@GET("/address/detail/{id}")
Future<BaseData> queryAddress(@Path("id") String id);
///查询用户所有的收货地址
@GET("/address/queryMemberAddress")
Future<BaseData<List<Address>>> queryMemberAddress();
///更新收货地址
@POST("/address/update")
Future<BaseData> updateAddress(@Body() Map<String, dynamic> param);
///查询领券列表
@POST("/coupon/centreList")
Future<BaseData<PageInfo<Coupon>>> queryCoupon(
@Body() Map<String, dynamic> param);
///查询卡包列表
@POST("/coupon/packageList")
Future<BaseData<PageInfo<Coupon>>> queryCard(
@Body() Map<String, dynamic> param);
///门店地址列表
@POST("/store/list")
Future<BaseData<List<Store>>> queryStore(@Body() Map<String, dynamic> param);
///分页查看资讯列表
@POST("/information/list")
Future<BaseData<PageInfo<Activity>>> informationList(
@Body() Map<String, dynamic> param);
///查看资讯详情
@GET("/information/{id}")
Future<BaseData<Article>> informationInfo(@Path("id") String id);
///查看活动详情
@GET("/information/{id}")
Future<BaseData<Activity>> activityInfo(@Path("id") String id);
///积分订单兑换到券包
@GET("/creditOrder/receive/{id}")
Future<BaseData> creditOrderReceive(@Path("id") String id);
///首页数据
@GET("/home/home")
Future<BaseData<BrandData>> queryHome();
///查询店铺商家详情
@GET("/store/{id}")
Future<BaseData> queryStoreInfo(@Path("id") String id);
///分页查看资讯列表
@POST("/information/list")
Future<BaseData<PageInfo<Article>>> queryArticle(@Body() Map<String, dynamic> param);
///banner查询
@POST("/banner/page")
Future<BaseData<PageInfo<BannerData>>> queryBanner(@Body() Map<String, dynamic> param);
///品牌信息
@GET("/home/brand")
Future<BaseData> queryHomeBrand();
/// 小程序会员登录
@GET("/auth/mini/login/{storeId}")
Future<BaseData> minLogin(@Path("storeId") String storeId);
/// 各种消费记录
@POST("/member/listBill")
Future<BaseData<PageInfo<UserBill>>> queryBillInfo(
@Body() Map<String, dynamic> param);
///会员等级列表
@GET("/member/rankList")
Future<BaseData<List<Rank>>> rankList();
///订单列表
@POST("/order/list")
Future<BaseData<PageInfo<OrderInfo>>> orderList(
@Body() Map<String, dynamic> param);
///订单详情
@GET("/order/orderDetail?id={id}")
Future<BaseData<OrderInfo>> orderDetail(@Path("id") String id);
///继续付款
@POST("/order/continuePay")
Future<BaseData> continuePay(@Body() Map<String, dynamic> param);
///积分订单兑换到券包
@GET("/creditOrder/receive/{id}")
Future<BaseData> receiveToCard(@Path("id") String id);
///会员卡列表
@POST("/member/vipList")
Future<BaseData<List<VipCard>>> vipList(@Body() Map<String, dynamic> param);
///会员卡详情
@POST("/member/vipDetail")
Future<BaseData<VipCard>> vipDetail(@Body() Map<String, dynamic> param);
///分页查询App消息列表
@POST("/app-msg/list")
Future<BaseData<PageInfo<Message>>> msgList(
@Body() Map<String, dynamic> param);
///App消息详情
@GET("/app-msg/{id}")
Future<BaseData> queryMsg(@Path("id") String id);
///App消息 统计各类消息数量
@GET("/app-msg/stats")
Future<BaseData<List<MsgStats>>> stats();
///给文章/活动点赞
@GET("/information/likes/{id}")
Future<BaseData> informationLikes(@Path("id") String id);
///发布评论
@POST("/memberComment")
Future<BaseData> memberComment(@Body() Map<String, dynamic> param);
///查询评论列表
@POST("/memberComment/list")
Future<BaseData<PageInfo<MemberCommentList>>> memberCommentList(
@Body() Map<String, dynamic> param);
///评论点赞
@GET("/memberComment/likes/{id}")
Future<BaseData> commentLike(@Path("id") String id);
///评论删除
@DELETE("/memberComment/{id}")
Future<BaseData> delComment(@Path("id") String id);
///查询物流轨迹
@GET("/order/getShippingTrace/{shipperCode}/{logisticCode}")
Future<BaseData<Logistics>> shippingTrace(
@Path("shipperCode") String shipperCode,
@Path("logisticCode") String logisticCode);
// ///反馈
// @POST("/other/report")
// Future<BaseData<dynamic>> report(@Body() Map<String, String> map);
///取消订单
@GET("/order/cancel/{id}")
Future<BaseData<dynamic>> orderCancel(@Path("id") String id);
///继续付款?
@POST("/order/settlement")
Future<BaseData<String>> settlement(@Body() Map<String, String> map);
/// 发表动态
@POST("/information/trend")
Future<BaseData<bool>> trend(@Body() Map<String, dynamic> map);
/// 动态列表
@POST("/information/trend-list")
Future<BaseData<PageInfo<ComunityComment>>> trendList(@Body() Map<String, dynamic> map);
/// 我关注/粉丝的会员列表
@POST("/member/follow/list")
Future<BaseData<PageInfo<ListData>>> followList(@Body() Map<String, dynamic> map);
///关注/取关会员
@PUT("/member/follow/{followId}")
Future<BaseData> follow(@Path("followId") String followId);
///删除动态
@DELETE("/information/trend/{id}")
Future<BaseData> deleteTrend(@Path("id") String id);
///个人社交信息(粉丝/关注数量/成就数量)
@GET("/member/socialInfo")
Future<BaseData<SocialInfo>> socialInfo();
///课程分类列表
@GET("/course/categoryList")
Future<BaseData<List<CategorySelectList>>> categoryList();
///课程章节列表
@GET("/course/catalogList/{courseId}")
Future<BaseData<List<Chapter>>> catalogList(@Path("courseId") String courseId);
/// 课程列表
@POST("/course/list")
Future<BaseData<PageInfo<CourseList>>> courseList(@Body() Map<String, dynamic> map);
///课程的合集列表
@GET("/course/collectList")
Future<BaseData<List<CollectClassList>>> collectList();
///合集包含的课程列表
@GET("/course/collect/{collectId}")
Future<BaseData<List<CourseList>>> collect(@Path("collectId") String collectId);
///课程详情
@GET("/course/{id}")
Future<BaseData<CourseDetails>> course(@Path("id") String id);
///给文章/活动点赞
@GET("/course/likes/{courseId}")
Future<BaseData> courseLikes(@Path("courseId") String courseId);
/// APP查询所有成就徽章 并显示会员完成的
@POST("/app-memberAchievement/findBadges")
Future<BaseData<List<VipBadgesList>>> findBadges(@Body() Map<String, dynamic> map);
///查看一个成就大类详情
@GET("/app-memberAchievement/getAchievementDetail?achievementCategoryId={achievementCategoryId}")
Future<BaseData<List<AchievementDetailList>>> getAchievementDetail(@Path("achievementCategoryId") String achievementCategoryId);
///会员的权益列表
@GET("/member/benefitList")
Future<BaseData<List<VipBenefitList>>> benefitList();
///会员权益
@GET("/home/vipBenefit")
Future<BaseData<VipRuleDetails>> vipBenefit();
///查询副卡列表
@GET("/member/secondCardList")
Future<BaseData<List<SecondCardList>>> secondCardList();
///绑定副卡
@GET("/member/bindSecondCard/{phone}")
Future<BaseData> bindSecondCard(@Path("phone") String phone);
///解绑副卡
@GET("/member/unbindSecondCard/{phone}")
Future<BaseData> unbindSecondCard(@Path("phone") String phone);
///查看积分订单物流
@GET("/creditOrder/getAppShippingTrace?orderId={orderId}")
Future<BaseData<Logistics>> getAppShippingTrace(@Path("orderId") String orderId);
///购买会员等级
@POST("/member/rankBuy")
Future<BaseData<dynamic>> rankBuy(@Body() Map<String, dynamic> param);
///文章合集列表
@GET("/information/categoryList")
Future<BaseData<List<HeadlinesList>>> headlinesList();
///文章合集详情
@GET("/information/category/{id}")
Future<BaseData<HeadlinesListDetails>> headlinesDetails(@Path("id") String id);
/// 我的邀请会员列表
@POST("/member/inviteMemberList")
Future<BaseData<PageInfo<InvitationList>>> inviteMemberList(@Body() Map<String, dynamic> map);
///核销优惠券
@GET("/coupon/wiped/{memberCouponId}")
Future<BaseData> wiped(@Path("memberCouponId") String memberCouponId);
///查询优惠券详情
@GET("/coupon/detail/")
Future<BaseData<CouponDetail>> couponDetail(@Path("") String memberCouponId);
///查询会员信息
@GET("/member/detail/{id}")
Future<BaseData<MemberInfor>> memberDetail(@Path("id") String id);
///活动弹窗
@GET("/home/appPopup")
Future<BaseData<ActivityPos>> appPopup();
///注销会员
@GET("/member/deleteMine")
Future<BaseData> deleteMine();
///投诉资讯/动态
@POST("/information/complaint")
Future<BaseData> complaint(@Body() Map<String, dynamic> param);
///app自动更新
@GET("/home/version")
Future<BaseData<AppUpdate>> appVersion();
///App推荐排行
@GET("/home/recommendRank")
Future<BaseData<HomeRank>> recommendRank();
///发送修改支付密码的短信验证
@GET("/member/sendVerifyByUpdatePayPwd")
Future<BaseData> sendVerifyByUpdatePayPwd();
///修改支付密码
@POST("/member/updatePayPwd")
Future<BaseData> updatePayPwd(@Body() Map<String, dynamic> param);
///验证验证码
@POST("/member/verifyByUpdatePayPwd")
Future<BaseData> verifyByUpdatePayPwd(@Body() Map<String, dynamic> param);
}