In view of the complementary characteristics of the UAV communication network and satellite communication network, we consider UAVs, satellites, and ground devices to form a space-air-ground integrated network (SAGIN) that can provide service to ground users after a natural disaster. In this scenario, an unmanned aerial vehicle (UAV) is employed as a base station (BS) or mobile edge computing (MEC) server to provide communication/computation services to ground users. In addition, the UAV MEC server can offload computing tasks to a satellite. To achieve the goal of satisfying the users' quality-of-experience (QoE) requirements and simultaneously maximizing the energy efficiency, we investigate the problem of joint optimization of the UAV 3D trajectory with resource allocation. Thus, this article establishes a joint optimization problem. Given that the above optimization problem contains a fractional multivariate objective function and nonconvex constraints, we solve the optimization problem by using an effective iterative algorithm. The simulation results show that the proposed optimization scheme achieves high energy efficiency.