This is a question which I have answered dimensions of in the past, with relevant write-ups including:
How great of an effect did the first Opium War have on the Taiping Rebellion?
How and why did the 'century of humiliation' narrative become dominant?
If you have any followups do feel free to ask and I'll be happy to answer.