A compound having a chemical structure of formula I, wherein n is 0 or 1, X is N or C-R1, R1 is H or Cl, R2 and R3 are independently H, a halogen or an alkyl group, Ar is a substituted or unsubstituted phenylene or naphthylene group, with the substituted or unsubstituted phenylene group being A or B, and the naphthylene group being C, R4 is H, a halogen or an alkyl group, R5 is H, a halogen, an alkyl group, an alkoxyl group or a hydroxyl group, R6 is H or a hydroxyl group, and R7 is a substituted or unsubstituted aryl group. The compound has SHP-1 agonist activity, and can be used to treat cancer.