commit
This commit is contained in:
62
figma_html_page/js/profile.js
Normal file
62
figma_html_page/js/profile.js
Normal file
@@ -0,0 +1,62 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
loadUserInfo();
|
||||
});
|
||||
|
||||
function loadUserInfo() {
|
||||
const isLoggedIn = localStorage.getItem('isLoggedIn');
|
||||
const userName = localStorage.getItem('userName');
|
||||
const userCompany = localStorage.getItem('userCompany');
|
||||
const isBound = localStorage.getItem('isBound');
|
||||
|
||||
const userAvatar = document.getElementById('userAvatar');
|
||||
const userNameEl = document.getElementById('userName');
|
||||
const accountStatus = document.getElementById('accountStatus');
|
||||
const emptyRecords = document.getElementById('emptyRecords');
|
||||
const recordsGrid = document.getElementById('recordsGrid');
|
||||
|
||||
if (isLoggedIn && userName) {
|
||||
userAvatar.innerHTML = '<img src="https://img.alicdn.com/imgextra/i4/O1CN01Z5paLz1O0zuCC7osS_!!6000000001644-55-tps-83-82.svg" alt="">';
|
||||
|
||||
const userInfo = document.getElementById('userInfo');
|
||||
userInfo.innerHTML = `
|
||||
<div class="avatar" id="userAvatar">
|
||||
<img src="https://img.alicdn.com/imgextra/i4/O1CN01Z5paLz1O0zuCC7osS_!!6000000001644-55-tps-83-82.svg" alt="">
|
||||
</div>
|
||||
<div>
|
||||
<div class="user-name">${userName}</div>
|
||||
<div class="user-company">${userCompany || ''}</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
if (isBound) {
|
||||
accountStatus.textContent = userName;
|
||||
accountStatus.style.color = '#333';
|
||||
emptyRecords.style.display = 'none';
|
||||
recordsGrid.style.display = 'grid';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleAccountClick() {
|
||||
const isBound = localStorage.getItem('isBound');
|
||||
|
||||
if (isBound) {
|
||||
document.getElementById('unbindModal').classList.add('active');
|
||||
} else {
|
||||
window.location.href = 'bind-account.html';
|
||||
}
|
||||
}
|
||||
|
||||
function closeUnbindModal() {
|
||||
document.getElementById('unbindModal').classList.remove('active');
|
||||
}
|
||||
|
||||
function confirmUnbind() {
|
||||
localStorage.removeItem('isBound');
|
||||
closeUnbindModal();
|
||||
|
||||
document.getElementById('accountStatus').textContent = '未绑定';
|
||||
document.getElementById('accountStatus').style.color = '#999';
|
||||
document.getElementById('emptyRecords').style.display = 'flex';
|
||||
document.getElementById('recordsGrid').style.display = 'none';
|
||||
}
|
||||
Reference in New Issue
Block a user