dm-design/商家端APP/注册/自主经营者初始化店铺.html

870 lines
29 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>创建店铺</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
background-color: #f5f5f5;
}
.header {
background-color: #fff;
padding: 16px;
border-bottom: 1px solid #e5e5e5;
}
.header h1 {
font-size: 18px;
font-weight: 500;
color: #333;
}
.section {
background-color: #fff;
margin-top: 10px;
padding: 16px;
}
.section-title {
font-size: 16px;
font-weight: 500;
color: #333;
margin-bottom: 16px;
padding-bottom: 8px;
border-bottom: 2px solid #4CAF50;
}
.form-item {
margin-bottom: 20px;
}
.form-label {
display: block;
font-size: 14px;
color: #666;
margin-bottom: 8px;
}
.form-label .required {
color: #f44336;
margin-right: 4px;
}
.form-input {
width: 100%;
padding: 12px;
font-size: 15px;
border: 1px solid #ddd;
border-radius: 4px;
background-color: #fff;
-webkit-appearance: none;
}
.form-input:focus {
outline: none;
border-color: #4CAF50;
}
.form-input::placeholder {
color: #bbb;
}
select.form-input {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 12px center;
padding-right: 36px;
}
.image-upload {
width: 120px;
height: 120px;
border: 1px dashed #ddd;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
background-color: #fafafa;
cursor: pointer;
position: relative;
}
.image-upload-large {
width: 100%;
height: 160px;
}
.image-upload svg {
width: 40px;
height: 40px;
color: #bbb;
}
.image-upload input {
position: absolute;
width: 100%;
height: 100%;
opacity: 0;
cursor: pointer;
}
.image-preview {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 4px;
}
.image-upload-container {
display: flex;
gap: 10px;
flex-wrap: wrap;
}
.switch-container {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 0;
}
.switch-group {
display: flex;
align-items: center;
justify-content: space-between;
}
.switch-labels {
display: flex;
gap: 15px;
}
.switch {
position: relative;
display: inline-block;
width: 50px;
height: 28px;
flex-shrink: 0;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #dcdfe6;
transition: .3s;
border-radius: 28px;
}
.slider:before {
position: absolute;
content: "";
height: 22px;
width: 22px;
left: 3px;
bottom: 3px;
background-color: white;
transition: .3s;
border-radius: 50%;
}
input:checked + .slider {
background-color: #4CAF50;
}
input:checked + .slider:before {
transform: translateX(22px);
}
.switch-label {
color: #606266;
font-size: 14px;
}
.switch-label.active {
color: #4CAF50;
font-weight: 500;
}
.time-input-group {
display: flex;
align-items: center;
gap: 10px;
}
.time-input {
flex: 1;
padding: 12px;
font-size: 15px;
border: 1px solid #ddd;
border-radius: 4px;
}
.checkbox-group {
display: flex;
gap: 20px;
margin-bottom: 12px;
}
.checkbox-item {
display: flex;
align-items: center;
gap: 6px;
}
.checkbox-item input[type="checkbox"] {
width: 18px;
height: 18px;
cursor: pointer;
}
.radio-group {
display: flex;
gap: 20px;
margin-top: 12px;
}
.radio-item {
display: flex;
align-items: center;
gap: 6px;
}
.radio-item input[type="radio"] {
width: 18px;
height: 18px;
cursor: pointer;
}
.time-range {
display: flex;
align-items: center;
gap: 10px;
margin-top: 12px;
}
.time-range input {
flex: 1;
}
.submit-btn {
padding: 16px;
background-color: #fff;
border-top: 1px solid #e5e5e5;
margin-top: 10px;
}
.submit-btn button {
width: 100%;
padding: 14px;
font-size: 16px;
font-weight: 500;
color: #fff;
background-color: #4CAF50;
border: none;
border-radius: 4px;
cursor: pointer;
-webkit-appearance: none;
}
.submit-btn button:active {
background-color: #45a049;
}
.form-hint {
font-size: 12px;
color: #999;
margin-top: 6px;
}
.image-item {
position: relative;
display: inline-block;
}
.image-item .remove-btn {
position: absolute;
top: -8px;
right: -8px;
width: 24px;
height: 24px;
background-color: #f44336;
color: white;
border: none;
border-radius: 50%;
cursor: pointer;
font-size: 16px;
line-height: 1;
padding: 0;
}
/* 地图位置选择 */
.map-placeholder {
width: 100%;
height: 200px;
border: 1px solid #ddd;
border-radius: 4px;
background-color: #f5f5f5;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: background-color 0.3s;
}
.map-placeholder:active {
background-color: #e8ebf0;
}
.map-placeholder-content {
text-align: center;
}
.map-icon {
font-size: 48px;
margin-bottom: 10px;
}
.map-text {
color: #999;
font-size: 14px;
}
.location-text {
font-size: 12px;
margin-top: 5px;
color: #f44336;
}
.location-text.selected {
color: #4CAF50;
}
/* 隐藏元素 */
.hidden {
display: none !important;
}
/* 自定义下拉框样式 */
.custom-select {
position: relative;
width: 100%;
}
.custom-select-trigger {
width: 100%;
padding: 12px;
font-size: 15px;
border: 1px solid #ddd;
border-radius: 4px;
background-color: #fff;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
user-select: none;
}
.custom-select-trigger:active {
background-color: #f5f5f5;
}
.custom-select-trigger span:first-child {
color: #333;
}
.custom-select-trigger.placeholder span:first-child {
color: #bbb;
}
.custom-select-trigger .arrow {
color: #666;
font-size: 12px;
transition: transform 0.3s;
}
.custom-select.active .arrow {
transform: rotate(180deg);
}
.custom-options {
display: none;
position: absolute;
top: 100%;
left: 0;
right: 0;
background-color: #fff;
border: 1px solid #ddd;
border-top: none;
border-radius: 0 0 4px 4px;
max-height: 200px;
overflow-y: auto;
z-index: 100;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.custom-select.active .custom-options {
display: block;
}
.custom-option {
padding: 12px;
cursor: pointer;
transition: background-color 0.2s;
border-bottom: 1px solid #f5f5f5;
}
.custom-option:last-child {
border-bottom: none;
}
.custom-option:active {
background-color: #e8f5e9;
}
.custom-option.selected {
background-color: #f1f1f1;
color: #4CAF50;
}
</style>
</head>
<body>
<div class="header">
<h1>创建店铺</h1>
</div>
<div class="section">
<div class="section-title">店铺基础信息</div>
<div class="form-item">
<label class="form-label">
<span class="required">*</span>摊位名称
</label>
<input type="text" class="form-input" placeholder="请输入摊位名称" required>
</div>
<div class="form-item">
<label class="form-label">
<span class="required">*</span>归属菜市场名称
</label>
<input type="text" class="form-input" placeholder="请输入归属菜市场名称" required>
</div>
<div class="form-item">
<label class="form-label">
<span class="required">*</span>商品类目类型
</label>
<div class="custom-select" id="categoryTypeSelect">
<div class="custom-select-trigger placeholder">
<span id="categoryTypeSelected">请选择商品类目类型</span>
<span class="arrow"></span>
</div>
<div class="custom-options">
<div class="custom-option" data-value="offline">线下菜市场</div>
<div class="custom-option" data-value="cloud">云店</div>
</div>
</div>
<input type="hidden" id="categoryType" name="categoryType" value="">
</div>
<div class="form-item">
<label class="form-label">
<span class="required">*</span>主营类目
</label>
<div class="custom-select" id="mainCategorySelect">
<div class="custom-select-trigger placeholder">
<span id="mainCategorySelected">请选择主营类目</span>
<span class="arrow"></span>
</div>
<div class="custom-options">
<div class="custom-option" data-value="vegetable">蔬菜</div>
<div class="custom-option" data-value="fruit">水果</div>
<div class="custom-option" data-value="meat">肉类</div>
<div class="custom-option" data-value="seafood">海鲜</div>
<div class="custom-option" data-value="grain">粮油</div>
<div class="custom-option" data-value="other">其他</div>
</div>
</div>
<input type="hidden" id="mainCategory" name="mainCategory" value="">
</div>
<div class="form-item">
<label class="form-label">
<span class="required">*</span>摊位背景图
</label>
<div class="image-upload image-upload-large" id="bgImageUpload">
<input type="file" accept="image/*" onchange="handleImageUpload(event, 'bgImagePreview')">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg>
<img id="bgImagePreview" class="image-preview" style="display: none;">
</div>
</div>
<div class="form-item">
<label class="form-label">摊位照片</label>
<div class="image-upload-container" id="photoContainer">
<div class="image-upload">
<input type="file" accept="image/*" multiple onchange="handleMultipleImages(event)">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg>
</div>
</div>
</div>
<div class="form-item">
<label class="form-label">
<span class="required">*</span>菜市场背景图
</label>
<div class="image-upload image-upload-large" id="marketBgImageUpload">
<input type="file" accept="image/*" onchange="handleImageUpload(event, 'marketBgImagePreview')">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg>
<img id="marketBgImagePreview" class="image-preview" style="display: none;">
</div>
</div>
<div class="form-item">
<label class="form-label">
<span class="required">*</span>营业执照
</label>
<div class="image-upload image-upload-large" id="businessLicenseUpload">
<input type="file" accept="image/*" onchange="handleImageUpload(event, 'businessLicensePreview')">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg>
<img id="businessLicensePreview" class="image-preview" style="display: none;">
</div>
</div>
<div class="form-item">
<label class="form-label">
<span class="required">*</span>菜市场实拍图
</label>
<div class="image-upload-container" id="marketPhotoContainer">
<div class="image-upload">
<input type="file" accept="image/*" multiple onchange="handleMarketPhotos(event)">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg>
</div>
</div>
<div class="form-hint">支持上传多张图片</div>
</div>
<div class="form-item">
<label class="form-label">摊位联系电话</label>
<input type="tel" class="form-input" placeholder="请输入联系电话/手机号">
</div>
<div class="form-item">
<label class="form-label">
<span class="required">*</span>摊位位置
</label>
<input type="text" class="form-input" placeholder="请输入摊位位置A区-01号" required>
</div>
<div class="form-item">
<label class="form-label">
<span class="required">*</span>摊位地图定位
</label>
<div class="map-placeholder" onclick="selectLocation()">
<div class="map-placeholder-content">
<div class="map-icon">📍</div>
<div class="map-text">点击选择地图定位</div>
<div class="location-text" id="selectedLocationText">请选择定位</div>
</div>
</div>
<input type="hidden" id="locationLat" value="">
<input type="hidden" id="locationLng" value="">
</div>
<div class="form-item">
<label class="form-label">许可证</label>
<div class="image-upload-container">
<div class="image-upload">
<input type="file" accept="image/*" onchange="handleImageUpload(event, 'license1Preview')">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg>
<img id="license1Preview" class="image-preview" style="display: none;">
</div>
<div class="image-upload">
<input type="file" accept="image/*" onchange="handleImageUpload(event, 'license2Preview')">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg>
<img id="license2Preview" class="image-preview" style="display: none;">
</div>
</div>
</div>
</div>
<div class="section">
<div class="form-item">
<label class="form-label">
<span class="required">*</span>摊位营业时间
</label>
<div class="switch-group">
<div class="switch-labels">
<span class="switch-label">手动营业</span>
<span class="switch-label active" id="autoLabel">自动营业</span>
</div>
<label class="switch">
<input type="checkbox" id="autoBusinessTime" checked onchange="toggleBusinessTimeOptions()">
<span class="slider"></span>
</label>
</div>
<div class="checkbox-group" id="businessDayOptions">
<div class="checkbox-item">
<input type="checkbox" id="everyday">
<label for="everyday">每天</label>
</div>
<div class="checkbox-item">
<input type="checkbox" id="workday">
<label for="workday">工作日</label>
</div>
<div class="checkbox-item">
<input type="checkbox" id="custom">
<label for="custom">自定义</label>
</div>
</div>
<div class="time-range" id="businessTimeRange">
<input type="time" class="form-input time-input" id="startTime" placeholder="开始营业时间">
<span></span>
<input type="time" class="form-input time-input" id="endTime" placeholder="结束营业时间">
</div>
</div>
<div class="form-item">
<label class="form-label">承诺送达时间</label>
<input type="number" class="form-input" placeholder="请输入小时数" min="0" step="1">
<div class="form-hint">小时以内</div>
</div>
</div>
<div class="submit-btn">
<button type="button" onclick="handleSubmit()">保存</button>
</div>
<script>
function handleImageUpload(event, previewId) {
const file = event.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
const preview = document.getElementById(previewId);
preview.src = e.target.result;
preview.style.display = 'block';
event.target.style.display = 'none';
}
reader.readAsDataURL(file);
}
}
function handleMultipleImages(event) {
const files = event.target.files;
const container = document.getElementById('photoContainer');
Array.from(files).forEach(file => {
const reader = new FileReader();
reader.onload = function(e) {
const imageItem = document.createElement('div');
imageItem.className = 'image-item';
imageItem.innerHTML = `
<div class="image-upload">
<img src="${e.target.result}" class="image-preview" style="display: block;">
</div>
<button class="remove-btn" onclick="removeImage(this)">×</button>
`;
container.insertBefore(imageItem, container.firstChild);
}
reader.readAsDataURL(file);
});
event.target.value = '';
}
function handleMarketPhotos(event) {
const files = event.target.files;
const container = document.getElementById('marketPhotoContainer');
Array.from(files).forEach(file => {
const reader = new FileReader();
reader.onload = function(e) {
const imageItem = document.createElement('div');
imageItem.className = 'image-item';
imageItem.innerHTML = `
<div class="image-upload">
<img src="${e.target.result}" class="image-preview" style="display: block;">
</div>
<button class="remove-btn" onclick="removeImage(this)">×</button>
`;
container.insertBefore(imageItem, container.firstChild);
}
reader.readAsDataURL(file);
});
event.target.value = '';
}
function removeImage(btn) {
btn.parentElement.remove();
}
// 切换营业时间选项的显示/隐藏
function toggleBusinessTimeOptions() {
const autoBusinessTime = document.getElementById('autoBusinessTime');
const businessDayOptions = document.getElementById('businessDayOptions');
const businessTimeRange = document.getElementById('businessTimeRange');
const autoLabel = document.getElementById('autoLabel');
const manualLabel = autoLabel.previousElementSibling;
if (autoBusinessTime.checked) {
// 自动营业,显示时间范围和日期选项
businessDayOptions.classList.remove('hidden');
businessTimeRange.classList.remove('hidden');
autoLabel.classList.add('active');
manualLabel.classList.remove('active');
} else {
// 手动营业,隐藏时间范围和日期选项
businessDayOptions.classList.add('hidden');
businessTimeRange.classList.add('hidden');
autoLabel.classList.remove('active');
manualLabel.classList.add('active');
}
}
// 选择地图定位
function selectLocation() {
// 这里应该打开地图选择器实际应调用地图API
alert('此处应打开地图选择器实际开发时需要集成地图API如高德地图、百度地图等');
// 模拟选择了一个位置
const mockLat = 31.230416;
const mockLng = 121.473701;
document.getElementById('locationLat').value = mockLat;
document.getElementById('locationLng').value = mockLng;
document.getElementById('selectedLocationText').textContent = '已选择: ' + mockLat + ', ' + mockLng;
document.getElementById('selectedLocationText').classList.add('selected');
}
function handleSubmit() {
const requiredFields = document.querySelectorAll('[required]');
let isValid = true;
requiredFields.forEach(field => {
if (!field.value.trim()) {
isValid = false;
field.style.borderColor = '#f44336';
} else {
field.style.borderColor = '#ddd';
}
});
if (isValid) {
alert('表单提交成功!');
// 这里添加实际的提交逻辑
} else {
alert('请填写所有必填项!');
}
}
// 防止页面缩放
document.addEventListener('gesturestart', function(e) {
e.preventDefault();
});
// 优化移动端输入体验
document.querySelectorAll('.form-input').forEach(input => {
input.addEventListener('focus', function() {
setTimeout(() => {
this.scrollIntoView({ behavior: 'smooth', block: 'center' });
}, 300);
});
});
// 自定义下拉框功能
function initCustomSelect(selectId, hiddenInputId, displayId) {
const selectElement = document.getElementById(selectId);
const trigger = selectElement.querySelector('.custom-select-trigger');
const options = selectElement.querySelectorAll('.custom-option');
const hiddenInput = document.getElementById(hiddenInputId);
const displaySpan = document.getElementById(displayId);
// 点击触发器切换下拉列表
trigger.addEventListener('click', function(e) {
e.stopPropagation();
// 关闭其他打开的下拉框
document.querySelectorAll('.custom-select.active').forEach(el => {
if (el !== selectElement) {
el.classList.remove('active');
}
});
selectElement.classList.toggle('active');
});
// 选择选项
options.forEach(option => {
option.addEventListener('click', function(e) {
e.stopPropagation();
const value = this.getAttribute('data-value');
const text = this.textContent;
// 更新显示文本
displaySpan.textContent = text;
trigger.classList.remove('placeholder');
// 更新隐藏输入框的值
hiddenInput.value = value;
// 更新选中状态
options.forEach(opt => opt.classList.remove('selected'));
this.classList.add('selected');
// 关闭下拉列表
selectElement.classList.remove('active');
});
});
}
// 点击页面其他地方关闭下拉框
document.addEventListener('click', function() {
document.querySelectorAll('.custom-select.active').forEach(el => {
el.classList.remove('active');
});
});
// 页面加载完成后初始化
document.addEventListener('DOMContentLoaded', function() {
// 初始化营业时间选项显示状态
toggleBusinessTimeOptions();
// 初始化自定义下拉框
initCustomSelect('categoryTypeSelect', 'categoryType', 'categoryTypeSelected');
initCustomSelect('mainCategorySelect', 'mainCategory', 'mainCategorySelected');
});
</script>
</body>
</html>