A method for preparing a nanofiltration membrane used for removing divalent cation and PPCPs with positive charges is disclosed. The PEI/TMC/HTCC composite nanofiltration membrane is prepared by adopting polyethersulfone nanofiltration membrane as a base membrane, and adopting twice interfacial polymerization, with polyethyleneimine and quaternized chitosan being adopted as water-phase monomers offirst and second times of interfacial polymerization respectively and 1,3,5-trimesoyl chloride being adopted as an organic-phase monomer. The inorganic salt trapping priority of the composite membrane is in this order: MgCl2, CaCl2, MgSO4, Na2SO4, NaCl and KCl. The trapping rates for MgCl2 and Na2SO4 are respectively 90.48% and 78.13%, and the composite membrane shows a high removing rate for a high-valence cation salt solution. The trapping priority of the composite membrane for carbamazepine, ibuprofen, atenolol and amlodipine which are four different PPCPs is in this order: AML, ATE, CBZ and IBU, the trapping rate for AML with positive charges is 90.12%, and the trapping rate for PPCPs with positive charges is higher than trapping rates for PPCPs with positive charges and electric-neutral PPCPs. The method is simple, and low in cost. The prepared composite nanofiltration membrane has a pure water permeability coefficient of 25.37 L.m<-2>.h<-1>MPa<-1>, the molecular weight cut-off is 481 Da, and the composite nanofiltration membrane has good hydrophilicity and fouling resistance.