Are you sure it is loosing charge or just a loose connection?
My wife's Cannondale had a problem where the shifting would stop working intermittently.
I finally accessed the junction box in the BB and reseated all the connectors and the problem went away.
Took months to figure out.