Hopefully Time Machine has included the iTunes folder in its backups. If not see Empty/corrupt iTunes library after upgrade/crash for a way to restore a recent backup of your library database which should restore your playlists. More importantly let us hope all of your media is still where it ought to be and iTunes hasn't deleted anything while you've been flipping the options. I can only assume that what happened was that you started to load your library to Apple Music, interrupted the process. Then when you turned it on again you've been served up the partially loaded iCloud Music Library rather than your original collection.
Sign out of iCloud Music library before attempting any repairs. For Time Machine you should be able to pick a moment in time from before you first enabled Apple Music. If no media has been removed you should be able to restore the files in the iTunes folder and the whole of the Album Artwork folder inside it. If media files have been deleted then you'll want to restore the entire iTunes folder and all subfolders it contains. It may be wise to take a copy of the existing iTunes folder on an external drive before trying to restore from Time Machine in case what exists there is incomplete for some reason. See OS X Yosemite: Recover items using Time Machine and Spotlight, for example, for more on restoring with Time Machine. The key file that contains the playlist is iTunes Library.itl, but it makes sense to restore the supporting files and album artwork folder at the same time so there are no inconsistencies.
When you allow Apple Music to scan your library it is possible that some playlists that contain ineligible content or incompatible rules will be excluded from what is added to the iCloud Music library. You'd probably want to resolve any such issues before joining the iPhone to the iCloud Music library as, when you do so, it stops syncing with iTunes over USB and syncs with the iCloud Music Library instead. I don't have an active Apple Music subscription, but in many ways it is similar to iTunes Match which I do have.
See also these articles:
When I took the trial of Apple Music my library was too big to be included so I made a second test library to explore its features. I have a separate library now for iTunes Match mainly because I've only planned to use the service for a year and I want to be able to experiment with how things work without risking my main library. You might consider this approach with any remaining trial of Apple Music that you have.
tt2