710 lines
		
	
	
		
			23 KiB
		
	
	
	
		
			HTML
		
	
	
	
			
		
		
	
	
			710 lines
		
	
	
		
			23 KiB
		
	
	
	
		
			HTML
		
	
	
	
| <!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;
 | ||
|         }
 | ||
|     </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>
 | ||
|             <select class="form-input" required>
 | ||
|                 <option value="">请选择主营类目</option>
 | ||
|                 <option value="vegetable">蔬菜</option>
 | ||
|                 <option value="fruit">水果</option>
 | ||
|                 <option value="meat">肉类</option>
 | ||
|                 <option value="seafood">海鲜</option>
 | ||
|                 <option value="grain">粮油</option>
 | ||
|                 <option value="other">其他</option>
 | ||
|             </select>
 | ||
|         </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);
 | ||
|             });
 | ||
|         });
 | ||
| 
 | ||
|         // 页面加载完成后初始化
 | ||
|         document.addEventListener('DOMContentLoaded', function() {
 | ||
|             // 初始化营业时间选项显示状态
 | ||
|             toggleBusinessTimeOptions();
 | ||
|         });
 | ||
|     </script>
 | ||
| </body>
 | ||
| </html> |