Recently, the rapid development of the bike-sharing system (BSS) has dramatically influenced passengers' travel modes. However, whether the relationship between the BSS and public transit is competitive or complementary remains unclear. In this paper, a difference-in-differences (DID) model is proposed to figure out the impact of the dockless BSS (DBSS) on bus ridership. The data was collected from Shanghai, China, which includes data from automatic fare collection (AFC) systems, automatic vehicle location (AVL) systems, DBSS transaction data, and point-of-interest (POI) data. The research is based on the route-level, and the results indicate that shared bikes have a substitution impact on bus ridership. Regarding all the travel distance, each shared bike along the route leads to a 0.39 decrease in daily bus ridership on the weekdays, and a 0.17 decrease in daily bus ridership on the weekends, respectively, indicating that dockless shared bikes lead to a stronger decrease in bus ridership on weekends compared to weekdays. Additionally, the substitution effects of shared bikes on bus ridership gradually decays from 0.104 to 0.016 in daily bus ridership on weekends, respectively, with the increase in the travel distance within 0-3 km. This paper reveals that the travel distance of passengers greatly influences the relationship between the DBSS and public transit on the route level.