Definitely have the surgery. I'm guessing that once you get that knee fixed the pain in your other knee and hips will start going away. At 18 your recovery is going to be 10x better now then it will be trying to do the same thing a couple years down the road. As long as your diet is in check then getting fat and losing muscle shouldn't be an issue. Your weight might drop during recovery but it'll come back up quick once you start back at it.
I'd use trueproteins BodyFX Cell Swell Matrix during your recovery if it's really freaking you out about losing muscle. Good luck bro.