fix
This commit is contained in:
522
html/write-review.html
Normal file
522
html/write-review.html
Normal file
@@ -0,0 +1,522 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="vi">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Viết đánh giá sản phẩm - EuroTile Worker</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link rel="stylesheet" href="assets/css/style.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="page-wrapper">
|
||||
<!-- Header -->
|
||||
<div class="header">
|
||||
<a href="product-detail-1.html" class="back-button">
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
</a>
|
||||
<h1 class="header-title">Viết đánh giá sản phẩm</h1>
|
||||
<div style="width: 40px;"></div>
|
||||
</div>
|
||||
|
||||
<div class="container" style="padding-bottom: 120px;">
|
||||
<!-- Product Card (Read-only) -->
|
||||
<div class="product-review-card">
|
||||
<img id="productImage"
|
||||
src="https://images.unsplash.com/photo-1615971677499-5467cbab01c0?w=100&h=100&fit=crop"
|
||||
alt="Product"
|
||||
class="product-review-image">
|
||||
<div class="product-review-info">
|
||||
<h3 id="productName" class="product-review-name">Gạch Eurotile MỘC LAM E03</h3>
|
||||
<p class="product-review-code">Mã: ET-ML-E03</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Review Form -->
|
||||
<form id="reviewForm" onsubmit="submitReview(event)">
|
||||
|
||||
<!-- Rating Section (Required) -->
|
||||
<div class="form-section">
|
||||
<h3 class="section-title required-field">Xếp hạng của bạn</h3>
|
||||
<p class="section-subtitle">Bấm vào ngôi sao để chọn đánh giá</p>
|
||||
|
||||
<div class="star-rating-selector" id="starRatingSelector">
|
||||
<button type="button" class="star-btn" data-rating="1" onclick="selectRating(1)">
|
||||
<i class="far fa-star"></i>
|
||||
</button>
|
||||
<button type="button" class="star-btn" data-rating="2" onclick="selectRating(2)">
|
||||
<i class="far fa-star"></i>
|
||||
</button>
|
||||
<button type="button" class="star-btn" data-rating="3" onclick="selectRating(3)">
|
||||
<i class="far fa-star"></i>
|
||||
</button>
|
||||
<button type="button" class="star-btn" data-rating="4" onclick="selectRating(4)">
|
||||
<i class="far fa-star"></i>
|
||||
</button>
|
||||
<button type="button" class="star-btn" data-rating="5" onclick="selectRating(5)">
|
||||
<i class="far fa-star"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="rating-label-container">
|
||||
<span id="ratingLabel" class="rating-label">Chưa chọn đánh giá</span>
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="ratingValue" name="rating" required>
|
||||
<div id="ratingError" class="error-message" style="display: none;">
|
||||
Vui lòng chọn số sao đánh giá
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Review Title (Optional) -->
|
||||
<!--<div class="form-section">
|
||||
<label for="reviewTitle" class="section-title">Tiêu đề đánh giá</label>
|
||||
<input type="text"
|
||||
id="reviewTitle"
|
||||
name="title"
|
||||
class="form-input"
|
||||
placeholder="VD: Sản phẩm chất lượng tốt"
|
||||
maxlength="100">
|
||||
<div class="input-hint">Không bắt buộc • Tối đa 100 ký tự</div>
|
||||
</div>-->
|
||||
|
||||
<!-- Review Content (Required) -->
|
||||
<div class="form-section">
|
||||
<label for="reviewContent" class="section-title required-field">Nội dung đánh giá</label>
|
||||
<textarea id="reviewContent"
|
||||
name="content"
|
||||
class="form-textarea"
|
||||
placeholder="Chia sẻ trải nghiệm của bạn về sản phẩm này..."
|
||||
rows="6"
|
||||
required
|
||||
minlength="20"
|
||||
maxlength="1000"></textarea>
|
||||
<div class="textarea-counter">
|
||||
<span id="charCount">0</span> / 1000 ký tự
|
||||
</div>
|
||||
<div id="contentError" class="error-message" style="display: none;">
|
||||
Nội dung đánh giá phải có ít nhất 20 ký tự
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Guidelines -->
|
||||
<div class="review-guidelines">
|
||||
<div class="guideline-header">
|
||||
<i class="fas fa-lightbulb"></i>
|
||||
<span>Gợi ý viết đánh giá tốt</span>
|
||||
</div>
|
||||
<ul class="guideline-list">
|
||||
<li>Chia sẻ trải nghiệm thực tế của bạn về sản phẩm</li>
|
||||
<li>Đề cập đến chất lượng, màu sắc, độ bền của sản phẩm</li>
|
||||
<li>Nêu rõ điểm tốt và điểm chưa tốt (nếu có)</li>
|
||||
<li>Tránh spam, nội dung không phù hợp hoặc vi phạm</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Submit Button -->
|
||||
<div class="fixed-bottom-action">
|
||||
<button type="submit" class="btn-submit-review" id="submitBtn">
|
||||
<i class="fas fa-paper-plane"></i>
|
||||
Gửi đánh giá
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--primary-blue: #005B9A;
|
||||
--star-gold: #ffc107;
|
||||
--star-selected: #ff9800;
|
||||
--text-dark: #333;
|
||||
--text-light: #666;
|
||||
--text-muted: #999;
|
||||
--border-color: #e0e0e0;
|
||||
--background-gray: #f8f9fa;
|
||||
--success-color: #28a745;
|
||||
--danger-color: #dc3545;
|
||||
--white: #ffffff;
|
||||
}
|
||||
|
||||
/* Product Review Card */
|
||||
.product-review-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 16px;
|
||||
background: var(--white);
|
||||
border: 2px solid var(--border-color);
|
||||
border-radius: 12px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.product-review-image {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
border-radius: 8px;
|
||||
object-fit: cover;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.product-review-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.product-review-name {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--text-dark);
|
||||
margin: 0 0 6px 0;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.product-review-code {
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Form Sections */
|
||||
.form-section {
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--text-dark);
|
||||
margin-bottom: 8px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.section-title.required-field::after {
|
||||
content: ' *';
|
||||
color: var(--danger-color);
|
||||
}
|
||||
|
||||
.section-subtitle {
|
||||
font-size: 14px;
|
||||
color: var(--text-light);
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
/* Star Rating Selector */
|
||||
.star-rating-selector {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
justify-content: center;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.star-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 8px;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.star-btn:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.star-btn:active {
|
||||
transform: scale(0.95);
|
||||
}
|
||||
|
||||
.star-btn i {
|
||||
font-size: 36px;
|
||||
color: var(--border-color);
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.star-btn:hover i {
|
||||
color: var(--star-gold);
|
||||
}
|
||||
|
||||
.star-btn.selected i {
|
||||
color: var(--star-selected);
|
||||
}
|
||||
|
||||
.star-btn.selected:hover i {
|
||||
color: var(--star-gold);
|
||||
}
|
||||
|
||||
/* Rating Label */
|
||||
.rating-label-container {
|
||||
text-align: center;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.rating-label {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--text-light);
|
||||
padding: 8px 20px;
|
||||
background: var(--background-gray);
|
||||
border-radius: 20px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.rating-label.selected {
|
||||
color: var(--star-selected);
|
||||
background: #fff3e0;
|
||||
}
|
||||
|
||||
/* Form Inputs */
|
||||
.form-input {
|
||||
width: 100%;
|
||||
padding: 14px 16px;
|
||||
border: 2px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
font-size: 15px;
|
||||
color: var(--text-dark);
|
||||
transition: border-color 0.3s ease;
|
||||
}
|
||||
|
||||
.form-input:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary-blue);
|
||||
}
|
||||
|
||||
.form-textarea {
|
||||
width: 100%;
|
||||
padding: 14px 16px;
|
||||
border: 2px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
font-size: 15px;
|
||||
color: var(--text-dark);
|
||||
resize: vertical;
|
||||
font-family: inherit;
|
||||
line-height: 1.6;
|
||||
transition: border-color 0.3s ease;
|
||||
}
|
||||
|
||||
.form-textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary-blue);
|
||||
}
|
||||
|
||||
/* Input Hints */
|
||||
.input-hint {
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.textarea-counter {
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
text-align: right;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
/* Error Messages */
|
||||
.error-message {
|
||||
font-size: 13px;
|
||||
color: var(--danger-color);
|
||||
margin-top: 6px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.error-message::before {
|
||||
content: '⚠';
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* Guidelines */
|
||||
.review-guidelines {
|
||||
padding: 16px;
|
||||
background: #f0f7ff;
|
||||
border-left: 4px solid var(--primary-blue);
|
||||
border-radius: 8px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.guideline-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--primary-blue);
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.guideline-header i {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.guideline-list {
|
||||
margin: 0;
|
||||
padding-left: 24px;
|
||||
}
|
||||
|
||||
.guideline-list li {
|
||||
font-size: 14px;
|
||||
color: var(--text-dark);
|
||||
line-height: 1.6;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
/* Fixed Bottom Action */
|
||||
.fixed-bottom-action {
|
||||
position: fixed;
|
||||
bottom: 70px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 16px;
|
||||
background: var(--white);
|
||||
border-top: 1px solid var(--border-color);
|
||||
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.btn-submit-review {
|
||||
width: 100%;
|
||||
background: var(--primary-blue);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 16px 24px;
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.btn-submit-review:hover {
|
||||
background: #004578;
|
||||
}
|
||||
|
||||
.btn-submit-review:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
.btn-submit-review:disabled {
|
||||
background: var(--border-color);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.btn-submit-review i {
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
let selectedRating = 0;
|
||||
const ratingLabels = {
|
||||
0: 'Chưa chọn đánh giá',
|
||||
1: 'Rất không hài lòng',
|
||||
2: 'Không hài lòng',
|
||||
3: 'Bình thường',
|
||||
4: 'Hài lòng',
|
||||
5: 'Rất hài lòng'
|
||||
};
|
||||
|
||||
// Load product info from localStorage
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const productData = localStorage.getItem('reviewProduct');
|
||||
if (productData) {
|
||||
const product = JSON.parse(productData);
|
||||
document.getElementById('productName').textContent = product.name;
|
||||
document.getElementById('productImage').src = product.image;
|
||||
}
|
||||
|
||||
// Character counter
|
||||
const textarea = document.getElementById('reviewContent');
|
||||
const charCount = document.getElementById('charCount');
|
||||
|
||||
textarea.addEventListener('input', function() {
|
||||
const count = this.value.length;
|
||||
charCount.textContent = count;
|
||||
|
||||
if (count < 20) {
|
||||
charCount.style.color = 'var(--danger-color)';
|
||||
} else {
|
||||
charCount.style.color = 'var(--text-muted)';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Star rating selection
|
||||
function selectRating(rating) {
|
||||
selectedRating = rating;
|
||||
document.getElementById('ratingValue').value = rating;
|
||||
document.getElementById('ratingError').style.display = 'none';
|
||||
|
||||
// Update star buttons
|
||||
const starButtons = document.querySelectorAll('.star-btn');
|
||||
starButtons.forEach((btn, index) => {
|
||||
const icon = btn.querySelector('i');
|
||||
if (index < rating) {
|
||||
btn.classList.add('selected');
|
||||
icon.classList.remove('far');
|
||||
icon.classList.add('fas');
|
||||
} else {
|
||||
btn.classList.remove('selected');
|
||||
icon.classList.remove('fas');
|
||||
icon.classList.add('far');
|
||||
}
|
||||
});
|
||||
|
||||
// Update rating label
|
||||
const ratingLabel = document.getElementById('ratingLabel');
|
||||
ratingLabel.textContent = ratingLabels[rating];
|
||||
ratingLabel.classList.add('selected');
|
||||
}
|
||||
|
||||
// Form submission
|
||||
function submitReview(event) {
|
||||
event.preventDefault();
|
||||
|
||||
// Validation
|
||||
let isValid = true;
|
||||
|
||||
// Check rating
|
||||
if (selectedRating === 0) {
|
||||
document.getElementById('ratingError').style.display = 'block';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// Check content length
|
||||
const content = document.getElementById('reviewContent').value;
|
||||
if (content.length < 20) {
|
||||
document.getElementById('contentError').style.display = 'block';
|
||||
isValid = false;
|
||||
} else {
|
||||
document.getElementById('contentError').style.display = 'none';
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Show loading state
|
||||
const submitBtn = document.getElementById('submitBtn');
|
||||
const originalText = submitBtn.innerHTML;
|
||||
submitBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Đang gửi...';
|
||||
submitBtn.disabled = true;
|
||||
|
||||
// Simulate API call
|
||||
setTimeout(() => {
|
||||
// Set flag for product-detail page
|
||||
localStorage.setItem('reviewJustSubmitted', 'true');
|
||||
|
||||
// Navigate to success page
|
||||
window.location.href = 'review-submitted.html';
|
||||
}, 1500);
|
||||
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user