This commit is contained in:
		
							parent
							
								
									ae6fb3410e
								
							
						
					
					
						commit
						0527ed70fd
					
				|  | @ -253,6 +253,11 @@ | |||
|             margin: 0; | ||||
|         } | ||||
| 
 | ||||
|         .exchange-only, | ||||
|         .discount-only { | ||||
|             transition: opacity 0.3s ease; | ||||
|         } | ||||
| 
 | ||||
|         .modal-footer { | ||||
|             padding: 16px 24px; | ||||
|             border-top: 1px solid #f0f0f0; | ||||
|  | @ -344,33 +349,14 @@ | |||
|                     <span class="info-label">SKU-ID:</span> | ||||
|                     <span class="info-value">194105142774503836</span> | ||||
|                 </div> | ||||
|             </div> | ||||
| 
 | ||||
|             <div class="form-group"> | ||||
|                 <label class="form-label">积分类型 <span class="required">*</span></label> | ||||
|                 <div class="radio-group"> | ||||
|                     <div class="radio-option"> | ||||
|                         <input type="radio" id="pointsDiscount" name="pointsType" value="discount" checked> | ||||
|                         <label for="pointsDiscount">积分优惠购</label> | ||||
|                     </div> | ||||
|                     <div class="radio-option"> | ||||
|                         <input type="radio" id="pointsExchange" name="pointsType" value="exchange"> | ||||
|                         <label for="pointsExchange">积分换购</label> | ||||
|                     </div> | ||||
|                 <div class="info-row"> | ||||
|                     <span class="info-label">商品原价:</span> | ||||
|                     <span class="info-value">¥12.80</span> | ||||
|                 </div> | ||||
|             </div> | ||||
| 
 | ||||
|             <div class="form-group"> | ||||
|                 <label class="form-label">兑换所需积分设置 <span class="required">*</span></label> | ||||
|                 <div class="number-input-group"> | ||||
|                     <button class="number-btn" onclick="decreasePoints()">-</button> | ||||
|                     <input type="number" class="number-input" id="pointsInput" value="1" min="1"> | ||||
|                     <button class="number-btn" onclick="increasePoints()">+</button> | ||||
|                 </div> | ||||
|             </div> | ||||
| 
 | ||||
|             <div class="form-group"> | ||||
|                 <label class="form-label">兑换库存设置 <span class="required">*</span></label> | ||||
|                 <label class="form-label">库存设置 <span class="required">*</span></label> | ||||
|                 <div class="number-input-group"> | ||||
|                     <button class="number-btn" onclick="decreaseStock()">-</button> | ||||
|                     <input type="number" class="number-input" id="stockInput" value="10" min="0"> | ||||
|  | @ -379,28 +365,46 @@ | |||
|             </div> | ||||
| 
 | ||||
|             <div class="form-group"> | ||||
|                 <label class="form-label">限制兑换(每人购买不超) <span class="required">*</span></label> | ||||
|                 <div class="limit-setting"> | ||||
|                     <div class="limit-input"> | ||||
|                         <div class="number-input-group"> | ||||
|                             <button class="number-btn" onclick="decreaseLimit()">-</button> | ||||
|                             <input type="number" class="number-input" id="limitInput" value="0" min="0"> | ||||
|                             <button class="number-btn" onclick="increaseLimit()">+</button> | ||||
|                         </div> | ||||
|                 <label class="form-label">积分类型 <span class="required">*</span></label> | ||||
|                 <div class="radio-group"> | ||||
|                     <div class="radio-option"> | ||||
|                         <input type="radio" id="pointsDiscount" name="pointsType" value="discount" checked onchange="toggleFieldsByType()"> | ||||
|                         <label for="pointsDiscount">积分优惠购</label> | ||||
|                     </div> | ||||
|                     <div class="limit-select"> | ||||
|                         <div class="select-wrapper"> | ||||
|                             <select class="form-select" id="limitType"> | ||||
|                                 <option value="daily">每天</option> | ||||
|                                 <option value="weekly">每周</option> | ||||
|                                 <option value="monthly">每月</option> | ||||
|                                 <option value="total">总计</option> | ||||
|                             </select> | ||||
|                             <span class="select-arrow">▼</span> | ||||
|                         </div> | ||||
|                     <div class="radio-option"> | ||||
|                         <input type="radio" id="pointsExchange" name="pointsType" value="exchange" onchange="toggleFieldsByType()"> | ||||
|                         <label for="pointsExchange">积分换购</label> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
| 
 | ||||
|             <!-- 积分换购专用字段 --> | ||||
|             <div class="form-group exchange-only"> | ||||
|                 <label class="form-label">兑换所需积分设置 <span class="required">*</span></label> | ||||
|                 <div class="number-input-group"> | ||||
|                     <button class="number-btn" onclick="decreasePoints()">-</button> | ||||
|                     <input type="number" class="number-input" id="pointsInput" value="1" min="1"> | ||||
|                     <button class="number-btn" onclick="increasePoints()">+</button> | ||||
|                 </div> | ||||
|             </div> | ||||
| 
 | ||||
| 
 | ||||
|             <!-- 积分优惠购专用字段 --> | ||||
|             <div class="form-group discount-only" style="display: none;"> | ||||
|                 <label class="form-label">优惠购所需积分 <span class="required">*</span></label> | ||||
|                 <div class="number-input-group"> | ||||
|                     <button class="number-btn" onclick="decreaseDiscountPoints()">-</button> | ||||
|                     <input type="number" class="number-input" id="discountPointsInput" value="1" min="1"> | ||||
|                     <button class="number-btn" onclick="increaseDiscountPoints()">+</button> | ||||
|                 </div> | ||||
|             </div> | ||||
| 
 | ||||
|             <div class="form-group discount-only" style="display: none;"> | ||||
|                 <label class="form-label">优惠购商品价格 <span class="required">*</span></label> | ||||
|                 <div class="input-wrapper"> | ||||
|                     <input type="number" class="form-input" id="discountPriceInput" placeholder="请输入优惠购价格" step="0.01" min="0"> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
| 
 | ||||
|         <div class="modal-footer"> | ||||
|  | @ -410,7 +414,7 @@ | |||
|     </div> | ||||
| 
 | ||||
|     <script> | ||||
|         // 积分设置 | ||||
|         // 积分设置(兑换专用) | ||||
|         function increasePoints() { | ||||
|             const input = document.getElementById('pointsInput'); | ||||
|             input.value = parseInt(input.value) + 1; | ||||
|  | @ -424,6 +428,20 @@ | |||
|             } | ||||
|         } | ||||
| 
 | ||||
|         // 优惠购积分设置 | ||||
|         function increaseDiscountPoints() { | ||||
|             const input = document.getElementById('discountPointsInput'); | ||||
|             input.value = parseInt(input.value) + 1; | ||||
|         } | ||||
| 
 | ||||
|         function decreaseDiscountPoints() { | ||||
|             const input = document.getElementById('discountPointsInput'); | ||||
|             const currentValue = parseInt(input.value); | ||||
|             if (currentValue > 1) { | ||||
|                 input.value = currentValue - 1; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         // 库存设置 | ||||
|         function increaseStock() { | ||||
|             const input = document.getElementById('stockInput'); | ||||
|  | @ -438,19 +456,6 @@ | |||
|             } | ||||
|         } | ||||
| 
 | ||||
|         // 限制兑换设置 | ||||
|         function increaseLimit() { | ||||
|             const input = document.getElementById('limitInput'); | ||||
|             input.value = parseInt(input.value) + 1; | ||||
|         } | ||||
| 
 | ||||
|         function decreaseLimit() { | ||||
|             const input = document.getElementById('limitInput'); | ||||
|             const currentValue = parseInt(input.value); | ||||
|             if (currentValue > 0) { | ||||
|                 input.value = currentValue - 1; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         // 关闭弹窗 | ||||
|         function closeModal() { | ||||
|  | @ -461,33 +466,61 @@ | |||
|             // 或者隐藏弹窗元素 | ||||
|         } | ||||
| 
 | ||||
|         // 切换字段显示 | ||||
|         function toggleFieldsByType() { | ||||
|             const pointsType = document.querySelector('input[name="pointsType"]:checked').value; | ||||
|             const exchangeFields = document.querySelectorAll('.exchange-only'); | ||||
|             const discountFields = document.querySelectorAll('.discount-only'); | ||||
| 
 | ||||
|             if (pointsType === 'exchange') { | ||||
|                 // 积分换购:显示兑换字段,隐藏优惠购字段 | ||||
|                 exchangeFields.forEach(field => field.style.display = 'block'); | ||||
|                 discountFields.forEach(field => field.style.display = 'none'); | ||||
|             } else { | ||||
|                 // 积分优惠购:隐藏兑换字段,显示优惠购字段 | ||||
|                 exchangeFields.forEach(field => field.style.display = 'none'); | ||||
|                 discountFields.forEach(field => field.style.display = 'block'); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         // 确认选择 | ||||
|         function confirmSelection() { | ||||
|             const pointsType = document.querySelector('input[name="pointsType"]:checked').value; | ||||
|             const points = document.getElementById('pointsInput').value; | ||||
|             const stock = document.getElementById('stockInput').value; | ||||
|             const limit = document.getElementById('limitInput').value; | ||||
|             const limitType = document.getElementById('limitType').value; | ||||
| 
 | ||||
|             // 验证必填项 | ||||
|             if (!pointsType || !points || !stock || limit === '') { | ||||
|                 alert('请填写所有必填项'); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             // 这里可以添加提交数据的逻辑 | ||||
|             const data = { | ||||
|              | ||||
|             let data = { | ||||
|                 productId: '192401649879976960', | ||||
|                 productName: '黑木耳100g', | ||||
|                 shopName: '牛生蔬菜店', | ||||
|                 skuId: '194105142774503836', | ||||
|                 pointsType: pointsType, | ||||
|                 points: points, | ||||
|                 stock: stock, | ||||
|                 limit: limit, | ||||
|                 limitType: limitType | ||||
|                 stock: stock | ||||
|             }; | ||||
| 
 | ||||
|             if (pointsType === 'exchange') { | ||||
|                 // 积分换购验证 | ||||
|                 const points = document.getElementById('pointsInput').value; | ||||
|                  | ||||
|                 if (!points || !stock) { | ||||
|                     alert('请填写所有必填项'); | ||||
|                     return; | ||||
|                 } | ||||
|                  | ||||
|                 data.points = points; | ||||
|             } else { | ||||
|                 // 积分优惠购验证 | ||||
|                 const discountPoints = document.getElementById('discountPointsInput').value; | ||||
|                 const discountPrice = document.getElementById('discountPriceInput').value; | ||||
|                  | ||||
|                 if (!discountPoints || !stock || !discountPrice) { | ||||
|                     alert('请填写所有必填项'); | ||||
|                     return; | ||||
|                 } | ||||
|                  | ||||
|                 data.discountPoints = discountPoints; | ||||
|                 data.discountPrice = discountPrice; | ||||
|             } | ||||
| 
 | ||||
|             console.log('提交数据:', data); | ||||
|             alert('设置成功!'); | ||||
|         } | ||||
|  | @ -505,6 +538,11 @@ | |||
|                 closeModal(); | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         // 页面加载时初始化字段显示 | ||||
|         document.addEventListener('DOMContentLoaded', function() { | ||||
|             toggleFieldsByType(); | ||||
|         }); | ||||
|     </script> | ||||
| </body> | ||||
| </html> | ||||
		Loading…
	
		Reference in New Issue