Aiming at problems of power allocation and economic scheduling for independent multi-microgrid systems, a bi-level optimization method based on optimal power flow and consensus algorithm is proposed. The novelty of the method is that an independent multi-microgrid system is divided into two layers: in the upper layer, with the predicted output range of the microgrids as the input data, each microgrid is considered as a virtual power supply or virtual load, and taking the minimum network loss as the goal, the energy mutual aid and power allocation among the microgrids are transformed into solving the optimal power flow; in the lower layer, taking the upper layer power distribution scheme as the constraint condition, considering load fluctuation and wind/solar generation uncertainty, the optimal dispatch model of the controllable distributed generator is established based on the distributed theory and the consensus algorithm of equal cost increment, and the "plug and play" of the distributed generator is also realized. An islanded multi-microgrid cluster is taken as an example to verify the economy, security, and reliability of the proposed scheme. The advantages of the scheme have been shown by the simulation example. Simulation results show that the upper-layer method not only realizes the optimal power allocation of microgrids, but also reduces the power loss of the energy mutual aid among the microgrids; through the optimal scheduling of controllable power supply in the microgrid, the lower-level scheme not only improves the economic benefit of the microgrid, but also well suppresses the negative effects of the uncertainties, prediction errors and power fault removal on the multi-microgrid system, which improves the robustness of the system.