Researches state that you are more likely to eat junk food if you are in a bad mood and when you are in a good mood you will always opt for the healthier option! An upbeat mind is more likely to focus on the future and recognise the long term benefits associated with eating healthy food.
When you're in a bad mood you aren't really thinking properly and your attitude is that you don't care what you consume. Stay upbeat, stay positive and motivated.
Reference - Daily Mail - http://www.dailymail.co.uk/health/article-2564403/Why-bad-mood-make-want-murder-burger-Negative-thinking-makes-people-focus-short-term-gain.html