The dipole moment function and spectroscopic constants for the CH+ and CD+ ion-molecules