The invention relates to a box type packaging mechanism, and particularly relates to a box type packaging mechanism which can bidirectionally turn on and turn off a power source and has a photoelectric sensing function. The box type packaging mechanism disclosed by the invention consists of two modules, namely, a base and a top box, comprising thirteen parts, namely, a box base, a connecting strip, a hoop, a light adjusting cover, set screws, a fastening washer, a press block, a centrally-arranged screw, a centrally-arranged elastic plate, a side screw, a side elastic plate, a box cover, a shifting block and the like. A packaging closing device for electronic component circuits has the characteristics of being capable of bidirectionally turning on and turning off a power supply, retaining external elements, adjusting the lightness of light, and being wide in adaptability. The packaging mechanism is widely applied in working environments, such as plains, mountainous areas, hills, islands, high altitude and the like, and accords with the use requirements of electric industry, mechanical industry, chemical industry and the like, and has the advantages of easiness in operation and manufacturing, beautiful appearance of formed products, solid and durable structure, use convenience, wide marketing space, and high application value and additional economic value.