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. 219
      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:dio/dio.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -303,8 +305,7 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
Navigator.of(context).pushNamed('/router/system_msg_page'); Navigator.of(context).pushNamed('/router/system_msg_page');
///
// activityShowAlertDialog();
}, },
child: Container( child: Container(
height: 24, height: 24,
@ -478,6 +479,11 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
} else if (await Permission.camera.isGranted) { } else if (await Permission.camera.isGranted) {
// http://pos.app.gznl.top/placeorder/?tableId=1315903669597634560&tenantCode=1166&shopId=1300372027722432512 // http://pos.app.gznl.top/placeorder/?tableId=1315903669597634560&tenantCode=1166&shopId=1300372027722432512
var result = await Navigator.of(context).pushNamed('/router/qr_scan'); 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(); // String result = await scanner.scan();
Uri uri = Uri.parse(result); Uri uri = Uri.parse(result);
String tableId = uri.queryParameters["tableId"]; String tableId = uri.queryParameters["tableId"];
@ -526,12 +532,12 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
); );
} }
activityShowAlertDialog() { activityShowAlertDialog(String result) {
// //
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext 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'; part 'retrofit_api.g.dart';
// const base_url = "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 baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///
// const base_url = "http://platform.prod.kunqi.lotus-wallet.com/app/"; ///222 // const base_url = "http://platform.prod.kunqi.lotus-wallet.com/app/"; ///222
// const baseUrl = "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 base_url = "http://192.168.10.236:8766/app/"; ///
const baseUrl = "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 base_url = "http://192.168.10.159:8766/app/"; ///
// const baseUrl = "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 { class _ApiService implements ApiService {
_ApiService(this._dio, {this.baseUrl}) { _ApiService(this._dio, {this.baseUrl}) {
ArgumentError.checkNotNull(_dio, '_dio'); ArgumentError.checkNotNull(_dio, '_dio');
baseUrl ??= 'http://192.168.10.236:8766/app/'; baseUrl ??= 'https://pos.platform.lotus-wallet.com/app/';
} }
final Dio _dio; final Dio _dio;

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

Loading…
Cancel
Save