For a connected graph, the first Zagreb eccentricity index xi _{1} is defined as the sum of the squares of the eccentricities of all vertices, and the second Zagreb eccentricity index xi _{2} is defined as the sum of the products of the eccentricities of pairs of adjacent vertices. In this paper, we mainly present a different and universal approach to determine the upper bounds respectively on the Zagreb eccentricity indices of trees, unicyclic graphs and bicyclic graphs, and characterize these corresponding extremal graphs, which extend the ordering results of trees, unicyclic graphs and bicyclic graphs in (Du et al. in Croat. Chem. Acta 85:359–362, 2012; Qi et al. in Discrete Appl. Math. 233:166–174, 2017; Li and Zhang in Appl. Math. Comput. 352:180–187, 2019). Specifically, we determine the n-vertex trees with the i-th largest indices xi _{1} and xi _{2} for i up to lfloor n/2+1 rfloor compared with the first three largest results of xi _{1} and xi _{2} in (Du et al. in Croat. Chem. Acta 85:359–362, 2012), the n-vertex unicyclic graphs with respectively the i-th and the j-th largest indices xi _{1} and xi _{2} for i up to lfloor n/2-1 rfloor and j up to lfloor 2n/5+1 rfloor compared with respectively the first two and the first three largest results of xi _{1} and xi _{2} in (Qi et al. in Discrete Appl. Math. 233:166–174, 2017), and the n-vertex bicyclic graphs with respectively the i-th and the j-th largest indices xi _{1} and xi _{2} for i up to lfloor n/2-2rfloor and j up to lfloor 2n/15+1rfloor compared with the first two largest results of xi _{2} in (Li and Zhang in Appl. Math. Comput. 352:180–187, 2019), where nge 6. More importantly, we propose two kinds of index functions for the eccentricity-based topological indices, which can yield more general extremal results simultaneously for some classes of indices. As applications, we obtain and extend some ordering results about the average eccentricity of bicyclic graphs, and the eccentric connectivity index of trees, unicyclic graphs and bicyclic graphs.