Commit b6b50f8f770380a0811b6096560707cf5377ad53

Authored by weixin_45529955
2 parents 540afd59 b2515336

Merge branch 'v7.2.0+' into v7.3.0+

class SellerVersionModel {
int? ret;
List<SellerVersionSunModel>? data;
... ... @@ -37,6 +36,7 @@ class SellerVersionSunModel {
String? rdate;
String? edate;
String? cdate;
double? price;
SellerVersionSunModel(
{this.id,
... ... @@ -46,9 +46,10 @@ class SellerVersionSunModel {
this.vname,
this.rdate,
this.edate,
this.cdate});
this.cdate,
this.price});
SellerVersionSunModel.fromJson(Map<String, dynamic> json){
SellerVersionSunModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
sid = json['sid'];
vid = json['vid'];
... ... @@ -59,7 +60,10 @@ class SellerVersionSunModel {
// edate = json['vid'] == '4' ? '1695005146' : '1694832346';
edate = json['edate'];
cdate = json['cdate'];
}
price = json['price'] is num
? (json['price'] as num).toDouble()
: double.tryParse('${json['price']}');
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
... ... @@ -71,6 +75,7 @@ class SellerVersionSunModel {
data['rdate'] = this.rdate;
data['edate'] = this.edate;
data['cdate'] = this.cdate;
data['price'] = this.price;
return data;
}
}
... ...
... ... @@ -239,7 +239,7 @@ class DioUtil {
return new BaseResp(_status, _code, _msg, _data, _responseData);
} catch (e) {
Loading.hideLoading(context);
// Loading is dismissed once by the outer DioException handler below.
throw new DioException(
requestOptions: response.requestOptions,
response: response,
... ... @@ -248,7 +248,7 @@ class DioUtil {
);
}
}
Loading.hideLoading(context);
// Loading is dismissed once by the outer DioException handler below.
throw new DioException(
requestOptions: response.requestOptions,
response: response,
... ...
... ... @@ -3,7 +3,7 @@ class HttpUrl {
static const String server_address = "http://xt04.colorcun.com/"; //服务端请求地址
// static const String server_address = "http://192.168.5.90:8000/public/"; //服务端请求地址
static const String app_user_login =
"?service=Android.User.AppUserLogin"; //登录地址
static const String user_token_init =
... ... @@ -480,6 +480,8 @@ class HttpUrl {
static const String get_seller_version =
"?service=App.SellerVersion.GetSellerVersion"; // 获取商家的版本信息
static const String get_version_list =
"?service=App.SellerVersion.GetVersionList"; // 获取所有版本列表
static const String get_seller_template_color_list =
"?service=App.Seller.GetSellerTemplateColorList"; // 模板/颜色配置信息
... ... @@ -675,14 +677,9 @@ class HttpUrl {
static const get_free_meal_config_by_seller =
"?service=App.Activity.GetFreeMealConfigBySeller"; // 获取当餐免费的配置信息
static const clear_seller_user_wechat_bind =
static const clear_seller_user_wechat_bind =
"?service=App.Wechat.ClearSellerUserWechatBind"; // 解绑员工账号微信
static const get_customer_target_group_list =
"?service=App.Activity.GetCustomerTargetGroupList"; // 获取客户目标群体列表
... ...
... ... @@ -98,7 +98,7 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> {
// }
/// 获取定位权限
_requestLocationPermission() async {
_requestLocationPermission({bool forceCenter = false}) async {
await AmapLocation.instance.updatePrivacyShow(true);
await AmapLocation.instance.updatePrivacyAgree(true);
bool canLocation = false;
... ... @@ -128,7 +128,8 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> {
// App.sp.setString("lat", "39.684670899");
// App.sp.setString("lng", "118.17630045");
} else {
if (widget.long == null ||
if (forceCenter ||
widget.long == null ||
widget.long == '' ||
widget.long == 'null') {
latitude = location.latLng!.latitude;
... ... @@ -288,8 +289,7 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> {
bottom: w(10),
child: InkWell(
onTap: () {
_controller!.setCenterCoordinate(
LatLng(latitudeLocation, longitudeLocation));
_requestLocationPermission(forceCenter: true);
},
child: Container(
decoration: BoxDecoration(
... ...
... ... @@ -162,6 +162,9 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
// }
WidgetsBinding.instance.addObserver(this);
EventBus().on('refreshSellerVersion', (arg) {
getSellerVersion();
});
_currIndex = widget.initialIndex;
... ... @@ -2028,6 +2031,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
LogUtil.v("home_dispose");
// bus.off('refresh_token');
EventBus().off('refreshSellerVersion');
if (timer != null) {
timer!.cancel();
}
... ...
... ... @@ -592,6 +592,12 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
fields += element.code! + ',';
}
});
// GetExportInfo 服务端会无条件读取 con_amount。若不导出该字段,
// 响应体会带 PHP Notice,Dio 无法解析 JSON,导致导出流程中断。
if (!customerProvider.reportFieldModelData!.any((element) =>
element.select && element.code == 'con_amount')) {
fields += 'con_amount,';
}
if (fields.endsWith(',')) {
fields = fields.substring(0, fields.length - 1);
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluwx/fluwx.dart';
import 'package:one_key/models/seller_version_model.dart';
import 'package:one_key/models/wechat_pay_model.dart';
import 'package:one_key/provider/collect_store_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:provider/provider.dart';
class FunctionUpgradePage extends StatefulWidget {
const FunctionUpgradePage({super.key, required this.collectStoreProvider});
final CollectStoreProvider collectStoreProvider;
@override
State<FunctionUpgradePage> createState() => _FunctionUpgradePageState();
}
class _FunctionUpgradePageState extends State<FunctionUpgradePage> {
final List<_UpgradeModule> _modules = [];
bool _loading = true;
bool _loadFailed = false;
late FluwxCancelable _wxPay;
final Fluwx _fluwx = Fluwx();
_UpgradeModule? get _selectedModule {
for (final module in _modules) {
if (module.selected) {
return module;
}
}
return null;
}
double get _total => _selectedModule?.price ?? 0;
bool get _hasSelection => _selectedModule != null;
@override
void initState() {
super.initState();
Utils.changeStatusColor(color: Colors.transparent);
_wxPay = _fluwx.addSubscriber((res) {
_wxPay.cancel();
if (res is WeChatPaymentResponse) {
if (res.errCode == 0) {
_handlePaySuccess();
} else if (res.errCode == -1) {
Utils.showToast('支付错误');
} else if (res.errCode == -2) {
Utils.showToast('您已取消支付');
}
}
});
WidgetsBinding.instance.addPostFrameCallback((_) {
_loadModules();
});
}
Future<void> _loadModules() async {
setState(() {
_loading = true;
_loadFailed = false;
});
final List<SellerVersionSunModel>? list =
await widget.collectStoreProvider.getFunctionUpgradeList(context);
if (!mounted) {
return;
}
setState(() {
_modules.clear();
if (list != null) {
for (final item in list) {
final _UpgradeModule? module = _mapModule(item);
if (module != null) {
module.selected = false;
_modules.add(module);
}
}
}
_loading = false;
_loadFailed = list == null;
});
}
_UpgradeModule? _mapModule(SellerVersionSunModel item) {
final String? vid = item.vid;
final String? name = item.vname;
if (vid == null || name == null || name.trim().isEmpty) {
return null;
}
final String vtype = item.vtype ?? '';
final String desc;
if (vtype == '1') {
desc = '包含现有全部功能组件模块以及未来扩展的功能模块。';
} else if (vtype == '3') {
desc = '$name为独立功能模块,开通后有效期一年。';
} else {
desc = '$name套餐,开通后有效期一年。';
}
return _UpgradeModule(
vid: vid,
name: name,
desc: desc,
price: item.price ?? 0,
);
}
void _toggleModule(int index) {
final bool selected = _modules[index].selected;
setState(() {
for (final module in _modules) {
module.selected = false;
}
_modules[index].selected = !selected;
});
}
Future<void> _pay() async {
final _UpgradeModule? selected = _selectedModule;
if (selected == null) {
Utils.showToast('请先选择需要开通的模块');
return;
}
if (selected.price <= 0) {
Utils.showToast('当前模块暂不支持购买');
return;
}
final bool isInstalled = await _fluwx.isWeChatInstalled;
if (!isInstalled) {
Utils.showToast('请先安装微信');
return;
}
final String? sellerid =
Provider.of<UserModel>(context, listen: false).user?.sellerid;
if (sellerid == null || sellerid.isEmpty) {
Utils.showToast('商家信息异常');
return;
}
final bool success = await widget.collectStoreProvider.appPayJiSuVersion(
context,
{'sellerid': sellerid, 'vid': selected.vid},
);
if (!success || !mounted) {
return;
}
final WechatPaySunModel? sunModel = widget.collectStoreProvider.sunModel;
if (sunModel == null ||
sunModel.appId == null ||
sunModel.package == null ||
sunModel.timeStamp == null ||
sunModel.nonceStr == null) {
Utils.showToast('支付参数异常');
return;
}
final String prepayId = sunModel.package!.substring(10);
final Map<String, String?> signParams = {
'appid': sunModel.appId,
'partnerid': '1489752232',
'prepayid': prepayId,
'timestamp': sunModel.timeStamp,
'noncestr': sunModel.nonceStr,
'package': 'Sign=WXPay',
};
final String sign = Utils.keySort(signParams);
_fluwx
.pay(
which: Payment(
appId: sunModel.appId!,
partnerId: '1489752232',
prepayId: prepayId,
packageValue: 'Sign=WXPay',
nonceStr: sunModel.nonceStr!,
timestamp: int.parse(sunModel.timeStamp!),
sign: sign,
),
)
.then((data) {
print('version pay: $data');
}).catchError((error) {
print(error.toString());
Utils.showToast('支付调起失败');
});
}
Future<void> _handlePaySuccess() async {
Utils.showToast('购买成功');
await widget.collectStoreProvider
.refreshSellerVersion(context, showLoading: false);
EventBus().emit('refreshSellerVersion');
if (!mounted) {
return;
}
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
}
String _formatPrice(double price) {
if (price == price.roundToDouble()) {
return price.toInt().toString();
}
return price.toStringAsFixed(2);
}
@override
void dispose() {
_wxPay.cancel();
EventBus().emit('changeStatusColor');
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: MyColours.color_F0F0F0,
appBar: SystemAppBar('功能升级'),
body: Column(
children: [
Expanded(child: _buildBody()),
_buildBottomBar(),
],
),
);
}
Widget _buildBody() {
if (_loading) {
return const Center(
child: CircularProgressIndicator(color: MyColours.color_529EA4),
);
}
return SingleChildScrollView(
padding: EdgeInsets.all(ScreenUtil().setWidth(24)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: double.infinity,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(24),
vertical: ScreenUtil().setWidth(18),
),
decoration: BoxDecoration(
color: MyColours.color_529EA4,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(10),
),
),
child: Text(
'请选择购买的组件模块,所有模块购买激活后均有一年有效期。',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(26),
height: 1.5,
),
),
),
SizedBox(height: ScreenUtil().setWidth(24)),
if (_loadFailed)
_buildRetry()
else if (_modules.isEmpty)
_buildEmpty()
else
for (int index = 0; index < _modules.length; index++)
_buildModuleCard(index),
],
),
);
}
Widget _buildRetry() {
return Container(
width: double.infinity,
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(80)),
alignment: Alignment.center,
child: Column(
children: [
Text(
'加载失败,请稍后重试',
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(26),
),
),
SizedBox(height: ScreenUtil().setWidth(24)),
GestureDetector(
onTap: _loadModules,
child: Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(16),
),
decoration: BoxDecoration(
color: MyColours.color_529EA4,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(8),
),
),
child: Text(
'重新加载',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(26),
),
),
),
),
],
),
);
}
Widget _buildEmpty() {
return Container(
width: double.infinity,
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(80)),
alignment: Alignment.center,
child: Text(
'暂无可升级的功能',
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(26),
),
),
);
}
Widget _buildModuleCard(int index) {
final _UpgradeModule module = _modules[index];
final bool selected = module.selected;
return GestureDetector(
onTap: () => _toggleModule(index),
child: Container(
margin: EdgeInsets.only(bottom: ScreenUtil().setWidth(20)),
padding: EdgeInsets.all(ScreenUtil().setWidth(24)),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(12)),
border: Border.all(
color: selected ? MyColours.color_529EA4 : MyColours.color_d9d9d9,
width: ScreenUtil().setWidth(2),
),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
Utils.getImgPath(selected ? 'base_radio_sel' : 'base_radio_un'),
width: ScreenUtil().setWidth(36),
height: ScreenUtil().setWidth(36),
),
SizedBox(width: ScreenUtil().setWidth(18)),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
module.name,
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(30),
fontWeight: FontWeight.bold,
),
),
),
SizedBox(width: ScreenUtil().setWidth(16)),
Text(
'¥${_formatPrice(module.price)}',
style: TextStyle(
color: MyColours.color_529EA4,
fontSize: ScreenUtil().setSp(30),
fontWeight: FontWeight.bold,
),
),
],
),
SizedBox(height: ScreenUtil().setWidth(12)),
Text(
module.desc,
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(24),
height: 1.4,
),
),
],
),
),
],
),
),
);
}
Widget _buildBottomBar() {
return Container(
color: const Color(0xFF98C0C8),
padding: EdgeInsets.fromLTRB(
ScreenUtil().setWidth(24),
ScreenUtil().setWidth(16),
ScreenUtil().setWidth(24),
ScreenUtil().setWidth(16),
),
child: SafeArea(
top: false,
child: Row(
children: [
Text(
'¥${_formatPrice(_total)}',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(36),
fontWeight: FontWeight.bold,
),
),
const Spacer(),
GestureDetector(
onTap: _hasSelection ? _pay : null,
child: Container(
width: ScreenUtil().setWidth(220),
height: ScreenUtil().setWidth(78),
alignment: Alignment.center,
decoration: BoxDecoration(
color: MyColours.color_ffffff,
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(39)),
),
child: Text(
'立即支付',
style: TextStyle(
color: _hasSelection
? MyColours.color_515151
: MyColours.color_999999,
fontSize: ScreenUtil().setSp(30),
fontWeight: FontWeight.bold,
),
),
),
),
],
),
),
);
}
}
class _UpgradeModule {
_UpgradeModule({
required this.vid,
required this.name,
required this.desc,
required this.price,
});
final String vid;
final String name;
final String desc;
final double price;
bool selected = false;
}
... ...
... ... @@ -26,6 +26,7 @@ import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/my_item.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:one_key/pages/my/function_upgrade_page.dart';
import 'package:provider/provider.dart';
import '../../app.dart';
... ... @@ -132,6 +133,10 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
_getCustomerActivityBaseinfo();
// getMyPageCountData();
});
EventBus().on('refreshSellerVersion', (arg) {
getSellerVersion();
getMyPageCountData();
});
}
@override
... ... @@ -143,6 +148,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
EventBus().off('refreshMySms');
EventBus().off('refreshMyImage');
EventBus().off('refreshSellerVersion');
}
@override
... ... @@ -2302,6 +2308,41 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
],
)),
VEmptyView(48),
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => FunctionUpgradePage(
collectStoreProvider:
collectStoreProvider),
),
);
},
child: Row(
children: [
Image.asset(
Utils.getImgPath('bbsj'),
width: ScreenUtil().setWidth(22 * 2),
),
HEmptyView(26),
Text(
'功能升级',
style: TextStyle(
fontWeight: FontWeight.bold,
color: MyColours.color_515151,
fontSize:
ScreenUtil().setWidth(28)),
),
Spacer(),
Image.asset(
"assets/arrow_right_new.png",
width: ScreenUtil().setWidth(14),
height: ScreenUtil().setWidth(22),
)
],
)),
VEmptyView(48),
Consumer<UserModel>(
builder: (BuildContext context, UserModel model,
Widget? child) {
... ...
... ... @@ -112,15 +112,11 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> {
///从时间选择器中获取分钟数字符串 00 or 30
String _getMinuteStrFromPicker(List value) {
if (value[1] == 0) {
int? minute = SetTimeWidget.dateData[value[0]].values.last[value[1]];
if (minute == 0) {
return '00';
} else if (value[1] == 1) {
return '15';
}
if (value[1] == 2) {
return '30';
}
return '45';
return '${minute}';
}
@override
... ... @@ -1930,7 +1926,8 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
},
keyboardType: TextInputType.numberWithOptions(),
keyboardType:
TextInputType.numberWithOptions(),
),
)),
HEmptyView(20),
... ... @@ -2016,7 +2013,8 @@ class _StoreBaseInfoPageState extends State<StoreBaseInfoPage> {
.requestFocus(
FocusNode()); //点击空白处隐藏键盘
},
keyboardType: TextInputType.numberWithOptions(),
keyboardType: TextInputType
.numberWithOptions(),
),
)),
HEmptyView(20),
... ...
... ... @@ -93,10 +93,14 @@ class TableManagerPage extends StatefulWidget {
}
}
class TableManagerPageState extends State<TableManagerPage> {
class TableManagerPageState extends State<TableManagerPage>
with WidgetsBindingObserver {
TableManagerModelOrReserve? tableManagerModel;
final ItemScrollController itemScrollController = ItemScrollController();
bool isTap = false;
bool _isFollowingToday = true;
late DateTime _lastObservedDay;
Timer? _dayCheckTimer;
// 进度监听对象
int? min;
int? max;
... ... @@ -200,6 +204,10 @@ class TableManagerPageState extends State<TableManagerPage> {
dateTime = DateTime.now();
dateText = returnDate(dateTime);
dateTimeSelect = dateTime;
_lastObservedDay = DateTime(dateTime.year, dateTime.month, dateTime.day);
WidgetsBinding.instance.addObserver(this);
_startDayCheckTimer();
personNumList = Utils.getPersonNumList();
... ... @@ -262,6 +270,7 @@ class TableManagerPageState extends State<TableManagerPage> {
};
await storeBaseIndoProvider.getMealSectionByDay(context, pramas,
showLoading: false);
if (!mounted) return;
initTimeTable(needInit: needInit);
}
... ... @@ -431,6 +440,9 @@ class TableManagerPageState extends State<TableManagerPage> {
//生成日期文本
createDateText1(BuildContext context, DateTime day) {
if (Utils.isOneDay(day, dateTime)) return; //日期没变
final DateTime now = DateTime.now();
_isFollowingToday = Utils.isOneDay(day, now);
_lastObservedDay = DateTime(now.year, now.month, now.day);
dateTimeSelect = day;
dateText = returnDate(day);
... ... @@ -473,6 +485,51 @@ class TableManagerPageState extends State<TableManagerPage> {
return date;
}
void _startDayCheckTimer() {
_dayCheckTimer?.cancel();
_dayCheckTimer = Timer.periodic(const Duration(minutes: 1), (_) {
_checkDateRollover();
});
}
void _refreshDateTexts() {
dateText = returnDate(dateTime);
selectDateStr = returnDayDateStr(dateTime);
if (currTimeIndex != null &&
(storeBaseIndoProvider.dayDateData?.length ?? 0) > 0) {
selectWeekAndLunarCalendar = returnWeekAndLunarCalendar(dateTime, context);
}
if (mounted) {
setState(() {});
}
}
void _checkDateRollover() {
if (!mounted) return;
final DateTime now = DateTime.now();
if (Utils.isOneDay(now, _lastObservedDay)) return;
_lastObservedDay = DateTime(now.year, now.month, now.day);
if (_isFollowingToday) {
dateTime = now;
dateTimeSelect = dateTime;
_refreshDateTexts();
getMealSectionByDay();
} else {
// 用户手动选了其他日期时,只重算“今天/明天/后天”文案,不抢回今天。
_refreshDateTexts();
}
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
if (state == AppLifecycleState.resumed) {
_checkDateRollover();
}
}
_getDoltStr(BuildContext context) {
if ((storeBaseIndoProvider.dayDateData?.length ?? 0) > 0) {
int index = storeBaseIndoProvider.dayDateData!
... ... @@ -519,6 +576,8 @@ class TableManagerPageState extends State<TableManagerPage> {
@override
void dispose() {
// TODO: implement dispose
WidgetsBinding.instance.removeObserver(this);
_dayCheckTimer?.cancel();
super.dispose();
EventBus().off("refresh_tablemanager");
EventBus().off("refresh_tablePhoto");
... ...
... ... @@ -160,6 +160,9 @@ class HomePageSimState extends State<HomePageSim> with WidgetsBindingObserver {
// }
WidgetsBinding.instance.addObserver(this);
EventBus().on('refreshSellerVersion', (arg) {
getSellerVersion();
});
_currIndex = widget.initialIndex;
... ... @@ -2068,6 +2071,7 @@ class HomePageSimState extends State<HomePageSim> with WidgetsBindingObserver {
LogUtil.v("home_dispose");
// bus.off('refresh_token');
EventBus().off('refreshSellerVersion');
if (timer != null) {
timer!.cancel();
}
... ...
... ... @@ -28,6 +28,7 @@ import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/my_item.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:one_key/pages/my/function_upgrade_page.dart';
import 'package:provider/provider.dart';
import '../../app.dart';
... ... @@ -131,6 +132,10 @@ class MyPageSimState extends State<MyPageSim> with WidgetsBindingObserver {
EventBus().on('refreshMySms', (arg) {
getMyPageCountData();
});
EventBus().on('refreshSellerVersion', (arg) {
getSellerVersion();
getMyPageCountData();
});
}
void wxSubscriptionClose() => _wxPay?.cancel();
... ... @@ -142,6 +147,7 @@ class MyPageSimState extends State<MyPageSim> with WidgetsBindingObserver {
// AzhonAppUpdate.dispose();
EventBus().off('changeStatusColor');
EventBus().off('refreshMySms');
EventBus().off('refreshSellerVersion');
wxSubscriptionClose();
}
... ... @@ -1793,6 +1799,41 @@ class MyPageSimState extends State<MyPageSim> with WidgetsBindingObserver {
],
)),
VEmptyView(48),
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => FunctionUpgradePage(
collectStoreProvider:
collectStoreProvider),
),
);
},
child: Row(
children: [
Image.asset(
Utils.getImgPath('bbsj'),
width: ScreenUtil().setWidth(28 * 2),
),
HEmptyView(26),
Text(
'功能升级',
style: TextStyle(
fontWeight: FontWeight.bold,
color: MyColours.color_515151,
fontSize:
ScreenUtil().setWidth(28)),
),
Spacer(),
Image.asset(
"assets/arrow_right_new.png",
width: ScreenUtil().setWidth(14),
height: ScreenUtil().setWidth(22),
)
],
)),
VEmptyView(48),
Consumer<UserModel>(
builder: (BuildContext context, UserModel model,
Widget? child) {
... ...
... ... @@ -101,15 +101,11 @@ class _StoreBaseInfoPageSimState extends State<StoreBaseInfoPageSim> {
///从时间选择器中获取分钟数字符串 00 or 30
String _getMinuteStrFromPicker(List value) {
if (value[1] == 0) {
int? minute = SetTimeWidget.dateData[value[0]].values.last[value[1]];
if (minute == 0) {
return '00';
} else if (value[1] == 1) {
return '15';
}
if (value[1] == 2) {
return '30';
}
return '45';
return '${minute}';
}
@override
... ...
... ... @@ -238,7 +238,7 @@ class CollectStoreProvider with ChangeNotifier {
// List<SellerVersionSunModel> tempList =
// SellerVersionModel.fromJson(baseResp.responseData).data;
if (tempList != null && tempList.length > 0) {
if (tempList.length > 0) {
tempList.forEach((element) {
DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(
int.parse(element.rdate.toString()) * 1000);
... ... @@ -274,7 +274,7 @@ class CollectStoreProvider with ChangeNotifier {
}
//准备好数据
if (sellerVersionList != null && sellerVersionList.length > 0) {
if (sellerVersionList.length > 0) {
List<String?> versionCodeList = [];
sellerVersionList.forEach((element) {
versionCodeList.add(element.vid);
... ... @@ -535,7 +535,7 @@ class CollectStoreProvider with ChangeNotifier {
}
//准备好数据
if (sellerVersionList != null && sellerVersionList.length > 0) {
if (sellerVersionList.length > 0) {
List<String?> versionCodeList = [];
sellerVersionList.forEach((element) {
versionCodeList.add(element.vid);
... ... @@ -740,6 +740,71 @@ class CollectStoreProvider with ChangeNotifier {
}
}
// 获取功能升级页可购买的版本/模块列表
Future<List<SellerVersionSunModel>?> getFunctionUpgradeList(
BuildContext context,
{bool showLoading = true}) async {
try {
final BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>(
context, Method.post, HttpUrl.get_version_list,
data: const <String, String?>{}, showLoading: showLoading);
if (baseResp.code == Constant.status_success) {
final Map<String, dynamic> response =
baseResp.responseData as Map<String, dynamic>;
final List<dynamic>? rawList = response['data'] as List<dynamic>?;
final List<SellerVersionSunModel> list = <SellerVersionSunModel>[];
if (rawList != null) {
for (final item in rawList) {
if (item is! Map) {
continue;
}
final Map<String, dynamic> map = Map<String, dynamic>.from(item);
final dynamic id = map['id'];
final dynamic name = map['name'];
if (id == null || name == null) {
continue;
}
list.add(SellerVersionSunModel(
vid: '$id',
vname: '$name',
vtype: map['type'] == null ? null : '${map['type']}',
price: map['price'] is num
? (map['price'] as num).toDouble()
: double.tryParse('${map['price']}'),
));
}
}
return list;
}
Utils.showToast(baseResp.msg ?? '请求失败,请重试');
} catch (error) {
print(error.toString());
Utils.showToast('请求失败,请重试');
}
return null;
}
// 刷新商家版本信息,并同步通知依赖页面的 UI。
Future<bool> refreshSellerVersion(BuildContext context,
{bool showLoading = true}) async {
final bool success =
await getSellerVersion(context, showLoading: showLoading);
final user = Provider.of<UserModel>(context, listen: false).user;
if (user != null) {
final Map<String, String?> params = {
'sellerid': user.sellerid,
};
if (Utils.getAuthority(context, '个人-月订单量')) {
params['uid'] = user.openid;
}
await getMyPageCountData(context, params, showLoading: showLoading);
}
notifyListeners();
return success;
}
/// App调起支付(购买版本)
Future<bool> appPayJiSuVersion(
BuildContext context, Map<String, String?> params,
... ... @@ -748,7 +813,7 @@ class CollectStoreProvider with ChangeNotifier {
BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>(
context, Method.post, HttpUrl.app_pay_jisu_version,
data: params, showLoading: isShowLoading);
if (baseResp != null && baseResp.code == Constant.status_success) {
if (baseResp.code == Constant.status_success) {
sunModel = WechatPayModel.fromJson(
baseResp.responseData as Map<String, dynamic>)
.data;
... ...
import 'dart:async';
import 'dart:ui';
import 'package:cached_network_image/cached_network_image.dart';
... ... @@ -14,12 +13,12 @@ import 'package:flutter_lunar_datetime_picker/flutter_lunar_datetime_picker.dart
import 'package:flutter_picker_plus/flutter_picker_plus.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/filter_btn_model.dart';
import 'package:one_key/models/remark.dart';
import 'package:one_key/models/seller_role_model.dart';
import 'package:one_key/models/table_list.dart';
import 'package:one_key/pages/my/function_upgrade_page.dart';
import 'package:one_key/pages/message/message_dialog_item_f.dart';
import 'package:one_key/provider/message_dialog_model.dart';
... ... @@ -78,6 +77,18 @@ typedef ClickkListCallbac = void Function(List<String?> value);
// };
class DialogUtil {
static void goFunctionUpgradePage(BuildContext context) {
final CollectStoreProvider collectStoreProvider =
Provider.of<CollectStoreProvider>(context, listen: false);
Navigator.push(
context,
MaterialPageRoute(
builder: (_) =>
FunctionUpgradePage(collectStoreProvider: collectStoreProvider),
),
);
}
static List<Widget> labelSelectBtn(List<CustomerLabelSunModel> labelList,
state, List<String?> datas, ClickkListCallbac callback) {
List<Widget> temp = [];
... ... @@ -1084,6 +1095,7 @@ class DialogUtil {
static showSellerVersionEdateDialog(BuildContext context,
List<SellerVersionSunModel> showData, CustomCallBack callback,
{GestureTapCallback? onTapLeft, GestureTapCallback? onTapRight}) {
final BuildContext outerContext = context;
List<String?> names = showData.map((e) => e.vname).toList();
ScrollController controller = ScrollController();
return showDialog(
... ... @@ -1204,17 +1216,12 @@ class DialogUtil {
MyDivider(double.infinity, w(1),
color: MyColours.color_DBDBDB),
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
flex: 1,
child: RoundButton(
text: '确定',
// width: (ScreenUtil().screenWidth -
// ScreenUtil().setWidth(62) * 2) /
// 2,
height: ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_515151,
... ... @@ -1225,6 +1232,25 @@ class DialogUtil {
Navigator.pop(context);
}
})),
MyDivider(ScreenUtil().setWidth(2),
ScreenUtil().setWidth(112),
color: MyColours.color_DBDBDB),
Expanded(
flex: 1,
child: RoundButton(
text: '去购买',
height: ScreenUtil().setWidth(112),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_438E93,
fontSize: 32,
onPressed: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
DialogUtil.goFunctionUpgradePage(
outerContext);
})),
],
),
])));
... ... @@ -1419,6 +1445,7 @@ class DialogUtil {
static showSellerVersionBuyDialog(
BuildContext context, String title, CustomCallBack callback,
{GestureTapCallback? onTapLeft, GestureTapCallback? onTapRight}) {
final BuildContext outerContext = context;
return showDialog(
context: context,
barrierDismissible: true,
... ... @@ -1501,41 +1528,25 @@ class DialogUtil {
Navigator.pop(context);
}
})),
// MyDivider(ScreenUtil().setWidth(2),
// ScreenUtil().setWidth(112),
// color: MyColours.color_DBDBDB),
// Expanded(
// flex: 1,
// child: RoundButton(
// text: '前往开通',
// // width: (ScreenUtil().screenWidth -
// // ScreenUtil().setWidth(62) * 2) /
// // 2,
// height: ScreenUtil().setWidth(112),
// // radius: ScreenUtil().setWidth(10),
// gradientStart: Colors.transparent,
// gradientEnd: Colors.transparent,
// textColor: MyColours.color_438E93,
// fontSize: 32,
// onPressed: () {
// // Navigator.pop(context, {
// // 'spec': menuSunModel.specCan != null &&
// // menuSunModel.specCan.length > 0
// // ? menuSunModel.specCan
// // .where((element) =>
// // element.select == true)
// // .toList()
// // : [],
// // 'practice': menuSunModel.practice !=
// // null &&
// // menuSunModel.practice.length > 0
// // ? menuSunModel.practice
// // .where((element) =>
// // element.select == true)
// // .toList()
// // : []
// // });
// })),
MyDivider(ScreenUtil().setWidth(2),
ScreenUtil().setWidth(112),
color: MyColours.color_DBDBDB),
Expanded(
flex: 1,
child: RoundButton(
text: '去购买',
height: ScreenUtil().setWidth(112),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_438E93,
fontSize: 32,
onPressed: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
DialogUtil.goFunctionUpgradePage(
outerContext);
})),
],
),
])));
... ... @@ -11378,6 +11389,7 @@ class DialogUtil {
VoidCallback? lCallback,
VoidCallback? rCallback}) async {
// bool isRed = content != '' ? false : true;
final BuildContext outerContext = context;
final action = await showDialog(
context: context,
barrierDismissible: false,
... ... @@ -11464,15 +11476,13 @@ class DialogUtil {
// Navigator.pop(context);
// }),
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
RoundButton(
text: lTitle,
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2) /
2,
3,
height: ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_E6000000,
... ... @@ -11490,9 +11500,8 @@ class DialogUtil {
text: rTitle,
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2) /
2,
3,
height: ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_438E93,
... ... @@ -11503,6 +11512,26 @@ class DialogUtil {
Navigator.pop(context);
}
}),
MyDivider(ScreenUtil().setWidth(2),
ScreenUtil().setWidth(112),
color: MyColours.color_f3f3f3),
RoundButton(
text: '去购买',
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2) /
3,
height: ScreenUtil().setWidth(112),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_438E93,
fontSize: 32,
onPressed: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
DialogUtil.goFunctionUpgradePage(
outerContext);
}),
],
)
],
... ... @@ -11521,7 +11550,7 @@ class DialogUtil {
{String title = "",
String content = "内容",
String lTitle = "我知道了",
String rTitle = "立即续费",
String rTitle = "去购买",
Color rColor = MyColours.color_438E93,
bool isBold = false,
bool isBoldContent = false,
... ... @@ -11529,6 +11558,7 @@ class DialogUtil {
VoidCallback? lCallback,
VoidCallback? rCallback}) async {
// bool isRed = content != '' ? false : true;
final BuildContext outerContext = context;
final action = await showDialog(
context: context,
barrierDismissible: false,
... ... @@ -11600,62 +11630,46 @@ class DialogUtil {
VEmptyView(66),
MyDivider(double.infinity, ScreenUtil().setWidth(2),
color: MyColours.color_f3f3f3),
RoundButton(
text: lTitle,
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2),
height: ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_E6000000,
isBold: false,
fontSize: 32,
onPressed: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
}),
// Row(
// // mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// RoundButton(
// text: lTitle,
// width: (ScreenUtil().screenWidth -
// ScreenUtil().setWidth(62) * 2) /
// 2,
// height: ScreenUtil().setWidth(112),
// // radius: ScreenUtil().setWidth(10),
// gradientStart: Colors.transparent,
// gradientEnd: Colors.transparent,
// textColor: MyColours.color_E6000000,
// isBold: false,
// fontSize: 32,
// onPressed: () {
// Navigator.pop(context);
// }),
// MyDivider(ScreenUtil().setWidth(2),
// ScreenUtil().setWidth(112),
// color: MyColours.color_f3f3f3),
// RoundButton(
// text: rTitle,
// width: (ScreenUtil().screenWidth -
// ScreenUtil().setWidth(62) * 2) /
// 2,
// height: ScreenUtil().setWidth(112),
// // radius: ScreenUtil().setWidth(10),
// gradientStart: Colors.transparent,
// gradientEnd: Colors.transparent,
// textColor: MyColours.color_438E93,
// fontSize: 32,
// onPressed: () {
// rCallback();
// Navigator.pop(
// context,
// );
// }),
// ],
// )
Row(
children: [
RoundButton(
text: lTitle,
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2) /
2,
height: ScreenUtil().setWidth(112),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_E6000000,
isBold: false,
fontSize: 32,
onPressed: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
}),
MyDivider(ScreenUtil().setWidth(2),
ScreenUtil().setWidth(112),
color: MyColours.color_f3f3f3),
RoundButton(
text: rTitle,
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2) /
2,
height: ScreenUtil().setWidth(112),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_438E93,
fontSize: 32,
onPressed: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
DialogUtil.goFunctionUpgradePage(
outerContext);
}),
],
)
],
),
),
... ... @@ -11680,6 +11694,7 @@ class DialogUtil {
VoidCallback? lCallback,
VoidCallback? rCallback}) async {
// bool isRed = content != '' ? false : true;
final BuildContext outerContext = context;
final action = await showDialog(
context: context,
barrierDismissible: false,
... ... @@ -11761,15 +11776,13 @@ class DialogUtil {
// lCallback();
// }),
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
RoundButton(
text: lTitle,
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2) /
2,
3,
height: ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_E6000000,
... ... @@ -11788,9 +11801,8 @@ class DialogUtil {
text: rTitle,
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2) /
2,
3,
height: ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_438E93,
... ... @@ -11801,6 +11813,26 @@ class DialogUtil {
Navigator.pop(context);
}
}),
MyDivider(ScreenUtil().setWidth(2),
ScreenUtil().setWidth(112),
color: MyColours.color_f3f3f3),
RoundButton(
text: '去购买',
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2) /
3,
height: ScreenUtil().setWidth(112),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_438E93,
fontSize: 32,
onPressed: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
DialogUtil.goFunctionUpgradePage(
outerContext);
}),
],
)
],
... ... @@ -11819,7 +11851,7 @@ class DialogUtil {
{String title = "",
String content = "内容",
String lTitle = "我知道了",
String rTitle = "立即续费",
String rTitle = "去购买",
Color rColor = MyColours.color_438E93,
bool isBold = false,
bool isBoldContent = false,
... ... @@ -11827,6 +11859,7 @@ class DialogUtil {
VoidCallback? lCallback,
VoidCallback? rCallback}) async {
// bool isRed = content != '' ? false : true;
final BuildContext outerContext = context;
final action = await showDialog(
context: context,
barrierDismissible: false,
... ... @@ -11892,64 +11925,47 @@ class DialogUtil {
VEmptyView(66),
MyDivider(double.infinity, ScreenUtil().setWidth(2),
color: MyColours.color_f3f3f3),
RoundButton(
text: lTitle,
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2),
height: ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_E6000000,
isBold: false,
fontSize: 32,
onPressed: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
lCallback!();
}),
// Row(
// // mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// RoundButton(
// text: lTitle,
// width: (ScreenUtil().screenWidth -
// ScreenUtil().setWidth(62) * 2) /
// 2,
// height: ScreenUtil().setWidth(112),
// // radius: ScreenUtil().setWidth(10),
// gradientStart: Colors.transparent,
// gradientEnd: Colors.transparent,
// textColor: MyColours.color_E6000000,
// isBold: false,
// fontSize: 32,
// onPressed: () {
// Navigator.pop(context);
// lCallback();
// }),
// MyDivider(ScreenUtil().setWidth(2),
// ScreenUtil().setWidth(112),
// color: MyColours.color_f3f3f3),
// RoundButton(
// text: rTitle,
// width: (ScreenUtil().screenWidth -
// ScreenUtil().setWidth(62) * 2) /
// 2,
// height: ScreenUtil().setWidth(112),
// // radius: ScreenUtil().setWidth(10),
// gradientStart: Colors.transparent,
// gradientEnd: Colors.transparent,
// textColor: MyColours.color_438E93,
// fontSize: 32,
// onPressed: () {
// rCallback();
// Navigator.pop(
// context,
// );
// }),
// ],
// )
Row(
children: [
RoundButton(
text: lTitle,
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2) /
2,
height: ScreenUtil().setWidth(112),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_E6000000,
isBold: false,
fontSize: 32,
onPressed: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
lCallback?.call();
}),
MyDivider(ScreenUtil().setWidth(2),
ScreenUtil().setWidth(112),
color: MyColours.color_f3f3f3),
RoundButton(
text: rTitle,
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2) /
2,
height: ScreenUtil().setWidth(112),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_438E93,
fontSize: 32,
onPressed: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
DialogUtil.goFunctionUpgradePage(
outerContext);
}),
],
)
],
),
),
... ... @@ -13429,5 +13445,4 @@ class DialogUtil {
},
);
}
}
... ...
import 'package:flutter/material.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/utils.dart';
... ... @@ -9,76 +8,76 @@ class SetTimeWidget {
static SetTimeWidget init = SetTimeWidget();
static List dateData = [
{
'深夜00时': [00, 15, 30, 45]
'深夜00时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'深夜01时': [00, 15, 30, 45]
'深夜01时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'深夜02时': [00, 15, 30, 45]
'深夜02时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'深夜03时': [00, 15, 30, 45]
'深夜03时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'深夜04时': [00, 15, 30, 45]
'深夜04时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'深夜05时': [00, 15, 30, 45]
'深夜05时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'早上06时': [00, 15, 30, 45]
'早上06时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'早上07时': [00, 15, 30, 45]
'早上07时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'早上08时': [00, 15, 30, 45]
'早上08时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'早上09时': [00, 15, 30, 45]
'早上09时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'中午10时': [00, 15, 30, 45]
'中午10时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'中午11时': [00, 15, 30, 45]
'中午11时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'中午12时': [00, 15, 30, 45]
'中午12时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'中午13时': [00, 15, 30, 45]
'中午13时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'中午14时': [00, 15, 30, 45]
'中午14时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'下午15时': [00, 15, 30, 45]
'下午15时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'下午16时': [00, 15, 30, 45]
'下午16时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'下午17时': [00, 15, 30, 45]
'下午17时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'下午18时': [00, 15, 30, 45]
'下午18时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'晚上19时': [00, 15, 30, 45]
'晚上19时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'晚上20时': [00, 15, 30, 45]
'晚上20时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'晚上21时': [00, 15, 30, 45]
'晚上21时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'晚上22时': [00, 15, 30, 45]
'晚上22时': [0, 10, 15, 20, 30, 40, 45, 50]
},
{
'晚上23时': [00, 15, 30, 45]
'晚上23时': [0, 10, 15, 20, 30, 40, 45, 50]
}
];
... ... @@ -202,10 +201,14 @@ class SetTimeWidget {
context, data, hourAndMinute, SetTimeCallback setTimeCallback) {
DialogUtil.showSelectCusmanTimerDialog(context, data, (value) {
setTimeCallback(value);
}, selecteds:hourAndMinute == null?[]: [
_getFirSelected(hourAndMinute, data),
_getSecSelected(hourAndMinute, data)
]).then((value) {
},
selecteds: hourAndMinute == null
? []
: [
_getFirSelected(hourAndMinute, data),
_getSecSelected(hourAndMinute, data)
])
.then((value) {
print(value);
});
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:one_key/models/seller_version_model.dart';
import 'package:one_key/provider/collect_store_provider.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:provider/provider.dart';
class _FakeCollectStoreProvider extends CollectStoreProvider {
@override
Future<List<SellerVersionSunModel>?> getFunctionUpgradeList(
BuildContext context, {
bool showLoading = true,
}) async {
return <SellerVersionSunModel>[];
}
}
Widget _buildTestApp(
_FakeCollectStoreProvider provider,
void Function(BuildContext context) openDialog,
) {
return ScreenUtilInit(
designSize: const Size(750, 1334),
minTextAdapt: true,
splitScreenMode: true,
builder: (context, child) {
return ChangeNotifierProvider<CollectStoreProvider>.value(
value: provider,
child: MaterialApp(
home: Scaffold(
body: Center(
child: Builder(
builder: (context) {
return TextButton(
onPressed: () => openDialog(context),
child: const Text('打开弹窗'),
);
},
),
),
),
),
);
},
);
}
Future<void> _tapAndOpenUpgrade(WidgetTester tester) async {
await tester.tap(find.text('打开弹窗'));
await tester.pumpAndSettle();
expect(find.text('去购买'), findsOneWidget);
await tester.tap(find.text('去购买'));
await tester.pump();
await tester.pump(const Duration(milliseconds: 600));
expect(find.text('功能升级'), findsOneWidget);
}
void _setPhoneViewport(WidgetTester tester) {
tester.view.physicalSize = const Size(1080, 2340);
tester.view.devicePixelRatio = 1.0;
addTearDown(() {
tester.view.physicalSize = const Size(800, 600);
tester.view.devicePixelRatio = 1.0;
});
}
void main() {
testWidgets('未购买模块弹窗可以去购买', (tester) async {
_setPhoneViewport(tester);
final provider = _FakeCollectStoreProvider();
await tester.pumpWidget(
_buildTestApp(provider, (context) {
DialogUtil.showSellerVersionBuyDialog(context, '宴会管理', (_) {});
}),
);
await _tapAndOpenUpgrade(tester);
});
testWidgets('普通版模块过期弹窗可以去购买', (tester) async {
_setPhoneViewport(tester);
final provider = _FakeCollectStoreProvider();
final showData = <SellerVersionSunModel>[
SellerVersionSunModel(
vid: '12',
vname: '宴会管理',
edate: '1798761600',
),
];
await tester.pumpWidget(
_buildTestApp(provider, (context) {
DialogUtil.showSellerVersionEdateDialog(context, showData, (_) {});
}),
);
await _tapAndOpenUpgrade(tester);
});
testWidgets('极速版模块过期弹窗可以去购买', (tester) async {
_setPhoneViewport(tester);
final provider = _FakeCollectStoreProvider();
await tester.pumpWidget(
_buildTestApp(provider, (context) {
DialogUtil.cupertinoAlertSellerEdateDialogSim(
context,
title: '温馨提示',
content: '2026-10-01',
rCallback: () {},
);
}),
);
await _tapAndOpenUpgrade(tester);
});
testWidgets('普通版店铺过期弹窗可以去购买', (tester) async {
_setPhoneViewport(tester);
final provider = _FakeCollectStoreProvider();
await tester.pumpWidget(
_buildTestApp(provider, (context) {
DialogUtil.cupertinoAlertSellerHasEdateDialog(
context,
title: '温馨提示',
lCallback: () {},
rCallback: () {},
);
}),
);
await _tapAndOpenUpgrade(tester);
});
testWidgets('极速版店铺过期弹窗可以去购买', (tester) async {
_setPhoneViewport(tester);
final provider = _FakeCollectStoreProvider();
await tester.pumpWidget(
_buildTestApp(provider, (context) {
DialogUtil.cupertinoAlertSellerHasEdateDialogSim(
context,
title: '温馨提示',
lCallback: () {},
rCallback: () {},
);
}),
);
await _tapAndOpenUpgrade(tester);
});
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:one_key/models/seller_version_model.dart';
import 'package:one_key/provider/collect_store_provider.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:provider/provider.dart';
class _PreviewCollectStoreProvider extends CollectStoreProvider {
@override
Future<List<SellerVersionSunModel>?> getFunctionUpgradeList(
BuildContext context, {
bool showLoading = true,
}) async {
return <SellerVersionSunModel>[];
}
}
Widget _buildPreviewApp(
_PreviewCollectStoreProvider provider,
void Function(BuildContext context) openDialog,
) {
return ScreenUtilInit(
designSize: const Size(750, 1334),
minTextAdapt: true,
splitScreenMode: true,
builder: (context, child) {
return ChangeNotifierProvider<CollectStoreProvider>.value(
value: provider,
child: MaterialApp(
home: Scaffold(
backgroundColor: Colors.white,
body: Center(
child: Builder(
builder: (context) {
return TextButton(
onPressed: () => openDialog(context),
child: const Text('打开弹窗'),
);
},
),
),
),
),
);
},
);
}
void _setPhoneViewport(WidgetTester tester) {
tester.view.physicalSize = const Size(1080, 2340);
tester.view.devicePixelRatio = 1.0;
const MethodChannel statusBarChannel =
MethodChannel('plugins.sameer.com/statusbar');
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
statusBarChannel,
(call) async => null,
);
addTearDown(() {
tester.view.physicalSize = const Size(800, 600);
tester.view.devicePixelRatio = 1.0;
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
statusBarChannel,
null,
);
});
}
void main() {
testWidgets('导出未购买和跳转预览图', (tester) async {
_setPhoneViewport(tester);
final provider = _PreviewCollectStoreProvider();
await tester.pumpWidget(
_buildPreviewApp(provider, (context) {
DialogUtil.showSellerVersionBuyDialog(context, '宴会管理', (_) {});
}),
);
await tester.tap(find.text('打开弹窗'));
await tester.pumpAndSettle();
await expectLater(
find.byType(MaterialApp),
matchesGoldenFile('goldens/preview_buy_dialog.png'),
);
await tester.tap(find.text('去购买'));
await tester.pump();
await tester.pump(const Duration(milliseconds: 600));
await tester.pump(const Duration(milliseconds: 200));
await expectLater(
find.byType(MaterialApp),
matchesGoldenFile('goldens/preview_upgrade_page.png'),
);
});
testWidgets('导出普通版模块过期预览图', (tester) async {
_setPhoneViewport(tester);
final provider = _PreviewCollectStoreProvider();
final showData = <SellerVersionSunModel>[
SellerVersionSunModel(
vid: '12',
vname: '宴会管理',
edate: '1798761600',
),
];
await tester.pumpWidget(
_buildPreviewApp(provider, (context) {
DialogUtil.showSellerVersionEdateDialog(context, showData, (_) {});
}),
);
await tester.tap(find.text('打开弹窗'));
await tester.pumpAndSettle();
await expectLater(
find.byType(MaterialApp),
matchesGoldenFile('goldens/preview_expire_dialog.png'),
);
});
testWidgets('导出极速版模块过期预览图', (tester) async {
_setPhoneViewport(tester);
final provider = _PreviewCollectStoreProvider();
await tester.pumpWidget(
_buildPreviewApp(provider, (context) {
DialogUtil.cupertinoAlertSellerEdateDialogSim(
context,
title: '温馨提示',
content: '2026-10-01',
rCallback: () {},
);
}),
);
await tester.tap(find.text('打开弹窗'));
await tester.pumpAndSettle();
await expectLater(
find.byType(MaterialApp),
matchesGoldenFile('goldens/preview_sim_expire_dialog.png'),
);
});
testWidgets('导出普通版店铺过期预览图', (tester) async {
_setPhoneViewport(tester);
final provider = _PreviewCollectStoreProvider();
await tester.pumpWidget(
_buildPreviewApp(provider, (context) {
DialogUtil.cupertinoAlertSellerHasEdateDialog(
context,
title: '温馨提示',
lCallback: () {},
rCallback: () {},
);
}),
);
await tester.tap(find.text('打开弹窗'));
await tester.pumpAndSettle();
await expectLater(
find.byType(MaterialApp),
matchesGoldenFile('goldens/preview_store_expire_dialog.png'),
);
});
testWidgets('导出极速版店铺过期预览图', (tester) async {
_setPhoneViewport(tester);
final provider = _PreviewCollectStoreProvider();
await tester.pumpWidget(
_buildPreviewApp(provider, (context) {
DialogUtil.cupertinoAlertSellerHasEdateDialogSim(
context,
title: '温馨提示',
lCallback: () {},
rCallback: () {},
);
}),
);
await tester.tap(find.text('打开弹窗'));
await tester.pumpAndSettle();
await expectLater(
find.byType(MaterialApp),
matchesGoldenFile('goldens/preview_sim_store_expire_dialog.png'),
);
});
}
... ...