navigator_util.dart 14.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:one_key/models/cookbook_model.dart';
import 'package:one_key/models/coupon_model.dart';
import 'package:one_key/models/integral_model.dart';
import 'package:one_key/models/notebook.dart';
import 'package:one_key/models/notebook_detail.dart';
import 'package:one_key/models/sms_info.dart';
import 'package:one_key/models/statics_model.dart';
import 'package:one_key/models/table_list.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/routes.dart';
import 'package:one_key/utils/fluro_convert_utils.dart';
import 'package:one_key/utils/utils.dart';
import 'package:sqflite/sqlite_api.dart';

import '../app.dart';

class NavigatorUtil {
  static Future _navigateTo(BuildContext context, String path,
      {bool replace = false,
      bool clearStack = false,
      TransitionType transitionType = TransitionType.material,
      Duration transitionDuration = const Duration(milliseconds: 250),
      RouteTransitionsBuilder transitionBuilder}) {
    Utils.changeStatusColor(color: MyColours.color_ffffff);
    return App.router.navigateTo(context, path,
        replace: replace,
        clearStack: clearStack,
        transitionDuration: transitionDuration,
        transitionBuilder: transitionBuilder,
        transition: transitionType);
  }

  /// 登录页
  static void goLoginPage(BuildContext context) {
    _navigateTo(context, Routes.login, clearStack: true);
  }

  /// 首页
  static void goHomePage(BuildContext context, {int initialIndex = 2}) {
    _navigateTo(context, "${Routes.home}?initialIndex=$initialIndex",
        clearStack: true);
  }

  /// 订单详情
  static void goNotebookDetailPage(BuildContext context, String rid, String uid,
      {String mid = "", bool fromNotify = false, replace = false}) {
    _navigateTo(context,
        "${Routes.reserve_detail}?rid=$rid&mid=$mid&uid=$uid&fromNotify=$fromNotify",
        replace: replace);
  }

  /// 处理在线预订
  static Future goHandleOnlinePage(BuildContext context, String rid, String mid,
      {fromNotify = false, replace = false}) {
    return _navigateTo(context,
        "${Routes.handle_online_page}?rid=$rid&mid=$mid&fromNotify=$fromNotify",
        replace: replace);
  }

  /// 选择桌位
  static Future goSelectTablePage(
      BuildContext context, String rid, int dateTime, String ddate_slot,
      {bool canChoose = false,
      Map object,
      String fromPage = 'change',
      String tid = ''}) {
    if (object != null) {
      return _navigateTo(context,
          "${Routes.select_table}?rid=$rid&tid=$tid&dateTime=$dateTime&fromPage=$fromPage&ddate_slot=$ddate_slot&canChoose=$canChoose&object=${FluroConvertUtils.object2string(object)}");
    }
    // object = {'object': [], "tid": ''};
    return _navigateTo(context,
        "${Routes.select_table}?rid=$rid&tid=$tid&dateTime=$dateTime&fromPage=$fromPage&ddate_slot=$ddate_slot&canChoose=$canChoose");
  }

  /// 邀请函
  static void goInvicationPage(
      BuildContext context,
      String rid,
      String tableInfo,
      String ddate,
      String ddateStr,
      String phone,
      String ddate_solt,
      {bool replace = false,
      String tid}) {
    _navigateTo(context,
        "${Routes.invication}?rid=$rid&tid=$tid&tableInfo=${FluroConvertUtils.fluroCnParamsEncode(tableInfo)}&ddate=$ddate&ddateStr=${FluroConvertUtils.fluroCnParamsEncode(ddateStr)}&phone=$phone&ddate_solt=$ddate_solt",
        replace: replace);
  }

  /// 发短信
  static void goSmsPage(BuildContext context, String rid) {
    _navigateTo(context, "${Routes.sms}?rid=$rid");
  }

  /// 浏览器
  static void goWebviewPage(BuildContext context) {
    _navigateTo(context, "${Routes.webview}");
  }

  ///协议
  static Future<dynamic> goWebPage(
      BuildContext context, String title, String url) {
    return _navigateTo(
      context,
      "${Routes.web_page}?title=${Uri.encodeComponent(title)}&url=$url",
    );
  }

  /// 变更预订
  static void goNoteBookChangePage(
      BuildContext context, NotebookDetail detailEntity, String rid,
      {replace = false}) {
    if (detailEntity.type == "0") {
      //内部预订
      detailEntity.is_set_ddate = "1";
    }
    _navigateTo(context,
        "${Routes.change_detail}?detail=${FluroConvertUtils.object2string(detailEntity)}&rid=$rid",
        replace: replace);
  }

  /// 可订时段管理
  static void goBookTimeSetPage(BuildContext context) {
    _navigateTo(context, "${Routes.book_time_set}");
  }

  /// 可订时段管理
  static void goReceiveOrdersTimeSetPage(BuildContext context) {
    _navigateTo(context, "${Routes.receive_orders_time_set}");
  }

  /// 常用备注管理
  static void goRemarkManagerPage(BuildContext context) {
    _navigateTo(context, "${Routes.remark_manager}");
  }

  /// 已选菜品
  static void goHasOrderFoodPage(BuildContext context,
      {String rid, fromNotify = false, replace = false}) {
    _navigateTo(
        context, "${Routes.has_order_food}?rid=${rid}&fromNotify=${fromNotify}",
        replace: replace);
  }

  /// 提前买单编辑页面
  static Future goOnlineCheckEditPage(BuildContext context,
      {String rid, String mid, fromNotify = false, replace = false}) {
    return _navigateTo(context,
        "${Routes.online_check_edit}?fromNotify=${fromNotify}&rid=${rid}&mid=$mid",
        replace: replace);
  }

  /// 提前买单查看页面
  static void goOnlineCheckDetailPage(BuildContext context,
      {String rid, fromNotify = false, replace = false}) {
    _navigateTo(context,
        "${Routes.online_check_detail}?fromNotify=${fromNotify}&rid=${rid}",
        replace: replace);
  }

  /// 发票详情
  static void goInvoiceDetailPage(BuildContext context,
      {String rid, fromNotify = false, replace = false}) {
    _navigateTo(
        context, "${Routes.invoice_detail}?fromNotify=${fromNotify}&rid=${rid}",
        replace: replace);
  }

  ///  优惠券列表
  static void goCouponPage(BuildContext context,
      {replace = false, needRefrsh = false}) {
    _navigateTo(context, "${Routes.coupon}?needRefrsh=${needRefrsh}",
        replace: replace);
  }

  ///  优惠券历史列表
  static void goCouponHistoryPage(BuildContext context, {replace = false}) {
    _navigateTo(context, "${Routes.coupon_history}", replace: replace);
  }

  ///  创建优惠券
  static Future<dynamic> goCouponEditPage(BuildContext context,
      {replace = false}) {
    return _navigateTo(context, "${Routes.coupon_edit}", replace: replace);
  }

  ///  选择优惠券
  static Future<dynamic> goCouponSelectPage(BuildContext context,
      {String from, bool hasModify, replace = false}) {
    return _navigateTo(
        context, "${Routes.coupon_select}?from=${from}&hasModify=${hasModify}",
        replace: replace);
  }

  ///  优惠券详情页
  static Future<dynamic> goCouponDetailPage(
      BuildContext context, CouponSunModel couponSunModel,
      {replace = false}) {
    return _navigateTo(context,
        "${Routes.coupon_detail}?couponSunModel=${FluroConvertUtils.object2string(couponSunModel)}",
        replace: replace);
  }

  ///  个人资料页面
  static Future<dynamic> goBaseInfoPage(BuildContext context,
      {replace = false}) {
    return _navigateTo(context, "${Routes.base_info}", replace: replace);
  }

  ///  绑定手机号吗页面
  static Future<dynamic> goBindingPhonePage(BuildContext context,
      {replace = false, bool wechat = true}) {
    return _navigateTo(context, "${Routes.binding_phone}?wechat=${wechat}",
        replace: replace);
  }

  ///  是否新建店铺页面
  static Future<dynamic> goIfNeedCreateStorePage(BuildContext context,
      {replace = false, bool noStore}) {
    return _navigateTo(
        context, "${Routes.if_need_create_store}?noStore=${noStore}",
        replace: replace);
  }

  ///  新建店铺页面
  static Future<dynamic> goCreateStorePage(BuildContext context,
      {replace = false}) {
    return _navigateTo(context, "${Routes.create_store}", replace: replace);
  }

  ///  播放视频页
  static Future<dynamic> goPlayVideoPage(BuildContext context,
      {replace = false, String urlStr}) {
    return _navigateTo(context,
        "${Routes.play_video}?urlStr=${FluroConvertUtils.fluroCnParamsEncode(urlStr)}",
        replace: replace,
        transitionType: TransitionType.materialFullScreenDialog);
  }

  ///  地图选择页
  static Future<dynamic> goMapChoicePointPage(BuildContext context,
      {replace = false, String urlStr}) {
    return _navigateTo(context, "${Routes.map_choice_point}", replace: replace);
  }

  ///  店铺名称
  static Future<dynamic> goEnterStoreNamePage(BuildContext context,
      {replace = false}) {
    return _navigateTo(context, "${Routes.enter_store_name}", replace: replace);
  }

  ///  店铺地址
  static Future<dynamic> goEnterStoreAddressPage(BuildContext context,
      {replace = false}) {
    return _navigateTo(context, "${Routes.enter_store_address}",
        replace: replace);
  }

  ///  店铺担任角色
  static Future<dynamic> goEnterStorePositionPage(BuildContext context,
      {replace = false}) {
    return _navigateTo(context, "${Routes.enter_store_position}",
        replace: replace);
  }

  ///  店铺营业时间
  static Future<dynamic> goEnterStoreTimePage(BuildContext context,
      {replace = false}) {
    return _navigateTo(context, "${Routes.enter_store_time}", replace: replace);
  }

  ///  店铺接单电话
  static Future<dynamic> goEnterStorePhonePage(BuildContext context,
      {replace = false}) {
    return _navigateTo(context, "${Routes.enter_store_phone}",
        replace: replace);
  }

  ///  店铺门头照片
  static Future<dynamic> goEnterStoreFrontPhotoPage(BuildContext context,
      {replace = false}) {
    return _navigateTo(context, "${Routes.enter_store_front_photo}",
        replace: replace);
  }

  ///  店铺环境
  static Future<dynamic> goEnterStoreEnvironmentPage(BuildContext context,
      {replace = false}) {
    return _navigateTo(context, "${Routes.enter_store_environment}",
        replace: replace);
  }

  ///  新建店铺完成页面
  static Future<dynamic> goCompleteStorePage(BuildContext context,
      {replace = false}) {
    return _navigateTo(context, "${Routes.complete_create_store}",
        replace: replace);
  }

  ///  我的积分页面
  static Future<dynamic> goMyIntegralPage(BuildContext context,
      {replace = false, IntegralSunModel sunModel}) {
    return _navigateTo(context,
        "${Routes.my_integral_page}?sunModel=${FluroConvertUtils.object2string(sunModel)}",
        replace: replace);
  }

  ///  我的联系人页面
  static Future<dynamic> goMyContantPage(BuildContext context,
      {replace = false, IntegralSunModel sunModel}) {
    return _navigateTo(context, "${Routes.my_contant_page}", replace: replace);
  }

  ///  桌位照片管理
  static Future<dynamic> goTablePhotoManagerPage(BuildContext context,
      {replace = false, String tid, String tname}) {
    return _navigateTo(context,
        "${Routes.table_photo_manager}?tid=${tid}&tname=${Uri.encodeComponent(tname)}",
        replace: replace);
  }

  ///  统计
  static Future<dynamic> goStatisticsPage(BuildContext context,
      {replace = false}) {
    return _navigateTo(context, "${Routes.statistics_page}", replace: replace);
  }

  ///  统计发短信
  static Future<dynamic> goStatisticsSmsPage(BuildContext context,
      {replace = false, Map<String, List> selectData}) {
    return _navigateTo(context,
        "${Routes.statistics_sms_page}?selectData=${FluroConvertUtils.object2string(selectData)}",
        replace: replace);
  }

  ///  包间类型置满
  static Future<dynamic> goStoreTypeFillManagePage(BuildContext context,
      {replace = false}) {
    return _navigateTo(context, "${Routes.store_type_fill_manage_page}",
        replace: replace);
  }

  ///  短信余额显示
  static Future<dynamic> goSmsManagePage(BuildContext context,
      {replace = false, SmsInfoData smsInfoData}) {
    return _navigateTo(context,
        "${Routes.sms_manager_page}?smsInfoData=${FluroConvertUtils.object2string(smsInfoData)}",
        replace: replace);
  }

  ///  短信充值
  static Future<dynamic> goSmsRechargePage(BuildContext context,
      {replace = false, SmsInfoData smsInfoData}) {
    return _navigateTo(context,
        "${Routes.sms_recharge_page}?smsInfoData=${FluroConvertUtils.object2string(smsInfoData)}",
        replace: replace);
  }

  ///  店铺信息
  static Future<dynamic> goStoreBaseInfoPage(BuildContext context,
      {replace = false, SmsInfoData smsInfoData}) {
    return _navigateTo(context, "${Routes.store_base_info_page}",
        replace: replace);
  }

  ///  包间类型管理
  static Future<dynamic> goRoomTypeManagePage(BuildContext context,
      {replace = false, SmsInfoData smsInfoData}) {
    return _navigateTo(context, "${Routes.room_type_manage_page}",
        replace: replace);
  }

  ///  包间类型创建
  static Future<dynamic> goRoomTypeCreatePage(BuildContext context,
      {replace = false,
      SmsInfoData smsInfoData,
      bool isNew = true,
      String tableClassId}) {
    return _navigateTo(context,
        "${Routes.room_type_create_page}?isnew=${isNew}&tableClassId=${tableClassId}",
        replace: replace);
  }

  ///包间管理中 ------ 选择桌位
  static Future goRoomTypeSelectTablePage(
      BuildContext context, String rid, int dateTime, String ddate_slot,
      {bool canChoose = false,
      String object,
      String fromPage = 'change',
      String tid = ''}) {
    if (object != null) {
      return _navigateTo(context,
          "${Routes.room_type_select_table_page}?rid=$rid&tid=$tid&dateTime=$dateTime&fromPage=$fromPage&ddate_slot=$ddate_slot&canChoose=$canChoose&object=${object}");
    }
    // object = {'object': [], "tid": ''};
    return _navigateTo(context,
        "${Routes.room_type_select_table_page}?rid=$rid&tid=$tid&dateTime=$dateTime&fromPage=$fromPage&ddate_slot=$ddate_slot&canChoose=$canChoose");
  }

  ///  菜单管理
  static Future<dynamic> goMenuManagePage(BuildContext context,
      {replace = false}) {
    return _navigateTo(context, "${Routes.menu_manage_page}", replace: replace);
  }

  ///  菜单分类管理
  static Future<dynamic> goMenuCategoryPage(BuildContext context,
      {replace = false}) {
    return _navigateTo(context, "${Routes.menu_category_page}",
        replace: replace);
  }

  ///  添加菜品页面
  static Future<dynamic> goMenuAddDishesPage(BuildContext context,
      {replace = false, bool isNew = true, String idstr}) {
    return _navigateTo(
        context, "${Routes.menu_add_dishes_page}?isNew=$isNew&idstr=${idstr}",
        replace: replace);
  }
}