From 3bb7c372f6f1ce656bc4b7e9acff06c1383ea08b Mon Sep 17 00:00:00 2001 From: wylyl22 <2373073266@qq.com> Date: Thu, 15 Sep 2022 18:17:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 9 ++++++--- lib/ui/home/set/func/user_info_func.dart | 19 +++++++++++++++++++ lib/ui/user/user_card_page.dart | 9 +++++++-- lib/ui/user/user_page.dart | 8 +++++++- 4 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 lib/ui/home/set/func/user_info_func.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index f3a8036..412388c 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -30,7 +30,7 @@ class API { static _App app = _App(); static _Pay pay = _Pay(); static _Exclude exclude = _Exclude(); - static _Content content=_Content(); + static _Content content = _Content(); } class _App { @@ -56,7 +56,7 @@ class _App { String get trialVip => '/app/user/trialVip'; } -class _Content{ +class _Content { ///自定义短信 String get content => '/app/user/content'; @@ -70,13 +70,16 @@ class _Content{ String get find => '/app/user/content/find'; ///查看短信列表 - String get findByStatus =>'/app/user/content/findByStatus'; + String get findByStatus => '/app/user/content/findByStatus'; ///更新VIP状态(已合并至用户信息) String get updateVip => '/app/user/updateVip'; ///会员体验 String get trialVip => '/app/user/trialVip'; + + ///兑换会员 + String get redeemVip => '/app/user/redeem'; } class _Pay { diff --git a/lib/ui/home/set/func/user_info_func.dart b/lib/ui/home/set/func/user_info_func.dart new file mode 100644 index 0000000..6c237dc --- /dev/null +++ b/lib/ui/home/set/func/user_info_func.dart @@ -0,0 +1,19 @@ +import 'package:project_telephony/model/network/api_client.dart'; +import 'package:project_telephony/model/network/base_model.dart'; + +import '../../../../constants/api.dart'; +import '../../../../utils/toast/cloud_toast.dart'; + +class UserInfoFunc { + static Future getAddVip(String code) async { + BaseModel res = + await apiClient.request(API.content.redeemVip, data: {"code": code}); + if(res.code==0){ + CloudToast.show("卡密兑换成功"); + return true; + }else{ + CloudToast.show(res.msg); + return false; + } + } +} diff --git a/lib/ui/user/user_card_page.dart b/lib/ui/user/user_card_page.dart index 792ffbc..e3ab8a6 100644 --- a/lib/ui/user/user_card_page.dart +++ b/lib/ui/user/user_card_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:project_telephony/base/base_style.dart'; +import 'package:project_telephony/ui/home/set/func/user_info_func.dart'; import 'package:project_telephony/ui/widget/plone_bottom.dart'; import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/toast/cloud_toast.dart'; @@ -68,11 +69,15 @@ class _UserCardPageState extends State { 88.hb, PloneBottom( blM: false, - onTap: () { + onTap: () async{ if(cardMi.isEmpty){ CloudToast.show("卡密为空"); }else{ - CloudToast.show("卡密兑换成功"); + var res= await UserInfoFunc.getAddVip(cardMi); + if(res){ + Get.back(); + } + // CloudToast.show("卡密兑换成功"); } }, border: cardMi.isEmpty?true:false, diff --git a/lib/ui/user/user_page.dart b/lib/ui/user/user_page.dart index 2a75c3b..8dd6305 100644 --- a/lib/ui/user/user_page.dart +++ b/lib/ui/user/user_page.dart @@ -114,6 +114,7 @@ class _UserPageState extends State { children: [ Expanded( child: EasyRefresh( + controller: _easyRefreshController, firstRefresh: true, header: MaterialHeader(), onRefresh: () async { @@ -475,7 +476,12 @@ class _UserPageState extends State { )); break; case "卡密兑换": - Get.to(()=>UserCardPage()); + + Navigator.of(context) + .push( + MaterialPageRoute(builder: (_) => const UserCardPage()), + ) + .then((val) => _easyRefreshController.callRefresh()); break; default: break;