Browse Source

Merge branches 'dev' and 'master' of https://git.lotus-wallet.com/fmk/huixiang_app

master
fmk 3 years ago
parent
commit
6ea323c51f
  1. 32
      lib/home/home_view/coupon.dart
  2. 92
      lib/mine/fans_page.dart
  3. 12
      lib/retrofit/data/follow_list.dart

32
lib/home/home_view/coupon.dart

@ -24,7 +24,6 @@ class CouponView extends StatefulWidget {
class _CouponView extends State<CouponView> { class _CouponView extends State<CouponView> {
ApiService apiService; ApiService apiService;
int pageNum = 1;
List<Coupon> coupons = []; List<Coupon> coupons = [];
@ -45,21 +44,16 @@ class _CouponView extends State<CouponView> {
queryCoupon() async { queryCoupon() async {
BaseData<PageInfo<Coupon>> baseData = await apiService.queryCoupon({ BaseData<PageInfo<Coupon>> baseData = await apiService.queryCoupon({
"centre": true, "centre": true,
"pageNum": pageNum, "pageNum": 1,
"pageSize": 10, "pageSize": 10,
"searchKey": "", "searchKey": "",
"state": 0 "state": 0
}).catchError((onError) { }).catchError((onError) {
}); });
if (pageNum == 1) coupons.clear(); coupons.clear();
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
coupons.addAll(baseData.data.list); coupons.addAll(baseData.data.list);
if (baseData.data.pageNum == baseData.data.pages) {
} else {
pageNum += 1;
}
setState(() {}); setState(() {});
} else {
} }
} }
@ -252,11 +246,13 @@ class _CouponView extends State<CouponView> {
), ),
GestureDetector( GestureDetector(
onTap: (){ onTap: (){
if((coupon?.status??0) == 0)
receiveCoupon(coupon?.id??"");
}, },
child:RoundButton( child:RoundButton(
text: "领取", text: ((coupon?.status??0) == 0) ? "领取" : "领取",
textColor: Colors.white, textColor: Colors.white,
backgroup: Color(0xFF32A060), backgroup: ((coupon?.status??0) == 0)?Color(0xFF32A060):Colors.grey,
radius: 100, radius: 100,
padding: EdgeInsets.symmetric(vertical: 3.h, horizontal: 14.w), padding: EdgeInsets.symmetric(vertical: 3.h, horizontal: 14.w),
), ),
@ -279,5 +275,21 @@ class _CouponView extends State<CouponView> {
); );
} }
receiveCoupon(couponId) async {
BaseData baseData = await apiService.receiveCoupon(couponId);
if (baseData != null && baseData.isSuccess) {
queryCoupon();
showAlertDialog();
}
}
showAlertDialog() {
//
showDialog(
context: context,
builder: (BuildContext context) {
return ReceiveSuccess();
},
);
}
} }

92
lib/mine/fans_page.dart

@ -82,11 +82,12 @@ class _FansPage extends State<FansPage> {
} }
/// ///
_vipFollow(followId) async { _vipFollow(followId,isFollow) async {
BaseData baseData = await apiService.follow(followId); BaseData baseData = await apiService.follow(followId);
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
widget.refresh(); widget.refresh();
SmartDialog.showToast("关注成功", alignment: Alignment.center); _queryFollowList();
SmartDialog.showToast(isFollow?"取关成功":"关注成功", alignment: Alignment.center);
} else { } else {
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
} }
@ -170,68 +171,35 @@ class _FansPage extends State<FansPage> {
borderRadius: BorderRadius.circular(11.w), borderRadius: BorderRadius.circular(11.w),
color: Color(0xFF32A060), color: Color(0xFF32A060),
), ),
child: child: GestureDetector(
// GestureDetector( onTap: () {
// onTap: () { setState(() {
// setState(() { _vipFollow(list.mid,list?.isFollow ?? false);
// if (widget.commentType == 0) { });
// comment?.selfFollow = },
// !(comment?.selfFollow ?? false); child: RoundButton(
// _vipFollow(list.mid); padding: EdgeInsets.symmetric(
// } horizontal: 8,
// }); vertical: 3,
// },
// child: (widget.commentType == 0)
// ? RoundButton(
// padding: EdgeInsets.symmetric(
// horizontal: 8,
// vertical: 3,
// ),
// backgroup: (comment?.selfFollow ?? false)
// ? Color(0xFFE6E6E6)
// : Color(0xFF32A060),
// textColor: (comment?.selfFollow ?? false)
// ? Color(0xFF808080)
// : Colors.white,
// text: (comment?.selfFollow ?? false) ? "已关注" : "关注",
// radius: 20,
// icons: Icon(
// (comment?.selfFollow ?? false)
// ? Icons.check
// : Icons.add,
// color: (comment?.selfFollow ?? false)
// ? Color(0xFF808080)
// : Colors.white,
// size: 14,
// ),
// )
// : Icon(
// Icons.close,
// color: Colors.black,
// size: 16,
// ),
// ),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment:CrossAxisAlignment.center,
children: [
Icon(
Icons.add,
color: Colors.white,
size: 14,
),
SizedBox(
width:4,
), ),
Text( backgroup: (list?.isFollow ?? false)
"关注", ? Color(0xFFE6E6E6)
style: TextStyle( : Color(0xFF32A060),
color: Colors.white, textColor: (list?.isFollow ?? false)
fontSize: 12.sp, ? Color(0xFF808080)
fontWeight: MyFontWeight.regular, : Colors.white,
), text: (list?.isFollow ?? false) ? "已关注" : "关注",
radius: 20,
icons: Icon(
(list?.isFollow ?? false)
? Icons.check
: Icons.add,
color: (list?.isFollow ?? false)
? Color(0xFF808080)
: Colors.white,
size: 14,
), ),
], ),
), ),
), ),
], ],

12
lib/retrofit/data/follow_list.dart

@ -115,25 +115,30 @@ class FollowList {
class ListData { class ListData {
ListData({ ListData({
String mid, String mid,
bool isFollow,
String nickname, String nickname,
String avatar,}){ String avatar,}){
_mid = mid; _mid = mid;
_nickname = nickname; _nickname = nickname;
_isFollow = isFollow;
_avatar = avatar; _avatar = avatar;
} }
ListData.fromJson(dynamic json) { ListData.fromJson(dynamic json) {
_mid = json['mid']; _mid = json['mid'];
_nickname = json['nickname']; _nickname = json['nickname'];
_isFollow = json['isFollow'];
_avatar = json['avatar']; _avatar = json['avatar'];
} }
String _mid; String _mid;
String _nickname; String _nickname;
String _avatar; String _avatar;
bool _isFollow;
String get mid => _mid; String get mid => _mid;
String get nickname => _nickname; String get nickname => _nickname;
bool get isFollow => _isFollow;
String get avatar => _avatar; String get avatar => _avatar;
@ -141,10 +146,15 @@ class ListData {
_mid = value; _mid = value;
} }
set isFollow(bool value) {
_isFollow = value;
}
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final map = <String, dynamic>{}; final map = <String, dynamic>{};
map['mid'] = _mid; map['mid'] = _mid;
map['nickname'] = _nickname; map['nickname'] = _nickname;
map['isFollow'] = _isFollow;
map['avatar'] = _avatar; map['avatar'] = _avatar;
return map; return map;
} }

Loading…
Cancel
Save