A method for controlling a locker based on a delivery message, comprising: obtaining, by an electronic device, a delivery message of a first package that is sent by a server, wherein the delivery message comprises pickup information of the first package and location information of a locker in which the first package is placed, and the pickup information is used to open a pickup box in which the first package is placed in the locker; determining, by the electronic device, a first area based on the location information, wherein the locker is located in the first area; displaying, by the electronic device, an enabled pickup function item in response to detecting that that the electronic device enters the first area; and sending, by the electronic device, a locker opening request to the server when it is detected that a user triggers the pickup function item, wherein the locker opening request comprises the pickup information of the first package, and the pickup information is used to open the pickup box in which the first package is placed in the locker, characterized in that, after the obtaining, by an electronic device, the delivery message of a first package that is sent by a server, the method further comprises: determining, by the electronic device, a range of a second area based on the location information, wherein the locker is located in the second area, the second area comprises the first area, or the second area is an area in a third area other than the first area, and the third area comprises the first area; and displaying, by the electronic device, a pickup reminder in response to detecting that the electronic device enters the second area, wherein the pickup reminder is used to prompt the user to pick up the first package. obtaining, by an electronic device, a delivery message of a first package that is sent by a server, wherein the delivery message comprises pickup information of the first package and location information of a locker in which the first package is placed, and the pickup information is used to open a pickup box in which the first package is placed in the locker; determining, by the electronic device, a first area based on the location information, wherein the locker is located in the first area; displaying, by the electronic device, an enabled pickup function item in response to detecting that that the electronic device enters the first area; and sending, by the electronic device, a locker opening request to the server when it is detected that a user triggers the pickup function item, wherein the locker opening request comprises the pickup information of the first package, and the pickup information is used to open the pickup box in which the first package is placed in the locker, characterized in that, after the obtaining, by an electronic device, the delivery message of a first package that is sent by a server, the method further comprises: determining, by the electronic device, a range of a second area based on the location information, wherein the locker is located in the second area, the second area comprises the first area, or the second area is an area in a third area other than the first area, and the third area comprises the first area; and displaying, by the electronic device, a pickup reminder in response to detecting that the electronic device enters the second area, wherein the pickup reminder is used to prompt the user to pick up the first package. determining, by the electronic device, a range of a second area based on the location information, wherein the locker is located in the second area, the second area comprises the first area, or the second area is an area in a third area other than the first area, and the third area comprises the first area; and displaying, by the electronic device, a pickup reminder in response to detecting that the electronic device enters the second area, wherein the pickup reminder is used to prompt the user to pick up the first package.