The mobile edge computing (MEC) technology is introduced into the traditional mobile cloud computing (MCC) mode to form a cloud-edge-terminal collaborative network architecture (CETCN) to jointly process the massive data and improve the operating efficiency. However, there are still some problems such as high energy consumption of some edge nodes and limited terminal energy in this network architecture. In order to solve the above problems, this paper proposes a computation offloading algorithm based on sleep mechanism. Firstly, time delay and energy consumption models of cloud layer, edge layer and terminal layer are built according to the requirements of different scenes of smart city. Then, the communication and computing resources of each network segment are allocated jointly with the optimization goals of time delay and energy consumption, and the edge server sleep mechanism is used to further improve the resource utilization of the edge nodes. The simulation results show that the proposed algorithm can reduce the network delay and energy consumption, and has practicability.