WiFi fingerprint-based positioning is a method for indoor localization with the advent of widespread deployment of WiFi and the Internet of Things. However, single WiFi fingerprint positioning has the problems of mismatch, unstable signal strength and limited accuracy. Aiming to address these issues, this paper proposes the fusion algorithm combining WiFi and pedestrian dead reckoning (PDR). Firstly, the particle swarm optimization (PSO) model is utilized to optimize the weighted k-nearest neighbors (WKNN) in the WiFi part. Additionally, the artemisinin optimization (AO) algorithm is used to optimize the particle filter (PF) to improve the fusion effect of the WiFi and PDR. Finally, to thoroughly validate the localization performance of the proposed algorithm, we designed experiments involving two scenarios with four smartphone gestures: calling, dangling, handheld, and pocketed. The experimental results unequivocally indicate that the positioning error of AO-PSO-PF algorithm is lower than that of other algorithms including PDR, WiFi, PF, APF, and FPF. The average positioning errors for the two experiments are 0.95 m and 1.42 m, respectively.