The problem, only working when you're near the router, can be either a bad wifi adapter (or antenna connection) in the phone, or a bad wifi transceiver (or antenna connection or antenna) in the router.
If other devices connect from 50-100 feet away, it's the phone., If no device connects unless it's close to the router, but they connect to other routers from a distance, it's the router.
It usually doesn't pay to repair the router - most homes aren't large enough to need more than a cheap 150mbps router, and most people don't have enough devices connected to the router to need more than that. (The Netgear WNR 2000 is only about $40-$50, and the repair is going to be more than that.)
If it's a problem with the phone, it probably means a motherboard replacement (unless the antenna connector just got unplugged), then you have to compare the repair cost to the cost of replacing the phone. A fairly new flagship phone is worth repairing, an4 year old cheapie isn't.
Andreas, your problem didn't involve how close the phone was to the router, so it's a completely different kind of problem.