getRechargeList method

Future<void> getRechargeList(
  1. dynamic changed, {
  2. String type = '0',
  3. bool mode = true,
  4. bool pop = true,
  5. bool cache = true,
})

审核模式-mode:true审核模式,false正式模式

Implementation

Future<void> getRechargeList(changed,
    {String type = '0',
    bool mode = true,
    bool pop = true,
    bool cache = true}) async {
  if (mode) {
    if (cache &&
        rechargeModels.isNotEmpty &&
        rechargeModels.values.first.isNotEmpty) {
      changed?.call(CommonUtils.pageStatusSuccess);
      return;
    }
    clearRechargeList();
    showLoading = false;
    changed?.call(CommonUtils.pageStatusLoading);
    RechargeTypeList codeType = RechargeTypeList()
      ..type = Platform.isAndroid ? '2' : '1';
    bool ok = await rechargeInList(type, codeType, pop: pop);
    changed
        ?.call(rechargeModels.isEmpty || rechargeModels.values.first.isEmpty
            ? CommonUtils.pageStatusEmpty
            : ok
                ? CommonUtils.pageStatusSuccess
                : CommonUtils.pageStatusError);
  } else {
    showLoading = false;
    changed?.call(CommonUtils.pageStatusLoading);
    RechargeDao.rechargeSupport().then((res) async {
      if (res.result) {
        List<RechargeTypeList> list = res.data.rechargeModels;
        if (list.isNotEmpty) {
          clearRechargeList();
          bool ok = false;
          for (RechargeTypeList item in list) {
            ok = await rechargeInList(type, item, pop: pop);
            if (!ok) {
              changed?.call(CommonUtils.pageStatusError);
              return;
            }
          }
        } else {
          clearRechargeList();
        }
      }
      changed?.call(
          rechargeModels.isEmpty || rechargeModels.values.first.isEmpty
              ? CommonUtils.pageStatusEmpty
              : CommonUtils.pageStatusSuccess);
    });
  }
}