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> {
ApiService apiService;
int pageNum = 1;
List<Coupon> coupons = [];
@ -45,21 +44,16 @@ class _CouponView extends State<CouponView> {
queryCoupon() async {
BaseData<PageInfo<Coupon>> baseData = await apiService.queryCoupon({
"centre": true,
"pageNum": pageNum,
"pageNum": 1,
"pageSize": 10,
"searchKey": "",
"state": 0
}).catchError((onError) {
});
if (pageNum == 1) coupons.clear();
coupons.clear();
if (baseData != null && baseData.isSuccess) {
coupons.addAll(baseData.data.list);
if (baseData.data.pageNum == baseData.data.pages) {
} else {
pageNum += 1;
}
setState(() {});
} else {
}
}
@ -252,11 +246,13 @@ class _CouponView extends State<CouponView> {
),
GestureDetector(
onTap: (){
if((coupon?.status??0) == 0)
receiveCoupon(coupon?.id??"");
},
child:RoundButton(
text: "领取",
text: ((coupon?.status??0) == 0) ? "领取" : "领取",
textColor: Colors.white,
backgroup: Color(0xFF32A060),
backgroup: ((coupon?.status??0) == 0)?Color(0xFF32A060):Colors.grey,
radius: 100,
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);
if (baseData != null && baseData.isSuccess) {
widget.refresh();
SmartDialog.showToast("关注成功", alignment: Alignment.center);
_queryFollowList();
SmartDialog.showToast(isFollow?"取关成功":"关注成功", alignment: Alignment.center);
} else {
SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
}
@ -170,68 +171,35 @@ class _FansPage extends State<FansPage> {
borderRadius: BorderRadius.circular(11.w),
color: Color(0xFF32A060),
),
child:
// GestureDetector(
// onTap: () {
// setState(() {
// if (widget.commentType == 0) {
// comment?.selfFollow =
// !(comment?.selfFollow ?? false);
// _vipFollow(list.mid);
// }
// });
// },
// 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,
child: GestureDetector(
onTap: () {
setState(() {
_vipFollow(list.mid,list?.isFollow ?? false);
});
},
child: RoundButton(
padding: EdgeInsets.symmetric(
horizontal: 8,
vertical: 3,
),
Text(
"关注",
style: TextStyle(
color: Colors.white,
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
),
backgroup: (list?.isFollow ?? false)
? Color(0xFFE6E6E6)
: Color(0xFF32A060),
textColor: (list?.isFollow ?? false)
? Color(0xFF808080)
: 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 {
ListData({
String mid,
String mid,
bool isFollow,
String nickname,
String avatar,}){
_mid = mid;
_nickname = nickname;
_isFollow = isFollow;
_avatar = avatar;
}
ListData.fromJson(dynamic json) {
_mid = json['mid'];
_nickname = json['nickname'];
_isFollow = json['isFollow'];
_avatar = json['avatar'];
}
String _mid;
String _nickname;
String _avatar;
bool _isFollow;
String get mid => _mid;
String get nickname => _nickname;
bool get isFollow => _isFollow;
String get avatar => _avatar;
@ -141,10 +146,15 @@ class ListData {
_mid = value;
}
set isFollow(bool value) {
_isFollow = value;
}
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['mid'] = _mid;
map['nickname'] = _nickname;
map['isFollow'] = _isFollow;
map['avatar'] = _avatar;
return map;
}

Loading…
Cancel
Save