Transition-metal dichalcogenide bilayers: Switching materials for spintronic and valleytronic applications