Thermodynamics of grain boundary premelting in alloys. I. Phase-field modeling