you start always with the position vector to the masses .

**Case I**

$$\vec P_m=\begin{bmatrix}
  X \\
  Y \\
\end{bmatrix}=\left[ \begin {array}{c}  \left( l+x \right) \sin \left( \phi
 \right) \\  - \left( l+x \right) \cos \left( \phi
 \right) \end {array} \right] 
$$ 
the generalized coordinates are $~x(t)~,\phi(t)~$

from here the velocity
$$v^2=\dot X^2+\dot Y^2 $$
and the kinetic energy 
$$T=\frac m2\,v^2+\frac k2\,(l+x)^2$$

**Case II**

Position to $~m_1$

$$\vec P_1=\begin{bmatrix}
  X_1 \\
  Y_1 \\
\end{bmatrix}=\left[ \begin {array}{c} r\sin \left( \phi_{{1}} \right) 
\\ r\cos \left( \phi_{{1}} \right) \end {array}
 \right] 
$$

Position to $~m_2$
$$\vec P_2=\begin{bmatrix}
  X_2 \\
  Y_2 \\
\end{bmatrix}=2\,\vec P_1+\left[ \begin {array}{c} r\sin \left( \phi_{{2}} \right) 
\\ r\cos \left( \phi_{{2}} \right) \end {array}
 \right] 
$$

the generalized coordinates are $~\phi_1(t)~,\phi_2(t)~$

thus the velocities are

$$v_1^2=\dot X_1^2+\dot Y_1^2 \\
v_2^2=\dot X_2^2+\dot Y_2^2$$

and the kinetic energy 

$$T=\frac m2\,(v_1^2+v_2^2)$$