我想把web3.0区块链技术应用在无人医院的AI医生上,帮我设计一个网站实现上述梦想设计一个网站,要求前后端都能生效响应 - Follow Up Deployment
Browse files- index.html +133 -14
index.html
CHANGED
|
@@ -6,7 +6,58 @@
|
|
| 6 |
<title>MediChain - Web3 Autonomous Hospital</title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
|
|
|
|
|
| 9 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
tailwind.config = {
|
| 11 |
theme: {
|
| 12 |
extend: {
|
|
@@ -109,9 +160,10 @@
|
|
| 109 |
</div>
|
| 110 |
</div>
|
| 111 |
<div class="hidden sm:ml-6 sm:flex sm:items-center">
|
| 112 |
-
<button class="bg-primary hover:bg-indigo-700 text-white px-4 py-2 rounded-md text-sm font-medium flex items-center">
|
| 113 |
-
<i class="fas fa-wallet mr-2"></i> Connect Wallet
|
| 114 |
</button>
|
|
|
|
| 115 |
</div>
|
| 116 |
<div class="-mr-2 flex items-center sm:hidden">
|
| 117 |
<button type="button" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-primary" aria-controls="mobile-menu" aria-expanded="false">
|
|
@@ -650,6 +702,41 @@
|
|
| 650 |
</div>
|
| 651 |
</div>
|
| 652 |
</footer>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 653 |
|
| 654 |
<script>
|
| 655 |
// Mobile menu toggle
|
|
@@ -686,18 +773,50 @@
|
|
| 686 |
});
|
| 687 |
|
| 688 |
// Connect Wallet button functionality
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 701 |
</script>
|
| 702 |
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=echo3700/https-huggingface-co-echo3700" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 703 |
</html>
|
|
|
|
| 6 |
<title>MediChain - Web3 Autonomous Hospital</title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/web3@1.5.2/dist/web3.min.js"></script>
|
| 10 |
+
<script src="https://cdn.ethers.io/lib/ethers-5.2.umd.min.js"></script>
|
| 11 |
<script>
|
| 12 |
+
// Smart Contract ABI (simplified example)
|
| 13 |
+
const mediChainABI = [
|
| 14 |
+
{
|
| 15 |
+
"inputs": [],
|
| 16 |
+
"name": "consultAI",
|
| 17 |
+
"outputs": [{"internalType": "string", "name": "", "type": "string"}],
|
| 18 |
+
"stateMutability": "payable",
|
| 19 |
+
"type": "function"
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
"inputs": [],
|
| 23 |
+
"name": "getMedicalRecord",
|
| 24 |
+
"outputs": [{"internalType": "string", "name": "", "type": "string"}],
|
| 25 |
+
"stateMutability": "view",
|
| 26 |
+
"type": "function"
|
| 27 |
+
}
|
| 28 |
+
];
|
| 29 |
+
const contractAddress = "0x1234..."; // Your deployed contract address
|
| 30 |
+
|
| 31 |
+
let web3;
|
| 32 |
+
let contract;
|
| 33 |
+
let accounts = [];
|
| 34 |
+
|
| 35 |
+
// Initialize Web3
|
| 36 |
+
async function initWeb3() {
|
| 37 |
+
if (window.ethereum) {
|
| 38 |
+
web3 = new Web3(window.ethereum);
|
| 39 |
+
try {
|
| 40 |
+
accounts = await window.ethereum.request({ method: 'eth_requestAccounts' });
|
| 41 |
+
const provider = new ethers.providers.Web3Provider(window.ethereum);
|
| 42 |
+
const signer = provider.getSigner();
|
| 43 |
+
contract = new ethers.Contract(contractAddress, mediChainABI, signer);
|
| 44 |
+
updateUI();
|
| 45 |
+
} catch (error) {
|
| 46 |
+
console.error("User denied account access");
|
| 47 |
+
}
|
| 48 |
+
} else {
|
| 49 |
+
alert("Please install MetaMask!");
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
function updateUI() {
|
| 54 |
+
document.querySelectorAll('.wallet-address').forEach(el => {
|
| 55 |
+
el.textContent = `${accounts[0].slice(0,6)}...${accounts[0].slice(-4)}`;
|
| 56 |
+
});
|
| 57 |
+
document.getElementById('connectWalletBtn').textContent = "Connected";
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
// Tailwind config
|
| 61 |
tailwind.config = {
|
| 62 |
theme: {
|
| 63 |
extend: {
|
|
|
|
| 160 |
</div>
|
| 161 |
</div>
|
| 162 |
<div class="hidden sm:ml-6 sm:flex sm:items-center">
|
| 163 |
+
<button id="connectWalletBtn" class="bg-primary hover:bg-indigo-700 text-white px-4 py-2 rounded-md text-sm font-medium flex items-center">
|
| 164 |
+
<i class="fas fa-wallet mr-2"></i> <span>Connect Wallet</span>
|
| 165 |
</button>
|
| 166 |
+
<div class="wallet-address ml-2 hidden text-sm text-gray-700"></div>
|
| 167 |
</div>
|
| 168 |
<div class="-mr-2 flex items-center sm:hidden">
|
| 169 |
<button type="button" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-primary" aria-controls="mobile-menu" aria-expanded="false">
|
|
|
|
| 702 |
</div>
|
| 703 |
</div>
|
| 704 |
</footer>
|
| 705 |
+
|
| 706 |
+
<!-- Consultation Modal -->
|
| 707 |
+
<div id="consultModal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50">
|
| 708 |
+
<div class="bg-white rounded-lg p-6 max-w-md w-full">
|
| 709 |
+
<div class="flex justify-between items-center mb-4">
|
| 710 |
+
<h3 class="text-xl font-bold">AI Doctor Consultation</h3>
|
| 711 |
+
<button onclick="document.getElementById('consultModal').classList.add('hidden')" class="text-gray-500 hover:text-gray-700">
|
| 712 |
+
<i class="fas fa-times"></i>
|
| 713 |
+
</button>
|
| 714 |
+
</div>
|
| 715 |
+
<div class="mb-4">
|
| 716 |
+
<label class="block text-gray-700 mb-2">Describe your symptoms:</label>
|
| 717 |
+
<textarea id="symptomsInput" class="w-full px-3 py-2 border rounded-lg" rows="4"></textarea>
|
| 718 |
+
</div>
|
| 719 |
+
<button onclick="consultAI()" class="w-full bg-primary hover:bg-indigo-700 text-white py-2 rounded-lg">
|
| 720 |
+
<i class="fas fa-robot mr-2"></i> Get Diagnosis (0.1 ETH)
|
| 721 |
+
</button>
|
| 722 |
+
</div>
|
| 723 |
+
</div>
|
| 724 |
+
|
| 725 |
+
<!-- Result Modal -->
|
| 726 |
+
<div id="resultModal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50">
|
| 727 |
+
<div class="bg-white rounded-lg p-6 max-w-md w-full">
|
| 728 |
+
<div class="flex justify-between items-center mb-4">
|
| 729 |
+
<h3 class="text-xl font-bold">AI Diagnosis</h3>
|
| 730 |
+
<button onclick="document.getElementById('resultModal').classList.add('hidden')" class="text-gray-500 hover:text-gray-700">
|
| 731 |
+
<i class="fas fa-times"></i>
|
| 732 |
+
</button>
|
| 733 |
+
</div>
|
| 734 |
+
<div id="diagnosisResult" class="mb-4 p-4 bg-gray-100 rounded-lg"></div>
|
| 735 |
+
<button onclick="document.getElementById('resultModal').classList.add('hidden')" class="w-full bg-primary hover:bg-indigo-700 text-white py-2 rounded-lg">
|
| 736 |
+
Close
|
| 737 |
+
</button>
|
| 738 |
+
</div>
|
| 739 |
+
</div>
|
| 740 |
|
| 741 |
<script>
|
| 742 |
// Mobile menu toggle
|
|
|
|
| 773 |
});
|
| 774 |
|
| 775 |
// Connect Wallet button functionality
|
| 776 |
+
document.getElementById('connectWalletBtn').addEventListener('click', initWeb3);
|
| 777 |
+
|
| 778 |
+
// AI Consultation Function
|
| 779 |
+
async function consultAI() {
|
| 780 |
+
if (!accounts.length) {
|
| 781 |
+
alert("Please connect your wallet first");
|
| 782 |
+
return;
|
| 783 |
+
}
|
| 784 |
+
|
| 785 |
+
const symptoms = document.getElementById('symptomsInput').value;
|
| 786 |
+
if (!symptoms) {
|
| 787 |
+
alert("Please describe your symptoms");
|
| 788 |
+
return;
|
| 789 |
+
}
|
| 790 |
+
|
| 791 |
+
try {
|
| 792 |
+
// In a real implementation, you would call your smart contract
|
| 793 |
+
const result = await contract.consultAI({
|
| 794 |
+
value: web3.utils.toWei("0.1", "ether") // Example consultation fee
|
| 795 |
+
});
|
| 796 |
+
|
| 797 |
+
document.getElementById('diagnosisResult').textContent = result;
|
| 798 |
+
document.getElementById('resultModal').classList.remove('hidden');
|
| 799 |
+
} catch (error) {
|
| 800 |
+
console.error("Consultation failed:", error);
|
| 801 |
+
alert("Consultation failed. Please try again.");
|
| 802 |
+
}
|
| 803 |
+
}
|
| 804 |
+
|
| 805 |
+
// Medical Records Access
|
| 806 |
+
async function getMedicalRecords() {
|
| 807 |
+
if (!accounts.length) {
|
| 808 |
+
alert("Please connect your wallet first");
|
| 809 |
+
return;
|
| 810 |
+
}
|
| 811 |
+
|
| 812 |
+
try {
|
| 813 |
+
const records = await contract.getMedicalRecord();
|
| 814 |
+
document.getElementById('medicalRecords').textContent = records;
|
| 815 |
+
document.getElementById('recordsModal').classList.remove('hidden');
|
| 816 |
+
} catch (error) {
|
| 817 |
+
console.error("Failed to fetch records:", error);
|
| 818 |
+
}
|
| 819 |
+
}
|
| 820 |
</script>
|
| 821 |
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=echo3700/https-huggingface-co-echo3700" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 822 |
</html>
|