Joint Beamforming and Resource Allocation for Integrated Satellite-Terrestrial Networks