Browse Source

Merge remote-tracking branch 'origin/remove_uniapp' into remove_uniapp

ff_new
fmk 3 years ago
parent
commit
139abe7426
  1. 14
      lib/home/home_page.dart
  2. 8
      lib/retrofit/retrofit_api.dart
  3. 2
      lib/retrofit/retrofit_api.g.dart
  4. 157
      lib/view_widget/activity_coupons.dart
  5. 2
      lib/view_widget/login_tips.dart

14
lib/home/home_page.dart

@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -303,8 +305,7 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
child: GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/router/system_msg_page');
///
// activityShowAlertDialog();
},
child: Container(
height: 24,
@ -478,6 +479,11 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
} else if (await Permission.camera.isGranted) {
// http://pos.app.gznl.top/placeorder/?tableId=1315903669597634560&tenantCode=1166&shopId=1300372027722432512
var result = await Navigator.of(context).pushNamed('/router/qr_scan');
if(result.toString().contains("type\":\"coupon")){
///
activityShowAlertDialog(result.toString());
return;
}
// String result = await scanner.scan();
Uri uri = Uri.parse(result);
String tableId = uri.queryParameters["tableId"];
@ -526,12 +532,12 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
);
}
activityShowAlertDialog() {
activityShowAlertDialog(String result) {
//
showDialog(
context: context,
builder: (BuildContext context) {
return ActivityCoupons();
return ActivityCoupons(result);
},
);
}

8
lib/retrofit/retrofit_api.dart

@ -54,14 +54,14 @@ import 'data/wx_pay.dart';
part 'retrofit_api.g.dart';
// const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///
// const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///
const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///
const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///
// const base_url = "http://platform.prod.kunqi.lotus-wallet.com/app/"; ///222
// const baseUrl = "http://platform.prod.kunqi.lotus-wallet.com/app/"; ///222
const base_url = "http://192.168.10.236:8766/app/"; ///
const baseUrl = "http://192.168.10.236:8766/app/"; ///
// const base_url = "http://192.168.10.236:8766/app/"; ///
// const baseUrl = "http://192.168.10.236:8766/app/"; ///
// const base_url = "http://192.168.10.159:8766/app/"; ///
// const baseUrl = "http://192.168.10.159:8766/app/"; ///

2
lib/retrofit/retrofit_api.g.dart

@ -9,7 +9,7 @@ part of 'retrofit_api.dart';
class _ApiService implements ApiService {
_ApiService(this._dio, {this.baseUrl}) {
ArgumentError.checkNotNull(_dio, '_dio');
baseUrl ??= 'http://192.168.10.236:8766/app/';
baseUrl ??= 'https://pos.platform.lotus-wallet.com/app/';
}
final Dio _dio;

157
lib/view_widget/activity_coupons.dart

@ -1,18 +1,20 @@
import 'dart:collection';
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/login_info.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/coupon.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/receive_success.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:huixiang/view_widget/separator.dart';
import 'package:shared_preferences/shared_preferences.dart';
class ActivityCoupons extends StatefulWidget {
// final List<NewUserCouponList> newUserCouponList;
//
// ActivityCoupons(this.newUserCouponList);
final String result;
ActivityCoupons(this.result);
@override
State<StatefulWidget> createState() {
@ -21,16 +23,53 @@ class ActivityCoupons extends StatefulWidget {
}
class _ActivityCoupons extends State<ActivityCoupons> {
var resultData;
int pageNum = 1;
List<Coupon> coupons = [];
ApiService apiService;
var receiveCou = new Queue();
@override
void initState() {
super.initState();
resultData = jsonDecode(widget.result);
}
receiveCoupon() async {
var id = receiveCou.removeFirst();
if (apiService == null) {
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
);
}
BaseData baseData = await apiService.receiveCoupon(id).catchError((onError) {});
if (baseData != null && baseData.isSuccess) {
if (receiveCou.length > 0) {
receiveCoupon();
} else {
Navigator.of(context).pop();
SmartDialog.showToast("领取成功", alignment: Alignment.center);
}
}
else{
SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
Navigator.of(context).pop();
}
}
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(top:150.h),
margin: EdgeInsets.only(top: 150.h),
height: MediaQuery.of(context).size.height / 2,
child: Column(
children: [
Container(
width: double.infinity,
height:MediaQuery.of(context).size.height / 2,
height: MediaQuery.of(context).size.height / 2,
padding: EdgeInsets.only(top: 210.h),
margin: EdgeInsets.only(top: 20.h, left: 20, right: 20),
decoration: BoxDecoration(
@ -42,16 +81,18 @@ class _ActivityCoupons extends State<ActivityCoupons> {
child: Column(
children: [
Expanded(
child: reward(),
child: couponsActivity(),
),
GestureDetector(
onTap: () {
Navigator.of(context).pop();
SmartDialog.showToast("领取成功",alignment: Alignment.center);
(resultData["list"] as List).forEach((element) {
receiveCou..add(element["id"]);
});
receiveCoupon();
},
child: Container(
margin: EdgeInsets.only(
left: 60.w, right: 60.w, top: 20.h, bottom:20.h),
left: 60.w, right: 60.w, top: 20.h, bottom: 20.h),
decoration: BoxDecoration(
gradient: new LinearGradient(
begin: Alignment.centerLeft,
@ -96,23 +137,25 @@ class _ActivityCoupons extends State<ActivityCoupons> {
);
}
Widget reward() {
Widget couponsActivity() {
return ListView.builder(
padding: EdgeInsets.zero,
itemCount: 4,
itemCount: (resultData == null || resultData["list"] == null)
? 0
: (resultData["list"] as List).length,
scrollDirection: Axis.vertical,
shrinkWrap: true,
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {},
child: rewardItem(),
child: couponsItem(resultData["list"][position]),
);
},
);
}
Widget rewardItem() {
Widget couponsItem(listData) {
return Container(
height: 69.h,
width: double.infinity,
@ -123,31 +166,27 @@ class _ActivityCoupons extends State<ActivityCoupons> {
),
),
margin: EdgeInsets.symmetric(horizontal: 60, vertical: 5),
padding: EdgeInsets.only(left: 16.w, right: 25.w),
padding: EdgeInsets.only(left: 16.w, right: 10.w),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (listData["type"] == 1)
Text.rich(
TextSpan(
children: [
TextSpan(
text: "¥",
style: TextStyle(
fontSize: 25.sp,
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFFDE5F3B),
),
),
TextSpan(
// text: double.tryParse(
// "${newUserCouponList.discountAmount}" ?? "0")
// .toInt()
// .toString() ??
// "",
text: "10",
text: listData["discount"] ?? "",
style: TextStyle(
fontSize: 35.sp,
fontSize: 20.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFFDE5F3B),
),
@ -155,45 +194,59 @@ class _ActivityCoupons extends State<ActivityCoupons> {
],
),
),
Expanded(child:Padding(
padding: EdgeInsets.only(top: 4, bottom: 4,left:10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (listData["type"] == 3)
Text(
"海峡姐妹茶吧",
"兑换券",
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
fontSize: 14.sp,
fontSize: 16.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF181818),
color: Color(0xFFDE5F3B),
),
),
Text(
"10元代金劵一张",
overflow: TextOverflow.ellipsis,
maxLines: 2,
if (listData["type"] == 2)
Padding(
padding: EdgeInsets.only(right: 20),
child: Text.rich(
TextSpan(
children: [
TextSpan(
text: (listData["percent"] / 10).toString() ?? "",
style: TextStyle(
fontSize: 25.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFFDE5F3B),
),
),
TextSpan(
text: "",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFFD3623D),
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFFDE5F3B),
),
),
],
),
)),
Expanded(
child: Padding(
padding: EdgeInsets.only(top: 4, bottom: 4, left: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
// "有效期至:${(newUserCouponList.useEndTime != null && newUserCouponList.useEndTime != "")
// ? newUserCouponList.useEndTime.split(" ")[0]
// : "$newUserCouponList.useEndTime"}",
"有效期至:2021-07-30",
listData["name"] ?? "",
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
fontSize: 10.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF727272),
fontSize: 16.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF181818),
),
),
)
],
))),
],

2
lib/view_widget/login_tips.dart

@ -23,7 +23,7 @@ class LoginTips extends StatelessWidget {
// height: 0.7867.sw / (Platform.isAndroid ? 0.86 : 0.9),
width:double.infinity,
height:MediaQuery.of(context).size.width / 1,
margin: EdgeInsets.symmetric(horizontal:16.w),
margin: EdgeInsets.symmetric(horizontal:28.w),
padding: EdgeInsets.symmetric(vertical: 20.h, horizontal: 24.w),
decoration: BoxDecoration(
color: Colors.white,

Loading…
Cancel
Save