Two goals in three second-half minutes gave St Johnstone victory over Aberdeen at Pittodrie on Saturday.