Hi T2370,
I'll give you some options and my findings.
This picture of yours tells a story. The truck's 12-volt battery charge hot wire (black) terminal and the 12-volt truck ground wire (white) terminal show that those two pins got hot and started melting the plastic plug. Also, you get an A+ on your pics, clear and detailed. We can see some things you may not know to look for, yet anyway.
Here is the pinout of the RV industry plug. The truck charge wire is the pin to the left of the plug key when facing it (10:30 position). And the ground is at the bottom when facing it to the right of center (4:30 position)
You can tell which pin in the plug powers which by the location in relation to the key on the top.
You are correct, dirty and loose connections create heat in the connection, and the battery charge wires are live all the time the camper is plugged in, as long as the truck charge fuse in the camper is not blown.
For a plug replacement, I am aware of two brands that offer replacements.
Hopkins makes one, Part number 48505 7-blade trailer side plug. You can search where to buy it, here is Amazon,
Amazon.com
Curt also makes one, looks about the same as the Hopkins, Curt 58141 Trailer side 7 pin RV plug. Again, many places sell them, Amazon was faster to link.
Amazon.com
Now to the good and bad of the replacement plug. Either brand, the wire cable connection is not waterproof; it is water-resistant. As time goes on, corrosion in the screw on connections can and will start if the plug is often exposed to wet weather.
The Hopkins brand that came on my flatbed trailer did not fit my truck receptacle well. My Sunline camper Bargman brand 7-wire cable and plug works well and still does in the truck receptacle. Yet, the Hopkins screw terminal plug would wiggle, and I could lose a connection on some pins in a turn, as the fit to the receptacle was looser than that of the Bargman-branded one.
If you are going with a replacement plug, it is faster to do the repair to get you going for not a lot of money. I'm not sure how the Curt brand fits in the truck receptacle. As for long life, either brand may only last you 3 to 5 years before issues with water corrosion show up if the camper is outside in the elements all the time due to the lack of a waterproof cable connection versus an all-molded plug.
Next comes the all-molded cable connection plug. Here are some things to make sure you get the correct cable and molded plug. There is the RV color standard for wire colors, and there are the Trailer industry colors for wire color, and they do not 100% match. They will both work in any truck plug, but the wire colors differ between the two industries. I have no idea why, but they are.
You want to make sure you get the RV color standard.
Wire thickness: Be aware of this: knock-off brands often downsize the wire gauge. At a minimum, you want 10 AWG wire on the truck charge wire (black) and ground (white). On the brake blue wire, 12 awg. On the rest of the clearance, marker lights, stop, turn, and tail lights are 14 awg.
Next are the plug blades. It seems the replacement plug prongs differ from the all-molded plugs. I'm not sure why, but look for it.
NOTE: These are 8 ft cord sets. Make sure that the length will work on your camper. They do make 10 ft. if needed
The Hopkins replacement cord and plug have a single-blade plug like this one on Etrailer. I'm not a fan of this single prng plug personally.
https://www.etrailer.com/Trailer-Wiring/Hopkins/H20046.html
There is the Bargmen brand that looks like your old one; there are 2 prongs on each pin. I like this better as I feel it will grip the truck receptacle better.
https://www.etrailer.com/Trailer-Wiring/Bargman/54006-058.html
Personally, I would go with the Bargmen for the quality I have always had with Bargmen and the way the prongs are made.
The all-molded plug does not have the moisture corrosion issue associated with the replacement plug in the long term. The all molded also costs a lot more, but it will last longer, trouble-free.
Now to this picture,
There are two 30-amp fuses. One is to protect the wiring between the power converter and the battery, and the other is to protect the truck charge line and the battery. It is hard to see with the fuses and heavy red wires bundled up. If you unbundle them, I may be able to see more.
The connection from the brown wire to the black wire with the tan wire nut is unusual. Unless this black wire is a different shade of brown close up, then all is good.
I do not see any blue wires in that box, unless they are buried and we cannot see them. Blue is the brakes. Sunline may have connected the brakes to the 7-wire cable under the camper, not in the junction box. The emergency breakaway switch also needs to get live 12 VDC + power all the time, no fuses. That power feed might be a black wire tied into the thicker red cluster. Brown is a flashing right turn bulb filament along with a steady right stop light.
I hope this helps.
John