Iphone 7 keeps turning screen black but it's still working
My iPhone 7 was working perfectly, and last night it frequently kept doing the sound when you plugged it to the charger. I didn't know why it kept doing that until I woke up and started using my phone, a few seconds later the screen went black and the white bars started going around the circle and it gave me the unlock screen again. I entered my code and less than a minute after that the same thing happened.
I thought it was turning off and back on again on its one, but the a call came in, the screen went black again but It kept ringing and after the screen came back on again, I couldn't answer the call but it kept ringing until it went as a missed called.
It has been like this the whole day, I reset it or reboot it, holding the down volume button and power button at the same time but didn't change anything. I also let it loose all of it's battery charge until it went off and then charged it again, but still have the same problem.
What can I do? I don't want to erase it because of the information I have, but don't know any other options
iPhone 7, iOS 11.1.2