替换商城地址选择器

对接创建订单接口
pull/1/head
张萌 3 years ago
parent b6026d029c
commit 3fd7276dfc

File diff suppressed because it is too large Load Diff

@ -33,6 +33,7 @@ class SAASAPI {
static _Announce announce = _Announce();
static _Information information = _Information();
static _WorkOrder workOrder = _WorkOrder();
static _Pay pay = _Pay();
///
static _ProfileApi profile = _ProfileApi();
@ -247,3 +248,11 @@ class _WorkOrder {
///
String get list => '/app/user/workOrder/list';
}
class _Pay {
///
String get createGoodsOrder => '/app/user/alipay/createGoodsOrder';
///app
String get jcookOrderCheckAlipay => '/app/user/alipay/jcookOrderCheckAlipay';
}

@ -1198,9 +1198,6 @@ class $AssetsImagesGen {
class $AssetsJsonGen {
const $AssetsJsonGen();
/// File path: assets/json/province.json
String get province => 'assets/json/province.json';
}
class $AssetsStaticGen {

@ -1,12 +1,18 @@
import 'package:hive_flutter/adapters.dart';
import 'package:json_annotation/json_annotation.dart';
part 'community_model.g.dart';
@JsonSerializable()
@HiveType(typeId: 7)
class CommunityModel {
@HiveField(0)
final int id;
@HiveField(1)
final String name;
@HiveField(2)
final String address;
@HiveField(3)
final String addressDetails;
factory CommunityModel.fromJson(Map<String, dynamic> json) =>
_$CommunityModelFromJson(json);

@ -2,6 +2,53 @@
part of 'community_model.dart';
// **************************************************************************
// TypeAdapterGenerator
// **************************************************************************
class CommunityModelAdapter extends TypeAdapter<CommunityModel> {
@override
final int typeId = 7;
@override
CommunityModel read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return CommunityModel(
id: fields[0] as int,
name: fields[1] as String,
address: fields[2] as String,
addressDetails: fields[3] as String,
);
}
@override
void write(BinaryWriter writer, CommunityModel obj) {
writer
..writeByte(4)
..writeByte(0)
..write(obj.id)
..writeByte(1)
..write(obj.name)
..writeByte(2)
..write(obj.address)
..writeByte(3)
..write(obj.addressDetails);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is CommunityModelAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************

@ -1,10 +1,11 @@
import 'package:aku_new_community/ui/market/shop_car/shop_car_func.dart';
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
part 'good_detail_model.g.dart';
@JsonSerializable()
class GoodDetailModel {
class GoodDetailModel extends Equatable {
final int id;
final List<JcookImageVoList>? jcookImageVoList;
final num sellPrice;
@ -63,10 +64,29 @@ class GoodDetailModel {
required this.unit,
required this.weight,
});
@override
List<Object?> get props => [
jcookImageVoList,
sellPrice,
discountPrice,
skuName,
status,
shopStatus,
sellNum,
kind,
defaultLocation,
defaultAddressDetail,
stockStatus,
jcookSpecificationVoList,
isCollection,
unit,
weight,
];
}
@JsonSerializable()
class JcookImageVoList {
class JcookImageVoList extends Equatable {
final int id;
final int jcookGoodsId;
final String url;
@ -83,10 +103,18 @@ class JcookImageVoList {
required this.isPrimer,
required this.orderSort,
});
@override
List<Object?> get props => [
jcookGoodsId,
url,
isPrimer,
orderSort,
];
}
@JsonSerializable()
class JcookSpecificationVoList {
class JcookSpecificationVoList extends Equatable {
final String groupName;
final List<Attribute> attribute;
@ -97,10 +125,16 @@ class JcookSpecificationVoList {
required this.groupName,
required this.attribute,
});
@override
List<Object?> get props => [
groupName,
attribute,
];
}
@JsonSerializable()
class Attribute {
class Attribute extends Equatable {
final String? name;
final String? value;
@ -111,4 +145,10 @@ class Attribute {
required this.name,
required this.value,
});
@override
List<Object?> get props => [
name,
value,
];
}

@ -1,10 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart';
import 'package:aku_new_community/base/base_style.dart';
import 'package:aku_new_community/model/user/adress_model.dart';
import 'package:aku_new_community/model/user/province_model.dart';
@ -13,6 +6,13 @@ import 'package:aku_new_community/utils/headers.dart';
import 'package:aku_new_community/utils/hive_store.dart';
import 'package:aku_new_community/utils/text_utils.dart';
import 'package:aku_new_community/widget/bee_scaffold.dart';
import 'package:aku_new_community/widget/picker/bee_city_picker.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart';
import 'address_selector.dart';
import 'editView.dart';
@ -183,18 +183,19 @@ class _NewAddressPageState extends State<NewAddressPage> {
builder: (BuildContext context, StateSetter setSta) {
_addressStateSetter = setSta;
return GestureDetector(
onTap: () {
print('1');
if (_cityJsonModels.isEmpty) {
print('2');
getCityList().then((success) {
if (success) {
_selectAddress(context);
}
});
return;
onTap: () async {
// if (_cityJsonModels.isEmpty) {
// await getCityList();
// }
var _city = await BeeCityPicker.pick(context);
if (_city != null) {
_address.locationName = _city.address;
_address.location = _city.id;
_address.province = _city.province.name;
_address.city = _city.city.name;
_address.district = _city.district.name;
setState(() {});
}
_selectAddress(context);
},
child: Container(
padding: EdgeInsets.symmetric(vertical: 30.w, horizontal: 24.w),

@ -76,7 +76,7 @@ class Userfunc {
///
static Future<bool> setIsDefaultAddress(int addressId) async {
BaseModel model = await NetUtil().post(SAASAPI.market.address.setDefault,
BaseModel model = await NetUtil().get(SAASAPI.market.address.setDefault,
params: {'id': addressId}, showMessage: false);
if (model.success) {
BotToast.showText(text: '设置成功');

@ -151,8 +151,11 @@ class _ActivityDetailPageState extends State<ActivityDetailPage> {
bottomNavi: BottomButton(
child: '立即报名'.text.size(32.sp).color(Colors.black).bold.make(),
onPressed: () async {
await NetUtil().post(SAASAPI.activity.registration,
var re = await NetUtil().get(SAASAPI.activity.registration,
params: {'activityId': _model!.id}, showMessage: true);
if (re.success) {
_refreshController.callRefresh();
}
},
),
);
@ -189,8 +192,8 @@ class _ActivityDetailPageState extends State<ActivityDetailPage> {
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
width: 104.w,
height: 42.w,
padding:
EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.w),
decoration: BoxDecoration(
color: Color(0xFFFEC076).withOpacity(0.5),
borderRadius: BorderRadius.circular(10.w)),
@ -198,7 +201,7 @@ class _ActivityDetailPageState extends State<ActivityDetailPage> {
child: '${ActivityFunc.dateCheck(_model!.regisEndTime)}'
.text
.size(24.sp)
.color(Color(0xFFF481170))
.color(Color(0xFFF48117))
.make(),
),
],

@ -68,6 +68,16 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
Timer? _timer;
String get receiveAddress {
if (_addressModel == null) {
return (_goodDetail!.defaultLocation ?? '') +
(_goodDetail!.defaultAddressDetail ?? '');
} else {
return (_addressModel!.locationName ?? '') +
(_addressModel!.addressDetail ?? '');
}
}
@override
void initState() {
final appProvider = Provider.of<AppProvider>(Get.context!);
@ -112,8 +122,9 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
header: MaterialHeader(),
controller: _refreshController,
onRefresh: () async {
_goodDetail = await SearchFunc.getGoodDetail(widget.goodId);
_imageList = await SearchFunc.getGoodDetailImage(widget.goodId);
_goodDetail = await SearchFunc.getGoodDetail(
widget.goodId, _addressModel?.location);
// _imageList = await SearchFunc.getGoodDetailImage(widget.goodId);
if (_goodDetail != GoodDetailModel.fail()) {
_onload = false;
}
@ -380,6 +391,7 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
));
if (result != null) {
_addressModel = result;
_refreshController.callRefresh();
}
setState(() {});
},

@ -52,10 +52,11 @@ class SearchFunc {
}
///
static Future<GoodDetailModel> getGoodDetail(int shopId) async {
static Future<GoodDetailModel> getGoodDetail(
int shopId, int? addressId) async {
BaseModel model = await NetUtil().get(
SAASAPI.market.good.goodDetail,
params: {'appGoodsPushId': shopId},
params: {'appGoodsPushId': shopId, 'appGoodsAddressId': addressId},
);
if (model.data == null) return GoodDetailModel.fail();
return GoodDetailModel.fromJson(model.data);

@ -8,13 +8,13 @@ class SettlementGoodsDTO {
});
SettlementGoodsDTO.fromJson(Map<String, dynamic> json) {
appGoodsPushId = json['jcookGoodsId'];
appGoodsPushId = json['appGoodsPushId'];
num = json['num'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['jcookGoodsId'] = this.appGoodsPushId;
data['appGoodsPushId'] = this.appGoodsPushId;
data['num'] = this.num;
return data;

@ -16,6 +16,7 @@ import 'package:aku_new_community/utils/network/base_model.dart';
import 'package:aku_new_community/utils/network/net_util.dart';
import 'package:aku_new_community/widget/bee_scaffold.dart';
import 'package:aku_new_community/widget/buttons/end_button.dart';
import 'package:aku_new_community/widget/others/user_tool.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -177,17 +178,23 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
BotToast.showText(text: '请先选择地址');
}
Function cancel = BotToast.showLoading();
BaseModel baseModel = await NetUtil()
.post(API.pay.jcookOrderCreateOrder, params: {
"addressId": _addressModel!.id!,
"settlementGoodsDTOList":
_goodsList.map((v) => v.toJson()).toList(),
"payType": 1, //
"payPrice": _allPrice
});
BaseModel baseModel =
await NetUtil().post(SAASAPI.pay.createGoodsOrder,
params: {
"addressId": _addressModel!.id!,
"settlementGoodsDTOList":
_goodsList.map((v) => v.toJson()).toList(),
"payType": 1, //
"payPrice": _allPrice,
// 'points': widget.integral,
"residentId": UserTool.userProvider.userInfoModel!.id,
"payname": UserTool.userProvider.userInfoModel!.name,
"payTel": UserTool.userProvider.userInfoModel!.tel,
},
showMessage: true);
if (baseModel.success) {
bool result = await PayUtil()
.callAliPay(baseModel.msg, API.pay.jcookOrderCheckAlipay);
bool result = await PayUtil().callAliPay(
baseModel.msg, SAASAPI.pay.jcookOrderCheckAlipay);
if (result) {
Get.off(() => OrderPage(initIndex: 2));
} else {
@ -343,7 +350,6 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
}
int num = int.parse(_controllers.text);
print(num);
allNum += num;
allPrice += (widget.goodModel.sellPrice * num);

@ -1,5 +1,6 @@
import 'package:aku_new_community/model/user/province_model.dart';
import 'package:aku_new_community/models/login/china_region_model.dart';
import 'package:aku_new_community/models/login/community_model.dart';
import 'package:aku_new_community/models/login/history_login_model.dart';
import 'package:aku_new_community/models/login/picked_city_model.dart';
import 'package:aku_new_community/models/user/user_config_model.dart';
@ -36,6 +37,7 @@ class HiveStore {
Hive.registerAdapter(HistoryLoginModelAdapter()); //HiveTypeId:4
Hive.registerAdapter(UserConfigModelAdapter()); //HiveTypeId:5
Hive.registerAdapter(PickedCityModelAdapter()); //HiveTypeId:6
Hive.registerAdapter(CommunityModelAdapter());
_appBox = await Hive.openBox('app');
_userBox = await Hive.openBox('userBox');
_dataBox = await Hive.openBox('dataBox');

@ -77,6 +77,10 @@ class NetUtil {
_parseErr(e);
_baseModel = BaseModel(code: 0, msg: '未知错误', success: false, data: null);
}
if (showMessage) {
BotToast.showText(text: _baseModel.msg);
}
return _baseModel;
}
@ -108,6 +112,9 @@ class NetUtil {
_baseModel = BaseModel(code: 0, msg: '未知错误', success: false, data: null);
}
if (showMessage) {
BotToast.showText(text: _baseModel.msg);
}
return _baseModel;
}

Loading…
Cancel
Save