替换商城地址选择器

对接创建订单接口
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 _Announce announce = _Announce();
static _Information information = _Information(); static _Information information = _Information();
static _WorkOrder workOrder = _WorkOrder(); static _WorkOrder workOrder = _WorkOrder();
static _Pay pay = _Pay();
/// ///
static _ProfileApi profile = _ProfileApi(); static _ProfileApi profile = _ProfileApi();
@ -247,3 +248,11 @@ class _WorkOrder {
/// ///
String get list => '/app/user/workOrder/list'; 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 { class $AssetsJsonGen {
const $AssetsJsonGen(); const $AssetsJsonGen();
/// File path: assets/json/province.json
String get province => 'assets/json/province.json';
} }
class $AssetsStaticGen { class $AssetsStaticGen {

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

@ -2,6 +2,53 @@
part of 'community_model.dart'; 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 // JsonSerializableGenerator
// ************************************************************************** // **************************************************************************

@ -1,10 +1,11 @@
import 'package:aku_new_community/ui/market/shop_car/shop_car_func.dart'; 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'; import 'package:json_annotation/json_annotation.dart';
part 'good_detail_model.g.dart'; part 'good_detail_model.g.dart';
@JsonSerializable() @JsonSerializable()
class GoodDetailModel { class GoodDetailModel extends Equatable {
final int id; final int id;
final List<JcookImageVoList>? jcookImageVoList; final List<JcookImageVoList>? jcookImageVoList;
final num sellPrice; final num sellPrice;
@ -63,10 +64,29 @@ class GoodDetailModel {
required this.unit, required this.unit,
required this.weight, required this.weight,
}); });
@override
List<Object?> get props => [
jcookImageVoList,
sellPrice,
discountPrice,
skuName,
status,
shopStatus,
sellNum,
kind,
defaultLocation,
defaultAddressDetail,
stockStatus,
jcookSpecificationVoList,
isCollection,
unit,
weight,
];
} }
@JsonSerializable() @JsonSerializable()
class JcookImageVoList { class JcookImageVoList extends Equatable {
final int id; final int id;
final int jcookGoodsId; final int jcookGoodsId;
final String url; final String url;
@ -83,10 +103,18 @@ class JcookImageVoList {
required this.isPrimer, required this.isPrimer,
required this.orderSort, required this.orderSort,
}); });
@override
List<Object?> get props => [
jcookGoodsId,
url,
isPrimer,
orderSort,
];
} }
@JsonSerializable() @JsonSerializable()
class JcookSpecificationVoList { class JcookSpecificationVoList extends Equatable {
final String groupName; final String groupName;
final List<Attribute> attribute; final List<Attribute> attribute;
@ -97,10 +125,16 @@ class JcookSpecificationVoList {
required this.groupName, required this.groupName,
required this.attribute, required this.attribute,
}); });
@override
List<Object?> get props => [
groupName,
attribute,
];
} }
@JsonSerializable() @JsonSerializable()
class Attribute { class Attribute extends Equatable {
final String? name; final String? name;
final String? value; final String? value;
@ -111,4 +145,10 @@ class Attribute {
required this.name, required this.name,
required this.value, 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/base/base_style.dart';
import 'package:aku_new_community/model/user/adress_model.dart'; import 'package:aku_new_community/model/user/adress_model.dart';
import 'package:aku_new_community/model/user/province_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/hive_store.dart';
import 'package:aku_new_community/utils/text_utils.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/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 'address_selector.dart';
import 'editView.dart'; import 'editView.dart';
@ -183,18 +183,19 @@ class _NewAddressPageState extends State<NewAddressPage> {
builder: (BuildContext context, StateSetter setSta) { builder: (BuildContext context, StateSetter setSta) {
_addressStateSetter = setSta; _addressStateSetter = setSta;
return GestureDetector( return GestureDetector(
onTap: () { onTap: () async {
print('1'); // if (_cityJsonModels.isEmpty) {
if (_cityJsonModels.isEmpty) { // await getCityList();
print('2'); // }
getCityList().then((success) { var _city = await BeeCityPicker.pick(context);
if (success) { if (_city != null) {
_selectAddress(context); _address.locationName = _city.address;
} _address.location = _city.id;
}); _address.province = _city.province.name;
return; _address.city = _city.city.name;
_address.district = _city.district.name;
setState(() {});
} }
_selectAddress(context);
}, },
child: Container( child: Container(
padding: EdgeInsets.symmetric(vertical: 30.w, horizontal: 24.w), padding: EdgeInsets.symmetric(vertical: 30.w, horizontal: 24.w),

@ -76,7 +76,7 @@ class Userfunc {
/// ///
static Future<bool> setIsDefaultAddress(int addressId) async { 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); params: {'id': addressId}, showMessage: false);
if (model.success) { if (model.success) {
BotToast.showText(text: '设置成功'); BotToast.showText(text: '设置成功');

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

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

@ -8,13 +8,13 @@ class SettlementGoodsDTO {
}); });
SettlementGoodsDTO.fromJson(Map<String, dynamic> json) { SettlementGoodsDTO.fromJson(Map<String, dynamic> json) {
appGoodsPushId = json['jcookGoodsId']; appGoodsPushId = json['appGoodsPushId'];
num = json['num']; num = json['num'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = new Map<String, dynamic>();
data['jcookGoodsId'] = this.appGoodsPushId; data['appGoodsPushId'] = this.appGoodsPushId;
data['num'] = this.num; data['num'] = this.num;
return data; 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/utils/network/net_util.dart';
import 'package:aku_new_community/widget/bee_scaffold.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/buttons/end_button.dart';
import 'package:aku_new_community/widget/others/user_tool.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -177,17 +178,23 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
BotToast.showText(text: '请先选择地址'); BotToast.showText(text: '请先选择地址');
} }
Function cancel = BotToast.showLoading(); Function cancel = BotToast.showLoading();
BaseModel baseModel = await NetUtil() BaseModel baseModel =
.post(API.pay.jcookOrderCreateOrder, params: { await NetUtil().post(SAASAPI.pay.createGoodsOrder,
"addressId": _addressModel!.id!, params: {
"settlementGoodsDTOList": "addressId": _addressModel!.id!,
_goodsList.map((v) => v.toJson()).toList(), "settlementGoodsDTOList":
"payType": 1, // _goodsList.map((v) => v.toJson()).toList(),
"payPrice": _allPrice "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) { if (baseModel.success) {
bool result = await PayUtil() bool result = await PayUtil().callAliPay(
.callAliPay(baseModel.msg, API.pay.jcookOrderCheckAlipay); baseModel.msg, SAASAPI.pay.jcookOrderCheckAlipay);
if (result) { if (result) {
Get.off(() => OrderPage(initIndex: 2)); Get.off(() => OrderPage(initIndex: 2));
} else { } else {
@ -343,7 +350,6 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
} }
int num = int.parse(_controllers.text); int num = int.parse(_controllers.text);
print(num);
allNum += num; allNum += num;
allPrice += (widget.goodModel.sellPrice * 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/model/user/province_model.dart';
import 'package:aku_new_community/models/login/china_region_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/history_login_model.dart';
import 'package:aku_new_community/models/login/picked_city_model.dart'; import 'package:aku_new_community/models/login/picked_city_model.dart';
import 'package:aku_new_community/models/user/user_config_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(HistoryLoginModelAdapter()); //HiveTypeId:4
Hive.registerAdapter(UserConfigModelAdapter()); //HiveTypeId:5 Hive.registerAdapter(UserConfigModelAdapter()); //HiveTypeId:5
Hive.registerAdapter(PickedCityModelAdapter()); //HiveTypeId:6 Hive.registerAdapter(PickedCityModelAdapter()); //HiveTypeId:6
Hive.registerAdapter(CommunityModelAdapter());
_appBox = await Hive.openBox('app'); _appBox = await Hive.openBox('app');
_userBox = await Hive.openBox('userBox'); _userBox = await Hive.openBox('userBox');
_dataBox = await Hive.openBox('dataBox'); _dataBox = await Hive.openBox('dataBox');

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

Loading…
Cancel
Save