Hey.
First of all, head to Settings > Wi-Fi, forget this network and then join again. When joined, tap info of your network and make sure that Auto-Login is on.
Then you could try to disable Wi-Fi networking services. This can also help in fixing the Wi-Fi disconnects when iPhone is locked issue as reported by many users. Moreover, turning off the Wi-Fi network will also help you save battery. To turn off the Wi-Fi networking, go to Settings> Privacy > Location Services> System Services and then slide the Wi-Fi networking toggle to off.
If it is and you still experience this issue, Reset Network Settings under Settings > General > Reset.
This also resets Wi-Fi networks and passwords, cellular settings, and VPN and APN settings that you've used before.
You might also wanna check if there are any software updates for the router you are using. Sometimes, Wi-Fi router can also cause problems like Wi-Fi disconnects when iPhone is locked. You can try updating the router firmware if it is outdated. As every router manufacturer has a different process of updating the firmware, visit the official website of your router manufacturer to get the detailed information about the process.