Commit b646ef319a405b093f1b40a74fa43aca4f2cfd2e

Authored by wdn127929
1 parent 905896f2

切换店铺

... ... @@ -105,6 +105,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
));
WidgetsBinding.instance.addPostFrameCallback((_) {
initPlatformState();
List<PullMarketingByUidSunModel> data =
Provider.of<UserModel>(context, listen: false)
.pullMarketingByUidSunModel;
... ... @@ -146,6 +147,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
timer = Timer.periodic(Duration(minutes: 3), (_) {
_getAllUnMessages();
});
_getUnMsgNum();
});
}
... ... @@ -551,7 +553,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
}
//获取未处理消息数目
bool _getUnMsgNum() {
bool _getUnMsgNumUI() {
MessageModel messageModel =
Provider.of<MessageModel>(context, listen: true);
if (messageModel.onlineTotal +
... ... @@ -563,6 +565,16 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
return false;
}
//三种分类各自的未读消息数目
_getUnMsgNum() async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
Map<String, String> params = {"sid": userModel.user.sellerid};
MessageModel messageModel =
Provider.of<MessageModel>(context, listen: false);
await messageModel.getUnMsgNum(context, params);
setState(() {});
}
// 系统窗口相关改变回调
void didChangeMetrics() {
super.didChangeMetrics();
... ... @@ -628,7 +640,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(16)),
color: _getUnMsgNum()
color: _getUnMsgNumUI()
? MyColours.color_fa5151
: Colors.transparent),
),
... ... @@ -651,7 +663,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(16)),
color: _getUnMsgNum()
color: _getUnMsgNumUI()
? MyColours.color_fa5151
: Colors.transparent),
),
... ...
... ... @@ -23,10 +23,13 @@ import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart';
class IfNeedCreateStore extends StatefulWidget {
final List<CheckSellerAccSunModel> data;
IfNeedCreateStore({Key key, this.data}) : super(key: key);
final bool changeStatus;
IfNeedCreateStore({Key key, this.data, this.changeStatus = false})
: super(key: key);
@override
_IfNeedCreateStoreState createState() => _IfNeedCreateStoreState();
... ... @@ -122,183 +125,211 @@ class _IfNeedCreateStoreState extends State<IfNeedCreateStore>
@override
Widget build(BuildContext context) {
otherLoginProvider = Provider.of<OtherLoginProvider>(context, listen: true);
return Scaffold(
backgroundColor: Colors.white,
appBar: SystemAppBar(
'',
// leftTitle: '上一步',
onTap: () {
Navigator.of(context).pop();
},
),
body: Container(
// margin: EdgeInsets.only(bottom: ScreenUtil().setWidth(40)),
padding:
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(70)),
child: Consumer<OtherLoginProvider>(builder: (context, model, _) {
if (model.pageState != PageState.Success) {
if (model.pageState == PageState.Empty) {
return Container(
width: double.infinity,
padding: EdgeInsets.all(ScreenUtil().setWidth(40)),
child:
Column(crossAxisAlignment: CrossAxisAlignment.center,
return WillPopScope(
onWillPop: () async {
if (widget.changeStatus) {
EventBus().emit('changeStatusColor');
}
return true;
},
child: Scaffold(
backgroundColor: Colors.white,
appBar: SystemAppBar(
'',
// leftTitle: '上一步',
onTap: () {
if (widget.changeStatus) {
EventBus().emit('changeStatusColor');
}
Navigator.of(context).pop();
},
),
body: Container(
// margin: EdgeInsets.only(bottom: ScreenUtil().setWidth(40)),
padding:
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(70)),
child:
Consumer<OtherLoginProvider>(builder: (context, model, _) {
if (model.pageState != PageState.Success) {
if (model.pageState == PageState.Empty) {
return Container(
width: double.infinity,
padding: EdgeInsets.all(ScreenUtil().setWidth(40)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.center,
children: [
VEmptyView(80),
Image.asset(
Utils.getImgPath('not_member'),
width: ScreenUtil().setWidth(120),
height: ScreenUtil().setWidth(120),
),
VEmptyView(60),
Text(
'您还没有绑定任何店铺',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_333333,
fontWeight: FontWeight.bold),
),
VEmptyView(172),
InkWell(
onTap: () {
// if (!App.sp.containsKey('openid') ||
// App.sp.get("openid") == null ||
// App.sp.get("openid") == '') {
//跳转小程序
Utils.goMiniProgramCreatePage(context);
// } else {
// //跳转至新建店铺流程
// NavigatorUtil.goEnterStoreNamePage(context);
// }
},
child: Container(
width: double.infinity,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(18)),
decoration: BoxDecoration(
color: MyColours.color_24A4A8,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(10))),
child: Text(
'创建店铺',
textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(34)),
),
)),
]));
}
return ExceptionPage(
pageState: model.pageState,
callback: () {
_checkSellerAcc(showLoading: true);
},
emptyMsg: "",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Column(
children: [
VEmptyView(40),
Text(
'请选择您要进入的店铺',
style: TextStyle(
fontSize: ScreenUtil().setWidth(32),
color: MyColours.color_333333,
fontWeight: FontWeight.bold),
),
VEmptyView(100),
Expanded(
child: GridView.builder(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(50)),
// controller: widget.scrollController,
// padding: EdgeInsets.only(top: ScreenUtil().getAdapterSize(10)),
shrinkWrap: true,
itemCount: model.sellerList.length + 1,
cacheExtent: ScreenUtil().setWidth(197 * 2),
//SliverGridDelegateWithFixedCrossAxisCount 构建一个横轴固定数量Widget
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
//横轴元素个数
crossAxisCount: 2,
//纵轴间距
mainAxisSpacing: ScreenUtil().setWidth(50),
//横轴间距
crossAxisSpacing: ScreenUtil().setWidth(50),
//子组件宽高长度比例
childAspectRatio: 140 / 197),
itemBuilder: (BuildContext context, int index) {
if (index == model.sellerList.length) {
return InkWell(
VEmptyView(80),
Image.asset(
Utils.getImgPath('not_member'),
width: ScreenUtil().setWidth(120),
height: ScreenUtil().setWidth(120),
),
VEmptyView(60),
Text(
'您还没有绑定任何店铺',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_333333,
fontWeight: FontWeight.bold),
),
VEmptyView(172),
InkWell(
onTap: () {
// if (!App.sp.containsKey('openid') ||
// App.sp.get("openid") == null ||
// App.sp.get("openid") == '') {
// //跳转小程序
// Utils.goMiniProgramCreatePage(context);
//跳转小程序
Utils.goMiniProgramCreatePage(context);
// } else {
//跳转至新建店铺流程
NavigatorUtil.goEnterStoreNamePage(
context);
// //跳转至新建店铺流程
// NavigatorUtil.goEnterStoreNamePage(context);
// }
},
child: DottedBorder(
dashPattern: [5, 5, 5, 5],
borderType: BorderType.RRect,
radius: Radius.circular(
ScreenUtil().setWidth(10)),
// padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
color: MyColours.color_cccccc,
strokeWidth: ScreenUtil().setWidth(2),
child: ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(12)),
child: Container(
height:
ScreenUtil().setWidth(197 * 2),
width: ScreenUtil().setWidth(140 * 2),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Image.asset(
Utils.getImgPath('add_store'),
width: ScreenUtil()
.setWidth(32)),
VEmptyView(10),
Text(
'创建店铺',
style: TextStyle(
color:
MyColours.color_999999,
fontSize:
ScreenUtil().setSp(24)),
)
],
),
),
child: Container(
width: double.infinity,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(18)),
decoration: BoxDecoration(
color: MyColours.color_24A4A8,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(10))),
child: Text(
'创建店铺',
textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(34)),
),
));
}
return InkWell(
onTap: () {
_loginStore(context, model.sellerList[index]);
},
child: IfNeedCreateStoreItem(
model: model.sellerList[index]),
);
})),
// VEmptyView(40),
],
);
}
})));
)),
]));
}
return ExceptionPage(
pageState: model.pageState,
callback: () {
_checkSellerAcc(showLoading: true);
},
emptyMsg: "",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Column(
children: [
VEmptyView(40),
Text(
'请选择您要进入的店铺',
style: TextStyle(
fontSize: ScreenUtil().setWidth(32),
color: MyColours.color_333333,
fontWeight: FontWeight.bold),
),
VEmptyView(100),
Expanded(
child: GridView.builder(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(50)),
// controller: widget.scrollController,
// padding: EdgeInsets.only(top: ScreenUtil().getAdapterSize(10)),
shrinkWrap: true,
itemCount: model.sellerList.length + 1,
cacheExtent: ScreenUtil().setWidth(197 * 2),
//SliverGridDelegateWithFixedCrossAxisCount 构建一个横轴固定数量Widget
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
//横轴元素个数
crossAxisCount: 2,
//纵轴间距
mainAxisSpacing:
ScreenUtil().setWidth(50),
//横轴间距
crossAxisSpacing:
ScreenUtil().setWidth(50),
//子组件宽高长度比例
childAspectRatio: 140 / 197),
itemBuilder: (BuildContext context, int index) {
if (index == model.sellerList.length) {
return InkWell(
onTap: () {
// if (!App.sp.containsKey('openid') ||
// App.sp.get("openid") == null ||
// App.sp.get("openid") == '') {
// //跳转小程序
// Utils.goMiniProgramCreatePage(context);
// } else {
//跳转至新建店铺流程
NavigatorUtil.goEnterStoreNamePage(
context);
// }
},
child: DottedBorder(
dashPattern: [5, 5, 5, 5],
borderType: BorderType.RRect,
radius: Radius.circular(
ScreenUtil().setWidth(10)),
// padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
color: MyColours.color_cccccc,
strokeWidth: ScreenUtil().setWidth(2),
child: ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(12)),
child: Container(
height: ScreenUtil()
.setWidth(197 * 2),
width: ScreenUtil()
.setWidth(140 * 2),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Image.asset(
Utils.getImgPath(
'add_store'),
width: ScreenUtil()
.setWidth(32)),
VEmptyView(10),
Text(
'创建店铺',
style: TextStyle(
color: MyColours
.color_999999,
fontSize: ScreenUtil()
.setSp(24)),
)
],
),
),
),
));
}
return InkWell(
onTap: () async {
UserModel userModel =
Provider.of<UserModel>(context,
listen: false);
bool success = await userModel
.loginOutOnly(context, {
"seller_code":
userModel.user.sellercode,
"account": userModel.user.account
});
if (success) {
_loginStore(
context, model.sellerList[index]);
}
},
child: IfNeedCreateStoreItem(
model: model.sellerList[index]),
);
})),
// VEmptyView(40),
],
);
}
}))));
}
}
... ...
... ... @@ -222,40 +222,23 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
)),
Positioned(
right: ScreenUtil().setWidth(40),
bottom: ScreenUtil().setWidth(190),
bottom: ScreenUtil().setWidth(156),
child: RoundButton(
image: Utils.getImgPath('edit'),
text: '店铺信息',
gradientStart: Color.fromRGBO(255, 255, 255, 0.1),
gradientEnd: Color.fromRGBO(255, 255, 255, 0.1),
borderColor: Color.fromRGBO(255, 255, 255, 0.2),
width: ScreenUtil().setWidth(195),
height: ScreenUtil().setWidth(60),
text: '切换店铺',
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: MyColours.color_ffffff,
width: ScreenUtil().setWidth(150),
height: ScreenUtil().setWidth(56),
fontSize: 28,
isBold: false,
imgWidth: 26,
textColor: MyColours.color_199095,
radius: ScreenUtil().setWidth(20),
onPressed: () {
NavigatorUtil.goStoreBaseInfoPage(context);
NavigatorUtil.goIfNeedCreateStorePage(context,
changeStatus: true);
},
)),
Positioned(
right: ScreenUtil().setWidth(40),
bottom: ScreenUtil().setWidth(110),
child: RoundButton(
image: Utils.getImgPath('edit'),
text: '个人信息',
gradientStart: Color.fromRGBO(255, 255, 255, 0.1),
gradientEnd: Color.fromRGBO(255, 255, 255, 0.1),
borderColor: Color.fromRGBO(255, 255, 255, 0.2),
width: ScreenUtil().setWidth(195),
height: ScreenUtil().setWidth(60),
fontSize: 28,
isBold: false,
imgWidth: 26,
onPressed: () {
NavigatorUtil.goBaseInfoPage(context);
},
))
],
);
}),
... ... @@ -350,6 +333,32 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
VEmptyView(40),
MyItem(
title: "个人信息",
content: "",
callback: () {
NavigatorUtil.goBaseInfoPage(context);
},
),
MyDivider(
double.infinity,
ScreenUtil().setHeight(1),
color: MyColours.color_f3f3f3,
),
MyItem(
title: "店铺信息",
content: "",
callback: () {
NavigatorUtil.goStoreBaseInfoPage(context);
},
),
MyDivider(
double.infinity,
ScreenUtil().setHeight(1),
color: MyColours.color_f3f3f3,
),
MyItem(
title: "短信管理",
content:
myModel.smsInfo.isNotEmpty ? '剩余${myModel.smsInfo}条' : '',
... ... @@ -391,11 +400,6 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
ScreenUtil().setHeight(1),
color: MyColours.color_f3f3f3,
),
MyDivider(
double.infinity,
ScreenUtil().setHeight(1),
color: MyColours.color_f3f3f3,
),
MyItem(
title: "员工管理",
... ...
... ... @@ -218,7 +218,7 @@ class UserModel with ChangeNotifier {
if (baseResp != null && baseResp.code == Constant.status_success) {}
}
//版本更新弹框
//退出登录弹框
showLoginOutDialog(BuildContext pageContext) {
showDialog(
context: pageContext,
... ... @@ -327,6 +327,23 @@ class UserModel with ChangeNotifier {
}
}
///切换店铺时的退出登录
Future<bool> loginOutOnly(
BuildContext context, Map<String, String> params) async {
BaseResp<int> baseResp = await DioUtil()
.request<int>(context, Method.get, HttpUrl.login_out, data: params)
.catchError((error) {
print(error.toString());
});
if (baseResp.code != Constant.status_success) {
Utils.showToast(baseResp.msg ?? "切换店铺失败,请稍后重试");
return false;
} else {
XgFlutterPlugin().stopXg();
return true;
}
}
/// 保存用户信息到 sp
saveUserInfo(User user) {
_user = user;
... ...
... ... @@ -281,9 +281,9 @@ class NavigatorUtil {
/// 是否新建店铺页面
static Future<dynamic> goIfNeedCreateStorePage(BuildContext context,
{replace = false, bool noStore}) {
return _navigateTo(
context, "${Routes.if_need_create_store}?noStore=${noStore}",
{replace = false, bool noStore, bool changeStatus = false}) {
return _navigateTo(context,
"${Routes.if_need_create_store}?noStore=${noStore}&changeStatus=${changeStatus}",
replace: replace);
}
... ...
... ... @@ -500,8 +500,11 @@ var ifNeedCreateStorePageHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
// CouponSunModel couponSunModel = CouponSunModel.fromJson(json.decode(
// FluroConvertUtils.fluroCnParamsDecode(params["couponSunModel"].first)));
bool changeStatus =
FluroConvertUtils.string2bool(params["changeStatus"].first);
return ChangeNotifierProvider<OtherLoginProvider>(
create: (_) => OtherLoginProvider(), child: IfNeedCreateStore());
create: (_) => OtherLoginProvider(),
child: IfNeedCreateStore(changeStatus: changeStatus));
});
///新建店铺页面
... ... @@ -1173,13 +1176,13 @@ var myCustomerOrderPageHandle = new Handler(
///客情列表详情---再次预订
var tableManagerPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
Guest guest = Guest.fromJson(json
Guest guest = Guest.fromJson(json
.decode(FluroConvertUtils.fluroCnParamsDecode(params["guest"].first)));
// UserHistoryEntity userHistoryEntity = UserHistoryEntity.fromJson(json.decode(
// FluroConvertUtils.fluroCnParamsDecode(
// params["userHistoryEntity"].first)));
return ChangeNotifierProvider<TableManagerModel>(
create: (_) => TableManagerModel(),
child: TableManagerPage(guest:guest),
child: TableManagerPage(guest: guest),
);
});
... ...