Phaseless terahertz coded-aperture imaging (PL-TCAI) is a novel radar computational imaging method that utilizes the coded aperture and the incoherent detector array to achieve forward-looking and high-resolution imaging without relying on relative motion. In this paper, we propose a more reasonable and compact architecture for the PL-TCAI system and derive the imaging model of PL-TCAI based on the random frequency-hopping signal. Since most phase retrieval algorithms for PL-TCAI utilize only the intensity of echo signals to accurately reconstruct the target, excessive measurement samples are usually required. In order to reduce the number of measurement samples required for imaging, this paper proposes a sparse Wirtinger flow algorithm with optimal stepsize (SWFOS) by using the sparse prior of the target. The specific procedures of the SWFOS algorithm include the support recovery, initialization by truncated spectral method, iteration via gradient descent scheme, hard threshold operation, and stepsize optimization of iteration. Numerical simulations are performed, and the results show that the SWFOS algorithm not only has good performance for the PR problem, but can also sharply reduce the number of measurement samples required for imaging in the PL-TCAI system.