Unmanned Aerial Vehicle (UAV) Ad-Hoc Networks (UANET) enable collaborative work among UAVs for versatile task execution, but they face security challenges due to physical vulnerabilities, software issues, and dynamic wireless networks. This paper proposes a secure collaborative computing framework based on blockchain technology. Specifically, we first design a lightweight blockchain scheme suitable for UANET and present an improved Practical Byzantine Fault Tolerance (PBFT) consensus algorithm based on trust evaluation, aiming to reduce consensus overhead and establish trust relationships among UAVs. Furthermore, we devise a smart contract-based UAV task allocation strategy that considers both task execution efficiency and offloading security. This strategy enables UAVs to make optimal task-offloading decisions and facilitates collaborative computing according to smart contract rules. Simulation results demonstrate that our proposed consensus algorithm reduces average consensus latency by 47% and message count by 76% compared to PBFT-based algorithms. Additionally, the task allocation strategy decreases task costs by 48% compared to local computing strategies, achieving efficient and secure collaboration among UAVs in UANET. The real-world experiments with a UAV swarm further validate the efficiency and security of our framework, confirming its practical applicability in UANET.