File manager - Edit - /home/webapp69.cm.in.th/u69319090038/Shop/account.php
Back
<?php require_once __DIR__ . '/config/config.php'; ?> <!DOCTYPE html> <html lang="th"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>บัญชีของฉัน — Sarin Shop</title> <link rel="stylesheet" href="./public/css/style.css"> </head> <body> <nav class="navbar"> <a href="./index.php" class="nav-logo"><span>🛒</span> Sarin Shop</a> <div class="nav-actions" style="margin-left:auto;"> <a href="./index.php" class="nav-icon-btn">🏠 หน้าหลัก</a> <button id="logout-btn" class="btn btn-sm" style="background:rgba(255,255,255,.2);color:#fff;">ออกจากระบบ</button> </div> </nav> <main class="page-container"> <div class="account-layout"> <!-- Sidebar --> <aside> <div class="account-avatar-section"> <img id="profile-avatar" src="" alt="Avatar" class="account-avatar"> <div class="account-username" id="profile-username">กำลังโหลด...</div> <div class="account-role"> <span id="profile-role-badge" class="role-badge role-buyer">buyer</span> </div> </div> <button class="sidebar-link active" id="menu-profile" onclick="showSection('profile')"> <span class="icon">👤</span> ข้อมูลส่วนตัว </button> <button class="sidebar-link" id="menu-orders" onclick="showSection('orders')"> <span class="icon">📦</span> คำสั่งซื้อของฉัน </button> <button class="sidebar-link" id="menu-security" onclick="showSection('security')"> <span class="icon">🔒</span> ความปลอดภัย </button> <button class="sidebar-link" id="menu-seller" onclick="showSection('seller')"> <span class="icon">🏪</span> สมัครเป็นผู้ขาย </button> </aside> <!-- Content --> <div> <!-- Profile Section --> <div id="section-profile" class="card"> <h2 style="font-size:1.1rem; font-weight:700; margin-bottom:1.5rem;">ข้อมูลส่วนตัว</h2> <div style="display:grid; gap:1.25rem;"> <div class="form-group"> <label class="form-label">ชื่อผู้ใช้</label> <input type="text" class="form-input" id="edit-username" readonly style="background:var(--bg); cursor:not-allowed;"> </div> <div class="form-group"> <label class="form-label">อีเมล</label> <div class="input-wrap"> <input type="email" class="form-input has-icon" id="edit-email" readonly style="background:var(--bg); cursor:not-allowed;"> <span class="input-icon" id="email-verified-icon"></span> </div> </div> <div class="form-group"> <label class="form-label">เบอร์โทรศัพท์</label> <div class="input-wrap"> <input type="tel" class="form-input has-icon" id="edit-phone" placeholder="ยังไม่ได้เพิ่มเบอร์"> <span class="input-icon" id="phone-verified-icon"></span> </div> </div> <div class="form-group"> <label class="form-label">ชื่อ-นามสกุล</label> <input type="text" class="form-input" id="edit-fullname" placeholder="กรอกชื่อ-นามสกุล"> </div> <div class="form-group"> <label class="form-label">สมาชิกตั้งแต่</label> <input type="text" class="form-input" id="edit-created" readonly style="background:var(--bg);"> </div> </div> <button class="btn btn-primary mt-3" id="save-profile-btn">💾 บันทึกข้อมูล</button> </div> <!-- Orders Section --> <div id="section-orders" class="card" style="display:none;"> <h2 style="font-size:1.1rem; font-weight:700; margin-bottom:1rem;">คำสั่งซื้อของฉัน</h2> <div class="empty-state"> <div class="empty-icon">📦</div> <div class="empty-title">ยังไม่มีคำสั่งซื้อ</div> <div class="empty-desc">เริ่มช้อปปิ้งและสั่งซื้อสินค้าชิ้นแรกของคุณ!</div> <a href="./index.php" class="btn btn-primary mt-3">ช้อปเลย</a> </div> </div> <!-- Security Section --> <div id="section-security" class="card" style="display:none;"> <h2 style="font-size:1.1rem; font-weight:700; margin-bottom:1.5rem;">🔒 ความปลอดภัย</h2> <div style="display:flex; flex-direction:column; gap:1rem;"> <div style="display:flex; align-items:center; justify-content:space-between; padding:1rem; background:var(--bg); border-radius:var(--r-md);"> <div> <div style="font-weight:600; font-size:.95rem;">🔑 รหัสผ่าน</div> <div style="font-size:.8rem; color:var(--text-muted);">อัปเดตรหัสผ่านของคุณเป็นประจำ</div> </div> <button class="btn btn-outline btn-sm">เปลี่ยนรหัสผ่าน</button> </div> <div style="display:flex; align-items:center; justify-content:space-between; padding:1rem; background:var(--bg); border-radius:var(--r-md);"> <div> <div style="font-weight:600; font-size:.95rem;">📱 การยืนยัน 2 ขั้นตอน</div> <div style="font-size:.8rem; color:var(--text-muted);">เพิ่มความปลอดภัยให้บัญชีด้วย OTP</div> </div> <button class="btn btn-primary btn-sm">เปิดใช้งาน</button> </div> </div> </div> <!-- Seller Upgrade Section --> <div id="section-seller" style="display:none;"> <div id="seller-apply-form" class="upgrade-card"> <div class="upgrade-icon">🏪</div> <h2 class="upgrade-title">เปิดร้านค้าออนไลน์ของคุณ</h2> <p class="upgrade-desc">เข้าร่วมกับผู้ขายกว่า 2 ล้านรายบน Sarin Shop<br>เริ่มขายสินค้าได้ทันที ไม่มีค่าใช้จ่าย!</p> <div class="upgrade-perks"> <div class="upgrade-perk"><span class="upgrade-perk-icon">✅</span> ฟรีค่าธรรมเนียมการเปิดร้าน</div> <div class="upgrade-perk"><span class="upgrade-perk-icon">✅</span> เข้าถึงผู้ซื้อกว่า 50 ล้านคน</div> <div class="upgrade-perk"><span class="upgrade-perk-icon">✅</span> ระบบจัดการสินค้าที่ใช้งานง่าย</div> <div class="upgrade-perk"><span class="upgrade-perk-icon">✅</span> รายงานยอดขายแบบ Real-time</div> </div> <div class="form-group mb-2" style="text-align:left;"> <label class="form-label" for="shop-name">ชื่อร้านค้า <span class="req">*</span></label> <input type="text" id="shop-name" class="form-input" placeholder="ตั้งชื่อร้านของคุณ"> </div> <div class="form-group mb-2" style="text-align:left;"> <label class="form-label" for="shop-desc">คำอธิบายร้านค้า</label> <textarea id="shop-desc" class="form-input" rows="3" placeholder="บอกเล่าเกี่ยวกับร้านค้าของคุณ"></textarea> </div> <button class="btn btn-primary btn-block btn-lg" id="apply-seller-btn"> 🚀 สมัครเป็นผู้ขายเลย! </button> </div> <div id="seller-already" class="card" style="display:none; text-align:center; padding:3rem;"> <div style="font-size:3rem; margin-bottom:1rem;">🏪</div> <h2 style="font-weight:700; color:var(--text-primary); margin-bottom:.5rem;">คุณเป็นผู้ขายแล้ว!</h2> <p style="color:var(--text-secondary); margin-bottom:1.5rem;">ไปยังศูนย์ผู้ขายเพื่อจัดการร้านค้าของคุณ</p> <a href="./seller-center.php" class="btn btn-primary">ไปยังศูนย์ผู้ขาย →</a> </div> </div> </div> </div> </main> <script type="module"> import { requireAuth, api, Auth } from './public/js/api.js'; import { showToast, setButtonLoading, renderNavUser } from './public/js/ui.js'; (async () => { const user = await requireAuth(); if (!user) return; const profile = await api.getProfile(); if (!profile || !profile.ok) { showToast('ไม่สามารถโหลดข้อมูลได้', 'error'); return; } const u = profile.data.user; document.getElementById('profile-avatar').src = u.avatar_url || 'https://ui-avatars.com/api/?name=' + u.username + '&background=ee4d2d&color=fff'; document.getElementById('profile-username').textContent = u.username; document.getElementById('profile-role-badge').textContent = u.role; document.getElementById('profile-role-badge').className = 'role-badge role-' + u.role; document.getElementById('edit-username').value = u.username; document.getElementById('edit-email').value = u.email; document.getElementById('edit-phone').value = u.phone || ''; document.getElementById('edit-fullname').value = u.full_name || ''; document.getElementById('edit-created').value = new Date(u.created_at).toLocaleDateString('th-TH', { year:'numeric', month:'long', day:'numeric' }); document.getElementById('email-verified-icon').textContent = u.is_email_verified ? '✅' : '❌'; document.getElementById('phone-verified-icon').textContent = u.phone ? (u.is_phone_verified ? '✅' : '❌') : ''; if (u.role === 'seller' || u.role === 'admin') { document.getElementById('seller-apply-form').style.display = 'none'; document.getElementById('seller-already').style.display = 'block'; } window.showSection = function(name) { ['profile','orders','security','seller'].forEach(function(s) { document.getElementById('section-' + s).style.display = s === name ? (s === 'seller' ? '' : 'block') : 'none'; document.getElementById('menu-' + s).classList.toggle('active', s === name); }); }; const params = new URLSearchParams(window.location.search); if (params.get('upgrade') === '1') window.showSection('seller'); document.getElementById('save-profile-btn').addEventListener('click', function() { showToast('บันทึกข้อมูลสำเร็จ!', 'success'); }); const applyBtn = document.getElementById('apply-seller-btn'); applyBtn.addEventListener('click', async function() { const shopName = document.getElementById('shop-name').value.trim(); const shopDesc = document.getElementById('shop-desc').value.trim(); if (!shopName) { showToast('กรุณากรอกชื่อร้านค้า', 'warning'); return; } setButtonLoading(applyBtn, true, 'กำลังสมัคร...'); const result = await api.applySeller({ shop_name: shopName, shop_desc: shopDesc }); setButtonLoading(applyBtn, false); if (!result || !result.ok) { showToast((result && result.data && result.data.message) || 'สมัครไม่สำเร็จ', 'error'); return; } Auth.setToken(result.data.accessToken); showToast('ยินดีด้วย! คุณเป็นผู้ขายแล้ว 🎉', 'success'); setTimeout(function() { window.location.href = './seller-center.php'; }, 1500); }); document.getElementById('logout-btn').addEventListener('click', async function() { await api.logout(); Auth.logout(); showToast('ออกจากระบบแล้ว', 'info'); setTimeout(function() { window.location.href = './auth.php'; }, 800); }); })(); </script> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.22 |
proxy
|
phpinfo
|
Settings