Invest in a Dry Egg/Box
My suggestion it to take as little valuables as possible, and carry them in the water with you when you go for a dip. What I usually do is I take some form of plastic ID, a bit of cash, a payment card and my phone. I leave everything else at home since most likely I won't need it on the beach. Everything I take easily fits in what is called a freediving dry egg which, as the name suggests, is a gadget used by divers to keep their stuff dry whilst in the water. These gadgets come in various different sizes, cost under 20 EUR and look something like this (image courtesy of ScubaStore):
First thing you should do after purchasing your egg is to test ride it. Put a piece of paper in it, lock it up and throw it in a sink/bucket full of water. Then wiggle it around for a few minutes. Take it out, open it and check the paper: if it's wet you either did not close the egg properly or it leaks.
Locker Facilities Barcelona's Beaches
Some of the beaches in Barcelona have lockers, according to the official municipal website. This information is everything but easy to find, since it's usually only listed on the individual webpage of each beach. The results of my searches show that the following beaches have lockers: Nova Icaria, Somorrostro, Bogatell, Mar Bella, Barceloneta (in Catalan only - Consigna). Hopefully this information is up to date.