This study integrates the theory of convex optimization into the teaching of ideology and politics courses in colleges and universities and puts forward the characteristic teaching strategy of constructing the teaching resource management and network teaching platform of ideology and politics courses. It consists of a course resource module, an after-class Q&A module, and my module to compose the function of the Ideological and Political Science course network teaching platform. Model the computational migration resource division problem of the mobile terminal as a convex optimization problem and solve it using the Lagrange multiplier method to optimize energy consumption of the mobile terminal. Design the registration and login, personal center, likes and comments, resource upload, resource recommendation, and platform management modules as the functions of the teaching resource management platform for Ideology and Politics courses. Use the search algorithm to obtain the correspondence of physical nodes, use the time series prediction smoothing exponential model to reduce the probability of hotspot misjudgment, and determine the best form of placing network resources through global search optimization. Teaching practice is being conducted with the 2022 computer science major students at a university in Guangdong Province, China. The overall Ideology and Politics literacy of the subject students increased by 7.02 compared to the pre-experiment, P=0.031<0.05, showing a significant difference. Satisfaction with the teaching of ideology and politics courses also exceeds 3 and is close to 4, making more recognized classrooms for teaching ideology and politics.