You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
5095 lines
268 KiB
5095 lines
268 KiB
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>货源管理</title>
|
|
<style>
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
margin: 0;
|
|
padding: 0;
|
|
background-color: #f5f5f5;
|
|
color: #333;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.container {
|
|
max-width: 100%;
|
|
margin: 0 auto;
|
|
background-color: #fff;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
/* 标题栏 */
|
|
.title-bar {
|
|
background-color: #1677ff;
|
|
color: white;
|
|
padding: 15px 20px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 100;
|
|
}
|
|
|
|
.title-bar h1 {
|
|
margin: 0;
|
|
font-size: 18px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.title-bar-actions {
|
|
display: flex;
|
|
gap: 10px;
|
|
}
|
|
|
|
.title-bar-actions button {
|
|
background-color: rgba(255, 255, 255, 0.2);
|
|
color: white;
|
|
border: none;
|
|
padding: 8px 16px;
|
|
border-radius: 4px;
|
|
font-size: 14px;
|
|
cursor: pointer;
|
|
transition: background-color 0.3s;
|
|
}
|
|
|
|
.title-bar-actions button:hover {
|
|
background-color: rgba(255, 255, 255, 0.3);
|
|
}
|
|
|
|
/* 搜索框 */
|
|
.search-container {
|
|
padding: 15px 20px;
|
|
background-color: white;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
}
|
|
|
|
.search-box {
|
|
position: relative;
|
|
background-color: #f5f5f5;
|
|
border-radius: 20px;
|
|
padding: 0 15px;
|
|
}
|
|
|
|
.search-input {
|
|
width: 100%;
|
|
height: 40px;
|
|
border: none;
|
|
background: transparent;
|
|
font-size: 14px;
|
|
padding-right: 30px;
|
|
}
|
|
|
|
.search-input:focus {
|
|
outline: none;
|
|
}
|
|
|
|
.clear-icon {
|
|
position: absolute;
|
|
right: 15px;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
color: #999;
|
|
cursor: pointer;
|
|
}
|
|
|
|
/* 创建货源按钮 */
|
|
.create-supply-btn {
|
|
margin: 20px;
|
|
text-align: center;
|
|
}
|
|
|
|
.create-supply-btn button {
|
|
background-color: #07c160;
|
|
color: white;
|
|
border: none;
|
|
padding: 12px 40px;
|
|
border-radius: 20px;
|
|
font-size: 16px;
|
|
cursor: pointer;
|
|
transition: background-color 0.3s;
|
|
}
|
|
|
|
.create-supply-btn button:hover {
|
|
background-color: #06b158;
|
|
}
|
|
|
|
/* 货源列表 */
|
|
.supply-section {
|
|
margin: 20px;
|
|
background-color: white;
|
|
border-radius: 12px;
|
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.section-header {
|
|
padding: 16px 20px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
cursor: pointer;
|
|
background-color: #fafafa;
|
|
transition: background-color 0.3s;
|
|
}
|
|
|
|
.section-header:hover {
|
|
background-color: #f5f5f5;
|
|
}
|
|
|
|
.section-title {
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
color: #333;
|
|
}
|
|
|
|
.section-toggle {
|
|
font-size: 18px;
|
|
color: #999;
|
|
transition: transform 0.3s;
|
|
}
|
|
|
|
.section-toggle.expanded {
|
|
transform: rotate(180deg);
|
|
color: #1677ff;
|
|
}
|
|
|
|
.supply-list {
|
|
max-height: 0;
|
|
overflow: hidden;
|
|
transition: max-height 0.3s ease;
|
|
}
|
|
|
|
.supply-list.expanded {
|
|
max-height: none;
|
|
overflow: visible;
|
|
}
|
|
|
|
.supply-item {
|
|
padding: 20px;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
display: flex;
|
|
gap: 20px;
|
|
align-items: flex-start;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.supply-item:hover {
|
|
background-color: #fafafa;
|
|
}
|
|
|
|
.supply-item:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
/* 图片区域 */
|
|
.supply-images {
|
|
width: 120px;
|
|
height: 120px;
|
|
position: relative;
|
|
background-color: #f5f5f5;
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
flex-shrink: 0;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.image-slider {
|
|
width: 100%;
|
|
height: 100%;
|
|
position: relative;
|
|
}
|
|
|
|
.image-slider img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
transition: transform 0.3s;
|
|
}
|
|
|
|
.supply-images:hover .image-slider img {
|
|
transform: scale(1.05);
|
|
}
|
|
|
|
.image-indicator {
|
|
position: absolute;
|
|
bottom: 6px;
|
|
right: 6px;
|
|
background-color: rgba(0, 0, 0, 0.6);
|
|
color: white;
|
|
padding: 4px 8px;
|
|
border-radius: 12px;
|
|
font-size: 11px;
|
|
}
|
|
|
|
/* 信息区域 */
|
|
.supply-info {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 12px;
|
|
}
|
|
|
|
.supply-name {
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
color: #333;
|
|
}
|
|
|
|
.supply-status {
|
|
font-size: 12px;
|
|
padding: 4px 12px;
|
|
border-radius: 12px;
|
|
color: white;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.status-published {
|
|
background-color: #52c41a;
|
|
}
|
|
|
|
.status-pending {
|
|
background-color: #faad14;
|
|
}
|
|
|
|
.status-rejected {
|
|
background-color: #f5222d;
|
|
}
|
|
|
|
.status-draft {
|
|
background-color: #8c8c8c;
|
|
}
|
|
|
|
.supply-details {
|
|
display: grid;
|
|
grid-template-columns: repeat(2, 1fr);
|
|
gap: 10px;
|
|
}
|
|
|
|
.detail-item {
|
|
font-size: 14px;
|
|
color: #666;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
|
|
.detail-item::before {
|
|
content: "•";
|
|
color: #1677ff;
|
|
font-size: 16px;
|
|
}
|
|
|
|
.supply-actions {
|
|
display: flex;
|
|
gap: 10px;
|
|
}
|
|
|
|
.supply-actions button {
|
|
padding: 6px 15px;
|
|
border: none;
|
|
border-radius: 4px;
|
|
font-size: 12px;
|
|
cursor: pointer;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.btn-primary {
|
|
background-color: #1677ff;
|
|
color: white;
|
|
}
|
|
|
|
.btn-warning {
|
|
background-color: #faad14;
|
|
color: white;
|
|
}
|
|
|
|
.btn-danger {
|
|
background-color: #f5222d;
|
|
color: white;
|
|
}
|
|
|
|
.btn-success {
|
|
background-color: #52c41a;
|
|
color: white;
|
|
}
|
|
|
|
/* 模态框 */
|
|
.modal {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background-color: rgba(0, 0, 0, 0.5);
|
|
display: none;
|
|
justify-content: center;
|
|
align-items: flex-start;
|
|
padding-top: 50px;
|
|
z-index: 1000;
|
|
}
|
|
|
|
.modal.active {
|
|
display: flex;
|
|
}
|
|
|
|
.modal-content {
|
|
background-color: white;
|
|
width: 90%;
|
|
max-width: 600px;
|
|
max-height: 85vh;
|
|
border-radius: 12px;
|
|
overflow: hidden;
|
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
|
|
}
|
|
|
|
.modal-header {
|
|
padding: 20px;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
background-color: white;
|
|
}
|
|
|
|
.modal-title {
|
|
margin: 0;
|
|
font-size: 18px;
|
|
font-weight: 500;
|
|
color: #333;
|
|
}
|
|
|
|
.close-btn {
|
|
background: none;
|
|
border: none;
|
|
font-size: 24px;
|
|
cursor: pointer;
|
|
color: #999;
|
|
transition: color 0.3s;
|
|
}
|
|
|
|
.close-btn:hover {
|
|
color: #333;
|
|
}
|
|
|
|
.modal-body {
|
|
padding: 20px;
|
|
max-height: 65vh;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
/* 修复select下拉框向上显示问题 */
|
|
select.form-select {
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
|
|
/* 表单样式 */
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.form-label {
|
|
display: block;
|
|
margin-bottom: 8px;
|
|
font-weight: 500;
|
|
font-size: 14px;
|
|
color: #333;
|
|
}
|
|
|
|
.form-input,
|
|
.form-select {
|
|
width: 100%;
|
|
padding: 12px 16px;
|
|
border: 1px solid #d9d9d9;
|
|
border-radius: 8px;
|
|
font-size: 14px;
|
|
box-sizing: border-box;
|
|
transition: all 0.3s;
|
|
background-color: #fff;
|
|
}
|
|
|
|
.form-input:hover,
|
|
.form-select:hover {
|
|
border-color: #1677ff;
|
|
}
|
|
|
|
.form-input:focus,
|
|
.form-select:focus {
|
|
outline: none;
|
|
border-color: #1677ff;
|
|
box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.2);
|
|
}
|
|
|
|
/* 图片上传 */
|
|
.upload-area {
|
|
border: 2px dashed #d9d9d9;
|
|
border-radius: 8px;
|
|
padding: 20px;
|
|
text-align: center;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.upload-area:hover {
|
|
border-color: #1677ff;
|
|
background-color: #f0f8ff;
|
|
}
|
|
|
|
.upload-images {
|
|
display: flex;
|
|
gap: 10px;
|
|
flex-wrap: wrap;
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.upload-image {
|
|
position: relative;
|
|
width: 100px;
|
|
height: 100px;
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.upload-image:hover {
|
|
transform: scale(1.05);
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
}
|
|
|
|
.upload-image img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
outline: none;
|
|
}
|
|
|
|
/* 移除可能导致红点的伪元素 */
|
|
.upload-image::before,
|
|
.upload-image::after,
|
|
.upload-area::before,
|
|
.upload-area::after,
|
|
.add-image::before,
|
|
.add-image::after {
|
|
content: none !important;
|
|
}
|
|
|
|
/* 确保没有意外的背景或边框 */
|
|
.upload-image,
|
|
.upload-area,
|
|
.add-image {
|
|
outline: none !important;
|
|
box-shadow: none !important;
|
|
}
|
|
|
|
/* 隐藏删除按钮,移除红色背景 */
|
|
.delete-image {
|
|
position: absolute;
|
|
top: 8px;
|
|
right: 8px;
|
|
width: 24px;
|
|
height: 24px;
|
|
background-color: rgba(0, 0, 0, 0.6);
|
|
color: white;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
cursor: pointer;
|
|
font-size: 14px;
|
|
font-weight: bold;
|
|
transition: background-color 0.3s;
|
|
}
|
|
|
|
.delete-image:hover {
|
|
background-color: rgba(255, 0, 0, 0.8);
|
|
}
|
|
|
|
.delete-image::before {
|
|
content: '×';
|
|
}
|
|
|
|
.upload-image {
|
|
position: relative;
|
|
display: inline-block;
|
|
margin: 10px;
|
|
}
|
|
|
|
.upload-image img {
|
|
width: 100px;
|
|
height: 100px;
|
|
object-fit: cover;
|
|
border-radius: 8px;
|
|
cursor: pointer;
|
|
transition: transform 0.3s;
|
|
}
|
|
|
|
.upload-image img:hover {
|
|
transform: scale(1.05);
|
|
}
|
|
|
|
.add-image {
|
|
width: 100px;
|
|
height: 100px;
|
|
border: 2px dashed #1677ff;
|
|
border-radius: 8px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
background-color: #f0f8ff;
|
|
color: #1677ff;
|
|
cursor: pointer;
|
|
font-size: 30px;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.add-image:hover {
|
|
background-color: #e6f7ff;
|
|
transform: scale(1.05);
|
|
}
|
|
|
|
/* 模态框底部按钮 */
|
|
.modal-footer {
|
|
padding: 16px 20px;
|
|
border-top: 1px solid #f0f0f0;
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
gap: 10px;
|
|
background-color: #fafafa;
|
|
}
|
|
|
|
/* 按钮样式优化 */
|
|
.supply-actions button {
|
|
padding: 8px 16px;
|
|
border: none;
|
|
border-radius: 6px;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
cursor: pointer;
|
|
transition: all 0.3s;
|
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.supply-actions button:hover {
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
|
}
|
|
|
|
.btn-primary {
|
|
background-color: #1677ff;
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background-color: #4096ff;
|
|
}
|
|
|
|
.btn-success {
|
|
background-color: #52c41a;
|
|
color: white;
|
|
}
|
|
|
|
.btn-success:hover {
|
|
background-color: #73d13d;
|
|
}
|
|
|
|
.btn-warning {
|
|
background-color: #faad14;
|
|
color: white;
|
|
}
|
|
|
|
.btn-warning:hover {
|
|
background-color: #ffc53d;
|
|
}
|
|
|
|
.btn-danger {
|
|
background-color: #f5222d;
|
|
color: white;
|
|
}
|
|
|
|
.btn-danger:hover {
|
|
background-color: #ff4d4f;
|
|
}
|
|
|
|
/* 模态框按钮样式 */
|
|
.modal-btn {
|
|
padding: 10px 24px;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
cursor: pointer;
|
|
transition: all 0.3s;
|
|
min-width: 80px;
|
|
text-align: center;
|
|
}
|
|
|
|
.modal-btn-cancel {
|
|
background-color: #f5f5f5;
|
|
color: #666;
|
|
border: 1px solid #d9d9d9;
|
|
}
|
|
|
|
.modal-btn-cancel:hover {
|
|
background-color: #e8e8e8;
|
|
border-color: #bfbfbf;
|
|
}
|
|
|
|
.modal-btn-primary {
|
|
background-color: #52c41a;
|
|
color: white;
|
|
}
|
|
|
|
.modal-btn-primary:hover {
|
|
background-color: #73d13d;
|
|
box-shadow: 0 2px 8px rgba(82, 196, 26, 0.3);
|
|
}
|
|
|
|
/* 确保模态框底部按钮区域不会被遮挡 */
|
|
.modal-footer {
|
|
position: sticky;
|
|
bottom: 0;
|
|
background-color: white;
|
|
z-index: 10;
|
|
border-top: 1px solid #f0f0f0;
|
|
}
|
|
|
|
/* 搜索结果为空 */
|
|
.empty-state {
|
|
padding: 40px;
|
|
text-align: center;
|
|
color: #999;
|
|
}
|
|
|
|
/* 加载更多 */
|
|
.load-more {
|
|
padding: 15px;
|
|
text-align: center;
|
|
color: #999;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.loading-text {
|
|
color: #1677ff;
|
|
}
|
|
|
|
/* 图片预览 */
|
|
.image-preview {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background-color: rgba(0, 0, 0, 0.9);
|
|
display: none;
|
|
justify-content: center;
|
|
align-items: center;
|
|
z-index: 2000;
|
|
}
|
|
|
|
.image-preview.active {
|
|
display: flex;
|
|
}
|
|
|
|
.preview-content {
|
|
position: relative;
|
|
max-width: 90%;
|
|
max-height: 90%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
}
|
|
|
|
.preview-image {
|
|
max-width: 100%;
|
|
max-height: 75vh;
|
|
object-fit: contain;
|
|
}
|
|
|
|
.zoom-controls {
|
|
position: absolute;
|
|
bottom: -50px;
|
|
display: flex;
|
|
gap: 10px;
|
|
margin-top: 10px;
|
|
}
|
|
|
|
.zoom-btn {
|
|
width: 40px;
|
|
height: 40px;
|
|
border-radius: 50%;
|
|
border: none;
|
|
background-color: #1677ff;
|
|
color: white;
|
|
font-size: 18px;
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
transition: background-color 0.3s;
|
|
}
|
|
|
|
.zoom-btn:hover {
|
|
background-color: #4096ff;
|
|
}
|
|
|
|
.zoom-btn:nth-child(3) {
|
|
border-radius: 4px;
|
|
width: 60px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.close-preview {
|
|
position: absolute;
|
|
top: -40px;
|
|
right: -40px;
|
|
background-color: rgba(255, 255, 255, 0.2);
|
|
color: white;
|
|
width: 30px;
|
|
height: 30px;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
cursor: pointer;
|
|
font-size: 18px;
|
|
}
|
|
|
|
/* 图片查看器样式 - 与Reject.html保持一致 */
|
|
.image-viewer {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background-color: rgba(0, 0, 0, 0.9);
|
|
display: none;
|
|
justify-content: center;
|
|
align-items: center;
|
|
z-index: 2000;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.image-viewer.active {
|
|
display: flex;
|
|
}
|
|
|
|
.image-viewer-content {
|
|
position: relative;
|
|
width: 500px; /* 固定宽度 */
|
|
height: 350px; /* 固定高度 */
|
|
cursor: default;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
}
|
|
|
|
.image-viewer-close {
|
|
position: absolute;
|
|
top: -30px;
|
|
right: -30px;
|
|
width: 30px;
|
|
height: 30px;
|
|
background-color: rgba(255, 255, 255, 0.2);
|
|
color: white;
|
|
border: none;
|
|
border-radius: 50%;
|
|
font-size: 20px;
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
transition: background-color 0.3s;
|
|
}
|
|
|
|
.image-viewer-close:hover {
|
|
background-color: rgba(255, 255, 255, 0.3);
|
|
}
|
|
|
|
/* 图片导航按钮 */
|
|
.image-viewer-nav {
|
|
position: absolute;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
width: 40px;
|
|
height: 40px;
|
|
background-color: rgba(0, 0, 0, 0.6);
|
|
color: white;
|
|
border: none;
|
|
border-radius: 50%;
|
|
font-size: 24px;
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
transition: background-color 0.3s;
|
|
z-index: 10;
|
|
}
|
|
|
|
.image-viewer-nav:hover {
|
|
background-color: rgba(0, 0, 0, 0.8);
|
|
}
|
|
|
|
.prev-btn {
|
|
left: -60px;
|
|
}
|
|
|
|
.next-btn {
|
|
right: -60px;
|
|
}
|
|
|
|
/* 图片计数器 */
|
|
.image-viewer-counter {
|
|
position: absolute;
|
|
bottom: -30px;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
background-color: transparent;
|
|
color: white;
|
|
padding: 4px 12px;
|
|
border-radius: 15px;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
/* 选择弹窗 */
|
|
.select-modal {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background-color: rgba(0, 0, 0, 0.5);
|
|
display: none;
|
|
justify-content: center;
|
|
align-items: center;
|
|
z-index: 1500;
|
|
}
|
|
|
|
.select-modal.active {
|
|
display: flex;
|
|
}
|
|
|
|
.select-content {
|
|
background-color: white;
|
|
width: 90%;
|
|
max-width: 600px;
|
|
max-height: 70vh;
|
|
border-radius: 8px;
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.select-header {
|
|
padding: 20px;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.select-body {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.select-search {
|
|
padding: 15px 20px;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
}
|
|
|
|
.select-list {
|
|
padding: 0;
|
|
}
|
|
|
|
.select-item {
|
|
padding: 15px 20px;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
cursor: pointer;
|
|
text-align: center;
|
|
transition: background-color 0.3s;
|
|
}
|
|
|
|
.select-item:hover {
|
|
background-color: #f5f5f5;
|
|
}
|
|
|
|
.select-item.selected {
|
|
background-color: #e6f7ff;
|
|
color: #1677ff;
|
|
}
|
|
|
|
/* 适配移动端 */
|
|
@media (max-width: 768px) {
|
|
.supply-item {
|
|
flex-direction: column;
|
|
}
|
|
|
|
.supply-images,
|
|
.supply-info {
|
|
width: 100%;
|
|
}
|
|
|
|
.supply-info {
|
|
padding-left: 0;
|
|
margin-top: 15px;
|
|
}
|
|
|
|
.image-slider {
|
|
height: 150px;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<!-- 标题栏 -->
|
|
<div class="title-bar">
|
|
<div style="display: flex; align-items: center; gap: 15px;">
|
|
<button onclick="window.location.href='Reject.html'" style="background-color: rgba(255, 255, 255, 0.2); color: white; border: 1px solid rgba(255, 255, 255, 0.3); padding: 10px 20px; border-radius: 20px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.3s ease; display: flex; align-items: center; gap: 8px; backdrop-filter: blur(10px); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);">
|
|
返回
|
|
</button>
|
|
<h1 style="margin: 0;">我的货源</h1>
|
|
</div>
|
|
<div class="title-bar-actions">
|
|
<button onclick="contactCustomerService()">联系客服</button>
|
|
<button class="apply-settlement-btn">已入驻</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 搜索框 -->
|
|
<div class="search-container">
|
|
<div class="search-box">
|
|
<input type="text" class="search-input" placeholder="搜索货源名称或品种" id="searchInput" oninput="onSearchInput(event)" onkeypress="onSearchConfirm(event)">
|
|
<div id="clearSearch" class="clear-icon" style="display: none;" onclick="clearSearch()">✕</div>
|
|
</div>
|
|
<!-- 当前登录用户信息提示 -->
|
|
<div id="currentUserInfo" style="margin-top: 10px; font-size: 12px; color: #666; text-align: right;"></div>
|
|
</div>
|
|
|
|
<!-- 创建新货源按钮 -->
|
|
<div class="create-supply-btn">
|
|
<button onclick="showAddSupplyModal()">创建新货源</button>
|
|
</div>
|
|
|
|
<!-- 已上架货源 -->
|
|
<div class="supply-section">
|
|
<div class="section-header" onclick="toggleSection('published')">
|
|
<div class="section-title">已上架货源 (0)</div>
|
|
<div id="publishedToggle" class="section-toggle">▼</div>
|
|
</div>
|
|
<div id="publishedList" class="supply-list">
|
|
<div class="empty-state">暂无已上架的货源</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 审核中的货源 -->
|
|
<div class="supply-section">
|
|
<div class="section-header" onclick="toggleSection('pending')">
|
|
<div class="section-title">审核中的货源 (0)</div>
|
|
<div id="pendingToggle" class="section-toggle">▼</div>
|
|
</div>
|
|
<div id="pendingList" class="supply-list">
|
|
<div class="empty-state">暂无审核中的货源</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 审核失败的货源 -->
|
|
<div class="supply-section">
|
|
<div class="section-header" onclick="toggleSection('rejected')">
|
|
<div class="section-title">审核失败的货源 (0)</div>
|
|
<div id="rejectedToggle" class="section-toggle">▼</div>
|
|
</div>
|
|
<div id="rejectedList" class="supply-list">
|
|
<div class="empty-state">暂无审核失败的货源</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 下架状态货源 -->
|
|
<div class="supply-section">
|
|
<div class="section-header" onclick="toggleSection('draft')">
|
|
<div class="section-title">下架状态货源 (0)</div>
|
|
<div id="draftToggle" class="section-toggle">▼</div>
|
|
</div>
|
|
<div id="draftList" class="supply-list">
|
|
<div class="empty-state">暂无下架状态的货源</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 创建货源模态框 -->
|
|
<div id="createSupplyModal" class="modal">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h2 class="modal-title">创建货源</h2>
|
|
<button class="close-btn" onclick="hideAddSupplyModal()">×</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form id="createSupplyForm">
|
|
<!-- 货源状态选择 (预售/现货) -->
|
|
<div class="form-group">
|
|
<label class="form-label">货源状态</label>
|
|
<div style="display: flex; gap: 10px;">
|
|
<button type="button" id="preSaleBtn" class="status-button" onclick="setSupplyStatus('预售')" style="padding: 8px 20px; border: 2px solid #d9d9d9; background-color: white; color: #666; border-radius: 6px; cursor: pointer;">预售</button>
|
|
<button type="button" id="inStockBtn" class="status-button" onclick="setSupplyStatus('现货')" style="padding: 8px 20px; border: 2px solid #d9d9d9; background-color: white; color: #666; border-radius: 6px; cursor: pointer;">现货</button>
|
|
<input type="hidden" id="supplyStatus" value="">
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 商品图片 -->
|
|
<div class="form-group">
|
|
<label class="form-label">商品图片</label>
|
|
<div class="upload-area">
|
|
<div id="uploadImages" class="upload-images"></div>
|
|
<div class="add-image" onclick="triggerImageUpload()">+</div>
|
|
<input type="file" id="imageUpload" multiple accept="image/*" style="display: none;" onchange="handleImageUpload(event)">
|
|
<div style="font-size: 12px; color: #999; margin-top: 10px;">最多上传5张图片</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 货源类型 -->
|
|
<div class="form-group">
|
|
<label class="form-label">货源类型</label>
|
|
<div class="form-select" id="sourceTypeSelect" onclick="showSourceTypeSelectModal()" style="cursor: pointer; position: relative; padding-right: 30px;">
|
|
<span id="sourceTypeDisplayText">请选择货源类型</span>
|
|
<input type="hidden" id="sourceType" name="sourceType">
|
|
<span style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999;">▼</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 种类 -->
|
|
<div class="form-group">
|
|
<label class="form-label">种类</label>
|
|
<div class="form-select" id="categorySelect" onclick="showCategorySelectModal()" style="cursor: pointer; position: relative; padding-right: 30px;">
|
|
<span id="categoryDisplayText">请选择种类</span>
|
|
<input type="hidden" id="category" name="category">
|
|
<span style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999;">▼</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 商品名称 -->
|
|
<div class="form-group">
|
|
<label class="form-label">商品名称</label>
|
|
<div class="form-select" id="productNameSelect" onclick="showProductNameSelectModal()" style="cursor: pointer; position: relative; padding-right: 30px;">
|
|
<span id="productNameDisplayText">请选择商品名称</span>
|
|
<input type="hidden" id="productName" name="productName">
|
|
<span style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999;">▼</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 蛋黄类型 -->
|
|
<div class="form-group">
|
|
<label class="form-label">蛋黄类型</label>
|
|
<div class="form-select" id="yolkSelect" onclick="showYolkSelectModal()" style="cursor: pointer; position: relative; padding-right: 30px;">
|
|
<span id="yolkDisplayText">请选择蛋黄类型</span>
|
|
<input type="hidden" id="yolk" name="yolk">
|
|
<span style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999;">▼</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 规格 -->
|
|
<div class="form-group">
|
|
<label class="form-label">规格</label>
|
|
<div class="form-select" id="spec" onclick="showSpecSelectModal()" style="cursor: pointer; position: relative; padding-right: 30px;">
|
|
<span id="specDisplayText">请选择规格</span>
|
|
<input type="hidden" id="specValue" name="spec">
|
|
<span style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999;">▼</span>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<!-- 地区 -->
|
|
<div class="form-group">
|
|
<label class="form-label">地区</label>
|
|
<div class="form-select" id="region" onclick="showRegionSelectModal()" style="cursor: pointer; position: relative; padding-right: 30px;">
|
|
<span id="regionDisplayText">请选择地区</span>
|
|
<input type="hidden" id="regionValue" name="region">
|
|
<span style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999;">▼</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 分配联系人 -->
|
|
<div class="form-group">
|
|
<label class="form-label">分配联系人</label>
|
|
<div class="form-select" id="contactIdSelect" onclick="showContactIdSelectModal()" style="cursor: pointer; position: relative; padding-right: 30px;">
|
|
<span id="contactIdDisplayText">请选择联系人</span>
|
|
<input type="hidden" id="contactId" name="contactId">
|
|
<span style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999;">▼</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 价格 -->
|
|
<div class="form-group">
|
|
<label class="form-label">价格</label>
|
|
<input type="number" class="form-input" id="price" placeholder="请输入价格" step="0.01">
|
|
</div>
|
|
|
|
<!-- 件数 -->
|
|
<div class="form-group">
|
|
<label class="form-label">件数</label>
|
|
<input type="number" class="form-input" id="quantity" placeholder="请输入件数">
|
|
</div>
|
|
|
|
<!-- 斤重 -->
|
|
<div class="form-group">
|
|
<label class="form-label">斤重</label>
|
|
<input type="text" class="form-input" id="grossWeight" placeholder="请输入斤重">
|
|
</div>
|
|
|
|
<!-- 货源描述 -->
|
|
<div class="form-group">
|
|
<label class="form-label">货源描述</label>
|
|
<input type="text" class="form-input" id="description" placeholder="请输入货源描述">
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="modal-btn modal-btn-cancel" onclick="hideAddSupplyModal()">取消</button>
|
|
<button class="modal-btn modal-btn-primary" onclick="addSupply()">创建</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 图片预览 -->
|
|
<div id="imagePreview" class="image-viewer">
|
|
<div class="image-viewer-content">
|
|
<!-- 上一张按钮 -->
|
|
<button class="image-viewer-nav prev-btn" onclick="prevPreviewImage()">‹</button>
|
|
<!-- 图片显示 -->
|
|
<img id="previewImage" class="preview-image" src="" style="transform: scale(1); transition: transform 0.1s ease;">
|
|
<!-- 下一张按钮 -->
|
|
<button class="image-viewer-nav next-btn" onclick="nextPreviewImage()">›</button>
|
|
<!-- 关闭按钮 -->
|
|
<button class="image-viewer-close" onclick="closeImagePreview()">×</button>
|
|
<!-- 图片计数器 -->
|
|
<div id="previewCounter" class="image-viewer-counter"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 货源类型选择弹窗 -->
|
|
<div id="sourceTypeSelectModal" class="select-modal">
|
|
<div class="select-content">
|
|
<div class="select-header">
|
|
<h3>选择货源类型</h3>
|
|
<button class="close-btn" onclick="hideSourceTypeSelectModal()">×</button>
|
|
</div>
|
|
<div class="select-search">
|
|
<input type="text" id="sourceTypeSearchInput" placeholder="搜索货源类型" oninput="filterSourceTypeOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
|
|
</div>
|
|
<div class="select-body">
|
|
<div id="sourceTypeOptionsList" class="select-list">
|
|
<!-- 货源类型选项将通过JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
|
|
<button onclick="hideSourceTypeSelectModal()" style="padding: 10px 24px; background-color: #f5f5f5; color: #666; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease;">取消</button>
|
|
<button onclick="confirmSourceTypeSelection()" style="padding: 10px 24px; background-color: #1677ff; color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease;">确定</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 商品名称选择弹窗 -->
|
|
<div id="productNameSelectModal" class="select-modal">
|
|
<div class="select-content">
|
|
<div class="select-header">
|
|
<h3>选择商品名称</h3>
|
|
<button class="close-btn" onclick="hideProductNameSelectModal()">×</button>
|
|
</div>
|
|
<div class="select-search">
|
|
<input type="text" id="productNameSearchInput" placeholder="搜索商品名称" oninput="filterProductNameOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
|
|
</div>
|
|
<div class="select-body">
|
|
<div id="productNameOptionsList" class="select-list">
|
|
<!-- 商品名称选项将通过JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
|
|
<button onclick="hideProductNameSelectModal()" style="padding: 10px 24px; background-color: #f5f5f5; color: #666; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease;">取消</button>
|
|
<button onclick="confirmProductNameSelection()" style="padding: 10px 24px; background-color: #1677ff; color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease;">确定</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 蛋黄类型选择弹窗 -->
|
|
<div id="yolkSelectModal" class="select-modal">
|
|
<div class="select-content">
|
|
<div class="select-header">
|
|
<h3>选择蛋黄类型</h3>
|
|
<button class="close-btn" onclick="hideYolkSelectModal()">×</button>
|
|
</div>
|
|
<div class="select-search">
|
|
<input type="text" id="yolkSearchInput" placeholder="搜索蛋黄类型" oninput="filterYolkOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
|
|
</div>
|
|
<div class="select-body">
|
|
<div id="yolkOptionsList" class="select-list">
|
|
<!-- 蛋黄类型选项将通过JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
|
|
<button onclick="hideYolkSelectModal()" style="padding: 10px 24px; background-color: #f5f5f5; color: #666; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease;">取消</button>
|
|
<button onclick="confirmYolkSelection()" style="padding: 10px 24px; background-color: #1677ff; color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease;">确定</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 联系人选择弹窗 -->
|
|
<div id="contactIdSelectModal" class="select-modal">
|
|
<div class="select-content">
|
|
<div class="select-header">
|
|
<h3>选择联系人</h3>
|
|
<button class="close-btn" onclick="hideContactIdSelectModal()">×</button>
|
|
</div>
|
|
<div class="select-search">
|
|
<input type="text" id="contactIdSearchInput" placeholder="搜索联系人" oninput="filterContactIdOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
|
|
</div>
|
|
<div class="select-body">
|
|
<div id="contactIdOptionsList" class="select-list">
|
|
<!-- 联系人选项将通过JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
|
|
<button onclick="hideContactIdSelectModal()" style="padding: 10px 24px; background-color: #f5f5f5; color: #666; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease;">取消</button>
|
|
<button onclick="confirmContactIdSelection()" style="padding: 10px 24px; background-color: #1677ff; color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease;">确定</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 规格选择弹窗 -->
|
|
<div id="specSelectModal" class="select-modal">
|
|
<div class="select-content">
|
|
<div class="select-header">
|
|
<h3>选择规格</h3>
|
|
<button class="close-btn" onclick="hideSpecSelectModal()">×</button>
|
|
</div>
|
|
<div class="select-search">
|
|
<input type="text" id="specSearchInput" placeholder="搜索规格" oninput="filterSpecOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
|
|
</div>
|
|
<div class="select-body">
|
|
<div id="specOptionsList" class="select-list">
|
|
<!-- 规格选项将通过JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
|
|
<button onclick="hideSpecSelectModal()" style="padding: 10px 24px; background-color: #f5f5f5; color: #666; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease;">取消</button>
|
|
<button onclick="confirmSpecSelection()" style="padding: 10px 24px; background-color: #1677ff; color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease;">确定</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 地区选择弹窗 -->
|
|
<div id="regionSelectModal" class="select-modal">
|
|
<div class="select-content">
|
|
<div class="select-header">
|
|
<h3>选择地区</h3>
|
|
<button class="close-btn" onclick="hideRegionSelectModal()">×</button>
|
|
</div>
|
|
<div class="select-search">
|
|
<input type="text" id="regionSearchInput" placeholder="搜索地区" oninput="filterRegionOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
|
|
<div id="currentRegion" style="margin-top: 10px; padding: 8px 12px; background-color: #f0f8ff; border: 1px solid #91d5ff; border-radius: 4px; font-size: 12px; color: #1890ff;">当前选择: 未选择</div>
|
|
</div>
|
|
<div class="select-body">
|
|
<div id="regionOptionsList" style="display: flex; gap: 10px; padding: 10px;">
|
|
<!-- 省市区选择将通过JavaScript动态生成 -->
|
|
<div id="provinceList" style="flex: 1; overflow-y: auto;"></div>
|
|
<div id="cityList" style="flex: 1; overflow-y: auto;"></div>
|
|
<div id="districtList" style="flex: 1; overflow-y: auto;"></div>
|
|
</div>
|
|
</div>
|
|
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
|
|
<button onclick="hideRegionSelectModal()" style="padding: 10px 24px; background-color: #f5f5f5; color: #666; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease;">取消</button>
|
|
<button onclick="confirmRegionSelection()" style="padding: 10px 24px; background-color: #1677ff; color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease;">确定</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 种类选择弹窗 -->
|
|
<div id="categorySelectModal" class="select-modal">
|
|
<div class="select-content">
|
|
<div class="select-header">
|
|
<h3>选择种类</h3>
|
|
<button class="close-btn" onclick="hideCategorySelectModal()">×</button>
|
|
</div>
|
|
<div class="select-search">
|
|
<input type="text" id="categorySearchInput" placeholder="搜索种类" oninput="filterCategoryOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
|
|
</div>
|
|
<div class="select-body">
|
|
<div id="categoryOptionsList" class="select-list">
|
|
<!-- 种类选项将通过JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
|
|
<button onclick="hideCategorySelectModal()" style="padding: 10px 24px; background-color: #f5f5f5; color: #666; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease;">取消</button>
|
|
<button onclick="confirmCategorySelection()" style="padding: 10px 24px; background-color: #1677ff; color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease;">确定</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 审核失败原因弹窗 -->
|
|
<div id="rejectReasonModal" class="modal">
|
|
<div class="modal-content" style="max-width: 500px; max-height: 500px; border-radius: 8px; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);">
|
|
<div class="modal-header">
|
|
<h2 class="modal-title">审核失败原因</h2>
|
|
<button class="close-btn" onclick="closeRejectReasonModal()">×</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div id="rejectReasonContent" style="min-height: 100px; padding: 15px; background-color: #f8f9fa; border-radius: 4px; white-space: pre-wrap; font-size: 14px;"></div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="supply-actions button btn-success" onclick="resubmitRejectedSupply()" style="padding: 8px 20px;">重新提交</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 编辑货源模态框 -->
|
|
<div id="editSupplyModal" class="modal">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h2 class="modal-title">编辑货源</h2>
|
|
<button class="close-btn" onclick="hideEditSupplyModal()">×</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form id="editSupplyForm">
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">货源状态</label>
|
|
<div style="display: flex; gap: 10px;">
|
|
<button type="button" id="editPreSaleBtn" class="status-button" onclick="setEditSupplyStatus('预售')" style="padding: 8px 20px; border: 2px solid #d9d9d9; background-color: white; color: #666; border-radius: 6px; cursor: pointer;">预售</button>
|
|
<button type="button" id="editInStockBtn" class="status-button" onclick="setEditSupplyStatus('现货')" style="padding: 8px 20px; border: 2px solid #d9d9d9; background-color: white; color: #666; border-radius: 6px; cursor: pointer;">现货</button>
|
|
<input type="hidden" id="editSupplyStatus" value="">
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 商品图片 -->
|
|
<div class="form-group">
|
|
<label class="form-label">商品图片</label>
|
|
<div id="editUploadImages" class="upload-images" style="display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 15px;">
|
|
<!-- 图片将通过JavaScript动态加载 -->
|
|
</div>
|
|
<div style="font-size: 12px; color: #999;">提示:图片暂不支持编辑</div>
|
|
</div>
|
|
|
|
<!-- 货源类型 -->
|
|
<div class="form-group">
|
|
<label class="form-label">货源类型</label>
|
|
<div class="form-select" id="editSourceTypeSelect" onclick="showEditSourceTypeSelectModal()" style="cursor: pointer; position: relative; padding-right: 30px;">
|
|
<span id="editSourceTypeDisplayText">请选择货源类型</span>
|
|
<input type="hidden" id="editSourceType" name="sourceType">
|
|
<span style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999;">▼</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 种类 -->
|
|
<div class="form-group">
|
|
<label class="form-label">种类</label>
|
|
<div class="form-select" id="editCategorySelect" onclick="showEditCategorySelectModal()" style="cursor: pointer; position: relative; padding-right: 30px;">
|
|
<span id="editCategoryDisplayText">请选择种类</span>
|
|
<input type="hidden" id="editCategory" name="category">
|
|
<span style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999;">▼</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 商品名称 -->
|
|
<div class="form-group">
|
|
<label class="form-label">商品名称</label>
|
|
<div class="form-select" id="editProductNameSelect" onclick="showEditProductNameSelectModal()" style="cursor: pointer; position: relative; padding-right: 30px;">
|
|
<span id="editProductNameDisplayText">请选择商品名称</span>
|
|
<input type="hidden" id="editProductName" name="productName">
|
|
<span style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999;">▼</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 蛋黄类型 -->
|
|
<div class="form-group">
|
|
<label class="form-label">蛋黄类型</label>
|
|
<div class="form-select" id="editYolkSelect" onclick="showEditYolkSelectModal()" style="cursor: pointer; position: relative; padding-right: 30px;">
|
|
<span id="editYolkDisplayText">请选择蛋黄类型</span>
|
|
<input type="hidden" id="editYolk" name="yolk">
|
|
<span style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999;">▼</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 规格 -->
|
|
<div class="form-group">
|
|
<label class="form-label">规格</label>
|
|
<div class="form-select" id="editSpec" onclick="showEditSpecSelectModal()" style="cursor: pointer; position: relative; padding-right: 30px;">
|
|
<span id="editSpecDisplayText">请选择规格</span>
|
|
<input type="hidden" id="editSpecValue" name="spec">
|
|
<span style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999;">▼</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 地区 -->
|
|
<div class="form-group">
|
|
<label class="form-label">地区</label>
|
|
<div class="form-select" id="editRegion" onclick="showEditRegionSelectModal()" style="cursor: pointer; position: relative; padding-right: 30px;">
|
|
<span id="editRegionDisplayText">请选择地区</span>
|
|
<input type="hidden" id="editRegionValue" name="region">
|
|
<span style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999;">▼</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 分配联系人 -->
|
|
<div class="form-group">
|
|
<label class="form-label">分配联系人</label>
|
|
<div class="form-select" id="editContactIdSelect" onclick="showEditContactIdSelectModal()" style="cursor: pointer; position: relative; padding-right: 30px;">
|
|
<span id="editContactIdDisplayText">请选择联系人</span>
|
|
<input type="hidden" id="editContactId" name="contactId">
|
|
<span style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #999;">▼</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 价格 -->
|
|
<div class="form-group">
|
|
<label class="form-label">价格</label>
|
|
<input type="number" class="form-input" id="editPrice" placeholder="请输入价格" step="0.01">
|
|
</div>
|
|
|
|
<!-- 件数 -->
|
|
<div class="form-group">
|
|
<label class="form-label">件数</label>
|
|
<input type="number" class="form-input" id="editQuantity" placeholder="请输入件数">
|
|
</div>
|
|
|
|
<!-- 斤重 -->
|
|
<div class="form-group">
|
|
<label class="form-label">斤重</label>
|
|
<input type="text" class="form-input" id="editGrossWeight" placeholder="请输入斤重">
|
|
</div>
|
|
|
|
<!-- 货源描述 -->
|
|
<div class="form-group">
|
|
<label class="form-label">货源描述</label>
|
|
<input type="text" class="form-input" id="editDescription" placeholder="请输入货源描述">
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="modal-btn modal-btn-cancel" onclick="hideEditSupplyModal()">取消</button>
|
|
<button class="modal-btn modal-btn-primary" onclick="saveEditSupply()">保存</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 编辑规格选择弹窗 -->
|
|
<div id="editSpecSelectModal" class="select-modal">
|
|
<div class="select-content">
|
|
<div class="select-header">
|
|
<h3>选择规格</h3>
|
|
<button class="close-btn" onclick="hideEditSpecSelectModal()">×</button>
|
|
</div>
|
|
<div class="select-search">
|
|
<input type="text" id="editSpecSearchInput" placeholder="搜索规格" oninput="filterEditSpecOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
|
|
</div>
|
|
<div class="select-body">
|
|
<div id="editSpecOptionsList" class="select-list">
|
|
<!-- 规格选项将通过JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
|
|
<button onclick="hideEditSpecSelectModal()" style="padding: 8px 20px; background-color: #f5f5f5; color: #666; border: none; border-radius: 6px; cursor: pointer;">取消</button>
|
|
<button onclick="confirmEditSpecSelection()" style="padding: 8px 20px; background-color: #1677ff; color: white; border: none; border-radius: 6px; cursor: pointer;">确定</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 编辑货源类型选择弹窗 -->
|
|
<div id="editSourceTypeSelectModal" class="select-modal">
|
|
<div class="select-content">
|
|
<div class="select-header">
|
|
<h3>选择货源类型</h3>
|
|
<button class="close-btn" onclick="hideEditSourceTypeSelectModal()">×</button>
|
|
</div>
|
|
<div class="select-search">
|
|
<input type="text" id="editSourceTypeSearchInput" placeholder="搜索货源类型" oninput="filterEditSourceTypeOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
|
|
</div>
|
|
<div class="select-body">
|
|
<div id="editSourceTypeOptionsList" class="select-list">
|
|
<!-- 货源类型选项将通过JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
|
|
<button onclick="hideEditSourceTypeSelectModal()" style="padding: 8px 20px; background-color: #f5f5f5; color: #666; border: none; border-radius: 6px; cursor: pointer;">取消</button>
|
|
<button onclick="confirmEditSourceTypeSelection()" style="padding: 8px 20px; background-color: #1677ff; color: white; border: none; border-radius: 6px; cursor: pointer;">确定</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 编辑种类选择弹窗 -->
|
|
<div id="editCategorySelectModal" class="select-modal">
|
|
<div class="select-content">
|
|
<div class="select-header">
|
|
<h3>选择种类</h3>
|
|
<button class="close-btn" onclick="hideEditCategorySelectModal()">×</button>
|
|
</div>
|
|
<div class="select-search">
|
|
<input type="text" id="editCategorySearchInput" placeholder="搜索种类" oninput="filterEditCategoryOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
|
|
</div>
|
|
<div class="select-body">
|
|
<div id="editCategoryOptionsList" class="select-list">
|
|
<!-- 种类选项将通过JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
|
|
<button onclick="hideEditCategorySelectModal()" style="padding: 8px 20px; background-color: #f5f5f5; color: #666; border: none; border-radius: 6px; cursor: pointer;">取消</button>
|
|
<button onclick="confirmEditCategorySelection()" style="padding: 8px 20px; background-color: #1677ff; color: white; border: none; border-radius: 6px; cursor: pointer;">确定</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 编辑商品名称选择弹窗 -->
|
|
<div id="editProductNameSelectModal" class="select-modal">
|
|
<div class="select-content">
|
|
<div class="select-header">
|
|
<h3>选择商品名称</h3>
|
|
<button class="close-btn" onclick="hideEditProductNameSelectModal()">×</button>
|
|
</div>
|
|
<div class="select-search">
|
|
<input type="text" id="editProductNameSearchInput" placeholder="搜索商品名称" oninput="filterEditProductNameOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
|
|
</div>
|
|
<div class="select-body">
|
|
<div id="editProductNameOptionsList" class="select-list">
|
|
<!-- 商品名称选项将通过JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
|
|
<button onclick="hideEditProductNameSelectModal()" style="padding: 8px 20px; background-color: #f5f5f5; color: #666; border: none; border-radius: 6px; cursor: pointer;">取消</button>
|
|
<button onclick="confirmEditProductNameSelection()" style="padding: 8px 20px; background-color: #1677ff; color: white; border: none; border-radius: 6px; cursor: pointer;">确定</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 编辑蛋黄类型选择弹窗 -->
|
|
<div id="editYolkSelectModal" class="select-modal">
|
|
<div class="select-content">
|
|
<div class="select-header">
|
|
<h3>选择蛋黄类型</h3>
|
|
<button class="close-btn" onclick="hideEditYolkSelectModal()">×</button>
|
|
</div>
|
|
<div class="select-search">
|
|
<input type="text" id="editYolkSearchInput" placeholder="搜索蛋黄类型" oninput="filterEditYolkOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
|
|
</div>
|
|
<div class="select-body">
|
|
<div id="editYolkOptionsList" class="select-list">
|
|
<!-- 蛋黄类型选项将通过JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
|
|
<button onclick="hideEditYolkSelectModal()" style="padding: 8px 20px; background-color: #f5f5f5; color: #666; border: none; border-radius: 6px; cursor: pointer;">取消</button>
|
|
<button onclick="confirmEditYolkSelection()" style="padding: 8px 20px; background-color: #1677ff; color: white; border: none; border-radius: 6px; cursor: pointer;">确定</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 编辑联系人选择弹窗 -->
|
|
<div id="editContactIdSelectModal" class="select-modal">
|
|
<div class="select-content">
|
|
<div class="select-header">
|
|
<h3>选择联系人</h3>
|
|
<button class="close-btn" onclick="hideEditContactIdSelectModal()">×</button>
|
|
</div>
|
|
<div class="select-search">
|
|
<input type="text" id="editContactIdSearchInput" placeholder="搜索联系人" oninput="filterEditContactIdOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
|
|
</div>
|
|
<div class="select-body">
|
|
<div id="editContactIdOptionsList" class="select-list">
|
|
<!-- 联系人选项将通过JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
|
|
<button onclick="hideEditContactIdSelectModal()" style="padding: 8px 20px; background-color: #f5f5f5; color: #666; border: none; border-radius: 6px; cursor: pointer;">取消</button>
|
|
<button onclick="confirmEditContactIdSelection()" style="padding: 8px 20px; background-color: #1677ff; color: white; border: none; border-radius: 6px; cursor: pointer;">确定</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 编辑地区选择弹窗 -->
|
|
<div id="editRegionSelectModal" class="select-modal">
|
|
<div class="select-content">
|
|
<div class="select-header">
|
|
<h3>选择地区</h3>
|
|
<button class="close-btn" onclick="hideEditRegionSelectModal()">×</button>
|
|
</div>
|
|
<div class="select-search">
|
|
<input type="text" id="editRegionSearchInput" placeholder="搜索地区" oninput="filterEditRegionOptions()" style="width: 100%; padding: 10px; border: 1px solid #d9d9d9; border-radius: 8px; font-size: 14px;">
|
|
<div id="editCurrentRegion" style="margin-top: 10px; padding: 8px 12px; background-color: #f0f8ff; border: 1px solid #91d5ff; border-radius: 4px; font-size: 12px; color: #1890ff;">当前选择: 未选择</div>
|
|
</div>
|
|
<div class="select-body">
|
|
<div id="editRegionOptionsList" style="display: flex; gap: 10px; padding: 10px;">
|
|
<!-- 省市区选择将通过JavaScript动态生成 -->
|
|
<div id="editProvinceList" style="flex: 1; overflow-y: auto;"></div>
|
|
<div id="editCityList" style="flex: 1; overflow-y: auto;"></div>
|
|
<div id="editDistrictList" style="flex: 1; overflow-y: auto;"></div>
|
|
</div>
|
|
</div>
|
|
<div class="select-footer" style="padding: 16px 20px; display: flex; justify-content: space-between; border-top: 1px solid #f0f0f0; background-color: #fafafa;">
|
|
<button onclick="hideEditRegionSelectModal()" style="padding: 8px 20px; background-color: #f5f5f5; color: #666; border: none; border-radius: 6px; cursor: pointer;">取消</button>
|
|
<button onclick="confirmEditRegionSelection()" style="padding: 8px 20px; background-color: #1677ff; color: white; border: none; border-radius: 6px; cursor: pointer;">确定</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// 全局变量
|
|
let supplyData = {
|
|
supplies: [],
|
|
publishedSupplies: [],
|
|
pendingSupplies: [],
|
|
rejectedSupplies: [],
|
|
draftSupplies: [],
|
|
searchKeyword: '',
|
|
partnerstatus: 'approved',
|
|
uploadedImages: [],
|
|
// 分页相关属性
|
|
pagination: {
|
|
published: { currentPage: 1, pageSize: 20, total: 0, hasMore: true, isLoading: false },
|
|
pending: { currentPage: 1, pageSize: 20, total: 0, hasMore: true, isLoading: false },
|
|
rejected: { currentPage: 1, pageSize: 20, total: 0, hasMore: true, isLoading: false },
|
|
draft: { currentPage: 1, pageSize: 20, total: 0, hasMore: true, isLoading: false }
|
|
},
|
|
// 分状态存储分页数据
|
|
paginatedSupplies: {
|
|
published: [],
|
|
pending: [],
|
|
rejected: [],
|
|
draft: []
|
|
}
|
|
};
|
|
|
|
// 编辑相关全局变量
|
|
let currentEditSupplyId = null;
|
|
let editSelectedSpec = '';
|
|
let editSelectedProvince = '';
|
|
let editSelectedCity = '';
|
|
let editSelectedDistrict = '';
|
|
let editAllSourceTypes = ['平台货源', '三方认证', '三方未认证'];
|
|
let editFilteredSourceTypes = [...editAllSourceTypes];
|
|
let editSelectedSourceType = '';
|
|
let editAllCategories = ['粉壳', '红壳', '绿壳', '白壳'];
|
|
let editFilteredCategories = [...editAllCategories];
|
|
let editSelectedCategory = '';
|
|
let editAllProductNames = ['罗曼粉', '伊莎粉', '罗曼灰', '海蓝灰', '海蓝褐', '绿壳', '双黄蛋'];
|
|
let editFilteredProductNames = [...editAllProductNames];
|
|
let editSelectedProductName = '';
|
|
let editAllYolkTypes = ['红心', '黄心', '双色'];
|
|
let editFilteredYolkTypes = [...editAllYolkTypes];
|
|
let editSelectedYolk = '';
|
|
let editFilteredContacts = [];
|
|
let editSelectedContactId = '';
|
|
|
|
// 联系人数据
|
|
let contacts = [];
|
|
|
|
// 登录检查
|
|
function checkLogin() {
|
|
const userInfo = localStorage.getItem('userInfo');
|
|
const token = localStorage.getItem('token');
|
|
|
|
if (!userInfo || !token) {
|
|
// 未登录,跳转到登录页面
|
|
window.location.href = 'login.html';
|
|
return false;
|
|
}
|
|
|
|
// 已登录,解析用户信息
|
|
const parsedUserInfo = JSON.parse(userInfo);
|
|
|
|
// 展示登录信息
|
|
const applySettlementBtn = document.querySelector('.apply-settlement-btn');
|
|
if (applySettlementBtn) {
|
|
applySettlementBtn.innerHTML = `${parsedUserInfo.name} (${parsedUserInfo.phoneNumber})`;
|
|
applySettlementBtn.style.cursor = 'pointer';
|
|
// 添加点击事件,显示用户信息详情
|
|
applySettlementBtn.onclick = () => {
|
|
alert(`当前登录用户:${parsedUserInfo.name}\n职位:${parsedUserInfo.projectName}\n手机号:${parsedUserInfo.phoneNumber}\n用户ID:${parsedUserInfo.userId || parsedUserInfo.id || '未获取到'}`);
|
|
};
|
|
}
|
|
|
|
// 更新页面上的当前用户信息提示
|
|
const currentUserInfoEl = document.getElementById('currentUserInfo');
|
|
if (currentUserInfoEl) {
|
|
const userId = parsedUserInfo.userId || parsedUserInfo.id || '未获取到';
|
|
currentUserInfoEl.innerHTML = `当前登录用户:${parsedUserInfo.name} | 用户ID:${userId} | 职位:${parsedUserInfo.projectName}`;
|
|
}
|
|
|
|
return parsedUserInfo;
|
|
}
|
|
|
|
// 初始化
|
|
window.onload = function() {
|
|
// 登录检查
|
|
const userInfo = checkLogin();
|
|
if (!userInfo) {
|
|
return;
|
|
}
|
|
|
|
loadSupplies();
|
|
loadContacts();
|
|
bindEvents();
|
|
};
|
|
|
|
// 绑定事件
|
|
function bindEvents() {
|
|
// 监听窗口大小变化
|
|
window.addEventListener('resize', handleResize);
|
|
|
|
// 拖拽上传事件
|
|
const uploadArea = document.querySelector('.upload-area');
|
|
uploadArea.addEventListener('dragenter', (e) => {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
uploadArea.style.borderColor = '#1677ff';
|
|
uploadArea.style.backgroundColor = '#f0f8ff';
|
|
});
|
|
|
|
uploadArea.addEventListener('dragover', (e) => {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
});
|
|
|
|
uploadArea.addEventListener('dragleave', (e) => {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
uploadArea.style.borderColor = '#d9d9d9';
|
|
uploadArea.style.backgroundColor = '#fff';
|
|
});
|
|
|
|
uploadArea.addEventListener('drop', (e) => {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
uploadArea.style.borderColor = '#d9d9d9';
|
|
uploadArea.style.backgroundColor = '#fff';
|
|
|
|
const files = Array.from(e.dataTransfer.files);
|
|
// 过滤出图片文件
|
|
const imageFiles = files.filter(file => file.type.startsWith('image/'));
|
|
|
|
if (imageFiles.length > 0) {
|
|
handleDroppedImages(imageFiles);
|
|
}
|
|
});
|
|
|
|
// 复制粘贴上传事件
|
|
document.addEventListener('paste', (e) => {
|
|
// 检查是否在创建货源模态框中
|
|
const createSupplyModal = document.getElementById('createSupplyModal');
|
|
if (createSupplyModal.style.display !== 'flex') {
|
|
return;
|
|
}
|
|
|
|
// 检查是否有粘贴的图片
|
|
const items = e.clipboardData.items;
|
|
const imageFiles = [];
|
|
|
|
for (let i = 0; i < items.length; i++) {
|
|
if (items[i].type.startsWith('image/')) {
|
|
const file = items[i].getAsFile();
|
|
if (file) {
|
|
imageFiles.push(file);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (imageFiles.length > 0) {
|
|
handleDroppedImages(imageFiles);
|
|
}
|
|
});
|
|
}
|
|
|
|
// 处理拖拽或粘贴的图片
|
|
async function handleDroppedImages(imageFiles) {
|
|
for (let i = 0; i < imageFiles.length; i++) {
|
|
if (supplyData.uploadedImages.length >= 5) {
|
|
alert('最多只能上传5张图片');
|
|
break;
|
|
}
|
|
|
|
const file = imageFiles[i];
|
|
const reader = new FileReader();
|
|
|
|
reader.onload = async function(e) {
|
|
let imageUrl = e.target.result;
|
|
|
|
// 为图片添加水印
|
|
imageUrl = await addWatermarkToImage(imageUrl);
|
|
|
|
supplyData.uploadedImages.push(imageUrl);
|
|
renderUploadedImages();
|
|
// 图片上传后自动保存表单数据
|
|
saveFormData();
|
|
};
|
|
|
|
reader.readAsDataURL(file);
|
|
}
|
|
}
|
|
|
|
// 规格选择功能
|
|
let allSpecOptions = ['格子装', '散托', '不限规格', '净重47+', '净重46-47', '净重45-46', '净重44-45', '净重43-44', '净重42-43', '净重41-42', '净重40-41', '净重39-40', '净重38-39', '净重37-39', '净重37-38', '净重36-38', '净重36-37', '净重35-36', '净重34-35', '净重33-34', '净重32-33', '净重32-34', '净重31-32', '净重30-35', '净重30-34', '净重30-32', '净重30-31', '净重29-31', '净重29-30', '净重28-29', '净重28以下', '毛重52以上', '毛重50-51', '毛重48-49', '毛重47-48', '毛重46-47', '毛重45-47', '毛重45-46', '毛重44-45', '毛重43-44', '毛重42-43', '毛重41-42', '毛重40-41', '毛重38-39', '毛重36-37', '毛重34-35', '毛重32-33', '毛重30-31', '毛重30以下'];
|
|
let filteredSpecOptions = [...allSpecOptions];
|
|
let selectedSpec = '';
|
|
|
|
// 货源类型选择功能
|
|
let allSourceTypeOptions = ['平台货源', '三方认证', '三方未认证'];
|
|
let filteredSourceTypeOptions = [...allSourceTypeOptions];
|
|
let selectedSourceType = '';
|
|
|
|
// 商品名称选择功能
|
|
let allProductNameOptions = ['罗曼粉', '伊莎粉', '罗曼灰', '海蓝灰', '海蓝褐', '绿壳', '双黄蛋'];
|
|
let filteredProductNameOptions = [...allProductNameOptions];
|
|
let selectedProductName = '';
|
|
|
|
// 蛋黄类型选择功能
|
|
let allYolkOptions = ['红心', '黄心', '双色'];
|
|
let filteredYolkOptions = [...allYolkOptions];
|
|
let selectedYolk = '';
|
|
|
|
// 种类选择功能
|
|
let allCategoryOptions = ['粉壳', '红壳', '绿壳', '白壳'];
|
|
let filteredCategoryOptions = [...allCategoryOptions];
|
|
let selectedCategory = '';
|
|
|
|
// 联系人选择功能
|
|
let filteredContactIdOptions = [];
|
|
let selectedContactId = '';
|
|
|
|
// 显示规格选择弹窗
|
|
function showSpecSelectModal() {
|
|
const specSelectModal = document.getElementById('specSelectModal');
|
|
specSelectModal.classList.add('active');
|
|
// 重置搜索输入
|
|
document.getElementById('specSearchInput').value = '';
|
|
filteredSpecOptions = [...allSpecOptions];
|
|
generateSpecOptions();
|
|
}
|
|
|
|
// 隐藏规格选择弹窗
|
|
function hideSpecSelectModal() {
|
|
const specSelectModal = document.getElementById('specSelectModal');
|
|
specSelectModal.classList.remove('active');
|
|
}
|
|
|
|
// 生成规格选项
|
|
function generateSpecOptions() {
|
|
const specOptionsList = document.getElementById('specOptionsList');
|
|
specOptionsList.innerHTML = '';
|
|
|
|
filteredSpecOptions.forEach(spec => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = spec;
|
|
option.onclick = () => {
|
|
// 移除所有选项的选中状态
|
|
document.querySelectorAll('.select-item').forEach(item => {
|
|
item.classList.remove('selected');
|
|
});
|
|
// 添加当前选项的选中状态
|
|
option.classList.add('selected');
|
|
selectedSpec = spec;
|
|
};
|
|
option.ondblclick = () => {
|
|
// 双击直接确认选择
|
|
document.getElementById('specDisplayText').textContent = spec;
|
|
document.getElementById('specValue').value = spec;
|
|
hideSpecSelectModal();
|
|
};
|
|
specOptionsList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 过滤规格选项
|
|
function filterSpecOptions() {
|
|
const searchInput = document.getElementById('specSearchInput');
|
|
const searchKeyword = searchInput.value.toLowerCase();
|
|
|
|
filteredSpecOptions = allSpecOptions.filter(spec => {
|
|
return spec.toLowerCase().includes(searchKeyword);
|
|
});
|
|
|
|
generateSpecOptions();
|
|
}
|
|
|
|
// 确认规格选择
|
|
function confirmSpecSelection() {
|
|
if (selectedSpec) {
|
|
document.getElementById('specDisplayText').textContent = selectedSpec;
|
|
document.getElementById('specValue').value = selectedSpec;
|
|
}
|
|
hideSpecSelectModal();
|
|
}
|
|
|
|
// 显示货源类型选择弹窗
|
|
function showSourceTypeSelectModal() {
|
|
const sourceTypeSelectModal = document.getElementById('sourceTypeSelectModal');
|
|
sourceTypeSelectModal.classList.add('active');
|
|
// 重置搜索输入
|
|
document.getElementById('sourceTypeSearchInput').value = '';
|
|
filteredSourceTypeOptions = [...allSourceTypeOptions];
|
|
generateSourceTypeOptions();
|
|
}
|
|
|
|
// 隐藏货源类型选择弹窗
|
|
function hideSourceTypeSelectModal() {
|
|
const sourceTypeSelectModal = document.getElementById('sourceTypeSelectModal');
|
|
sourceTypeSelectModal.classList.remove('active');
|
|
}
|
|
|
|
// 生成货源类型选项
|
|
function generateSourceTypeOptions() {
|
|
const sourceTypeOptionsList = document.getElementById('sourceTypeOptionsList');
|
|
sourceTypeOptionsList.innerHTML = '';
|
|
|
|
filteredSourceTypeOptions.forEach(sourceType => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = sourceType;
|
|
if (sourceType === selectedSourceType) {
|
|
option.classList.add('selected');
|
|
}
|
|
option.onclick = () => {
|
|
// 移除所有选项的选中状态
|
|
document.querySelectorAll('#sourceTypeOptionsList .select-item').forEach(item => {
|
|
item.classList.remove('selected');
|
|
});
|
|
// 添加当前选项的选中状态
|
|
option.classList.add('selected');
|
|
selectedSourceType = sourceType;
|
|
};
|
|
option.ondblclick = () => {
|
|
// 双击直接确认选择
|
|
document.getElementById('sourceTypeDisplayText').textContent = sourceType;
|
|
document.getElementById('sourceType').value = sourceType;
|
|
hideSourceTypeSelectModal();
|
|
saveFormData(); // 保存选择
|
|
};
|
|
sourceTypeOptionsList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 过滤货源类型选项
|
|
function filterSourceTypeOptions() {
|
|
const searchInput = document.getElementById('sourceTypeSearchInput');
|
|
const searchKeyword = searchInput.value.toLowerCase();
|
|
|
|
filteredSourceTypeOptions = allSourceTypeOptions.filter(sourceType => {
|
|
return sourceType.toLowerCase().includes(searchKeyword);
|
|
});
|
|
|
|
generateSourceTypeOptions();
|
|
}
|
|
|
|
// 确认货源类型选择
|
|
function confirmSourceTypeSelection() {
|
|
if (selectedSourceType) {
|
|
document.getElementById('sourceTypeDisplayText').textContent = selectedSourceType;
|
|
document.getElementById('sourceType').value = selectedSourceType;
|
|
}
|
|
hideSourceTypeSelectModal();
|
|
saveFormData(); // 保存选择
|
|
}
|
|
|
|
// 显示商品名称选择弹窗
|
|
function showProductNameSelectModal() {
|
|
const productNameSelectModal = document.getElementById('productNameSelectModal');
|
|
productNameSelectModal.classList.add('active');
|
|
// 重置搜索输入
|
|
document.getElementById('productNameSearchInput').value = '';
|
|
filteredProductNameOptions = [...allProductNameOptions];
|
|
generateProductNameOptions();
|
|
}
|
|
|
|
// 隐藏商品名称选择弹窗
|
|
function hideProductNameSelectModal() {
|
|
const productNameSelectModal = document.getElementById('productNameSelectModal');
|
|
productNameSelectModal.classList.remove('active');
|
|
}
|
|
|
|
// 生成商品名称选项
|
|
function generateProductNameOptions() {
|
|
const productNameOptionsList = document.getElementById('productNameOptionsList');
|
|
productNameOptionsList.innerHTML = '';
|
|
|
|
filteredProductNameOptions.forEach(productName => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = productName;
|
|
if (productName === selectedProductName) {
|
|
option.classList.add('selected');
|
|
}
|
|
option.onclick = () => {
|
|
// 移除所有选项的选中状态
|
|
document.querySelectorAll('#productNameOptionsList .select-item').forEach(item => {
|
|
item.classList.remove('selected');
|
|
});
|
|
// 添加当前选项的选中状态
|
|
option.classList.add('selected');
|
|
selectedProductName = productName;
|
|
};
|
|
option.ondblclick = () => {
|
|
// 双击直接确认选择
|
|
document.getElementById('productNameDisplayText').textContent = productName;
|
|
document.getElementById('productName').value = productName;
|
|
hideProductNameSelectModal();
|
|
saveFormData(); // 保存选择
|
|
};
|
|
productNameOptionsList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 过滤商品名称选项
|
|
function filterProductNameOptions() {
|
|
const searchInput = document.getElementById('productNameSearchInput');
|
|
const searchKeyword = searchInput.value.toLowerCase();
|
|
|
|
filteredProductNameOptions = allProductNameOptions.filter(productName => {
|
|
return productName.toLowerCase().includes(searchKeyword);
|
|
});
|
|
|
|
generateProductNameOptions();
|
|
}
|
|
|
|
// 确认商品名称选择
|
|
function confirmProductNameSelection() {
|
|
if (selectedProductName) {
|
|
document.getElementById('productNameDisplayText').textContent = selectedProductName;
|
|
document.getElementById('productName').value = selectedProductName;
|
|
}
|
|
hideProductNameSelectModal();
|
|
saveFormData(); // 保存选择
|
|
}
|
|
|
|
// 显示蛋黄类型选择弹窗
|
|
function showYolkSelectModal() {
|
|
const yolkSelectModal = document.getElementById('yolkSelectModal');
|
|
yolkSelectModal.classList.add('active');
|
|
// 重置搜索输入
|
|
document.getElementById('yolkSearchInput').value = '';
|
|
filteredYolkOptions = [...allYolkOptions];
|
|
generateYolkOptions();
|
|
}
|
|
|
|
// 隐藏蛋黄类型选择弹窗
|
|
function hideYolkSelectModal() {
|
|
const yolkSelectModal = document.getElementById('yolkSelectModal');
|
|
yolkSelectModal.classList.remove('active');
|
|
}
|
|
|
|
// 生成蛋黄类型选项
|
|
function generateYolkOptions() {
|
|
const yolkOptionsList = document.getElementById('yolkOptionsList');
|
|
yolkOptionsList.innerHTML = '';
|
|
|
|
filteredYolkOptions.forEach(yolk => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = yolk;
|
|
if (yolk === selectedYolk) {
|
|
option.classList.add('selected');
|
|
}
|
|
option.onclick = () => {
|
|
// 移除所有选项的选中状态
|
|
document.querySelectorAll('#yolkOptionsList .select-item').forEach(item => {
|
|
item.classList.remove('selected');
|
|
});
|
|
// 添加当前选项的选中状态
|
|
option.classList.add('selected');
|
|
selectedYolk = yolk;
|
|
};
|
|
option.ondblclick = () => {
|
|
// 双击直接确认选择
|
|
document.getElementById('yolkDisplayText').textContent = yolk;
|
|
document.getElementById('yolk').value = yolk;
|
|
hideYolkSelectModal();
|
|
saveFormData(); // 保存选择
|
|
};
|
|
yolkOptionsList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 过滤蛋黄类型选项
|
|
function filterYolkOptions() {
|
|
const searchInput = document.getElementById('yolkSearchInput');
|
|
const searchKeyword = searchInput.value.toLowerCase();
|
|
|
|
filteredYolkOptions = allYolkOptions.filter(yolk => {
|
|
return yolk.toLowerCase().includes(searchKeyword);
|
|
});
|
|
|
|
generateYolkOptions();
|
|
}
|
|
|
|
// 确认蛋黄类型选择
|
|
function confirmYolkSelection() {
|
|
if (selectedYolk) {
|
|
document.getElementById('yolkDisplayText').textContent = selectedYolk;
|
|
document.getElementById('yolk').value = selectedYolk;
|
|
}
|
|
hideYolkSelectModal();
|
|
saveFormData(); // 保存选择
|
|
}
|
|
|
|
// 显示联系人选择弹窗
|
|
function showContactIdSelectModal() {
|
|
const contactIdSelectModal = document.getElementById('contactIdSelectModal');
|
|
contactIdSelectModal.classList.add('active');
|
|
// 重置搜索输入
|
|
document.getElementById('contactIdSearchInput').value = '';
|
|
filteredContactIdOptions = [...contacts];
|
|
generateContactIdOptions();
|
|
}
|
|
|
|
// 隐藏联系人选择弹窗
|
|
function hideContactIdSelectModal() {
|
|
const contactIdSelectModal = document.getElementById('contactIdSelectModal');
|
|
contactIdSelectModal.classList.remove('active');
|
|
}
|
|
|
|
// 生成联系人选项
|
|
function generateContactIdOptions() {
|
|
const contactIdOptionsList = document.getElementById('contactIdOptionsList');
|
|
contactIdOptionsList.innerHTML = '';
|
|
|
|
filteredContactIdOptions.forEach(contact => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = `${contact.name} (${contact.phoneNumber})`;
|
|
if (String(contact.id) === String(selectedContactId)) {
|
|
option.classList.add('selected');
|
|
}
|
|
option.onclick = () => {
|
|
// 移除所有选项的选中状态
|
|
document.querySelectorAll('#contactIdOptionsList .select-item').forEach(item => {
|
|
item.classList.remove('selected');
|
|
});
|
|
// 添加当前选项的选中状态
|
|
option.classList.add('selected');
|
|
selectedContactId = contact.id;
|
|
};
|
|
option.ondblclick = () => {
|
|
// 双击直接确认选择
|
|
document.getElementById('contactIdDisplayText').textContent = `${contact.name} (${contact.phoneNumber})`;
|
|
document.getElementById('contactId').value = contact.id;
|
|
hideContactIdSelectModal();
|
|
saveFormData(); // 保存选择
|
|
};
|
|
contactIdOptionsList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 过滤联系人选项
|
|
function filterContactIdOptions() {
|
|
const searchInput = document.getElementById('contactIdSearchInput');
|
|
const searchKeyword = searchInput.value.toLowerCase();
|
|
|
|
filteredContactIdOptions = contacts.filter(contact => {
|
|
return contact.name.toLowerCase().includes(searchKeyword) ||
|
|
contact.phoneNumber.toLowerCase().includes(searchKeyword);
|
|
});
|
|
|
|
generateContactIdOptions();
|
|
}
|
|
|
|
// 确认联系人选择
|
|
function confirmContactIdSelection() {
|
|
if (selectedContactId) {
|
|
const contact = contacts.find(c => String(c.id) === String(selectedContactId));
|
|
if (contact) {
|
|
document.getElementById('contactIdDisplayText').textContent = `${contact.name} (${contact.phoneNumber})`;
|
|
}
|
|
document.getElementById('contactId').value = selectedContactId;
|
|
}
|
|
hideContactIdSelectModal();
|
|
saveFormData(); // 保存选择
|
|
}
|
|
|
|
// 显示种类选择弹窗
|
|
function showCategorySelectModal() {
|
|
const categorySelectModal = document.getElementById('categorySelectModal');
|
|
categorySelectModal.classList.add('active');
|
|
// 重置搜索输入
|
|
document.getElementById('categorySearchInput').value = '';
|
|
filteredCategoryOptions = [...allCategoryOptions];
|
|
generateCategoryOptions();
|
|
}
|
|
|
|
// 隐藏种类选择弹窗
|
|
function hideCategorySelectModal() {
|
|
const categorySelectModal = document.getElementById('categorySelectModal');
|
|
categorySelectModal.classList.remove('active');
|
|
}
|
|
|
|
// 生成种类选项
|
|
function generateCategoryOptions() {
|
|
const categoryOptionsList = document.getElementById('categoryOptionsList');
|
|
categoryOptionsList.innerHTML = '';
|
|
|
|
filteredCategoryOptions.forEach(category => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = category;
|
|
if (category === selectedCategory) {
|
|
option.classList.add('selected');
|
|
}
|
|
option.onclick = () => {
|
|
// 移除所有选项的选中状态
|
|
document.querySelectorAll('#categoryOptionsList .select-item').forEach(item => {
|
|
item.classList.remove('selected');
|
|
});
|
|
// 添加当前选项的选中状态
|
|
option.classList.add('selected');
|
|
selectedCategory = category;
|
|
};
|
|
option.ondblclick = () => {
|
|
// 双击直接确认选择
|
|
selectedCategory = category;
|
|
confirmCategorySelection();
|
|
};
|
|
categoryOptionsList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 过滤种类选项
|
|
function filterCategoryOptions() {
|
|
const searchInput = document.getElementById('categorySearchInput');
|
|
const searchTerm = searchInput.value.toLowerCase();
|
|
|
|
filteredCategoryOptions = allCategoryOptions.filter(category => {
|
|
return category.toLowerCase().includes(searchTerm);
|
|
});
|
|
|
|
generateCategoryOptions();
|
|
}
|
|
|
|
// 确认种类选择
|
|
function confirmCategorySelection() {
|
|
if (selectedCategory) {
|
|
const categoryDisplayText = document.getElementById('categoryDisplayText');
|
|
const categoryInput = document.getElementById('category');
|
|
|
|
categoryDisplayText.textContent = selectedCategory;
|
|
categoryInput.value = selectedCategory;
|
|
hideCategorySelectModal();
|
|
saveFormData(); // 保存选择
|
|
}
|
|
}
|
|
|
|
// 地区选择功能
|
|
let allRegionOptions = [
|
|
{ province: '北京市', cities: [
|
|
{ city: '北京市', districts: ['东城区', '西城区', '朝阳区', '丰台区', '石景山区', '海淀区', '门头沟区', '房山区', '通州区', '顺义区', '昌平区', '大兴区', '怀柔区', '平谷区', '密云区', '延庆区'] }
|
|
]},
|
|
{ province: '陕西省', cities: [
|
|
{ city: '西安市', districts: ['新城区', '碑林区', '莲湖区', '灞桥区', '未央区', '雁塔区', '阎良区', '临潼区', '长安区', '高陵区', '鄠邑区', '蓝田县', '周至县'] },
|
|
{ city: '铜川市', districts: ['王益区', '印台区', '耀州区', '宜君县'] },
|
|
{ city: '宝鸡市', districts: ['渭滨区', '金台区', '陈仓区', '凤翔区', '岐山县', '扶风县', '眉县', '陇县', '千阳县', '麟游县', '凤县', '太白县'] },
|
|
{ city: '咸阳市', districts: ['秦都区', '杨陵区', '渭城区', '兴平市', '三原县', '泾阳县', '乾县', '礼泉县', '永寿县', '长武县', '旬邑县', '淳化县', '武功县'] },
|
|
{ city: '渭南市', districts: ['临渭区', '华州区', '韩城市', '华阴市', '潼关县', '大荔县', '合阳县', '澄城县', '蒲城县', '白水县', '富平县'] },
|
|
{ city: '延安市', districts: ['宝塔区', '安塞区', '延长县', '延川县', '子长市', '志丹县', '吴起县', '甘泉县', '富县', '洛川县', '宜川县', '黄龙县', '黄陵县'] },
|
|
{ city: '汉中市', districts: ['汉台区', '南郑区', '城固县', '洋县', '西乡县', '勉县', '宁强县', '略阳县', '镇巴县', '留坝县', '佛坪县'] },
|
|
{ city: '榆林市', districts: ['榆阳区', '横山区', '神木市', '府谷县', '靖边县', '定边县', '绥德县', '米脂县', '佳县', '吴堡县', '清涧县', '子洲县'] },
|
|
{ city: '安康市', districts: ['汉滨区', '汉阴县', '石泉县', '宁陕县', '紫阳县', '岚皋县', '平利县', '镇坪县', '旬阳市', '白河县'] },
|
|
{ city: '商洛市', districts: ['商州区', '洛南县', '丹凤县', '商南县', '山阳县', '镇安县', '柞水县'] }
|
|
]},
|
|
{ province: '甘肃省', cities: [
|
|
{ city: '兰州市', districts: ['城关区', '七里河区', '西固区', '安宁区', '红古区', '永登县', '皋兰县', '榆中县'] },
|
|
{ city: '嘉峪关市', districts: ['嘉峪关市'] },
|
|
{ city: '金昌市', districts: ['金川区', '永昌县'] },
|
|
{ city: '白银市', districts: ['白银区', '平川区', '靖远县', '会宁县', '景泰县'] },
|
|
{ city: '天水市', districts: ['秦州区', '麦积区', '清水县', '秦安县', '甘谷县', '武山县', '张家川回族自治县'] },
|
|
{ city: '武威市', districts: ['凉州区', '民勤县', '古浪县', '天祝藏族自治县'] },
|
|
{ city: '张掖市', districts: ['甘州区', '肃南裕固族自治县', '民乐县', '临泽县', '高台县', '山丹县'] },
|
|
{ city: '平凉市', districts: ['崆峒区', '泾川县', '灵台县', '崇信县', '华亭市', '庄浪县', '静宁县'] },
|
|
{ city: '酒泉市', districts: ['肃州区', '金塔县', '瓜州县', '肃北蒙古族自治县', '阿克塞哈萨克族自治县', '玉门市', '敦煌市'] },
|
|
{ city: '庆阳市', districts: ['西峰区', '庆城县', '环县', '华池县', '合水县', '正宁县', '宁县', '镇原县'] },
|
|
{ city: '定西市', districts: ['安定区', '通渭县', '陇西县', '渭源县', '临洮县', '漳县', '岷县'] },
|
|
{ city: '陇南市', districts: ['武都区', '成县', '文县', '宕昌县', '康县', '西和县', '礼县', '徽县', '两当县'] },
|
|
{ city: '临夏回族自治州', districts: ['临夏市', '临夏县', '康乐县', '永靖县', '广河县', '和政县', '东乡族自治县', '积石山保安族东乡族撒拉族自治县'] },
|
|
{ city: '甘南藏族自治州', districts: ['合作市', '临潭县', '卓尼县', '舟曲县', '迭部县', '玛曲县', '碌曲县', '夏河县'] }
|
|
]},
|
|
{ province: '青海省', cities: [
|
|
{ city: '西宁市', districts: ['城东区', '城中区', '城西区', '城北区', '大通回族土族自治县', '湟中区', '湟源县'] },
|
|
{ city: '海东市', districts: ['乐都区', '平安区', '民和回族土族自治县', '互助土族自治县', '化隆回族自治县', '循化撒拉族自治县'] },
|
|
{ city: '海北藏族自治州', districts: ['海晏县', '祁连县', '刚察县', '门源回族自治县'] },
|
|
{ city: '黄南藏族自治州', districts: ['同仁市', '尖扎县', '泽库县', '河南蒙古族自治县'] },
|
|
{ city: '海南藏族自治州', districts: ['共和县', '同德县', '贵德县', '兴海县', '贵南县'] },
|
|
{ city: '果洛藏族自治州', districts: ['玛沁县', '班玛县', '甘德县', '达日县', '久治县', '玛多县'] },
|
|
{ city: '玉树藏族自治州', districts: ['玉树市', '杂多县', '称多县', '治多县', '囊谦县', '曲麻莱县'] },
|
|
{ city: '海西蒙古族藏族自治州', districts: ['格尔木市', '德令哈市', '茫崖市', '天峻县', '都兰县', '乌兰县'] }
|
|
]},
|
|
{ province: '台湾省', cities: [
|
|
{ city: '台北市', districts: ['中正区', '大同区', '中山区', '松山区', '大安区', '万华区', '信义区', '士林区', '北投区', '内湖区', '南港区', '文山区'] },
|
|
{ city: '高雄市', districts: ['新兴区', '前金区', '苓雅区', '盐埕区', '鼓山区', '旗津区', '前镇区', '三民区', '楠梓区', '小港区', '左营区', '仁武区', '大树区', '鸟松区', '冈山区', '桥头区', '燕巢区', '田寮区', '阿莲区', '路竹区', '湖内区', '茄萣区', '永安区', '弥陀区', '梓官区', '旗山区', '美浓区', '六龟区', '甲仙区', '杉林区', '内门区', '茂林区', '桃源区', '那玛夏区'] },
|
|
{ city: '新北市', districts: ['板桥区', '三重区', '中和区', '永和区', '新庄区', '新店区', '树林区', '莺歌区', '三峡区', '淡水区', '汐止区', '瑞芳区', '土城区', '芦洲区', '五股区', '泰山区', '林口区', '八里区', '三芝区', '石门区', '金山区', '万里区', '金山区', '贡寮区', '坪林区', '乌来区', '深坑区', '石碇区', '新店区', '双溪区', '平溪区', '中山区', '大同区', '中正区', '万华区', '信义区', '松山区', '大安区', '南港区', '内湖区', '士林区', '北投区', '文山区'] },
|
|
{ city: '台中市', districts: ['中区', '东区', '南区', '西区', '北区', '北屯区', '西屯区', '南屯区', '太平区', '大里区', '雾峰区', '乌日区', '丰原区', '后里区', '石冈区', '东势区', '和平区', '新社区', '潭子区', '大雅区', '神冈区', '大肚区', '沙鹿区', '龙井区', '梧栖区', '清水区', '大甲区', '外埔区', '大安区长'] },
|
|
{ city: '台南市', districts: ['中西区', '东区', '南区', '北区', '安平区', '安南区', '永康区', '归仁区', '新化区', '左镇区', '玉井区', '楠西区', '南化区', '仁德区', '关庙区', '龙崎区', '官田区', '麻豆区', '佳里区', '西港区', '七股区', '将军区', '学甲区', '北门区', '新营区', '后壁区', '白河区', '东山区', '六甲区', '下营区', '柳营区', '盐水区', '善化区', '大内区', '山上区', '新市', '安定区'] },
|
|
{ city: '桃园市', districts: ['桃园区', '中坜区', '平镇区', '八德区', '杨梅区', '芦竹区', '大溪区', '龙潭区', '龟山区', '大园区', '观音区', '新屋区', '复兴区'] },
|
|
{ city: '宜兰县', districts: ['宜兰市', '头城镇', '罗东镇', '苏澳镇', '礁溪乡', '壮围乡', '员山乡', '冬山乡', '五结乡', '三星乡', '大同乡', '南澳乡'] },
|
|
{ city: '新竹县', districts: ['竹北市', '竹东镇', '新埔镇', '关西镇', '湖口乡', '新丰乡', '芎林乡', '宝山乡', '北埔乡', '峨眉乡', '尖石乡', '横山乡', '五峰乡'] },
|
|
{ city: '苗栗县', districts: ['苗栗市', '苑里镇', '通霄镇', '后龙镇', '竹南镇', '头份市', '造桥乡', '西湖乡', '头屋乡', '公馆乡', '铜锣乡', '三义乡', '西湖乡', '南庄乡', '大湖乡', '卓兰镇', '泰安乡'] },
|
|
{ city: '彰化县', districts: ['彰化市', '和美镇', '鹿港镇', '溪湖镇', '员林市', '北斗镇', '田中镇', '二林镇', '永靖乡', '伸港乡', '线西乡', '福兴乡', '秀水乡', '花坛乡', '芬园乡', '大村乡', '埔盐乡', '埔心乡', '溪州乡', '竹塘乡', '社头乡', '二水乡', '田尾乡', '埤头乡', '芳苑乡', '大城乡', '竹塘乡', '溪湖乡', '埤头乡'] },
|
|
{ city: '南投县', districts: ['南投市', '埔里镇', '草屯镇', '竹山镇', '集集镇', '名间乡', '鹿谷乡', '中寮乡', '鱼池乡', '国姓乡', '水里乡', '信义乡', '仁爱乡'] },
|
|
{ city: '云林县', districts: ['斗六市', '斗南镇', '虎尾镇', '土库镇', '西螺镇', '北港镇', '古坑乡', '大埤乡', '莿桐乡', '林内乡', '二仑乡', '仑背乡', '麦寮乡', '东势乡', '褒忠乡', '台西乡', '元长乡', '四湖乡', '口湖乡', '水林乡'] },
|
|
{ city: '嘉义县', districts: ['太保市', '朴子市', '布袋镇', '大林镇', '民雄乡', '溪口乡', '新港乡', '六脚乡', '东石乡', '义竹乡', '鹿草乡', '水上乡', '中埔乡', '竹崎乡', '梅山乡', '番路乡', '大埔乡', '阿里山乡'] },
|
|
{ city: '屏东县', districts: ['屏东市', '潮州镇', '东港镇', '恒春镇', '万丹乡', '长治乡', '麟洛乡', '九如乡', '里港乡', '盐埔乡', '高树乡', '万峦乡', '内埔乡', '竹田乡', '新埤乡', '枋寮乡', '枋山乡', '春日乡', '来义乡', '富里乡', '狮子乡', '牡丹乡', '车城乡', '满州乡', '枋寮乡', '三地门乡', '雾台乡'] },
|
|
{ city: '台东县', districts: ['台东市', '成功镇', '关山镇', '卑南乡', '鹿野乡', '池上乡', '东河乡', '长滨乡', '太麻里乡', '金峰乡', '大武乡', '绿岛乡', '兰屿乡', '延平乡', '海端乡', '达仁乡'] },
|
|
{ city: '花莲县', districts: ['花莲市', '凤林镇', '玉里镇', '新城乡', '吉安乡', '寿丰乡', '秀林乡', '光复乡', '丰滨乡', '瑞穗乡', '富里乡', '万荣乡', '卓溪乡'] },
|
|
{ city: '澎湖县', districts: ['马公市', '湖西乡', '白沙乡', '西屿乡', '望安乡', '七美乡'] },
|
|
{ city: '金门县', districts: ['金城镇', '金湖镇', '金沙镇', '金宁乡', '烈屿乡', '乌丘乡'] },
|
|
{ city: '连江县', districts: ['南竿乡', '北竿乡', '莒光乡', '东引乡'] }
|
|
]},
|
|
{ province: '云南省', cities: [
|
|
{ city: '昆明市', districts: ['五华区', '盘龙区', '官渡区', '西山区', '东川区', '呈贡区', '晋宁区', '富民县', '宜良县', '石林彝族自治县', '嵩明县', '禄劝彝族苗族自治县', '寻甸回族彝族自治县'] },
|
|
{ city: '曲靖市', districts: ['麒麟区', '沾益区', '马龙区', '宣威市', '富源县', '罗平县', '师宗县', '陆良县', '会泽县'] },
|
|
{ city: '玉溪市', districts: ['红塔区', '江川区', '澄江市', '通海县', '华宁县', '易门县', '峨山彝族自治县', '新平彝族傣族自治县', '元江哈尼族彝族傣族自治县'] },
|
|
{ city: '保山市', districts: ['隆阳区', '腾冲市', '施甸县', '龙陵县', '昌宁县'] },
|
|
{ city: '昭通市', districts: ['昭阳区', '鲁甸县', '巧家县', '盐津县', '大关县', '永善县', '绥江县', '镇雄县', '彝良县', '威信县', '水富市'] },
|
|
{ city: '丽江市', districts: ['古城区', '玉龙纳西族自治县', '永胜县', '华坪县', '宁蒗彝族自治县'] },
|
|
{ city: '普洱市', districts: ['思茅区', '宁洱哈尼族彝族自治县', '墨江哈尼族自治县', '景东彝族自治县', '景谷傣族彝族自治县', '镇沅彝族哈尼族拉祜族自治县', '江城哈尼族彝族自治县', '孟连傣族拉祜族佤族自治县', '澜沧拉祜族自治县', '西盟佤族自治县'] },
|
|
{ city: '临沧市', districts: ['临翔区', '凤庆县', '云县', '永德县', '镇康县', '双江拉祜族佤族布朗族傣族自治县', '耿马傣族佤族自治县', '沧源佤族自治县'] },
|
|
{ city: '楚雄彝族自治州', districts: ['楚雄市', '双柏县', '牟定县', '南华县', '姚安县', '大姚县', '永仁县', '元谋县', '武定县', '禄丰市'] },
|
|
{ city: '红河哈尼族彝族自治州', districts: ['蒙自市', '个旧市', '开远市', '弥勒市', '建水县', '石屏县', '泸西县', '元阳县', '红河县', '金平苗族瑶族傣族自治县', '绿春县', '屏边苗族自治县', '河口瑶族自治县'] },
|
|
{ city: '文山壮族苗族自治州', districts: ['文山市', '砚山县', '西畴县', '麻栗坡县', '马关县', '丘北县', '广南县', '富宁县'] },
|
|
{ city: '西双版纳傣族自治州', districts: ['景洪市', '勐海县', '勐腊县'] },
|
|
{ city: '大理白族自治州', districts: ['大理市', '漾濞彝族自治县', '祥云县', '宾川县', '弥渡县', '南涧彝族自治县', '巍山彝族回族自治县', '永平县', '云龙县', '洱源县', '剑川县', '鹤庆县'] },
|
|
{ city: '德宏傣族景颇族自治州', districts: ['芒市', '瑞丽市', '梁河县', '盈江县', '陇川县'] },
|
|
{ city: '怒江傈僳族自治州', districts: ['泸水市', '福贡县', '贡山独龙族怒族自治县', '兰坪白族普米族自治县'] },
|
|
{ city: '迪庆藏族自治州', districts: ['香格里拉市', '德钦县', '维西傈僳族自治县'] }
|
|
]},
|
|
{ province: '贵州省', cities: [
|
|
{ city: '贵阳市', districts: ['南明区', '云岩区', '花溪区', '乌当区', '白云区', '观山湖区', '开阳县', '息烽县', '修文县', '清镇市'] },
|
|
{ city: '六盘水市', districts: ['钟山区', '六枝特区', '水城区', '盘州市'] },
|
|
{ city: '遵义市', districts: ['红花岗区', '汇川区', '播州区', '赤水市', '仁怀市', '桐梓县', '绥阳县', '正安县', '道真仡佬族苗族自治县', '务川仡佬族苗族自治县', '凤冈县', '湄潭县', '余庆县', '习水县'] },
|
|
{ city: '安顺市', districts: ['西秀区', '平坝区', '普定县', '镇宁布依族苗族自治县', '关岭布依族苗族自治县', '紫云苗族布依族自治县'] },
|
|
{ city: '毕节市', districts: ['七星关区', '赫章县', '威宁彝族回族苗族自治县', '纳雍县', '织金县', '黔西县', '金沙县', '大方县'] },
|
|
{ city: '铜仁市', districts: ['碧江区', '万山区', '江口县', '玉屏侗族自治县', '石阡县', '思南县', '印江土家族苗族自治县', '德江县', '沿河土家族自治县', '松桃苗族自治县'] },
|
|
{ city: '黔东南苗族侗族自治州', districts: ['凯里市', '黄平县', '施秉县', '三穗县', '镇远县', '岑巩县', '天柱县', '锦屏县', '剑河县', '台江县', '黎平县', '榕江县', '从江县', '雷山县', '麻江县', '丹寨县'] },
|
|
{ city: '黔南布依族苗族自治州', districts: ['都匀市', '福泉市', '荔波县', '贵定县', '瓮安县', '独山县', '平塘县', '罗甸县', '长顺县', '龙里县', '惠水县', '三都水族自治县'] },
|
|
{ city: '黔西南布依族苗族自治州', districts: ['兴义市', '兴仁市', '普安县', '晴隆县', '贞丰县', '望谟县', '册亨县', '安龙县'] }
|
|
]},
|
|
{ province: '海南省', cities: [
|
|
{ city: '海口市', districts: ['秀英区', '龙华区', '琼山区', '美兰区'] },
|
|
{ city: '三亚市', districts: ['吉阳区', '天涯区', '海棠区', '崖州区'] },
|
|
{ city: '三沙市', districts: ['西沙区', '南沙区'] },
|
|
{ city: '儋州市', districts: ['那大镇', '和庆镇', '南丰镇', '大成镇', '雅星镇', '兰洋镇', '光村镇', '木棠镇', '海头镇', '峨蔓镇', '王五镇', '白马井镇', '中和镇', '排浦镇', '东成镇'] },
|
|
{ city: '五指山市', districts: ['通什镇', '南圣镇', '毛阳镇', '番阳镇', '水满乡', '畅好乡', '毛道乡'] },
|
|
{ city: '文昌市', districts: ['文城镇', '重兴镇', '蓬莱镇', '会文镇', '东路镇', '潭牛镇', '东阁镇', '文教镇', '东郊镇', '龙楼镇', '昌洒镇', '翁田镇', '抱罗镇', '冯坡镇', '锦山镇', '铺前镇', '公坡镇'] },
|
|
{ city: '琼海市', districts: ['嘉积镇', '万泉镇', '石壁镇', '中原镇', '博鳌镇', '阳江镇', '龙江镇', '潭门镇', '塔洋镇', '长坡镇', '会山镇', '大路镇'] },
|
|
{ city: '万宁市', districts: ['万城镇', '龙滚镇', '山根镇', '和乐镇', '后安镇', '大茂镇', '东澳镇', '礼纪镇', '长丰镇', '北大镇', '南桥镇', '三更罗镇', '东兴农场', '东和农场'] },
|
|
{ city: '东方市', districts: ['八所镇', '东河镇', '大田镇', '感城镇', '板桥镇', '三家镇', '四更镇', '新龙镇', '天安乡', '江边乡'] },
|
|
{ city: '定安县', districts: ['定城镇', '新竹镇', '龙湖镇', '雷鸣镇', '龙门镇', '岭口镇', '翰林镇', '龙河镇', '黄竹镇', '富文镇'] },
|
|
{ city: '屯昌县', districts: ['屯城镇', '新兴镇', '枫木镇', '乌坡镇', '南吕镇', '南坤镇', '坡心镇', '西昌镇'] },
|
|
{ city: '澄迈县', districts: ['金江镇', '老城镇', '瑞溪镇', '永发镇', '加乐镇', '文儒镇', '中兴镇', '仁兴镇', '福山镇', '桥头镇', '大丰镇', '邦溪镇'] },
|
|
{ city: '临高县', districts: ['临城镇', '波莲镇', '东英镇', '博厚镇', '皇桐镇', '多文镇', '和舍镇', '南宝镇', '新盈镇', '调楼镇', '加来镇'] },
|
|
{ city: '白沙黎族自治县', districts: ['牙叉镇', '七坊镇', '打安镇', '邦溪镇', '南开乡', '元门乡', '阜龙乡', '细水乡', '青松乡', '金波乡', '荣邦乡'] },
|
|
{ city: '昌江黎族自治县', districts: ['石碌镇', '叉河镇', '十月田镇', '乌烈镇', '昌化镇', '海尾镇', '七叉镇', '王下乡'] },
|
|
{ city: '乐东黎族自治县', districts: ['抱由镇', '万冲镇', '大安镇', '志仲镇', '千家镇', '九所镇', '利国镇', '黄流镇', '佛罗镇', '尖峰镇', '莺歌海镇', '尖峰岭', '山荣农场'] },
|
|
{ city: '陵水黎族自治县', districts: ['椰林镇', '新村镇', '英州镇', '本号镇', '隆广镇', '三才镇', '光坡镇', '文罗镇', '黎安镇', '提蒙乡', '群英乡'] },
|
|
{ city: '保亭黎族苗族自治县', districts: ['保城镇', '什玲镇', '加茂镇', '响水镇', '新政镇', '三道镇', '六弓乡', '南林乡', '毛感乡'] },
|
|
{ city: '琼中黎族苗族自治县', districts: ['营根镇', '湾岭镇', '黎母山镇', '和平镇', '长征镇', '红毛镇', '中平镇', '吊罗山乡', '上安乡', '什运乡'] }
|
|
]},
|
|
{ province: '内蒙古自治区', cities: [
|
|
{ city: '呼和浩特市', districts: ['新城区', '回民区', '玉泉区', '赛罕区', '土默特左旗', '托克托县', '和林格尔县', '清水河县', '武川县'] },
|
|
{ city: '包头市', districts: ['东河区', '昆都仑区', '青山区', '石拐区', '白云鄂博矿区', '九原区', '土默特右旗', '固阳县', '达尔罕茂明安联合旗'] },
|
|
{ city: '乌海市', districts: ['海勃湾区', '海南区', '乌达区'] },
|
|
{ city: '赤峰市', districts: ['红山区', '元宝山区', '松山区', '阿鲁科尔沁旗', '巴林左旗', '巴林右旗', '林西县', '克什克腾旗', '翁牛特旗', '喀喇沁旗', '宁城县', '敖汉旗'] },
|
|
{ city: '通辽市', districts: ['科尔沁区', '霍林郭勒市', '科尔沁左翼中旗', '科尔沁左翼后旗', '开鲁县', '库伦旗', '奈曼旗', '扎鲁特旗'] },
|
|
{ city: '鄂尔多斯市', districts: ['东胜区', '康巴什区', '达拉特旗', '准格尔旗', '鄂托克前旗', '鄂托克旗', '杭锦旗', '乌审旗', '伊金霍洛旗'] },
|
|
{ city: '呼伦贝尔市', districts: ['海拉尔区', '扎赉诺尔区', '满洲里市', '牙克石市', '扎兰屯市', '额尔古纳市', '根河市', '阿荣旗', '莫力达瓦达斡尔族自治旗', '鄂伦春自治旗', '鄂温克族自治旗', '陈巴尔虎旗', '新巴尔虎左旗', '新巴尔虎右旗'] },
|
|
{ city: '巴彦淖尔市', districts: ['临河区', '五原县', '磴口县', '乌拉特前旗', '乌拉特中旗', '乌拉特后旗', '杭锦后旗'] },
|
|
{ city: '乌兰察布市', districts: ['集宁区', '丰镇市', '卓资县', '化德县', '商都县', '兴和县', '凉城县', '察哈尔右翼前旗', '察哈尔右翼中旗', '察哈尔右翼后旗', '四子王旗'] },
|
|
{ city: '兴安盟', districts: ['乌兰浩特市', '阿尔山市', '科尔沁右翼前旗', '科尔沁右翼中旗', '扎赉特旗', '突泉县'] },
|
|
{ city: '锡林郭勒盟', districts: ['锡林浩特市', '二连浩特市', '阿巴嘎旗', '苏尼特左旗', '苏尼特右旗', '东乌珠穆沁旗', '西乌珠穆沁旗', '太仆寺旗', '镶黄旗', '正镶白旗', '正蓝旗', '多伦县'] },
|
|
{ city: '阿拉善盟', districts: ['阿拉善左旗', '阿拉善右旗', '额济纳旗'] }
|
|
]},
|
|
{ province: '广西壮族自治区', cities: [
|
|
{ city: '南宁市', districts: ['兴宁区', '青秀区', '江南区', '西乡塘区', '良庆区', '邕宁区', '武鸣区', '隆安县', '马山县', '上林县', '宾阳县', '横州市'] },
|
|
{ city: '柳州市', districts: ['城中区', '鱼峰区', '柳南区', '柳北区', '柳江区', '柳城县', '鹿寨县', '融安县', '融水苗族自治县', '三江侗族自治县'] },
|
|
{ city: '桂林市', districts: ['秀峰区', '叠彩区', '象山区', '七星区', '雁山区', '临桂区', '阳朔县', '灵川县', '全州县', '兴安县', '永福县', '灌阳县', '龙胜各族自治县', '资源县', '平乐县', '荔浦市', '恭城瑶族自治县'] },
|
|
{ city: '梧州市', districts: ['万秀区', '长洲区', '龙圩区', '苍梧县', '藤县', '蒙山县', '岑溪市'] },
|
|
{ city: '北海市', districts: ['海城区', '银海区', '铁山港区', '合浦县'] },
|
|
{ city: '防城港市', districts: ['港口区', '防城区', '上思县', '东兴市'] },
|
|
{ city: '钦州市', districts: ['钦南区', '钦北区', '灵山县', '浦北县'] },
|
|
{ city: '贵港市', districts: ['港北区', '港南区', '覃塘区', '平南县', '桂平市'] },
|
|
{ city: '玉林市', districts: ['玉州区', '福绵区', '容县', '陆川县', '博白县', '兴业县', '北流市'] },
|
|
{ city: '百色市', districts: ['右江区', '田阳区', '田东县', '德保县', '那坡县', '凌云县', '乐业县', '田林县', '西林县', '隆林各族自治县', '靖西市', '平果市'] },
|
|
{ city: '贺州市', districts: ['八步区', '平桂区', '昭平县', '钟山县', '富川瑶族自治县'] },
|
|
{ city: '河池市', districts: ['金城江区', '宜州区', '南丹县', '天峨县', '凤山县', '东兰县', '罗城仫佬族自治县', '环江毛南族自治县', '巴马瑶族自治县', '都安瑶族自治县', '大化瑶族自治县'] },
|
|
{ city: '来宾市', districts: ['兴宾区', '忻城县', '象州县', '武宣县', '金秀瑶族自治县', '合山市'] },
|
|
{ city: '崇左市', districts: ['江州区', '扶绥县', '宁明县', '龙州县', '大新县', '天等县', '凭祥市'] }
|
|
]},
|
|
{ province: '西藏自治区', cities: [
|
|
{ city: '拉萨市', districts: ['城关区', '堆龙德庆区', '达孜区', '林周县', '当雄县', '尼木县', '曲水县', '墨竹工卡县'] },
|
|
{ city: '日喀则市', districts: ['桑珠孜区', '南木林县', '江孜县', '定日县', '萨迦县', '拉孜县', '昂仁县', '谢通门县', '白朗县', '仁布县', '康马县', '定结县', '仲巴县', '亚东县', '吉隆县', '聂拉木县', '萨嘎县', '岗巴县'] },
|
|
{ city: '昌都市', districts: ['卡若区', '江达县', '贡觉县', '类乌齐县', '丁青县', '察雅县', '八宿县', '左贡县', '芒康县', '洛隆县', '边坝县'] },
|
|
{ city: '林芝市', districts: ['巴宜区', '工布江达县', '米林县', '墨脱县', '波密县', '察隅县', '朗县'] },
|
|
{ city: '山南市', districts: ['乃东区', '扎囊县', '贡嘎县', '桑日县', '琼结县', '曲松县', '措美县', '洛扎县', '加查县', '隆子县', '错那市', '浪卡子县'] },
|
|
{ city: '那曲市', districts: ['色尼区', '嘉黎县', '比如县', '聂荣县', '安多县', '申扎县', '索县', '班戈县', '巴青县', '尼玛县', '双湖县'] },
|
|
{ city: '阿里地区', districts: ['噶尔县', '普兰县', '札达县', '日土县', '革吉县', '改则县', '措勤县'] }
|
|
]},
|
|
{ province: '宁夏回族自治区', cities: [
|
|
{ city: '银川市', districts: ['兴庆区', '西夏区', '金凤区', '永宁县', '贺兰县', '灵武市'] },
|
|
{ city: '石嘴山市', districts: ['大武口区', '惠农区', '平罗县'] },
|
|
{ city: '吴忠市', districts: ['利通区', '红寺堡区', '盐池县', '同心县', '青铜峡市'] },
|
|
{ city: '固原市', districts: ['原州区', '西吉县', '隆德县', '泾源县', '彭阳县'] },
|
|
{ city: '中卫市', districts: ['沙坡头区', '中宁县', '海原县'] }
|
|
]},
|
|
{ province: '新疆维吾尔自治区', cities: [
|
|
{ city: '乌鲁木齐市', districts: ['天山区', '沙依巴克区', '新市区', '水磨沟区', '头屯河区', '达坂城区', '米东区', '乌鲁木齐县'] },
|
|
{ city: '克拉玛依市', districts: ['克拉玛依区', '独山子区', '白碱滩区', '乌尔禾区'] },
|
|
{ city: '吐鲁番市', districts: ['高昌区', '鄯善县', '托克逊县'] },
|
|
{ city: '哈密市', districts: ['伊州区', '巴里坤哈萨克自治县', '伊吾县'] },
|
|
{ city: '昌吉回族自治州', districts: ['昌吉市', '阜康市', '呼图壁县', '玛纳斯县', '奇台县', '吉木萨尔县', '木垒哈萨克自治县'] },
|
|
{ city: '博尔塔拉蒙古自治州', districts: ['博乐市', '阿拉山口市', '精河县', '温泉县'] },
|
|
{ city: '巴音郭楞蒙古自治州', districts: ['库尔勒市', '轮台县', '尉犁县', '若羌县', '且末县', '焉耆回族自治县', '和静县', '和硕县', '博湖县'] },
|
|
{ city: '阿克苏地区', districts: ['阿克苏市', '温宿县', '库车市', '沙雅县', '新和县', '拜城县', '乌什县', '阿瓦提县', '柯坪县'] },
|
|
{ city: '克孜勒苏柯尔克孜自治州', districts: ['阿图什市', '阿克陶县', '阿合奇县', '乌恰县'] },
|
|
{ city: '喀什地区', districts: ['喀什市', '疏附县', '疏勒县', '英吉沙县', '泽普县', '莎车县', '叶城县', '麦盖提县', '岳普湖县', '伽师县', '巴楚县', '塔什库尔干塔吉克自治县'] },
|
|
{ city: '和田地区', districts: ['和田市', '和田县', '墨玉县', '皮山县', '洛浦县', '策勒县', '于田县', '民丰县'] },
|
|
{ city: '伊犁哈萨克自治州', districts: ['伊宁市', '奎屯市', '霍尔果斯市', '伊宁县', '察布查尔锡伯自治县', '霍城县', '巩留县', '新源县', '昭苏县', '特克斯县', '尼勒克县'] },
|
|
{ city: '塔城地区', districts: ['塔城市', '乌苏市', '额敏县', '沙湾市', '托里县', '裕民县', '和布克赛尔蒙古自治县'] },
|
|
{ city: '阿勒泰地区', districts: ['阿勒泰市', '布尔津县', '富蕴县', '福海县', '哈巴河县', '青河县', '吉木乃县'] },
|
|
{ city: '石河子市', districts: ['新城街道', '向阳街道', '红山街道', '老街街道', '东城街道', '北泉镇', '石河子总场'] },
|
|
{ city: '阿拉尔市', districts: ['幸福路街道', '金银川路街道', '青松路街道', '南口街道', '托喀依乡'] },
|
|
{ city: '图木舒克市', districts: ['齐干却勒街道', '前海街道', '永安坝街道', '草湖镇'] },
|
|
{ city: '五家渠市', districts: ['军垦路街道', '青湖路街道', '人民路街道', '梧桐镇', '蔡家湖镇'] },
|
|
{ city: '铁门关市', districts: ['迎宾街道', '二十九团', '三十团'] },
|
|
{ city: '双河市', districts: ['红星路街道', '八十一团', '八十四团'] },
|
|
{ city: '可克达拉市', districts: ['幸福路街道', '六十六团', '六十七团'] },
|
|
{ city: '昆玉市', districts: ['昆泉镇', '二二四团', '四十七团'] },
|
|
{ city: '胡杨河市', districts: ['金山路街道', '一二九团', '一三三团'] },
|
|
{ city: '新星市', districts: ['中心团场'] }
|
|
]},
|
|
{ province: '上海市', cities: [
|
|
{ city: '上海市', districts: ['黄浦区', '徐汇区', '长宁区', '静安区', '普陀区', '虹口区', '杨浦区', '闵行区', '宝山区', '嘉定区', '浦东新区', '金山区', '松江区', '青浦区', '奉贤区', '崇明区'] }
|
|
]},
|
|
{ province: '天津市', cities: [
|
|
{ city: '天津市', districts: ['和平区', '河东区', '河西区', '南开区', '河北区', '红桥区', '东丽区', '西青区', '津南区', '北辰区', '武清区', '宝坻区', '滨海新区', '宁河区', '静海区', '蓟州区'] }
|
|
]},
|
|
{ province: '重庆市', cities: [
|
|
{ city: '重庆市', districts: ['渝中区', '大渡口区', '江北区', '沙坪坝区', '九龙坡区', '南岸区', '北碚区', '渝北区', '巴南区', '万州区', '涪陵区', '黔江区', '长寿区', '江津区', '合川区', '永川区', '南川区', '綦江区', '大足区', '璧山区', '铜梁区', '潼南区', '荣昌区', '开州区', '梁平区', '武隆区', '城口县', '丰都县', '垫江县', '忠县', '云阳县', '奉节县', '巫山县', '巫溪县', '石柱土家族自治县', '秀山土家族苗族自治县', '酉阳土家族苗族自治县', '彭水苗族土家族自治县'] }
|
|
]},
|
|
{ province: '河北省', cities: [
|
|
{ city: '石家庄市', districts: ['长安区', '桥西区', '新华区', '井陉矿区', '裕华区', '藁城区', '鹿泉区', '栾城区', '井陉县', '正定县', '行唐县', '灵寿县', '高邑县', '深泽县', '赞皇县', '无极县', '平山县', '元氏县', '赵县', '辛集市', '晋州市', '新乐市'] },
|
|
{ city: '唐山市', districts: ['路南区', '路北区', '古冶区', '开平区', '丰南区', '丰润区', '曹妃甸区', '滦南县', '乐亭县', '迁西县', '玉田县', '遵化市', '迁安市', '滦州市'] },
|
|
{ city: '秦皇岛市', districts: ['海港区', '山海关区', '北戴河区', '抚宁区', '青龙满族自治县', '昌黎县', '卢龙县'] },
|
|
{ city: '邯郸市', districts: ['邯山区', '丛台区', '复兴区', '峰峰矿区', '肥乡区', '永年区', '临漳县', '成安县', '大名县', '涉县', '磁县', '邱县', '鸡泽县', '广平县', '馆陶县', '曲周县', '武安市', '魏县'] },
|
|
{ city: '邢台市', districts: ['桥东区', '桥西区', '邢台县', '临城县', '内丘县', '柏乡县', '隆尧县', '任县', '南和县', '宁晋县', '巨鹿县', '新河县', '广宗县', '平乡县', '威县', '清河县', '临西县', '南宫市', '沙河市'] },
|
|
{ city: '保定市', districts: ['竞秀区', '莲池区', '满城区', '清苑区', '徐水区', '涞水县', '阜平县', '定兴县', '唐县', '高阳县', '容城县', '涞源县', '望都县', '安新县', '易县', '曲阳县', '蠡县', '顺平县', '博野县', '雄县', '涿州市', '定州市', '安国市', '高碑店市'] },
|
|
{ city: '张家口市', districts: ['桥东区', '桥西区', '宣化区', '下花园区', '万全区', '崇礼区', '张北县', '康保县', '沽源县', '尚义县', '蔚县', '阳原县', '怀安县', '怀来县', '涿鹿县', '赤城县'] },
|
|
{ city: '承德市', districts: ['双桥区', '双滦区', '鹰手营子矿区', '承德县', '兴隆县', '平泉市', '滦平县', '隆化县', '丰宁满族自治县', '宽城满族自治县', '围场满族蒙古族自治县'] },
|
|
{ city: '沧州市', districts: ['新华区', '运河区', '沧县', '青县', '东光县', '海兴县', '盐山县', '肃宁县', '南皮县', '吴桥县', '献县', '孟村回族自治县', '泊头市', '任丘市', '黄骅市', '河间市'] },
|
|
{ city: '廊坊市', districts: ['安次区', '广阳区', '固安县', '永清县', '香河县', '大城县', '文安县', '大厂回族自治县', '霸州市', '三河市'] },
|
|
{ city: '衡水市', districts: ['桃城区', '冀州区', '枣强县', '武邑县', '武强县', '饶阳县', '安平县', '故城县', '景县', '阜城县', '深州市'] }
|
|
]},
|
|
{ province: '山西省', cities: [
|
|
{ city: '太原市', districts: ['小店区', '迎泽区', '杏花岭区', '尖草坪区', '万柏林区', '晋源区', '清徐县', '阳曲县', '娄烦县', '古交市'] },
|
|
{ city: '大同市', districts: ['新荣区', '平城区', '云冈区', '云州区', '阳高县', '天镇县', '广灵县', '灵丘县', '浑源县', '左云县'] },
|
|
{ city: '阳泉市', districts: ['城区', '矿区', '郊区', '平定县', '盂县'] },
|
|
{ city: '长治市', districts: ['潞州区', '上党区', '屯留区', '潞城区', '襄垣县', '平顺县', '黎城县', '壶关县', '长子县', '武乡县', '沁县', '沁源县'] },
|
|
{ city: '晋城市', districts: ['城区', '沁水县', '阳城县', '陵川县', '泽州县', '高平市'] },
|
|
{ city: '朔州市', districts: ['朔城区', '平鲁区', '山阴县', '应县', '右玉县', '怀仁市'] },
|
|
{ city: '晋中市', districts: ['榆次区', '太谷区', '榆社县', '左权县', '和顺县', '昔阳县', '寿阳县', '祁县', '平遥县', '灵石县', '介休市'] },
|
|
{ city: '运城市', districts: ['盐湖区', '临猗县', '万荣县', '闻喜县', '稷山县', '新绛县', '绛县', '垣曲县', '夏县', '平陆县', '芮城县', '永济市', '河津市'] },
|
|
{ city: '忻州市', districts: ['忻府区', '定襄县', '五台县', '代县', '繁峙县', '宁武县', '静乐县', '神池县', '五寨县', '岢岚县', '河曲县', '保德县', '偏关县', '原平市'] },
|
|
{ city: '临汾市', districts: ['尧都区', '曲沃县', '翼城县', '襄汾县', '洪洞县', '古县', '安泽县', '浮山县', '吉县', '乡宁县', '大宁县', '隰县', '永和县', '蒲县', '汾西县', '侯马市', '霍州市'] },
|
|
{ city: '吕梁市', districts: ['离石区', '文水县', '交城县', '兴县', '临县', '柳林县', '石楼县', '岚县', '方山县', '中阳县', '交口县', '孝义市', '汾阳市'] }
|
|
]},
|
|
{ province: '辽宁省', cities: [
|
|
{ city: '沈阳市', districts: ['和平区', '沈河区', '大东区', '皇姑区', '铁西区', '苏家屯区', '浑南区', '沈北新区', '于洪区', '辽中区', '康平县', '法库县', '新民市'] },
|
|
{ city: '大连市', districts: ['中山区', '西岗区', '沙河口区', '甘井子区', '旅顺口区', '金州区', '普兰店区', '长海县', '瓦房店市', '庄河市'] },
|
|
{ city: '鞍山市', districts: ['铁东区', '铁西区', '立山区', '千山区', '台安县', '岫岩满族自治县', '海城市'] },
|
|
{ city: '抚顺市', districts: ['新抚区', '东洲区', '望花区', '顺城区', '抚顺县', '新宾满族自治县', '清原满族自治县'] },
|
|
{ city: '本溪市', districts: ['平山区', '溪湖区', '明山区', '南芬区', '本溪满族自治县', '桓仁满族自治县'] },
|
|
{ city: '丹东市', districts: ['元宝区', '振兴区', '振安区', '宽甸满族自治县', '东港市', '凤城市'] },
|
|
{ city: '锦州市', districts: ['古塔区', '凌河区', '太和区', '黑山县', '义县', '凌海市', '北镇市'] },
|
|
{ city: '营口市', districts: ['站前区', '西市区', '鲅鱼圈区', '老边区', '盖州市', '大石桥市'] },
|
|
{ city: '阜新市', districts: ['海州区', '新邱区', '太平区', '清河门区', '细河区', '阜新蒙古族自治县', '彰武县'] },
|
|
{ city: '辽阳市', districts: ['白塔区', '文圣区', '宏伟区', '弓长岭区', '太子河区', '辽阳县', '灯塔市'] },
|
|
{ city: '盘锦市', districts: ['双台子区', '兴隆台区', '大洼区', '盘山县'] },
|
|
{ city: '铁岭市', districts: ['银州区', '清河区', '铁岭县', '西丰县', '昌图县', '调兵山市', '开原市'] },
|
|
{ city: '朝阳市', districts: ['双塔区', '龙城区', '朝阳县', '建平县', '喀喇沁左翼蒙古族自治县', '北票市', '凌源市'] },
|
|
{ city: '葫芦岛市', districts: ['连山区', '龙港区', '南票区', '绥中县', '建昌县', '兴城市'] }
|
|
]},
|
|
{ province: '吉林省', cities: [
|
|
{ city: '长春市', districts: ['南关区', '宽城区', '朝阳区', '二道区', '绿园区', '双阳区', '九台区', '农安县', '榆树市', '德惠市', '公主岭市'] },
|
|
{ city: '吉林市', districts: ['昌邑区', '龙潭区', '船营区', '丰满区', '永吉县', '蛟河市', '桦甸市', '舒兰市', '磐石市'] },
|
|
{ city: '四平市', districts: ['铁西区', '铁东区', '梨树县', '伊通满族自治县', '双辽市'] },
|
|
{ city: '辽源市', districts: ['龙山区', '西安区', '东丰县', '东辽县'] },
|
|
{ city: '通化市', districts: ['东昌区', '二道江区', '通化县', '辉南县', '柳河县', '梅河口市', '集安市'] },
|
|
{ city: '白山市', districts: ['浑江区', '江源区', '抚松县', '靖宇县', '长白朝鲜族自治县', '临江市'] },
|
|
{ city: '松原市', districts: ['宁江区', '前郭尔罗斯蒙古族自治县', '长岭县', '乾安县', '扶余市'] },
|
|
{ city: '白城市', districts: ['洮北区', '镇赉县', '通榆县', '洮南市', '大安市'] },
|
|
{ city: '延边朝鲜族自治州', districts: ['延吉市', '图们市', '敦化市', '珲春市', '龙井市', '和龙市', '汪清县', '安图县'] }
|
|
]},
|
|
{ province: '黑龙江省', cities: [
|
|
{ city: '哈尔滨市', districts: ['道里区', '南岗区', '道外区', '平房区', '松北区', '香坊区', '呼兰区', '阿城区', '双城区', '依兰县', '方正县', '宾县', '巴彦县', '木兰县', '通河县', '延寿县', '尚志市', '五常市'] },
|
|
{ city: '齐齐哈尔市', districts: ['龙沙区', '建华区', '铁锋区', '昂昂溪区', '富拉尔基区', '碾子山区', '梅里斯达斡尔族区', '龙江县', '依安县', '泰来县', '甘南县', '富裕县', '克山县', '克东县', '拜泉县', '讷河市'] },
|
|
{ city: '鸡西市', districts: ['鸡冠区', '恒山区', '滴道区', '梨树区', '城子河区', '麻山区', '鸡东县', '虎林市', '密山市'] },
|
|
{ city: '鹤岗市', districts: ['向阳区', '工农区', '南山区', '兴安区', '东山区', '兴山区', '萝北县', '绥滨县'] },
|
|
{ city: '双鸭山市', districts: ['尖山区', '岭东区', '四方台区', '宝山区', '集贤县', '友谊县', '宝清县', '饶河县'] },
|
|
{ city: '大庆市', districts: ['萨尔图区', '龙凤区', '让胡路区', '红岗区', '大同区', '肇州县', '肇源县', '林甸县', '杜尔伯特蒙古族自治县'] },
|
|
{ city: '伊春市', districts: ['伊美区', '乌翠区', '友好区', '金林区', '汤旺县', '丰林县', '大箐山县', '南岔县', '嘉荫县', '铁力市'] },
|
|
{ city: '佳木斯市', districts: ['向阳区', '前进区', '东风区', '郊区', '桦南县', '桦川县', '汤原县', '抚远市', '同江市', '富锦市'] },
|
|
{ city: '七台河市', districts: ['新兴区', '桃山区', '茄子河区', '勃利县'] },
|
|
{ city: '牡丹江市', districts: ['东安区', '阳明区', '爱民区', '西安区', '东宁市', '绥芬河市', '海林市', '宁安市', '穆棱市', '林口县'] },
|
|
{ city: '黑河市', districts: ['爱辉区', '嫩江市', '北安市', '五大连池市', '逊克县', '孙吴县'] },
|
|
{ city: '绥化市', districts: ['北林区', '望奎县', '兰西县', '青冈县', '庆安县', '明水县', '绥棱县', '安达市', '肇东市', '海伦市'] },
|
|
{ city: '大兴安岭地区', districts: ['加格达奇区', '松岭区', '新林区', '呼中区', '呼玛县', '塔河县', '漠河市'] }
|
|
]},
|
|
{ province: '江苏省', cities: [
|
|
{ city: '南京市', districts: ['玄武区', '秦淮区', '建邺区', '鼓楼区', '浦口区', '栖霞区', '雨花台区', '江宁区', '六合区', '溧水区', '高淳区'] },
|
|
{ city: '无锡市', districts: ['锡山区', '惠山区', '滨湖区', '梁溪区', '新吴区', '江阴市', '宜兴市'] },
|
|
{ city: '徐州市', districts: ['鼓楼区', '云龙区', '贾汪区', '泉山区', '铜山区', '丰县', '沛县', '睢宁县', '新沂市', '邳州市'] },
|
|
{ city: '常州市', districts: ['天宁区', '钟楼区', '新北区', '武进区', '金坛区', '溧阳市'] },
|
|
{ city: '苏州市', districts: ['姑苏区', '虎丘区', '吴中区', '相城区', '吴江区', '苏州工业园区', '昆山市', '常熟市', '张家港市', '太仓市'] },
|
|
{ city: '南通市', districts: ['崇川区', '港闸区', '通州区', '如东县', '启东市', '如皋市', '海门市', '海安市'] },
|
|
{ city: '连云港市', districts: ['连云区', '海州区', '赣榆区', '东海县', '灌云县', '灌南县'] },
|
|
{ city: '淮安市', districts: ['淮安区', '淮阴区', '清江浦区', '洪泽区', '涟水县', '盱眙县', '金湖县'] },
|
|
{ city: '盐城市', districts: ['亭湖区', '盐都区', '大丰区', '响水县', '滨海县', '阜宁县', '射阳县', '建湖县', '东台市'] },
|
|
{ city: '扬州市', districts: ['广陵区', '邗江区', '江都区', '宝应县', '仪征市', '高邮市'] },
|
|
{ city: '镇江市', districts: ['京口区', '润州区', '丹徒区', '丹阳市', '扬中市', '句容市'] },
|
|
{ city: '泰州市', districts: ['海陵区', '高港区', '姜堰区', '兴化市', '靖江市', '泰兴市'] },
|
|
{ city: '宿迁市', districts: ['宿城区', '宿豫区', '沭阳县', '泗阳县', '泗洪县'] }
|
|
]},
|
|
{ province: '浙江省', cities: [
|
|
{ city: '杭州市', districts: ['上城区', '下城区', '江干区', '拱墅区', '西湖区', '滨江区', '萧山区', '余杭区', '富阳区', '临安区', '桐庐县', '淳安县', '建德市'] },
|
|
{ city: '宁波市', districts: ['海曙区', '江北区', '北仑区', '镇海区', '鄞州区', '奉化区', '象山县', '宁海县', '余姚市', '慈溪市'] },
|
|
{ city: '温州市', districts: ['鹿城区', '龙湾区', '瓯海区', '洞头区', '永嘉县', '平阳县', '苍南县', '文成县', '泰顺县', '瑞安市', '乐清市'] },
|
|
{ city: '嘉兴市', districts: ['南湖区', '秀洲区', '嘉善县', '海盐县', '海宁市', '平湖市', '桐乡市'] },
|
|
{ city: '湖州市', districts: ['吴兴区', '南浔区', '德清县', '长兴县', '安吉县'] },
|
|
{ city: '绍兴市', districts: ['越城区', '柯桥区', '上虞区', '新昌县', '诸暨市', '嵊州市'] },
|
|
{ city: '金华市', districts: ['婺城区', '金东区', '武义县', '浦江县', '磐安县', '兰溪市', '义乌市', '东阳市', '永康市'] },
|
|
{ city: '衢州市', districts: ['柯城区', '衢江区', '常山县', '开化县', '龙游县', '江山市'] },
|
|
{ city: '舟山市', districts: ['定海区', '普陀区', '岱山县', '嵊泗县'] },
|
|
{ city: '台州市', districts: ['椒江区', '黄岩区', '路桥区', '玉环市', '三门县', '天台县', '仙居县', '温岭市', '临海市'] },
|
|
{ city: '丽水市', districts: ['莲都区', '青田县', '缙云县', '遂昌县', '松阳县', '云和县', '庆元县', '景宁畲族自治县', '龙泉市'] }
|
|
]},
|
|
{ province: '安徽省', cities: [
|
|
{ city: '合肥市', districts: ['瑶海区', '庐阳区', '蜀山区', '包河区', '长丰县', '肥东县', '肥西县', '庐江县', '巢湖市'] },
|
|
{ city: '芜湖市', districts: ['镜湖区', '弋江区', '鸠江区', '三山区', '芜湖县', '繁昌县', '南陵县', '无为县'] },
|
|
{ city: '蚌埠市', districts: ['龙子湖区', '蚌山区', '禹会区', '淮上区', '怀远县', '五河县', '固镇县'] },
|
|
{ city: '淮南市', districts: ['大通区', '田家庵区', '谢家集区', '八公山区', '潘集区', '凤台县', '寿县'] },
|
|
{ city: '马鞍山市', districts: ['花山区', '雨山区', '博望区', '当涂县', '含山县', '和县'] },
|
|
{ city: '淮北市', districts: ['杜集区', '相山区', '烈山区', '濉溪县'] },
|
|
{ city: '铜陵市', districts: ['铜官区', '义安区', '郊区', '枞阳县'] },
|
|
{ city: '安庆市', districts: ['迎江区', '大观区', '宜秀区', '怀宁县', '枞阳县', '潜山县', '太湖县', '宿松县', '望江县', '岳西县', '桐城市'] },
|
|
{ city: '黄山市', districts: ['屯溪区', '黄山区', '徽州区', '歙县', '休宁县', '黟县', '祁门县'] },
|
|
{ city: '滁州市', districts: ['琅琊区', '南谯区', '来安县', '全椒县', '定远县', '凤阳县', '天长市', '明光市'] },
|
|
{ city: '阜阳市', districts: ['颍州区', '颍东区', '颍泉区', '临泉县', '太和县', '阜南县', '颍上县', '界首市'] },
|
|
{ city: '宿州市', districts: ['埇桥区', '砀山县', '萧县', '灵璧县', '泗县'] },
|
|
{ city: '六安市', districts: ['金安区', '裕安区', '叶集区', '霍邱县', '舒城县', '金寨县', '霍山县'] },
|
|
{ city: '亳州市', districts: ['谯城区', '涡阳县', '蒙城县', '利辛县'] },
|
|
{ city: '池州市', districts: ['贵池区', '东至县', '石台县', '青阳县'] },
|
|
{ city: '宣城市', districts: ['宣州区', '郎溪县', '广德县', '泾县', '绩溪县', '旌德县', '宁国市'] }
|
|
]},
|
|
{ province: '福建省', cities: [
|
|
{ city: '福州市', districts: ['鼓楼区', '台江区', '仓山区', '马尾区', '晋安区', '长乐区', '闽侯县', '连江县', '罗源县', '闽清县', '永泰县', '平潭县'] },
|
|
{ city: '厦门市', districts: ['思明区', '海沧区', '湖里区', '集美区', '同安区', '翔安区'] },
|
|
{ city: '莆田市', districts: ['城厢区', '涵江区', '荔城区', '秀屿区', '仙游县'] },
|
|
{ city: '三明市', districts: ['梅列区', '三元区', '明溪县', '清流县', '宁化县', '大田县', '尤溪县', '沙县', '将乐县', '泰宁县', '建宁县', '永安市'] },
|
|
{ city: '泉州市', districts: ['鲤城区', '丰泽区', '洛江区', '泉港区', '惠安县', '安溪县', '永春县', '德化县', '金门县', '石狮市', '晋江市', '南安市'] },
|
|
{ city: '漳州市', districts: ['芗城区', '龙文区', '云霄县', '漳浦县', '诏安县', '长泰县', '东山县', '南靖县', '平和县', '华安县', '龙海市'] },
|
|
{ city: '南平市', districts: ['延平区', '建阳区', '顺昌县', '浦城县', '光泽县', '松溪县', '政和县', '邵武市', '武夷山市', '建瓯市'] },
|
|
{ city: '龙岩市', districts: ['新罗区', '永定区', '长汀县', '上杭县', '武平县', '连城县', '漳平市'] },
|
|
{ city: '宁德市', districts: ['蕉城区', '霞浦县', '古田县', '屏南县', '寿宁县', '周宁县', '柘荣县', '福安市', '福鼎市'] }
|
|
]},
|
|
{ province: '江西省', cities: [
|
|
{ city: '南昌市', districts: ['东湖区', '西湖区', '青云谱区', '湾里区', '青山湖区', '新建区', '南昌县', '安义县', '进贤县'] },
|
|
{ city: '景德镇市', districts: ['昌江区', '珠山区', '浮梁县', '乐平市'] },
|
|
{ city: '萍乡市', districts: ['安源区', '湘东区', '莲花县', '上栗县', '芦溪县'] },
|
|
{ city: '九江市', districts: ['濂溪区', '浔阳区', '柴桑区', '武宁县', '修水县', '永修县', '德安县', '都昌县', '湖口县', '彭泽县', '瑞昌市', '共青城市', '庐山市'] },
|
|
{ city: '新余市', districts: ['渝水区', '分宜县'] },
|
|
{ city: '鹰潭市', districts: ['月湖区', '余江区', '贵溪市'] },
|
|
{ city: '赣州市', districts: ['章贡区', '南康区', '赣县区', '信丰县', '大余县', '上犹县', '崇义县', '安远县', '龙南县', '定南县', '全南县', '宁都县', '于都县', '兴国县', '会昌县', '寻乌县', '石城县', '瑞金市', '龙南市'] },
|
|
{ city: '吉安市', districts: ['吉州区', '青原区', '吉安县', '吉水县', '峡江县', '新干县', '永丰县', '泰和县', '遂川县', '万安县', '安福县', '永新县', '井冈山市'] },
|
|
{ city: '宜春市', districts: ['袁州区', '奉新县', '万载县', '上高县', '宜丰县', '靖安县', '铜鼓县', '丰城市', '樟树市', '高安市'] },
|
|
{ city: '抚州市', districts: ['临川区', '东乡区', '南城县', '黎川县', '南丰县', '崇仁县', '乐安县', '宜黄县', '金溪县', '资溪县', '广昌县'] },
|
|
{ city: '上饶市', districts: ['信州区', '广丰区', '广信区', '玉山县', '铅山县', '横峰县', '弋阳县', '余干县', '鄱阳县', '万年县', '婺源县', '德兴市'] }
|
|
]},
|
|
{ province: '山东省', cities: [
|
|
{ city: '济南市', districts: ['历下区', '市中区', '槐荫区', '天桥区', '历城区', '长清区', '章丘区', '济阳区', '莱芜区', '钢城区', '平阴县', '商河县'] },
|
|
{ city: '青岛市', districts: ['市南区', '市北区', '黄岛区', '崂山区', '李沧区', '城阳区', '即墨区', '胶州市', '平度市', '莱西市'] },
|
|
{ city: '淄博市', districts: ['淄川区', '张店区', '博山区', '临淄区', '周村区', '桓台县', '高青县', '沂源县'] },
|
|
{ city: '枣庄市', districts: ['市中区', '薛城区', '峄城区', '台儿庄区', '山亭区', '滕州市'] },
|
|
{ city: '东营市', districts: ['东营区', '河口区', '垦利区', '利津县', '广饶县'] },
|
|
{ city: '烟台市', districts: ['芝罘区', '福山区', '牟平区', '莱山区', '蓬莱区', '长岛县', '龙口市', '莱阳市', '莱州市', '蓬莱市', '招远市', '栖霞市', '海阳市'] },
|
|
{ city: '潍坊市', districts: ['潍城区', '寒亭区', '坊子区', '奎文区', '临朐县', '昌乐县', '青州市', '诸城市', '寿光市', '安丘市', '高密市', '昌邑市'] },
|
|
{ city: '济宁市', districts: ['任城区', '兖州区', '微山县', '鱼台县', '金乡县', '嘉祥县', '汶上县', '泗水县', '梁山县', '曲阜市', '邹城市'] },
|
|
{ city: '泰安市', districts: ['泰山区', '岱岳区', '宁阳县', '东平县', '新泰市', '肥城市'] },
|
|
{ city: '威海市', districts: ['环翠区', '文登区', '荣成市', '乳山市'] },
|
|
{ city: '日照市', districts: ['东港区', '岚山区', '五莲县', '莒县'] },
|
|
{ city: '临沂市', districts: ['兰山区', '罗庄区', '河东区', '沂南县', '郯城县', '沂水县', '兰陵县', '费县', '平邑县', '莒南县', '蒙阴县', '临沭县'] },
|
|
{ city: '德州市', districts: ['德城区', '陵城区', '宁津县', '庆云县', '临邑县', '齐河县', '平原县', '夏津县', '武城县', '乐陵市', '禹城市'] },
|
|
{ city: '聊城市', districts: ['东昌府区', '茌平区', '阳谷县', '莘县', '东阿县', '冠县', '高唐县', '临清市'] },
|
|
{ city: '滨州市', districts: ['滨城区', '沾化区', '惠民县', '阳信县', '无棣县', '博兴县', '邹平市'] },
|
|
{ city: '菏泽市', districts: ['牡丹区', '定陶区', '曹县', '单县', '成武县', '巨野县', '郓城县', '鄄城县', '东明县'] }
|
|
]},
|
|
{ province: '河南省', cities: [
|
|
{ city: '郑州市', districts: ['中原区', '二七区', '管城回族区', '金水区', '上街区', '惠济区', '中牟县', '巩义市', '荥阳市', '新密市', '新郑市', '登封市'] },
|
|
{ city: '开封市', districts: ['龙亭区', '顺河回族区', '鼓楼区', '禹王台区', '祥符区', '杞县', '通许县', '尉氏县', '兰考县'] },
|
|
{ city: '洛阳市', districts: ['老城区', '西工区', '瀍河回族区', '涧西区', '吉利区', '洛龙区', '孟津县', '新安县', '栾川县', '嵩县', '汝阳县', '宜阳县', '洛宁县', '伊川县', '偃师市'] },
|
|
{ city: '平顶山市', districts: ['新华区', '卫东区', '石龙区', '湛河区', '宝丰县', '叶县', '鲁山县', '郏县', '舞钢市', '汝州市'] },
|
|
{ city: '安阳市', districts: ['文峰区', '北关区', '殷都区', '龙安区', '安阳县', '汤阴县', '滑县', '内黄县', '林州市'] },
|
|
{ city: '鹤壁市', districts: ['鹤山区', '山城区', '淇滨区', '浚县', '淇县'] },
|
|
{ city: '新乡市', districts: ['红旗区', '卫滨区', '凤泉区', '牧野区', '新乡县', '获嘉县', '原阳县', '延津县', '封丘县', '长垣县', '卫辉市', '辉县市'] },
|
|
{ city: '焦作市', districts: ['解放区', '中站区', '马村区', '山阳区', '修武县', '博爱县', '武陟县', '温县', '沁阳市', '孟州市'] },
|
|
{ city: '濮阳市', districts: ['华龙区', '清丰县', '南乐县', '范县', '台前县', '濮阳县'] },
|
|
{ city: '许昌市', districts: ['魏都区', '建安区', '鄢陵县', '襄城县', '禹州市', '长葛市'] },
|
|
{ city: '漯河市', districts: ['源汇区', '郾城区', '召陵区', '舞阳县', '临颍县'] },
|
|
{ city: '三门峡市', districts: ['湖滨区', '陕州区', '渑池县', '卢氏县', '义马市', '灵宝市'] },
|
|
{ city: '南阳市', districts: ['宛城区', '卧龙区', '南召县', '方城县', '西峡县', '镇平县', '内乡县', '淅川县', '社旗县', '唐河县', '新野县', '桐柏县', '邓州市'] },
|
|
{ city: '商丘市', districts: ['梁园区', '睢阳区', '民权县', '睢县', '宁陵县', '柘城县', '虞城县', '夏邑县', '永城市'] },
|
|
{ city: '信阳市', districts: ['浉河区', '平桥区', '罗山县', '光山县', '新县', '商城县', '固始县', '潢川县', '淮滨县', '息县'] },
|
|
{ city: '周口市', districts: ['川汇区', '淮阳区', '扶沟县', '西华县', '商水县', '沈丘县', '郸城县', '太康县', '鹿邑县', '项城市'] },
|
|
{ city: '驻马店市', districts: ['驿城区', '西平县', '上蔡县', '平舆县', '正阳县', '确山县', '泌阳县', '汝南县', '遂平县', '新蔡县'] },
|
|
{ city: '济源市', districts: ['济源市'] }
|
|
]},
|
|
{ province: '湖北省', cities: [
|
|
{ city: '武汉市', districts: ['江岸区', '江汉区', '硚口区', '汉阳区', '武昌区', '青山区', '洪山区', '东西湖区', '汉南区', '蔡甸区', '江夏区', '黄陂区', '新洲区'] },
|
|
{ city: '黄石市', districts: ['黄石港区', '西塞山区', '下陆区', '铁山区', '阳新县', '大冶市'] },
|
|
{ city: '十堰市', districts: ['茅箭区', '张湾区', '郧阳区', '郧西县', '竹山县', '竹溪县', '房县', '丹江口市'] },
|
|
{ city: '宜昌市', districts: ['西陵区', '伍家岗区', '点军区', '猇亭区', '夷陵区', '远安县', '兴山县', '秭归县', '长阳土家族自治县', '五峰土家族自治县', '宜都市', '当阳市', '枝江市'] },
|
|
{ city: '襄阳市', districts: ['襄城区', '樊城区', '襄州区', '南漳县', '谷城县', '保康县', '老河口市', '枣阳市', '宜城市'] },
|
|
{ city: '鄂州市', districts: ['梁子湖区', '华容区', '鄂城区'] },
|
|
{ city: '荆门市', districts: ['东宝区', '掇刀区', '京山市', '沙洋县', '钟祥市'] },
|
|
{ city: '孝感市', districts: ['孝南区', '孝昌县', '大悟县', '云梦县', '应城市', '安陆市', '汉川市'] },
|
|
{ city: '荆州市', districts: ['沙市区', '荆州区', '公安县', '监利县', '江陵县', '石首市', '洪湖市', '松滋市'] },
|
|
{ city: '黄冈市', districts: ['黄州区', '团风县', '红安县', '罗田县', '英山县', '浠水县', '蕲春县', '黄梅县', '麻城市', '武穴市'] },
|
|
{ city: '咸宁市', districts: ['咸安区', '嘉鱼县', '通城县', '崇阳县', '通山县', '赤壁市'] },
|
|
{ city: '随州市', districts: ['曾都区', '随县', '广水市'] },
|
|
{ city: '恩施土家族苗族自治州', districts: ['恩施市', '利川市', '建始县', '巴东县', '宣恩县', '咸丰县', '来凤县', '鹤峰县'] },
|
|
{ city: '仙桃市', districts: ['仙桃市'] },
|
|
{ city: '潜江市', districts: ['潜江市'] },
|
|
{ city: '天门市', districts: ['天门市'] },
|
|
{ city: '神农架林区', districts: ['神农架林区'] }
|
|
]},
|
|
{ province: '湖南省', cities: [
|
|
{ city: '长沙市', districts: ['芙蓉区', '天心区', '岳麓区', '开福区', '雨花区', '望城区', '长沙县', '宁乡市', '浏阳市'] },
|
|
{ city: '株洲市', districts: ['荷塘区', '芦淞区', '石峰区', '天元区', '株洲县', '攸县', '茶陵县', '炎陵县', '醴陵市'] },
|
|
{ city: '湘潭市', districts: ['雨湖区', '岳塘区', '湘潭县', '湘乡市', '韶山市'] },
|
|
{ city: '衡阳市', districts: ['珠晖区', '雁峰区', '石鼓区', '蒸湘区', '南岳区', '衡阳县', '衡南县', '衡山县', '衡东县', '祁东县', '耒阳市', '常宁市'] },
|
|
{ city: '邵阳市', districts: ['双清区', '大祥区', '北塔区', '邵东县', '新邵县', '邵阳县', '隆回县', '洞口县', '绥宁县', '新宁县', '城步苗族自治县', '武冈市'] },
|
|
{ city: '岳阳市', districts: ['岳阳楼区', '云溪区', '君山区', '岳阳县', '华容县', '湘阴县', '平江县', '汨罗市', '临湘市'] },
|
|
{ city: '常德市', districts: ['武陵区', '鼎城区', '安乡县', '汉寿县', '澧县', '临澧县', '桃源县', '石门县', '津市市'] },
|
|
{ city: '张家界市', districts: ['永定区', '武陵源区', '慈利县', '桑植县'] },
|
|
{ city: '益阳市', districts: ['资阳区', '赫山区', '南县', '桃江县', '安化县', '沅江市'] },
|
|
{ city: '郴州市', districts: ['北湖区', '苏仙区', '桂阳县', '宜章县', '永兴县', '嘉禾县', '临武县', '汝城县', '桂东县', '安仁县', '资兴市'] },
|
|
{ city: '永州市', districts: ['零陵区', '冷水滩区', '祁阳县', '东安县', '双牌县', '道县', '江永县', '宁远县', '蓝山县', '新田县', '江华瑶族自治县'] },
|
|
{ city: '怀化市', districts: ['鹤城区', '中方县', '沅陵县', '辰溪县', '溆浦县', '会同县', '麻阳苗族自治县', '新晃侗族自治县', '芷江侗族自治县', '靖州苗族侗族自治县', '通道侗族自治县', '洪江市'] },
|
|
{ city: '娄底市', districts: ['娄星区', '双峰县', '新化县', '冷水江市', '涟源市'] },
|
|
{ city: '湘西土家族苗族自治州', districts: ['吉首市', '泸溪县', '凤凰县', '花垣县', '保靖县', '古丈县', '永顺县', '龙山县'] }
|
|
]},
|
|
{ province: '广东省', cities: [
|
|
{ city: '广州市', districts: ['荔湾区', '越秀区', '海珠区', '天河区', '白云区', '黄埔区', '番禺区', '花都区', '南沙区', '从化区', '增城区'] },
|
|
{ city: '深圳市', districts: ['罗湖区', '福田区', '南山区', '宝安区', '龙岗区', '盐田区', '龙华区', '坪山区', '光明区'] },
|
|
{ city: '珠海市', districts: ['香洲区', '斗门区', '金湾区'] },
|
|
{ city: '汕头市', districts: ['龙湖区', '金平区', '濠江区', '潮阳区', '潮南区', '澄海区', '南澳县'] },
|
|
{ city: '佛山市', districts: ['禅城区', '南海区', '顺德区', '三水区', '高明区'] },
|
|
{ city: '韶关市', districts: ['武江区', '浈江区', '曲江区', '始兴县', '仁化县', '翁源县', '乳源瑶族自治县', '新丰县', '乐昌市', '南雄市'] },
|
|
{ city: '河源市', districts: ['源城区', '紫金县', '龙川县', '连平县', '和平县', '东源县'] },
|
|
{ city: '梅州市', districts: ['梅江区', '梅县区', '大埔县', '丰顺县', '五华县', '平远县', '蕉岭县', '兴宁市'] },
|
|
{ city: '惠州市', districts: ['惠城区', '惠阳区', '博罗县', '惠东县', '龙门县'] },
|
|
{ city: '汕尾市', districts: ['城区', '海丰县', '陆河县', '陆丰市'] },
|
|
{ city: '东莞市', districts: ['东莞市'] },
|
|
{ city: '中山市', districts: ['中山市'] },
|
|
{ city: '江门市', districts: ['蓬江区', '江海区', '新会区', '台山市', '开平市', '鹤山市', '恩平市'] },
|
|
{ city: '阳江市', districts: ['江城区', '阳东区', '阳西县', '阳春市'] },
|
|
{ city: '湛江市', districts: ['赤坎区', '霞山区', '坡头区', '麻章区', '遂溪县', '徐闻县', '廉江市', '雷州市', '吴川市'] },
|
|
{ city: '茂名市', districts: ['茂南区', '电白区', '高州市', '化州市', '信宜市'] },
|
|
{ city: '肇庆市', districts: ['端州区', '鼎湖区', '高要区', '广宁县', '怀集县', '封开县', '德庆县', '四会市'] },
|
|
{ city: '清远市', districts: ['清城区', '清新区', '佛冈县', '阳山县', '连山壮族瑶族自治县', '连南瑶族自治县', '英德市', '连州市'] },
|
|
{ city: '潮州市', districts: ['湘桥区', '潮安区', '饶平县'] },
|
|
{ city: '揭阳市', districts: ['榕城区', '揭东区', '揭西县', '惠来县', '普宁市'] },
|
|
{ city: '云浮市', districts: ['云城区', '云安区', '新兴县', '郁南县', '罗定市'] },
|
|
{ city: '顺德区', districts: ['顺德区'] },
|
|
{ city: '南海区', districts: ['南海区'] },
|
|
{ city: '温州市', districts: ['鹿城区', '龙湾区', '瓯海区', '洞头区', '瑞安市', '乐清市', '永嘉县', '平阳县', '苍南县', '文成县', '泰顺县'] },
|
|
{ city: '嘉兴市', districts: ['南湖区', '秀洲区', '海宁市', '平湖市', '桐乡市', '嘉善县', '海盐县'] },
|
|
{ city: '湖州市', districts: ['吴兴区', '南浔区', '德清县', '长兴县', '安吉县'] }
|
|
]},
|
|
{ province: '四川省', cities: [
|
|
{ city: '成都市', districts: ['锦江区', '青羊区', '金牛区', '武侯区', '成华区', '龙泉驿区', '青白江区', '新都区', '温江区', '双流区', '郫都区', '新津区', '金堂县', '大邑县', '蒲江县', '都江堰市', '彭州市', '邛崃市', '崇州市', '简阳市'] },
|
|
{ city: '绵阳市', districts: ['涪城区', '游仙区', '安州区', '三台县', '盐亭县', '梓潼县', '北川羌族自治县', '平武县', '江油市'] },
|
|
{ city: '德阳市', districts: ['旌阳区', '罗江区', '中江县', '广汉市', '什邡市', '绵竹市'] },
|
|
{ city: '自贡市', districts: ['自流井区', '贡井区', '大安区', '沿滩区', '荣县', '富顺县'] },
|
|
{ city: '攀枝花市', districts: ['东区', '西区', '仁和区', '米易县', '盐边县'] },
|
|
{ city: '泸州市', districts: ['江阳区', '纳溪区', '龙马潭区', '泸县', '合江县', '叙永县', '古蔺县'] },
|
|
{ city: '广元市', districts: ['利州区', '昭化区', '朝天区', '旺苍县', '青川县', '剑阁县', '苍溪县'] },
|
|
{ city: '遂宁市', districts: ['船山区', '安居区', '蓬溪县', '射洪市', '大英县'] },
|
|
{ city: '内江市', districts: ['市中区', '东兴区', '威远县', '资中县', '隆昌市'] },
|
|
{ city: '乐山市', districts: ['市中区', '沙湾区', '五通桥区', '金口河区', '犍为县', '井研县', '夹江县', '沐川县', '峨边彝族自治县', '马边彝族自治县', '峨眉山市'] },
|
|
{ city: '资阳市', districts: ['雁江区', '安岳县', '乐至县'] },
|
|
{ city: '宜宾市', districts: ['翠屏区', '南溪区', '叙州区', '江安县', '长宁县', '高县', '珙县', '筠连县', '兴文县', '屏山县'] },
|
|
{ city: '南充市', districts: ['顺庆区', '高坪区', '嘉陵区', '南部县', '营山县', '蓬安县', '仪陇县', '西充县', '阆中市'] },
|
|
{ city: '广安市', districts: ['广安区', '前锋区', '岳池县', '武胜县', '邻水县', '华蓥市'] },
|
|
{ city: '达州市', districts: ['通川区', '达川区', '宣汉县', '开江县', '大竹县', '渠县', '万源市'] },
|
|
{ city: '巴中市', districts: ['巴州区', '恩阳区', '通江县', '南江县', '平昌县'] },
|
|
{ city: '眉山市', districts: ['东坡区', '彭山区', '仁寿县', '洪雅县', '丹棱县', '青神县'] },
|
|
{ city: '雅安市', districts: ['雨城区', '名山区', '荥经县', '汉源县', '石棉县', '天全县', '芦山县', '宝兴县'] },
|
|
{ city: '阿坝藏族羌族自治州', districts: ['马尔康市', '汶川县', '理县', '茂县', '松潘县', '九寨沟县', '金川县', '小金县', '黑水县', '壤塘县', '阿坝县', '若尔盖县', '红原县'] },
|
|
{ city: '甘孜藏族自治州', districts: ['康定市', '泸定县', '丹巴县', '九龙县', '雅江县', '道孚县', '炉霍县', '甘孜县', '新龙县', '德格县', '白玉县', '石渠县', '色达县', '理塘县', '巴塘县', '乡城县', '稻城县', '得荣县'] },
|
|
{ city: '凉山彝族自治州', districts: ['西昌市', '木里藏族自治县', '盐源县', '德昌县', '会理市', '会东县', '宁南县', '普格县', '布拖县', '金阳县', '昭觉县', '喜德县', '冕宁县', '越西县', '甘洛县', '美姑县', '雷波县'] }
|
|
]},
|
|
{ province: '香港特别行政区', cities: [
|
|
{ city: '香港岛', districts: ['中西区', '湾仔区', '东区', '南区'] },
|
|
{ city: '九龙', districts: ['油尖旺区', '深水埗区', '九龙城区', '黄大仙区', '观塘区'] },
|
|
{ city: '新界', districts: ['北区', '大埔区', '沙田区', '西贡区', '荃湾区', '屯门区', '元朗区', '葵青区', '离岛区'] }
|
|
]},
|
|
{ province: '澳门特别行政区', cities: [
|
|
{ city: '澳门半岛', districts: ['花地玛堂区', '圣安多尼堂区', '大堂区', '望德堂区', '风顺堂区'] },
|
|
{ city: '氹仔岛', districts: ['嘉模堂区'] },
|
|
{ city: '路环岛', districts: ['圣方济各堂区'] },
|
|
{ city: '路氹城', districts: ['路氹填海区'] }
|
|
]}
|
|
];
|
|
|
|
let selectedProvince = '';
|
|
let selectedCity = '';
|
|
let selectedDistrict = '';
|
|
let filteredProvinces = [...allRegionOptions];
|
|
|
|
// 显示地区选择弹窗
|
|
function showRegionSelectModal() {
|
|
const regionSelectModal = document.getElementById('regionSelectModal');
|
|
regionSelectModal.classList.add('active');
|
|
// 重置搜索输入
|
|
document.getElementById('regionSearchInput').value = '';
|
|
filteredProvinces = [...allRegionOptions];
|
|
generateRegionOptions();
|
|
}
|
|
|
|
// 隐藏地区选择弹窗
|
|
function hideRegionSelectModal() {
|
|
const regionSelectModal = document.getElementById('regionSelectModal');
|
|
regionSelectModal.classList.remove('active');
|
|
}
|
|
|
|
// 生成地区选项
|
|
function generateRegionOptions() {
|
|
const provinceList = document.getElementById('provinceList');
|
|
const cityList = document.getElementById('cityList');
|
|
const districtList = document.getElementById('districtList');
|
|
|
|
// 生成省份选项
|
|
provinceList.innerHTML = '';
|
|
filteredProvinces.forEach(province => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = province.province;
|
|
option.onclick = () => {
|
|
selectedProvince = province.province;
|
|
selectedCity = '';
|
|
selectedDistrict = '';
|
|
updateRegionDisplay();
|
|
// 生成城市选项
|
|
generateCityOptions(province.cities);
|
|
// 清空区县选项
|
|
districtList.innerHTML = '';
|
|
};
|
|
provinceList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 生成城市选项
|
|
function generateCityOptions(cities) {
|
|
const cityList = document.getElementById('cityList');
|
|
const districtList = document.getElementById('districtList');
|
|
|
|
cityList.innerHTML = '';
|
|
cities.forEach(city => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = city.city;
|
|
option.onclick = () => {
|
|
selectedCity = city.city;
|
|
selectedDistrict = '';
|
|
updateRegionDisplay();
|
|
// 生成区县选项
|
|
generateDistrictOptions(city.districts);
|
|
};
|
|
cityList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 生成区县选项
|
|
function generateDistrictOptions(districts) {
|
|
const districtList = document.getElementById('districtList');
|
|
|
|
districtList.innerHTML = '';
|
|
districts.forEach(district => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = district;
|
|
option.onclick = () => {
|
|
selectedDistrict = district;
|
|
updateRegionDisplay();
|
|
};
|
|
option.ondblclick = () => {
|
|
// 双击区县直接确认整个地区选择
|
|
selectedDistrict = district;
|
|
updateRegionDisplay();
|
|
// 构建完整的地区字符串
|
|
const regionString = `${selectedProvince} ${selectedCity} ${selectedDistrict}`;
|
|
// 设置到表单
|
|
document.getElementById('regionDisplayText').textContent = regionString;
|
|
document.getElementById('regionValue').value = regionString;
|
|
// 隐藏弹窗
|
|
hideRegionSelectModal();
|
|
saveFormData(); // 保存选择
|
|
};
|
|
districtList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 更新地区显示
|
|
function updateRegionDisplay() {
|
|
const currentRegion = document.getElementById('currentRegion');
|
|
let displayText = '当前选择: ';
|
|
if (selectedProvince && selectedCity && selectedDistrict) {
|
|
displayText += `${selectedProvince} ${selectedCity} ${selectedDistrict}`;
|
|
} else if (selectedProvince && selectedCity) {
|
|
displayText += `${selectedProvince} ${selectedCity}`;
|
|
} else if (selectedProvince) {
|
|
displayText += selectedProvince;
|
|
} else {
|
|
displayText += '未选择';
|
|
}
|
|
currentRegion.textContent = displayText;
|
|
}
|
|
|
|
// 过滤地区选项并自动填充
|
|
function filterRegionOptions() {
|
|
const searchInput = document.getElementById('regionSearchInput');
|
|
const searchKeyword = searchInput.value.toLowerCase();
|
|
|
|
// 重置选择
|
|
selectedProvince = '';
|
|
selectedCity = '';
|
|
selectedDistrict = '';
|
|
|
|
// 先尝试直接查找区县
|
|
let foundDistrict = false;
|
|
for (let i = 0; i < allRegionOptions.length; i++) {
|
|
const province = allRegionOptions[i];
|
|
for (let j = 0; j < province.cities.length; j++) {
|
|
const city = province.cities[j];
|
|
for (let k = 0; k < city.districts.length; k++) {
|
|
const district = city.districts[k];
|
|
if (district.toLowerCase().includes(searchKeyword)) {
|
|
// 找到匹配的区县,自动填充省市区
|
|
selectedProvince = province.province;
|
|
selectedCity = city.city;
|
|
selectedDistrict = district;
|
|
foundDistrict = true;
|
|
break;
|
|
}
|
|
}
|
|
if (foundDistrict) break;
|
|
}
|
|
if (foundDistrict) break;
|
|
}
|
|
|
|
if (foundDistrict) {
|
|
// 如果找到区县,只显示对应的省份
|
|
filteredProvinces = allRegionOptions.filter(province => province.province === selectedProvince);
|
|
generateRegionOptions();
|
|
|
|
// 自动生成城市选项并选择
|
|
const cityList = document.getElementById('cityList');
|
|
cityList.innerHTML = '';
|
|
const province = allRegionOptions.find(p => p.province === selectedProvince);
|
|
if (province) {
|
|
province.cities.forEach(city => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = city.city;
|
|
if (city.city === selectedCity) {
|
|
option.classList.add('selected');
|
|
}
|
|
option.onclick = () => {
|
|
selectedCity = city.city;
|
|
selectedDistrict = '';
|
|
updateRegionDisplay();
|
|
generateDistrictOptions(city.districts);
|
|
};
|
|
cityList.appendChild(option);
|
|
|
|
// 如果是选中的城市,生成区县选项
|
|
if (city.city === selectedCity) {
|
|
generateDistrictOptions(city.districts);
|
|
}
|
|
});
|
|
}
|
|
|
|
// 更新区县选项的选中状态
|
|
const districtList = document.getElementById('districtList');
|
|
const districtOptions = districtList.querySelectorAll('.select-item');
|
|
districtOptions.forEach(option => {
|
|
if (option.textContent === selectedDistrict) {
|
|
option.classList.add('selected');
|
|
}
|
|
});
|
|
} else {
|
|
// 否则按原逻辑过滤
|
|
filteredProvinces = allRegionOptions.filter(province => {
|
|
return province.province.toLowerCase().includes(searchKeyword) ||
|
|
province.cities.some(city => city.city.toLowerCase().includes(searchKeyword) ||
|
|
city.districts.some(district => district.toLowerCase().includes(searchKeyword)));
|
|
});
|
|
|
|
generateRegionOptions();
|
|
// 清空城市和区县选项
|
|
document.getElementById('cityList').innerHTML = '';
|
|
document.getElementById('districtList').innerHTML = '';
|
|
}
|
|
|
|
updateRegionDisplay();
|
|
}
|
|
|
|
// 确认地区选择
|
|
function confirmRegionSelection() {
|
|
if (selectedProvince && selectedCity && selectedDistrict) {
|
|
const regionDisplayText = document.getElementById('regionDisplayText');
|
|
const regionValue = document.getElementById('regionValue');
|
|
const regionText = `${selectedProvince} ${selectedCity} ${selectedDistrict}`;
|
|
regionDisplayText.textContent = regionText;
|
|
regionValue.value = regionText;
|
|
}
|
|
hideRegionSelectModal();
|
|
}
|
|
|
|
// 确认创建货源时,获取隐藏域的值
|
|
function addSupply() {
|
|
const spec = document.getElementById('specValue').value;
|
|
const region = document.getElementById('regionValue').value;
|
|
|
|
// 继续原有逻辑...
|
|
}
|
|
|
|
// 加载联系人数据
|
|
async function loadContacts() {
|
|
try {
|
|
const response = await fetch('/api/contacts');
|
|
if (!response.ok) {
|
|
throw new Error('服务器响应异常');
|
|
}
|
|
const result = await response.json();
|
|
// 确保contacts是一个数组
|
|
contacts = result.data || [];
|
|
console.log('联系人数据加载成功:', contacts);
|
|
updateContactSelects();
|
|
} catch (error) {
|
|
console.error('加载联系人数据失败:', error);
|
|
// 出错时将contacts设为空数组,避免后续错误
|
|
contacts = [];
|
|
}
|
|
}
|
|
|
|
// 更新联系人选择下拉框
|
|
function updateContactSelects() {
|
|
const contactSelect = document.getElementById('contactId');
|
|
if (!contactSelect) return;
|
|
|
|
// 清空现有选项
|
|
contactSelect.innerHTML = '';
|
|
|
|
// 添加默认选项
|
|
const defaultOption = document.createElement('option');
|
|
defaultOption.value = '';
|
|
defaultOption.textContent = '请选择联系人';
|
|
contactSelect.appendChild(defaultOption);
|
|
|
|
// 添加联系人选项,只显示有电话号码的联系人
|
|
contacts.forEach(contact => {
|
|
// 确保联系人有电话号码
|
|
if (contact.phoneNumber && contact.phoneNumber.trim() !== '') {
|
|
const option = document.createElement('option');
|
|
option.value = contact.id;
|
|
option.textContent = `${contact.name} (${contact.phoneNumber})`;
|
|
contactSelect.appendChild(option);
|
|
}
|
|
});
|
|
}
|
|
|
|
// 处理窗口大小变化
|
|
function handleResize() {
|
|
// 可以在这里添加响应式处理逻辑
|
|
}
|
|
|
|
// 加载货源列表
|
|
async function loadSupplies() {
|
|
try {
|
|
// 获取当前登录用户信息
|
|
const userInfo = checkLogin();
|
|
if (!userInfo) return;
|
|
|
|
// 重置所有状态的分页数据
|
|
supplyData.pagination = {
|
|
published: { currentPage: 1, pageSize: 20, total: 0, hasMore: true, isLoading: false },
|
|
pending: { currentPage: 1, pageSize: 20, total: 0, hasMore: true, isLoading: false },
|
|
rejected: { currentPage: 1, pageSize: 20, total: 0, hasMore: true, isLoading: false },
|
|
draft: { currentPage: 1, pageSize: 20, total: 0, hasMore: true, isLoading: false }
|
|
};
|
|
|
|
// 清空所有状态的分页数据
|
|
supplyData.paginatedSupplies = {
|
|
published: [],
|
|
pending: [],
|
|
rejected: [],
|
|
draft: []
|
|
};
|
|
|
|
// 构建查询参数,获取所有数据
|
|
const queryParams = new URLSearchParams({
|
|
sellerId: userInfo.userId,
|
|
page: 1,
|
|
pageSize: 1000 // 设置较大的pageSize,确保获取所有记录
|
|
});
|
|
|
|
const apiUrl = `/api/supplies?${queryParams}`;
|
|
console.log('加载货源列表API请求:', apiUrl);
|
|
|
|
const response = await fetch(apiUrl);
|
|
const result = await response.json();
|
|
if (result.success) {
|
|
console.log('加载到的货源数量:', result.data.list.length);
|
|
processSupplyData(result.data.list);
|
|
renderSupplyLists();
|
|
}
|
|
} catch (error) {
|
|
console.error('加载货源失败:', error);
|
|
}
|
|
}
|
|
|
|
// 处理货源数据
|
|
function processSupplyData(supplies) {
|
|
// 获取当前登录用户的userId,用于对比
|
|
const userInfo = JSON.parse(localStorage.getItem('userInfo'));
|
|
const currentUserId = userInfo?.userId || userInfo?.id || '未获取到';
|
|
|
|
console.log(`=== 处理货源数据 ===`);
|
|
console.log(`当前登录用户ID: ${currentUserId}`);
|
|
console.log(`API返回的货源总数: ${supplies.length}`);
|
|
|
|
// 检查每个货源的sellerId,确保只包含当前用户的货源
|
|
const filteredSupplies = supplies.filter(supply => {
|
|
// 如果货源没有sellerId,默认包含
|
|
if (!supply.sellerId) {
|
|
console.warn(`货源 ${supply.id || supply.productId} 没有sellerId,默认包含`);
|
|
return true;
|
|
}
|
|
|
|
// 检查货源的sellerId是否与当前用户ID匹配,考虑类型转换
|
|
const match = String(supply.sellerId) === String(currentUserId);
|
|
if (!match) {
|
|
console.log(`过滤掉不属于当前用户的货源: 货源sellerId=${supply.sellerId},当前用户ID=${currentUserId}`);
|
|
} else {
|
|
console.log(`保留当前用户的货源: 货源sellerId=${supply.sellerId},当前用户ID=${currentUserId}`);
|
|
}
|
|
return match;
|
|
});
|
|
|
|
console.log(`过滤后保留的货源数量: ${filteredSupplies.length}`);
|
|
|
|
// 使用过滤后的货源数据
|
|
supplyData.supplies = filteredSupplies;
|
|
|
|
// 按状态分类
|
|
supplyData.publishedSupplies = filteredSupplies.filter(item => item.status === 'published');
|
|
supplyData.pendingSupplies = filteredSupplies.filter(item => item.status === 'pending_review');
|
|
supplyData.rejectedSupplies = filteredSupplies.filter(item => item.status === 'rejected');
|
|
supplyData.draftSupplies = filteredSupplies.filter(item => item.status === 'hidden' || item.status === 'sold_out');
|
|
}
|
|
|
|
// 渲染货源列表
|
|
function renderSupplyLists() {
|
|
// 获取当前登录用户信息,用于调试
|
|
const userInfo = JSON.parse(localStorage.getItem('userInfo'));
|
|
const currentUserId = userInfo?.userId || userInfo?.id || '未获取到';
|
|
|
|
// 控制台输出当前状态,帮助调试
|
|
console.log(`=== 渲染货源列表 ===`);
|
|
console.log(`当前登录用户ID: ${currentUserId}`);
|
|
console.log(`已上架货源数量: ${supplyData.publishedSupplies.length}`);
|
|
console.log(`审核中货源数量: ${supplyData.pendingSupplies.length}`);
|
|
console.log(`审核失败货源数量: ${supplyData.rejectedSupplies.length}`);
|
|
console.log(`下架状态货源数量: ${supplyData.draftSupplies.length}`);
|
|
console.log(`总货源数量: ${supplyData.supplies.length}`);
|
|
|
|
// 渲染各个状态的货源列表
|
|
renderSupplyList('published', supplyData.publishedSupplies);
|
|
renderSupplyList('pending', supplyData.pendingSupplies);
|
|
renderSupplyList('rejected', supplyData.rejectedSupplies);
|
|
renderSupplyList('draft', supplyData.draftSupplies);
|
|
}
|
|
|
|
// 渲染单个货源列表
|
|
function renderSupplyList(type, supplies) {
|
|
const listElement = document.getElementById(`${type}List`);
|
|
const titleElement = listElement.previousElementSibling.querySelector('.section-title');
|
|
|
|
// 更新标题数量
|
|
titleElement.textContent = `${getSectionTitle(type)} (${supplies.length})`;
|
|
|
|
if (supplies.length === 0) {
|
|
listElement.innerHTML = '<div class="empty-state">暂无数据</div>';
|
|
return;
|
|
}
|
|
|
|
// 只在首次渲染或没有分页数据时初始化分页数据
|
|
if (!supplyData.paginatedSupplies[type] || supplyData.paginatedSupplies[type].length === 0) {
|
|
updatePaginatedSupplies(type, supplies);
|
|
}
|
|
|
|
const pagination = supplyData.pagination[type];
|
|
const paginatedSupplies = supplyData.paginatedSupplies[type] || [];
|
|
|
|
let html = '';
|
|
// 显示所有货源,不分页
|
|
supplies.forEach(supply => {
|
|
html += generateSupplyItemHTML(supply);
|
|
});
|
|
|
|
listElement.innerHTML = html;
|
|
}
|
|
|
|
// 加载更多货源
|
|
function loadMoreSupplies(type) {
|
|
const pagination = supplyData.pagination[type];
|
|
const allSupplies = getSuppliesByType(type);
|
|
|
|
if (pagination.isLoading || !pagination.hasMore) {
|
|
return;
|
|
}
|
|
|
|
pagination.isLoading = true;
|
|
|
|
// 更新加载状态文本
|
|
const loadMoreText = document.getElementById(`loadMoreText_${type}`);
|
|
if (loadMoreText) {
|
|
loadMoreText.textContent = '加载中...';
|
|
}
|
|
|
|
// 模拟加载延迟
|
|
setTimeout(() => {
|
|
// 计算下一页数据
|
|
const nextPage = pagination.currentPage + 1;
|
|
const startIndex = pagination.pageSize * pagination.currentPage;
|
|
const endIndex = startIndex + pagination.pageSize;
|
|
const newSupplies = allSupplies.slice(startIndex, endIndex);
|
|
|
|
// 更新分页数据
|
|
supplyData.paginatedSupplies[type] = [...supplyData.paginatedSupplies[type], ...newSupplies];
|
|
pagination.currentPage = nextPage;
|
|
pagination.hasMore = endIndex < allSupplies.length;
|
|
|
|
// 重新渲染列表
|
|
renderSupplyList(type, allSupplies);
|
|
|
|
// 重置加载状态
|
|
pagination.isLoading = false;
|
|
}, 500);
|
|
}
|
|
|
|
// 根据类型获取完整的货源列表
|
|
function getSuppliesByType(type) {
|
|
switch(type) {
|
|
case 'published': return supplyData.publishedSupplies;
|
|
case 'pending': return supplyData.pendingSupplies;
|
|
case 'rejected': return supplyData.rejectedSupplies;
|
|
case 'draft': return supplyData.draftSupplies;
|
|
default: return [];
|
|
}
|
|
}
|
|
|
|
// 更新分页数据
|
|
function updatePaginatedSupplies(status, supplies) {
|
|
const pagination = supplyData.pagination[status];
|
|
|
|
// 重置分页状态
|
|
pagination.currentPage = 1;
|
|
pagination.total = supplies.length;
|
|
pagination.hasMore = supplies.length > pagination.pageSize;
|
|
|
|
// 初始只显示第一页数据
|
|
supplyData.paginatedSupplies[status] = supplies.slice(0, pagination.pageSize);
|
|
|
|
console.log(`更新分页数据 - ${status}: 总数=${pagination.total}, 每页=${pagination.pageSize}, 有更多=${pagination.hasMore}`);
|
|
}
|
|
|
|
// 获取列表标题
|
|
function getSectionTitle(type) {
|
|
switch(type) {
|
|
case 'published': return '已上架货源';
|
|
case 'pending': return '审核中的货源';
|
|
case 'rejected': return '审核失败的货源';
|
|
case 'draft': return '下架状态货源';
|
|
default: return '货源';
|
|
}
|
|
}
|
|
|
|
// 生成货源项HTML
|
|
function generateSupplyItemHTML(supply) {
|
|
const statusMap = {
|
|
'published': { text: '已上架', class: 'status-published' },
|
|
'pending_review': { text: '审核中', class: 'status-pending' },
|
|
'rejected': { text: '审核失败', class: 'status-rejected' },
|
|
'hidden': { text: '已隐藏', class: 'status-draft' },
|
|
'sold_out': { text: '已下架', class: 'status-draft' }
|
|
};
|
|
|
|
const status = statusMap[supply.status] || { text: '未知', class: 'status-draft' };
|
|
|
|
// 处理图片
|
|
const imageUrl = supply.imageUrls && supply.imageUrls.length > 0 ? supply.imageUrls[0] : '';
|
|
|
|
// 处理操作按钮
|
|
let actionsHTML = '';
|
|
if (supply.status === 'published') {
|
|
actionsHTML = `<button class="btn-primary" onclick="unpublishSupply('${supply.id}')">下架</button>`;
|
|
} else if (supply.status === 'pending_review') {
|
|
actionsHTML = `
|
|
<button class="btn-warning" onclick="showEditSupply('${supply.id}')">编辑</button>
|
|
<button class="btn-danger" onclick="deleteSupply('${supply.id}')">删除</button>
|
|
`;
|
|
} else if (supply.status === 'rejected') {
|
|
actionsHTML = `
|
|
<button class="btn-success" onclick="preparePublishSupply('${supply.id}')">上架</button>
|
|
<button class="btn-danger" onclick="deleteSupply('${supply.id}')">删除</button>
|
|
<button class="btn-primary" onclick="showRejectReason('${supply.id}')">查看原因</button>
|
|
`;
|
|
} else if (supply.status === 'hidden' || supply.status === 'sold_out') {
|
|
actionsHTML = `
|
|
<button class="btn-primary" onclick="preparePublishSupply('${supply.id}')">上架</button>
|
|
<button class="btn-danger" onclick="deleteSupply('${supply.id}')">删除</button>
|
|
`;
|
|
}
|
|
|
|
return `
|
|
<div class="supply-item" data-id="${supply.id}">
|
|
<div class="supply-images">
|
|
<div class="image-slider">
|
|
<img src="${imageUrl || 'data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%22100%22 height=%22100%22%3E%3Crect width=%22100%22 height=%22100%22 fill=%22%23f5f5f5%22/%3E%3Ctext x=%2250%22 y=%2250%22 font-family=%22Arial%22 font-size=%2212%22 fill=%22%23999%22 text-anchor=%22middle%22 dominant-baseline=%22middle%22%3E暂无图片%3C/text%3E%3C/svg%3E'}" alt="${supply.productName}" onclick="previewImage('${imageUrl || ''}', ${supply.imageUrls ? `[${supply.imageUrls.map(url => `'${url}'`).join(', ')}]` : '[]'})">
|
|
</div>
|
|
</div>
|
|
<div class="supply-info">
|
|
<div class="supply-name">
|
|
${supply.productName}
|
|
<span class="supply-status ${status.class}">${status.text}</span>
|
|
</div>
|
|
<div class="supply-details">
|
|
<div class="detail-item">蛋黄: ${supply.yolk || '无'}</div>
|
|
<div class="detail-item">规格: ${supply.specification || supply.spec || '无'}</div>
|
|
<div class="detail-item">货源状态: ${supply.supplyStatus || '未设置'}</div>
|
|
<div class="detail-item">货源描述: ${supply.description || '无'}</div>
|
|
<div class="detail-item">件数: ${supply.quantity || '0'}件</div>
|
|
<div class="detail-item">斤重: ${supply.grossWeight || ''}斤</div>
|
|
<div class="detail-item">地区: ${supply.region || '未设置'}</div>
|
|
<div class="detail-item" style="color: #f5222d;">价格: ¥${supply.price || '0'}</div>
|
|
<div class="detail-item" style="font-size: 12px; color: #999;">创建时间: ${formatDate(supply.created_at)}</div>
|
|
</div>
|
|
<div class="supply-actions">
|
|
${actionsHTML}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
// 格式化日期
|
|
function formatDate(dateString) {
|
|
if (!dateString) return '未知';
|
|
const date = new Date(dateString);
|
|
return `${date.getFullYear()}/${(date.getMonth() + 1).toString().padStart(2, '0')}/${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`;
|
|
}
|
|
|
|
// 切换列表展开/折叠
|
|
function toggleSection(type) {
|
|
const listElement = document.getElementById(`${type}List`);
|
|
const toggleElement = document.getElementById(`${type}Toggle`);
|
|
|
|
if (listElement.classList.contains('expanded')) {
|
|
listElement.classList.remove('expanded');
|
|
toggleElement.classList.remove('expanded');
|
|
} else {
|
|
listElement.classList.add('expanded');
|
|
toggleElement.classList.add('expanded');
|
|
}
|
|
}
|
|
|
|
// 搜索功能
|
|
function onSearchInput(event) {
|
|
supplyData.searchKeyword = event.target.value;
|
|
const clearSearch = document.getElementById('clearSearch');
|
|
clearSearch.style.display = supplyData.searchKeyword ? 'block' : 'none';
|
|
|
|
// 可以在这里添加实时搜索逻辑
|
|
}
|
|
|
|
function onSearchConfirm(event) {
|
|
if (event.key === 'Enter') {
|
|
searchSupplies();
|
|
}
|
|
}
|
|
|
|
function clearSearch() {
|
|
const searchInput = document.getElementById('searchInput');
|
|
searchInput.value = '';
|
|
supplyData.searchKeyword = '';
|
|
document.getElementById('clearSearch').style.display = 'none';
|
|
searchSupplies();
|
|
}
|
|
|
|
async function searchSupplies() {
|
|
try {
|
|
// 获取当前登录用户信息
|
|
const userInfo = checkLogin();
|
|
if (!userInfo) return;
|
|
|
|
// 构建查询参数,添加sellerId
|
|
const queryParams = new URLSearchParams({
|
|
sellerId: userInfo.userId,
|
|
keyword: supplyData.searchKeyword
|
|
});
|
|
|
|
const response = await fetch(`/api/supplies?${queryParams}`);
|
|
const result = await response.json();
|
|
if (result.success) {
|
|
processSupplyData(result.data.list);
|
|
renderSupplyLists();
|
|
}
|
|
} catch (error) {
|
|
console.error('搜索失败:', error);
|
|
}
|
|
}
|
|
|
|
// 设置货源状态(预售/现货)
|
|
function setSupplyStatus(status) {
|
|
document.getElementById('supplyStatus').value = status;
|
|
// 更新按钮样式
|
|
if (status === '预售') {
|
|
document.getElementById('preSaleBtn').style.borderColor = '#1677ff';
|
|
document.getElementById('preSaleBtn').style.color = '#1677ff';
|
|
document.getElementById('inStockBtn').style.borderColor = '#d9d9d9';
|
|
document.getElementById('inStockBtn').style.color = '#666';
|
|
} else if (status === '现货') {
|
|
document.getElementById('inStockBtn').style.borderColor = '#1677ff';
|
|
document.getElementById('inStockBtn').style.color = '#1677ff';
|
|
document.getElementById('preSaleBtn').style.borderColor = '#d9d9d9';
|
|
document.getElementById('preSaleBtn').style.color = '#666';
|
|
}
|
|
// 自动保存表单数据
|
|
saveFormData();
|
|
}
|
|
|
|
// 重置表单函数(全局函数,以便多个地方可以调用)
|
|
function resetForm() {
|
|
document.getElementById('createSupplyForm').reset();
|
|
document.getElementById('uploadImages').innerHTML = '';
|
|
supplyData.uploadedImages = [];
|
|
// 重置自定义选择状态
|
|
document.getElementById('specDisplayText').textContent = '请选择规格';
|
|
document.getElementById('regionDisplayText').textContent = '请选择地区';
|
|
document.getElementById('sourceTypeDisplayText').textContent = '请选择货源类型';
|
|
document.getElementById('productNameDisplayText').textContent = '请选择商品名称';
|
|
document.getElementById('yolkDisplayText').textContent = '请选择蛋黄类型';
|
|
document.getElementById('contactIdDisplayText').textContent = '请选择联系人';
|
|
// 重置选择变量
|
|
selectedSpec = '';
|
|
selectedProvince = '';
|
|
selectedCity = '';
|
|
selectedDistrict = '';
|
|
selectedSourceType = '';
|
|
selectedProductName = '';
|
|
selectedYolk = '';
|
|
selectedContactId = '';
|
|
// 确保隐藏字段也被重置
|
|
document.getElementById('specValue').value = '';
|
|
document.getElementById('regionValue').value = '';
|
|
document.getElementById('supplyStatus').value = '';
|
|
document.getElementById('sourceType').value = '';
|
|
document.getElementById('productName').value = '';
|
|
document.getElementById('yolk').value = '';
|
|
document.getElementById('contactId').value = '';
|
|
// 重置货源状态按钮样式
|
|
document.getElementById('preSaleBtn').style.borderColor = '#d9d9d9';
|
|
document.getElementById('preSaleBtn').style.color = '#666';
|
|
document.getElementById('inStockBtn').style.borderColor = '#d9d9d9';
|
|
document.getElementById('inStockBtn').style.color = '#666';
|
|
}
|
|
|
|
// 显示创建货源模态框
|
|
function showAddSupplyModal() {
|
|
document.getElementById('createSupplyModal').style.display = 'flex';
|
|
|
|
// 尝试从localStorage加载保存的表单数据
|
|
const savedFormData = localStorage.getItem('supplyFormDraft');
|
|
if (savedFormData) {
|
|
try {
|
|
const formData = JSON.parse(savedFormData);
|
|
|
|
// 初始化图片数组,避免重复赋值导致潜在问题
|
|
supplyData.uploadedImages = [];
|
|
|
|
// 填充表单字段并添加空值检查
|
|
const productName = document.getElementById('productName');
|
|
const price = document.getElementById('price');
|
|
const quantity = document.getElementById('quantity');
|
|
const grossWeight = document.getElementById('grossWeight');
|
|
const yolk = document.getElementById('yolk');
|
|
const specValue = document.getElementById('specValue');
|
|
const supplyStatus = document.getElementById('supplyStatus');
|
|
const sourceType = document.getElementById('sourceType');
|
|
const description = document.getElementById('description');
|
|
const regionValue = document.getElementById('regionValue');
|
|
const contactId = document.getElementById('contactId');
|
|
const specDisplayText = document.getElementById('specDisplayText');
|
|
const regionDisplayText = document.getElementById('regionDisplayText');
|
|
|
|
// 安全地设置表单值
|
|
if (productName) productName.value = formData.productName || '';
|
|
if (price) price.value = formData.price || '';
|
|
if (quantity) quantity.value = formData.quantity || '';
|
|
if (grossWeight) grossWeight.value = formData.grossWeight || '';
|
|
if (yolk) yolk.value = formData.yolk || '';
|
|
if (specValue) specValue.value = formData.specification || '';
|
|
if (supplyStatus) supplyStatus.value = formData.supplyStatus || '';
|
|
if (sourceType) sourceType.value = formData.sourceType || '';
|
|
if (description) description.value = formData.description || '';
|
|
if (regionValue) regionValue.value = formData.region || '';
|
|
if (contactId) contactId.value = formData.contactId || '';
|
|
|
|
// 恢复自定义下拉框显示文本(规格和地区)
|
|
if (specDisplayText && formData.specificationDisplay) {
|
|
specDisplayText.textContent = formData.specificationDisplay;
|
|
}
|
|
if (regionDisplayText && formData.regionDisplay) {
|
|
regionDisplayText.textContent = formData.regionDisplay;
|
|
}
|
|
// 恢复其他自定义下拉框显示文本
|
|
if (sourceTypeDisplayText && formData.sourceTypeDisplay) {
|
|
sourceTypeDisplayText.textContent = formData.sourceTypeDisplay;
|
|
}
|
|
if (productNameDisplayText && formData.productNameDisplay) {
|
|
productNameDisplayText.textContent = formData.productNameDisplay;
|
|
}
|
|
if (yolkDisplayText && formData.yolkDisplay) {
|
|
yolkDisplayText.textContent = formData.yolkDisplay;
|
|
}
|
|
if (contactIdDisplayText && formData.contactIdDisplay) {
|
|
contactIdDisplayText.textContent = formData.contactIdDisplay;
|
|
}
|
|
|
|
// 对于标准select元素,确保设置value后触发change事件
|
|
// 这样select元素会自动显示正确的选项文本
|
|
const standardDropdowns = [productName, yolk, sourceType, contactId];
|
|
standardDropdowns.forEach(select => {
|
|
if (select && select.tagName === 'SELECT' && select.value) {
|
|
// 强制触发change事件以确保UI更新
|
|
const event = new Event('change', { bubbles: true });
|
|
select.dispatchEvent(event);
|
|
}
|
|
})
|
|
|
|
// 恢复自定义选择状态变量
|
|
if (formData.selectedSpec) selectedSpec = formData.selectedSpec;
|
|
if (formData.selectedProvince) selectedProvince = formData.selectedProvince;
|
|
if (formData.selectedCity) selectedCity = formData.selectedCity;
|
|
if (formData.selectedDistrict) selectedDistrict = formData.selectedDistrict;
|
|
|
|
// 为所有下拉框触发change事件,确保UI完全同步
|
|
const dropdownElements = [productName, yolk, sourceType, contactId];
|
|
dropdownElements.forEach(element => {
|
|
if (element && element.tagName === 'SELECT' && element.value) {
|
|
const event = new Event('change', { bubbles: true });
|
|
element.dispatchEvent(event);
|
|
}
|
|
});
|
|
|
|
// 设置货源状态按钮样式
|
|
if (formData.supplyStatus && (formData.supplyStatus === '预售' || formData.supplyStatus === '现货')) {
|
|
setSupplyStatus(formData.supplyStatus);
|
|
} else {
|
|
// 默认设置为预售
|
|
setSupplyStatus('预售');
|
|
}
|
|
|
|
// 恢复自定义选择显示文本和状态
|
|
if (specDisplayText) specDisplayText.textContent = formData.specificationDisplay || '请选择规格';
|
|
if (regionDisplayText) regionDisplayText.textContent = formData.regionDisplay || '请选择地区';
|
|
|
|
// 恢复自定义选择状态
|
|
selectedSpec = formData.selectedSpec || '';
|
|
selectedProvince = formData.selectedProvince || '';
|
|
selectedCity = formData.selectedCity || '';
|
|
selectedDistrict = formData.selectedDistrict || '';
|
|
selectedSourceType = formData.selectedSourceType || '';
|
|
selectedProductName = formData.selectedProductName || '';
|
|
selectedYolk = formData.selectedYolk || '';
|
|
selectedContactId = formData.selectedContactId || '';
|
|
|
|
// 恢复上传的图片信息 - 只执行一次,避免重复渲染
|
|
if (formData.imageUrls && Array.isArray(formData.imageUrls) && formData.imageUrls.length > 0) {
|
|
supplyData.uploadedImages = [...formData.imageUrls]; // 创建副本避免引用问题
|
|
renderUploadedImages();
|
|
}
|
|
|
|
console.log('已加载保存的表单数据');
|
|
} catch (e) {
|
|
console.error('加载保存的表单数据失败:', e);
|
|
// 如果加载失败,重置表单
|
|
resetForm();
|
|
}
|
|
} else {
|
|
// 没有保存的数据,重置表单
|
|
resetForm();
|
|
}
|
|
|
|
// 添加表单自动保存事件监听
|
|
setupAutoSave();
|
|
}
|
|
|
|
// 隐藏创建货源模态框
|
|
function hideAddSupplyModal() {
|
|
// 保存当前表单状态
|
|
saveFormData();
|
|
document.getElementById('createSupplyModal').style.display = 'none';
|
|
}
|
|
|
|
// 触发图片上传
|
|
function triggerImageUpload() {
|
|
document.getElementById('imageUpload').click();
|
|
}
|
|
|
|
// 为图片添加水印(前端Canvas实现)
|
|
function addWatermarkToImage(imageUrl) {
|
|
return new Promise((resolve, reject) => {
|
|
const img = new Image();
|
|
img.crossOrigin = 'anonymous'; // 允许跨域图片
|
|
|
|
img.onload = function() {
|
|
// 创建Canvas元素
|
|
const canvas = document.createElement('canvas');
|
|
const ctx = canvas.getContext('2d');
|
|
|
|
// 设置Canvas尺寸与图片相同
|
|
canvas.width = img.width;
|
|
canvas.height = img.height;
|
|
|
|
// 绘制原始图片
|
|
ctx.drawImage(img, 0, 0);
|
|
|
|
// 设置水印样式
|
|
ctx.font = '20px Arial';
|
|
ctx.fillStyle = 'rgba(0, 0, 0, 0.5)';
|
|
ctx.textAlign = 'right';
|
|
ctx.textBaseline = 'bottom';
|
|
|
|
// 水印文字
|
|
const watermarkText = '又鸟蛋平台';
|
|
|
|
// 计算文字位置(右下角)
|
|
const margin = 10;
|
|
|
|
// 绘制水印
|
|
ctx.fillText(watermarkText, canvas.width - margin, canvas.height - margin);
|
|
|
|
// 将Canvas转换为DataURL
|
|
const watermarkedImageUrl = canvas.toDataURL('image/jpeg', 0.9);
|
|
resolve(watermarkedImageUrl);
|
|
};
|
|
|
|
img.onerror = function() {
|
|
// 如果添加水印失败,返回原始图片
|
|
resolve(imageUrl);
|
|
};
|
|
|
|
img.src = imageUrl;
|
|
});
|
|
}
|
|
|
|
// 处理图片上传
|
|
function handleImageUpload(event) {
|
|
const files = event.target.files;
|
|
const uploadArea = document.getElementById('uploadImages');
|
|
|
|
for (let i = 0; i < files.length; i++) {
|
|
if (supplyData.uploadedImages.length >= 5) {
|
|
alert('最多只能上传5张图片');
|
|
break;
|
|
}
|
|
|
|
const file = files[i];
|
|
const reader = new FileReader();
|
|
|
|
reader.onload = async function(e) {
|
|
let imageUrl = e.target.result;
|
|
|
|
// 为图片添加水印
|
|
imageUrl = await addWatermarkToImage(imageUrl);
|
|
|
|
supplyData.uploadedImages.push(imageUrl);
|
|
renderUploadedImages();
|
|
// 图片上传后自动保存表单数据
|
|
saveFormData();
|
|
};
|
|
|
|
reader.readAsDataURL(file);
|
|
}
|
|
|
|
// 清空文件输入,允许再次选择相同文件
|
|
event.target.value = '';
|
|
}
|
|
|
|
// 渲染已上传图片
|
|
function renderUploadedImages() {
|
|
const uploadArea = document.getElementById('uploadImages');
|
|
uploadArea.innerHTML = '';
|
|
|
|
supplyData.uploadedImages.forEach((imageUrl, index) => {
|
|
const imageElement = document.createElement('div');
|
|
imageElement.className = 'upload-image';
|
|
imageElement.innerHTML = `
|
|
<img src="${imageUrl}" alt="商品图片" onclick="previewImage('${imageUrl}')">
|
|
<div class="delete-image" onclick="deleteUploadedImage(${index})"></div>
|
|
`;
|
|
uploadArea.appendChild(imageElement);
|
|
});
|
|
}
|
|
|
|
// 删除已上传图片
|
|
function deleteUploadedImage(index) {
|
|
supplyData.uploadedImages.splice(index, 1);
|
|
renderUploadedImages();
|
|
// 删除图片后自动保存表单数据
|
|
saveFormData();
|
|
}
|
|
|
|
// 设置表单自动保存
|
|
function setupAutoSave() {
|
|
// 为所有输入字段添加输入事件监听
|
|
const formFields = ['productName', 'price', 'quantity', 'grossWeight', 'yolk', 'specValue', 'supplyStatus', 'description', 'regionValue', 'contactId', 'sourceType'];
|
|
|
|
formFields.forEach(fieldId => {
|
|
const element = document.getElementById(fieldId);
|
|
if (element) {
|
|
// 先移除可能存在的事件监听器,避免重复添加
|
|
const newElement = element.cloneNode(true);
|
|
element.parentNode.replaceChild(newElement, element);
|
|
|
|
// 添加新的事件监听器
|
|
newElement.addEventListener('input', function() {
|
|
saveFormData();
|
|
});
|
|
|
|
// 为select元素添加change事件监听
|
|
if (newElement.tagName === 'SELECT') {
|
|
newElement.addEventListener('change', function() {
|
|
saveFormData();
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
// 为自定义选择区域添加额外的事件监听,确保所有自定义下拉框更改时也能保存
|
|
const customDisplays = [
|
|
'specDisplayText',
|
|
'regionDisplayText',
|
|
'sourceTypeDisplayText',
|
|
'productNameDisplayText',
|
|
'yolkDisplayText',
|
|
'contactIdDisplayText'
|
|
];
|
|
|
|
customDisplays.forEach(displayId => {
|
|
const display = document.getElementById(displayId);
|
|
// 使用MutationObserver监听文本变化
|
|
if (display) {
|
|
const observer = new MutationObserver(() => {
|
|
saveFormData();
|
|
});
|
|
observer.observe(display, { childList: true, characterData: true });
|
|
}
|
|
});
|
|
|
|
// 为货源状态按钮添加额外的事件监听,确保状态变更能被捕获
|
|
const preSaleBtn = document.getElementById('preSaleBtn');
|
|
const inStockBtn = document.getElementById('inStockBtn');
|
|
|
|
if (preSaleBtn && !preSaleBtn.hasAttribute('data-save-listener')) {
|
|
preSaleBtn.addEventListener('click', () => {
|
|
setTimeout(saveFormData, 0); // 使用setTimeout确保状态已更新
|
|
});
|
|
preSaleBtn.setAttribute('data-save-listener', 'true');
|
|
}
|
|
|
|
if (inStockBtn && !inStockBtn.hasAttribute('data-save-listener')) {
|
|
inStockBtn.addEventListener('click', () => {
|
|
setTimeout(saveFormData, 0); // 使用setTimeout确保状态已更新
|
|
});
|
|
inStockBtn.setAttribute('data-save-listener', 'true');
|
|
}
|
|
}
|
|
|
|
// 保存表单数据到localStorage
|
|
function saveFormData() {
|
|
try {
|
|
// 添加防御性编程,检查元素是否存在
|
|
const productName = document.getElementById('productName');
|
|
const price = document.getElementById('price');
|
|
const quantity = document.getElementById('quantity');
|
|
const grossWeight = document.getElementById('grossWeight');
|
|
const yolk = document.getElementById('yolk');
|
|
const specValue = document.getElementById('specValue');
|
|
const supplyStatus = document.getElementById('supplyStatus');
|
|
const sourceType = document.getElementById('sourceType');
|
|
const description = document.getElementById('description');
|
|
const regionValue = document.getElementById('regionValue');
|
|
const contactId = document.getElementById('contactId');
|
|
const category = document.getElementById('category');
|
|
const specDisplayText = document.getElementById('specDisplayText');
|
|
const regionDisplayText = document.getElementById('regionDisplayText');
|
|
const sourceTypeDisplayText = document.getElementById('sourceTypeDisplayText');
|
|
const productNameDisplayText = document.getElementById('productNameDisplayText');
|
|
const yolkDisplayText = document.getElementById('yolkDisplayText');
|
|
const contactIdDisplayText = document.getElementById('contactIdDisplayText');
|
|
const categoryDisplayText = document.getElementById('categoryDisplayText');
|
|
|
|
// 确保所有字段都是安全获取的
|
|
const formData = {
|
|
productName: productName ? productName.value : '',
|
|
category: category ? category.value : '',
|
|
price: price ? price.value : '',
|
|
quantity: quantity ? quantity.value : '',
|
|
grossWeight: grossWeight ? grossWeight.value : '',
|
|
yolk: yolk ? yolk.value : '',
|
|
specification: specValue ? specValue.value : '',
|
|
specificationDisplay: specDisplayText ? specDisplayText.textContent : '请选择规格',
|
|
supplyStatus: supplyStatus ? supplyStatus.value : '预售', // 默认预售
|
|
sourceType: sourceType ? sourceType.value : '',
|
|
description: description ? description.value : '',
|
|
region: regionValue ? regionValue.value : '',
|
|
regionDisplay: regionDisplayText ? regionDisplayText.textContent : '请选择地区',
|
|
contactId: contactId ? contactId.value : '',
|
|
// 保存其他自定义下拉框显示文本
|
|
sourceTypeDisplay: sourceTypeDisplayText ? sourceTypeDisplayText.textContent : '请选择货源类型',
|
|
productNameDisplay: productNameDisplayText ? productNameDisplayText.textContent : '请选择商品名称',
|
|
yolkDisplay: yolkDisplayText ? yolkDisplayText.textContent : '请选择蛋黄类型',
|
|
contactIdDisplay: contactIdDisplayText ? contactIdDisplayText.textContent : '请选择联系人',
|
|
categoryDisplay: categoryDisplayText ? categoryDisplayText.textContent : '请选择种类',
|
|
// 深拷贝图片数组,避免引用问题
|
|
imageUrls: Array.isArray(supplyData.uploadedImages) ? [...supplyData.uploadedImages] : [],
|
|
// 保存自定义选择状态
|
|
selectedSpec: selectedSpec || '',
|
|
selectedProvince: selectedProvince || '',
|
|
selectedCity: selectedCity || '',
|
|
selectedDistrict: selectedDistrict || '',
|
|
selectedSourceType: selectedSourceType || '',
|
|
selectedProductName: selectedProductName || '',
|
|
selectedYolk: selectedYolk || '',
|
|
selectedContactId: selectedContactId || '',
|
|
selectedCategory: selectedCategory || '',
|
|
// 添加时间戳,用于调试和潜在的过期处理
|
|
lastSaved: new Date().toISOString()
|
|
};
|
|
|
|
// 安全地保存到localStorage
|
|
localStorage.setItem('supplyFormDraft', JSON.stringify(formData));
|
|
console.log('表单数据已自动保存');
|
|
} catch (e) {
|
|
console.error('保存表单数据失败:', e);
|
|
// 保存失败时不影响用户体验,静默处理错误
|
|
}
|
|
}
|
|
|
|
// 创建货源
|
|
async function addSupply() {
|
|
// 获取当前登录用户信息
|
|
const userInfo = checkLogin();
|
|
if (!userInfo) return;
|
|
|
|
const formData = {
|
|
productName: document.getElementById('productName').value,
|
|
category: document.getElementById('category').value,
|
|
price: document.getElementById('price').value,
|
|
quantity: document.getElementById('quantity').value,
|
|
grossWeight: document.getElementById('grossWeight').value,
|
|
yolk: document.getElementById('yolk').value,
|
|
specification: document.getElementById('specValue').value,
|
|
supplyStatus: document.getElementById('supplyStatus').value,
|
|
sourceType: document.getElementById('sourceType').value,
|
|
description: document.getElementById('description').value,
|
|
region: document.getElementById('regionValue').value,
|
|
contactId: document.getElementById('contactId').value,
|
|
imageUrls: supplyData.uploadedImages,
|
|
sellerId: userInfo.userId // 添加当前登录用户的userId作为sellerId
|
|
};
|
|
|
|
// 验证表单
|
|
if (!formData.productName) {
|
|
alert('请选择商品名称');
|
|
return;
|
|
}
|
|
if (!formData.category) {
|
|
alert('请选择种类');
|
|
return;
|
|
}
|
|
if (!formData.price) {
|
|
alert('请输入价格');
|
|
return;
|
|
}
|
|
if (!formData.quantity) {
|
|
alert('请输入件数');
|
|
return;
|
|
}
|
|
if (!formData.supplyStatus) {
|
|
alert('请选择货源状态(预售/现货)');
|
|
return;
|
|
}
|
|
if (!formData.sourceType) {
|
|
alert('请选择货源类型');
|
|
return;
|
|
}
|
|
if (!formData.region) {
|
|
alert('请选择地区');
|
|
return;
|
|
}
|
|
if (!formData.contactId) {
|
|
alert('请选择联系人');
|
|
return;
|
|
}
|
|
if (!supplyData.uploadedImages || supplyData.uploadedImages.length === 0) {
|
|
alert('请上传至少一张商品图片');
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const response = await fetch('/api/supplies/create', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify(formData)
|
|
});
|
|
|
|
const result = await response.json();
|
|
if (result.success) {
|
|
// 创建成功,清除保存的表单数据
|
|
localStorage.removeItem('supplyFormDraft');
|
|
console.log('创建成功,已清除保存的表单数据');
|
|
alert('货源创建成功');
|
|
// 重置表单状态,确保下次打开时是空白状态
|
|
resetForm();
|
|
hideAddSupplyModal();
|
|
loadSupplies();
|
|
} else {
|
|
// 创建失败,保持保存的数据
|
|
alert('创建失败: ' + (result.message || '未知错误'));
|
|
}
|
|
} catch (error) {
|
|
console.error('创建货源失败:', error);
|
|
alert('创建失败: 网络错误');
|
|
}
|
|
}
|
|
|
|
// 图片预览 - 完整的缩放和拖动支持
|
|
// 缩放和拖动相关变量
|
|
let scale = 1;
|
|
let pointX = 0;
|
|
let pointY = 0;
|
|
let panning = false;
|
|
let start = { x: 0, y: 0 };
|
|
let lastScale = 1;
|
|
let origin = { x: 0, y: 0 };
|
|
let initialDistance = null;
|
|
let initialScale = 1;
|
|
|
|
// 预览图片 - 支持多张图片切换
|
|
let currentPreviewImages = [];
|
|
let currentPreviewIndex = 0;
|
|
|
|
function previewImage(imageUrl, images = []) {
|
|
if (!imageUrl) return;
|
|
|
|
// 如果传入了图片数组,使用它;否则使用单张图片
|
|
if (images.length > 0) {
|
|
currentPreviewImages = images;
|
|
currentPreviewIndex = currentPreviewImages.indexOf(imageUrl);
|
|
} else {
|
|
currentPreviewImages = [imageUrl];
|
|
currentPreviewIndex = 0;
|
|
}
|
|
|
|
const previewModal = document.getElementById('imagePreview');
|
|
const previewImage = document.getElementById('previewImage');
|
|
|
|
// 更新图片显示
|
|
updatePreviewImage();
|
|
|
|
// 重置缩放和拖动状态
|
|
resetImageTransform();
|
|
|
|
previewModal.classList.add('active');
|
|
|
|
// 设置图片查看器事件
|
|
setupImageViewerEvents();
|
|
}
|
|
|
|
// 更新预览图片
|
|
function updatePreviewImage() {
|
|
const previewImage = document.getElementById('previewImage');
|
|
const previewCounter = document.getElementById('previewCounter');
|
|
|
|
previewImage.src = currentPreviewImages[currentPreviewIndex];
|
|
|
|
// 更新图片计数器
|
|
if (previewCounter) {
|
|
previewCounter.textContent = `${currentPreviewIndex + 1}/${currentPreviewImages.length}`;
|
|
}
|
|
}
|
|
|
|
// 切换到上一张图片
|
|
function prevPreviewImage() {
|
|
if (currentPreviewImages.length <= 1) return;
|
|
|
|
currentPreviewIndex = (currentPreviewIndex - 1 + currentPreviewImages.length) % currentPreviewImages.length;
|
|
updatePreviewImage();
|
|
resetImageTransform();
|
|
}
|
|
|
|
// 切换到下一张图片
|
|
function nextPreviewImage() {
|
|
if (currentPreviewImages.length <= 1) return;
|
|
|
|
currentPreviewIndex = (currentPreviewIndex + 1) % currentPreviewImages.length;
|
|
updatePreviewImage();
|
|
resetImageTransform();
|
|
}
|
|
|
|
// 关闭图片预览
|
|
function closeImagePreview() {
|
|
const previewModal = document.getElementById('imagePreview');
|
|
previewModal.classList.remove('active');
|
|
}
|
|
|
|
// 重置图片变换
|
|
function resetImageTransform() {
|
|
const previewImage = document.getElementById('previewImage');
|
|
scale = 1;
|
|
lastScale = 1;
|
|
pointX = 0;
|
|
pointY = 0;
|
|
origin = { x: 0, y: 0 };
|
|
updateImageTransform();
|
|
}
|
|
|
|
// 更新图片变换
|
|
function updateImageTransform() {
|
|
const previewImage = document.getElementById('previewImage');
|
|
previewImage.style.transform = `translate(${pointX}px, ${pointY}px) scale(${scale})`;
|
|
}
|
|
|
|
// 设置图片查看器事件
|
|
let imageViewerEventsSetup = false;
|
|
function setupImageViewerEvents() {
|
|
// 避免重复添加事件监听器
|
|
if (imageViewerEventsSetup) {
|
|
return;
|
|
}
|
|
|
|
const previewImage = document.getElementById('previewImage');
|
|
const previewModal = document.getElementById('imagePreview');
|
|
const imageViewerContent = document.querySelector('.image-viewer-content');
|
|
|
|
// 鼠标滚轮缩放事件
|
|
if (imageViewerContent.addEventListener) {
|
|
imageViewerContent.addEventListener('wheel', handleWheel, { passive: false });
|
|
imageViewerContent.addEventListener('DOMMouseScroll', handleWheel, { passive: false });
|
|
} else {
|
|
imageViewerContent.attachEvent('onmousewheel', handleWheel);
|
|
}
|
|
|
|
// 鼠标拖动事件
|
|
previewImage.addEventListener('mousedown', handleMouseDown);
|
|
document.addEventListener('mousemove', handleMouseMove);
|
|
document.addEventListener('mouseup', handleMouseUp);
|
|
document.addEventListener('mouseleave', handleMouseUp);
|
|
|
|
// 移动端触摸事件支持
|
|
previewImage.addEventListener('touchstart', handleTouchStart, { passive: false });
|
|
previewImage.addEventListener('touchmove', handleTouchMove, { passive: false });
|
|
previewImage.addEventListener('touchend', handleTouchEnd);
|
|
|
|
// 点击背景关闭预览
|
|
previewModal.addEventListener('click', function(e) {
|
|
if (e.target === previewModal) {
|
|
closeImagePreview();
|
|
}
|
|
});
|
|
|
|
// 隐藏旧的缩放控件
|
|
const zoomControls = document.querySelector('.zoom-controls');
|
|
if (zoomControls) {
|
|
zoomControls.style.display = 'none';
|
|
}
|
|
|
|
imageViewerEventsSetup = true;
|
|
}
|
|
|
|
// 处理鼠标滚轮缩放
|
|
function handleWheel(e) {
|
|
e.preventDefault();
|
|
|
|
// 标准化滚轮事件数据
|
|
let delta = 0;
|
|
if (e.deltaY !== undefined) {
|
|
delta = e.deltaY;
|
|
} else if (e.wheelDelta !== undefined) {
|
|
delta = -e.wheelDelta;
|
|
} else if (e.detail !== undefined) {
|
|
delta = e.detail;
|
|
}
|
|
|
|
// 获取鼠标在图片内容区域的位置
|
|
const imageViewerContent = document.querySelector('.image-viewer-content');
|
|
const rect = imageViewerContent.getBoundingClientRect();
|
|
const mouseX = e.clientX - rect.left;
|
|
const mouseY = e.clientY - rect.top;
|
|
|
|
// 计算鼠标相对于图片的位置
|
|
const imageRect = document.getElementById('previewImage').getBoundingClientRect();
|
|
const relativeX = mouseX - (imageRect.left - rect.left + imageRect.width / 2);
|
|
const relativeY = mouseY - (imageRect.top - rect.top + imageRect.height / 2);
|
|
|
|
// 计算缩放中心点
|
|
const beforeScale = scale;
|
|
const wheelDelta = delta > 0 ? 0.9 : 1.1;
|
|
scale *= wheelDelta;
|
|
|
|
// 限制缩放范围
|
|
scale = Math.min(Math.max(scale, 1), 10);
|
|
|
|
// 根据鼠标位置调整偏移量,实现以鼠标位置为中心的缩放
|
|
const scaleDiff = scale - beforeScale;
|
|
pointX -= relativeX * scaleDiff;
|
|
pointY -= relativeY * scaleDiff;
|
|
|
|
updateImageTransform();
|
|
|
|
return false;
|
|
}
|
|
|
|
// 处理鼠标按下事件
|
|
function handleMouseDown(e) {
|
|
e.preventDefault();
|
|
panning = true;
|
|
start = { x: e.clientX - pointX, y: e.clientY - pointY };
|
|
}
|
|
|
|
// 处理鼠标移动事件
|
|
function handleMouseMove(e) {
|
|
e.preventDefault();
|
|
if (!panning) return;
|
|
|
|
pointX = e.clientX - start.x;
|
|
pointY = e.clientY - start.y;
|
|
|
|
updateImageTransform();
|
|
}
|
|
|
|
// 处理鼠标松开事件
|
|
function handleMouseUp() {
|
|
panning = false;
|
|
}
|
|
|
|
// 处理触摸开始事件
|
|
function handleTouchStart(e) {
|
|
e.preventDefault();
|
|
|
|
if (e.touches.length === 1) {
|
|
// 单点触摸 - 拖动
|
|
const touch = e.touches[0];
|
|
panning = true;
|
|
start = { x: touch.clientX - pointX, y: touch.clientY - pointY };
|
|
} else if (e.touches.length === 2) {
|
|
// 双指触摸 - 缩放
|
|
const touch1 = e.touches[0];
|
|
const touch2 = e.touches[1];
|
|
initialDistance = Math.hypot(
|
|
touch2.clientX - touch1.clientX,
|
|
touch2.clientY - touch1.clientY
|
|
);
|
|
initialScale = scale;
|
|
}
|
|
}
|
|
|
|
// 处理触摸移动事件
|
|
function handleTouchMove(e) {
|
|
e.preventDefault();
|
|
|
|
if (e.touches.length === 1 && panning) {
|
|
// 单点触摸 - 拖动
|
|
const touch = e.touches[0];
|
|
pointX = touch.clientX - start.x;
|
|
pointY = touch.clientY - start.y;
|
|
updateImageTransform();
|
|
} else if (e.touches.length === 2) {
|
|
// 双指触摸 - 缩放
|
|
const touch1 = e.touches[0];
|
|
const touch2 = e.touches[1];
|
|
const currentDistance = Math.hypot(
|
|
touch2.clientX - touch1.clientX,
|
|
touch2.clientY - touch1.clientY
|
|
);
|
|
|
|
if (initialDistance) {
|
|
const newScale = initialScale * (currentDistance / initialDistance);
|
|
scale = Math.min(Math.max(newScale, 1), 10);
|
|
updateImageTransform();
|
|
}
|
|
}
|
|
}
|
|
|
|
// 处理触摸结束事件
|
|
function handleTouchEnd() {
|
|
panning = false;
|
|
initialDistance = null;
|
|
}
|
|
|
|
// 联系客服
|
|
function contactCustomerService() {
|
|
// 创建客服联系信息弹窗
|
|
const contacts = [
|
|
{ phone: '15184349596', name: '孙文涛' },
|
|
{ phone: '17780155537', name: '刘杨' },
|
|
{ phone: '17844569862', name: '黄正季' },
|
|
{ phone: '18482694520', name: '徐飞洋' }
|
|
];
|
|
|
|
// 创建弹窗HTML
|
|
const modalHTML = `
|
|
<div class="contact-modal" style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center; z-index: 2000;">
|
|
<div style="background-color: white; width: 90%; max-width: 400px; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);">
|
|
<div style="padding: 20px; border-bottom: 1px solid #f0f0f0; background-color: white; display: flex; justify-content: space-between; align-items: center;">
|
|
<h3 style="margin: 0; font-size: 18px; font-weight: 500; color: #333;">联系客服</h3>
|
|
<button onclick="document.querySelector('.contact-modal').remove()" style="background: none; border: none; font-size: 24px; cursor: pointer; color: #999; transition: color 0.3s;">×</button>
|
|
</div>
|
|
<div style="padding: 20px; max-height: 300px; overflow-y: auto;">
|
|
${contacts.map((contact, index) => `
|
|
<div style="display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid #f5f5f5;">
|
|
<div>
|
|
<div style="font-size: 14px; font-weight: 500; color: #333;">${index + 1}. ${contact.name}</div>
|
|
<div style="font-size: 12px; color: #666; margin-top: 4px;">客服${index + 1}</div>
|
|
<div style="font-size: 14px; color: #333; margin-top: 4px;">${contact.phone}</div>
|
|
</div>
|
|
<div style="display: flex; gap: 10px;">
|
|
<button onclick="copyPhone('${contact.phone}')" style="padding: 6px 12px; border: 1px solid #1677ff; border-radius: 6px; background-color: #fff; color: #1677ff; font-size: 12px; cursor: pointer; transition: all 0.3s;">复制</button>
|
|
<a href="tel:${contact.phone}" style="padding: 6px 12px; border: none; border-radius: 6px; background-color: #1677ff; color: #fff; font-size: 12px; text-decoration: none; cursor: pointer; transition: all 0.3s;">拨打</a>
|
|
</div>
|
|
</div>
|
|
`).join('')}
|
|
</div>
|
|
<div style="padding: 16px 20px; border-top: 1px solid #f0f0f0; background-color: #fafafa; text-align: right;">
|
|
<button onclick="document.querySelector('.contact-modal').remove()" style="padding: 8px 20px; border: none; border-radius: 6px; background-color: #1677ff; color: #fff; font-size: 14px; cursor: pointer; transition: all 0.3s;">关闭</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
|
|
// 添加到页面
|
|
document.body.insertAdjacentHTML('beforeend', modalHTML);
|
|
}
|
|
|
|
// 复制手机号到剪贴板
|
|
function copyPhone(phone) {
|
|
navigator.clipboard.writeText(phone).then(() => {
|
|
alert('手机号已复制到剪贴板');
|
|
}).catch(err => {
|
|
console.error('复制失败:', err);
|
|
alert('复制失败,请手动复制');
|
|
});
|
|
}
|
|
|
|
// 下架货源
|
|
async function unpublishSupply(id) {
|
|
if (confirm('确定要下架该货源吗?')) {
|
|
try {
|
|
const response = await fetch(`/api/supplies/${id}/unpublish`, {
|
|
method: 'POST'
|
|
});
|
|
const result = await response.json();
|
|
if (result.success) {
|
|
alert('下架成功');
|
|
loadSupplies();
|
|
} else {
|
|
alert('下架失败: ' + (result.message || '未知错误'));
|
|
}
|
|
} catch (error) {
|
|
console.error('下架失败:', error);
|
|
alert('下架失败: 网络错误');
|
|
}
|
|
}
|
|
}
|
|
|
|
// 显示编辑货源
|
|
function showEditSupply(id) {
|
|
alert('编辑功能开发中');
|
|
}
|
|
|
|
// 删除货源
|
|
async function deleteSupply(id) {
|
|
if (confirm('确定要删除该货源吗?删除后将无法恢复。')) {
|
|
try {
|
|
const response = await fetch(`/api/supplies/${id}/delete`, {
|
|
method: 'POST'
|
|
});
|
|
const result = await response.json();
|
|
if (result.success) {
|
|
alert('删除成功');
|
|
loadSupplies();
|
|
} else {
|
|
alert('删除失败: ' + (result.message || '未知错误'));
|
|
}
|
|
} catch (error) {
|
|
console.error('删除失败:', error);
|
|
alert('删除失败: 网络错误');
|
|
}
|
|
}
|
|
}
|
|
|
|
// 准备发布货源
|
|
async function preparePublishSupply(id) {
|
|
if (confirm('确定要上架该货源吗?上架后将进入审核流程。')) {
|
|
try {
|
|
const response = await fetch(`/api/supplies/${id}/publish`, {
|
|
method: 'POST'
|
|
});
|
|
const result = await response.json();
|
|
if (result.success) {
|
|
alert('上架成功,已进入审核流程');
|
|
loadSupplies();
|
|
} else {
|
|
alert('上架失败: ' + (result.message || '未知错误'));
|
|
}
|
|
} catch (error) {
|
|
console.error('上架失败:', error);
|
|
alert('上架失败: 网络错误');
|
|
}
|
|
}
|
|
}
|
|
|
|
// 显示审核失败原因
|
|
async function showRejectReason(id) {
|
|
try {
|
|
const response = await fetch(`/api/supplies/${id}/reject-reason`);
|
|
const result = await response.json();
|
|
if (result.success) {
|
|
const modal = document.getElementById('rejectReasonModal');
|
|
modal.dataset.supplyId = id;
|
|
document.getElementById('rejectReasonContent').textContent = result.data.rejectReason || '暂无审核失败原因';
|
|
modal.style.display = 'flex';
|
|
}
|
|
} catch (error) {
|
|
console.error('获取审核失败原因失败:', error);
|
|
}
|
|
}
|
|
|
|
// 关闭审核失败原因弹窗
|
|
function closeRejectReasonModal() {
|
|
document.getElementById('rejectReasonModal').style.display = 'none';
|
|
}
|
|
|
|
// 重新提交拒绝的货源
|
|
function resubmitRejectedSupply() {
|
|
// 获取当前显示的审核失败货源ID
|
|
const currentRejectSupply = document.getElementById('rejectReasonModal').dataset.supplyId;
|
|
if (currentRejectSupply) {
|
|
preparePublishSupply(currentRejectSupply);
|
|
}
|
|
closeRejectReasonModal();
|
|
}
|
|
|
|
// 显示编辑货源
|
|
async function showEditSupply(id) {
|
|
try {
|
|
// 查找要编辑的货源,考虑类型转换
|
|
const supply = supplyData.supplies.find(s => String(s.id) === String(id));
|
|
if (!supply) {
|
|
console.error('找不到货源:', id, '所有货源:', supplyData.supplies);
|
|
alert('货源不存在');
|
|
return;
|
|
}
|
|
|
|
currentEditSupplyId = id;
|
|
|
|
// 填充表单数据
|
|
// 货源类型
|
|
document.getElementById('editSourceTypeDisplayText').textContent = supply.sourceType || '请选择货源类型';
|
|
document.getElementById('editSourceType').value = supply.sourceType || '';
|
|
editSelectedSourceType = supply.sourceType || '';
|
|
|
|
// 种类
|
|
document.getElementById('editCategoryDisplayText').textContent = supply.category || '请选择种类';
|
|
document.getElementById('editCategory').value = supply.category || '';
|
|
editSelectedCategory = supply.category || '';
|
|
|
|
// 商品名称
|
|
document.getElementById('editProductNameDisplayText').textContent = supply.productName || '请选择商品名称';
|
|
document.getElementById('editProductName').value = supply.productName || '';
|
|
// 蛋黄类型
|
|
document.getElementById('editYolkDisplayText').textContent = supply.yolk || '请选择蛋黄类型';
|
|
document.getElementById('editYolk').value = supply.yolk || '';
|
|
editSelectedYolk = supply.yolk || '';
|
|
|
|
document.getElementById('editSpecDisplayText').textContent = supply.specification || '请选择规格';
|
|
document.getElementById('editSpecValue').value = supply.specification || '';
|
|
editSelectedSpec = supply.specification || '';
|
|
|
|
// 货源状态(使用按钮组)
|
|
const supplyStatus = supply.supplyStatus || '预售';
|
|
document.getElementById('editSupplyStatus').value = supplyStatus;
|
|
setEditSupplyStatus(supplyStatus);
|
|
|
|
// 分配联系人
|
|
document.getElementById('editContactIdDisplayText').textContent = supply.contactId || '请选择联系人';
|
|
document.getElementById('editContactId').value = supply.contactId || '';
|
|
editSelectedContactId = supply.contactId || '';
|
|
document.getElementById('editDescription').value = supply.description || '';
|
|
document.getElementById('editRegionDisplayText').textContent = supply.region || '请选择地区';
|
|
document.getElementById('editRegionValue').value = supply.region || '';
|
|
document.getElementById('editPrice').value = supply.price || '';
|
|
document.getElementById('editQuantity').value = supply.quantity || '';
|
|
document.getElementById('editGrossWeight').value = supply.grossWeight || '';
|
|
|
|
// 显示商品图片
|
|
const editUploadImages = document.getElementById('editUploadImages');
|
|
editUploadImages.innerHTML = '';
|
|
if (supply.imageUrls && Array.isArray(supply.imageUrls)) {
|
|
supply.imageUrls.forEach(imageUrl => {
|
|
const imageElement = document.createElement('div');
|
|
imageElement.className = 'upload-image';
|
|
imageElement.innerHTML = `
|
|
<img src="${imageUrl}" alt="商品图片" onclick="previewImage('${imageUrl}')">
|
|
`;
|
|
editUploadImages.appendChild(imageElement);
|
|
});
|
|
}
|
|
|
|
// 显示编辑模态框
|
|
document.getElementById('editSupplyModal').style.display = 'flex';
|
|
} catch (error) {
|
|
console.error('显示编辑货源失败:', error);
|
|
alert('显示编辑货源失败');
|
|
}
|
|
}
|
|
|
|
// 隐藏编辑货源模态框
|
|
function hideEditSupplyModal() {
|
|
document.getElementById('editSupplyModal').style.display = 'none';
|
|
currentEditSupplyId = null;
|
|
}
|
|
|
|
// 编辑规格选择功能
|
|
let editFilteredSpecOptions = [...allSpecOptions];
|
|
|
|
// 显示编辑规格选择弹窗
|
|
function showEditSpecSelectModal() {
|
|
const specSelectModal = document.getElementById('editSpecSelectModal');
|
|
specSelectModal.classList.add('active');
|
|
// 重置搜索输入
|
|
document.getElementById('editSpecSearchInput').value = '';
|
|
editFilteredSpecOptions = [...allSpecOptions];
|
|
generateEditSpecOptions();
|
|
}
|
|
|
|
// 隐藏编辑规格选择弹窗
|
|
function hideEditSpecSelectModal() {
|
|
const specSelectModal = document.getElementById('editSpecSelectModal');
|
|
specSelectModal.classList.remove('active');
|
|
}
|
|
|
|
// 生成编辑规格选项
|
|
function generateEditSpecOptions() {
|
|
const specOptionsList = document.getElementById('editSpecOptionsList');
|
|
specOptionsList.innerHTML = '';
|
|
|
|
editFilteredSpecOptions.forEach(spec => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = spec;
|
|
if (spec === editSelectedSpec) {
|
|
option.classList.add('selected');
|
|
}
|
|
option.onclick = () => {
|
|
// 移除所有选项的选中状态
|
|
document.querySelectorAll('#editSpecOptionsList .select-item').forEach(item => {
|
|
item.classList.remove('selected');
|
|
});
|
|
// 添加当前选项的选中状态
|
|
option.classList.add('selected');
|
|
editSelectedSpec = spec;
|
|
};
|
|
specOptionsList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 过滤编辑规格选项
|
|
function filterEditSpecOptions() {
|
|
const searchInput = document.getElementById('editSpecSearchInput');
|
|
const searchKeyword = searchInput.value.toLowerCase();
|
|
|
|
editFilteredSpecOptions = allSpecOptions.filter(spec => {
|
|
return spec.toLowerCase().includes(searchKeyword);
|
|
});
|
|
|
|
generateEditSpecOptions();
|
|
}
|
|
|
|
// 确认编辑规格选择
|
|
function confirmEditSpecSelection() {
|
|
if (editSelectedSpec) {
|
|
document.getElementById('editSpecDisplayText').textContent = editSelectedSpec;
|
|
document.getElementById('editSpecValue').value = editSelectedSpec;
|
|
}
|
|
hideEditSpecSelectModal();
|
|
}
|
|
|
|
// 编辑地区选择功能
|
|
// 显示编辑地区选择弹窗
|
|
function showEditRegionSelectModal() {
|
|
const regionSelectModal = document.getElementById('editRegionSelectModal');
|
|
regionSelectModal.classList.add('active');
|
|
// 重置搜索输入
|
|
document.getElementById('editRegionSearchInput').value = '';
|
|
// 重置选择
|
|
editSelectedProvince = '';
|
|
editSelectedCity = '';
|
|
editSelectedDistrict = '';
|
|
// 更新显示
|
|
updateEditRegionDisplay();
|
|
// 生成地区选项
|
|
generateEditRegionOptions();
|
|
}
|
|
|
|
// 隐藏编辑地区选择弹窗
|
|
function hideEditRegionSelectModal() {
|
|
const regionSelectModal = document.getElementById('editRegionSelectModal');
|
|
regionSelectModal.classList.remove('active');
|
|
}
|
|
|
|
// 生成编辑地区选项
|
|
function generateEditRegionOptions() {
|
|
const provinceList = document.getElementById('editProvinceList');
|
|
const cityList = document.getElementById('editCityList');
|
|
const districtList = document.getElementById('editDistrictList');
|
|
|
|
// 生成省份选项
|
|
provinceList.innerHTML = '';
|
|
allRegionOptions.forEach(province => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = province.province;
|
|
if (province.province === editSelectedProvince) {
|
|
option.classList.add('selected');
|
|
}
|
|
option.onclick = () => {
|
|
editSelectedProvince = province.province;
|
|
editSelectedCity = '';
|
|
editSelectedDistrict = '';
|
|
updateEditRegionDisplay();
|
|
// 生成城市选项
|
|
generateEditCityOptions(province.cities);
|
|
// 清空区县选项
|
|
districtList.innerHTML = '';
|
|
};
|
|
provinceList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 生成编辑城市选项
|
|
function generateEditCityOptions(cities) {
|
|
const cityList = document.getElementById('editCityList');
|
|
const districtList = document.getElementById('editDistrictList');
|
|
|
|
cityList.innerHTML = '';
|
|
cities.forEach(city => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = city.city;
|
|
if (city.city === editSelectedCity) {
|
|
option.classList.add('selected');
|
|
}
|
|
option.onclick = () => {
|
|
editSelectedCity = city.city;
|
|
editSelectedDistrict = '';
|
|
updateEditRegionDisplay();
|
|
// 生成区县选项
|
|
generateEditDistrictOptions(city.districts);
|
|
};
|
|
cityList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 生成编辑区县选项
|
|
function generateEditDistrictOptions(districts) {
|
|
const districtList = document.getElementById('editDistrictList');
|
|
|
|
districtList.innerHTML = '';
|
|
districts.forEach(district => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = district;
|
|
if (district === editSelectedDistrict) {
|
|
option.classList.add('selected');
|
|
}
|
|
option.onclick = () => {
|
|
editSelectedDistrict = district;
|
|
updateEditRegionDisplay();
|
|
};
|
|
districtList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 更新编辑地区显示
|
|
function updateEditRegionDisplay() {
|
|
const currentRegion = document.getElementById('editCurrentRegion');
|
|
let displayText = '当前选择: ';
|
|
if (editSelectedProvince && editSelectedCity && editSelectedDistrict) {
|
|
displayText += `${editSelectedProvince} ${editSelectedCity} ${editSelectedDistrict}`;
|
|
} else if (editSelectedProvince && editSelectedCity) {
|
|
displayText += `${editSelectedProvince} ${editSelectedCity}`;
|
|
} else if (editSelectedProvince) {
|
|
displayText += editSelectedProvince;
|
|
} else {
|
|
displayText += '未选择';
|
|
}
|
|
currentRegion.textContent = displayText;
|
|
}
|
|
|
|
// 过滤编辑地区选项
|
|
function filterEditRegionOptions() {
|
|
const searchInput = document.getElementById('editRegionSearchInput');
|
|
const searchKeyword = searchInput.value.toLowerCase();
|
|
|
|
// 重置选择
|
|
editSelectedProvince = '';
|
|
editSelectedCity = '';
|
|
editSelectedDistrict = '';
|
|
|
|
// 先尝试直接查找区县
|
|
let foundDistrict = false;
|
|
for (let i = 0; i < allRegionOptions.length; i++) {
|
|
const province = allRegionOptions[i];
|
|
for (let j = 0; j < province.cities.length; j++) {
|
|
const city = province.cities[j];
|
|
for (let k = 0; k < city.districts.length; k++) {
|
|
const district = city.districts[k];
|
|
if (district.toLowerCase().includes(searchKeyword)) {
|
|
// 找到匹配的区县,自动填充省市区
|
|
editSelectedProvince = province.province;
|
|
editSelectedCity = city.city;
|
|
editSelectedDistrict = district;
|
|
foundDistrict = true;
|
|
break;
|
|
}
|
|
}
|
|
if (foundDistrict) break;
|
|
}
|
|
if (foundDistrict) break;
|
|
}
|
|
|
|
if (foundDistrict) {
|
|
// 生成地区选项并选择
|
|
generateEditRegionOptions();
|
|
|
|
// 自动生成城市选项并选择
|
|
const cityList = document.getElementById('editCityList');
|
|
cityList.innerHTML = '';
|
|
const province = allRegionOptions.find(p => p.province === editSelectedProvince);
|
|
if (province) {
|
|
province.cities.forEach(city => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = city.city;
|
|
if (city.city === editSelectedCity) {
|
|
option.classList.add('selected');
|
|
}
|
|
option.onclick = () => {
|
|
editSelectedCity = city.city;
|
|
editSelectedDistrict = '';
|
|
updateEditRegionDisplay();
|
|
generateEditDistrictOptions(city.districts);
|
|
};
|
|
cityList.appendChild(option);
|
|
|
|
// 如果是选中的城市,生成区县选项
|
|
if (city.city === editSelectedCity) {
|
|
generateEditDistrictOptions(city.districts);
|
|
}
|
|
});
|
|
}
|
|
|
|
// 更新区县选项的选中状态
|
|
const districtList = document.getElementById('editDistrictList');
|
|
const districtOptions = districtList.querySelectorAll('.select-item');
|
|
districtOptions.forEach(option => {
|
|
if (option.textContent === editSelectedDistrict) {
|
|
option.classList.add('selected');
|
|
}
|
|
});
|
|
} else {
|
|
// 否则按原逻辑生成所有省份
|
|
generateEditRegionOptions();
|
|
// 清空城市和区县选项
|
|
document.getElementById('editCityList').innerHTML = '';
|
|
document.getElementById('editDistrictList').innerHTML = '';
|
|
}
|
|
|
|
updateEditRegionDisplay();
|
|
}
|
|
|
|
// 确认编辑地区选择
|
|
function confirmEditRegionSelection() {
|
|
if (editSelectedProvince && editSelectedCity && editSelectedDistrict) {
|
|
const regionDisplayText = document.getElementById('editRegionDisplayText');
|
|
const regionValue = document.getElementById('editRegionValue');
|
|
const regionText = `${editSelectedProvince} ${editSelectedCity} ${editSelectedDistrict}`;
|
|
regionDisplayText.textContent = regionText;
|
|
regionValue.value = regionText;
|
|
}
|
|
hideEditRegionSelectModal();
|
|
}
|
|
|
|
// 编辑货源类型选择功能
|
|
// 显示编辑货源类型选择弹窗
|
|
function showEditSourceTypeSelectModal() {
|
|
const sourceTypeSelectModal = document.getElementById('editSourceTypeSelectModal');
|
|
sourceTypeSelectModal.classList.add('active');
|
|
document.getElementById('editSourceTypeSearchInput').value = '';
|
|
editFilteredSourceTypes = [...editAllSourceTypes];
|
|
generateEditSourceTypeOptions();
|
|
}
|
|
|
|
// 隐藏编辑货源类型选择弹窗
|
|
function hideEditSourceTypeSelectModal() {
|
|
const sourceTypeSelectModal = document.getElementById('editSourceTypeSelectModal');
|
|
sourceTypeSelectModal.classList.remove('active');
|
|
}
|
|
|
|
// 生成编辑货源类型选项
|
|
function generateEditSourceTypeOptions() {
|
|
const sourceTypeOptionsList = document.getElementById('editSourceTypeOptionsList');
|
|
sourceTypeOptionsList.innerHTML = '';
|
|
|
|
editFilteredSourceTypes.forEach(sourceType => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = sourceType;
|
|
if (sourceType === editSelectedSourceType) {
|
|
option.classList.add('selected');
|
|
}
|
|
option.onclick = () => {
|
|
document.querySelectorAll('#editSourceTypeOptionsList .select-item').forEach(item => {
|
|
item.classList.remove('selected');
|
|
});
|
|
option.classList.add('selected');
|
|
editSelectedSourceType = sourceType;
|
|
};
|
|
option.ondblclick = () => {
|
|
editSelectedSourceType = sourceType;
|
|
confirmEditSourceTypeSelection();
|
|
};
|
|
sourceTypeOptionsList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 过滤编辑货源类型选项
|
|
function filterEditSourceTypeOptions() {
|
|
const searchInput = document.getElementById('editSourceTypeSearchInput');
|
|
const searchTerm = searchInput.value.toLowerCase();
|
|
|
|
editFilteredSourceTypes = editAllSourceTypes.filter(sourceType => {
|
|
return sourceType.toLowerCase().includes(searchTerm);
|
|
});
|
|
|
|
generateEditSourceTypeOptions();
|
|
}
|
|
|
|
// 确认编辑货源类型选择
|
|
function confirmEditSourceTypeSelection() {
|
|
if (editSelectedSourceType) {
|
|
document.getElementById('editSourceTypeDisplayText').textContent = editSelectedSourceType;
|
|
document.getElementById('editSourceType').value = editSelectedSourceType;
|
|
}
|
|
hideEditSourceTypeSelectModal();
|
|
}
|
|
|
|
// 编辑种类选择功能
|
|
// 显示编辑种类选择弹窗
|
|
function showEditCategorySelectModal() {
|
|
const categorySelectModal = document.getElementById('editCategorySelectModal');
|
|
categorySelectModal.classList.add('active');
|
|
document.getElementById('editCategorySearchInput').value = '';
|
|
editFilteredCategories = [...editAllCategories];
|
|
generateEditCategoryOptions();
|
|
}
|
|
|
|
// 隐藏编辑种类选择弹窗
|
|
function hideEditCategorySelectModal() {
|
|
const categorySelectModal = document.getElementById('editCategorySelectModal');
|
|
categorySelectModal.classList.remove('active');
|
|
}
|
|
|
|
// 生成编辑种类选项
|
|
function generateEditCategoryOptions() {
|
|
const categoryOptionsList = document.getElementById('editCategoryOptionsList');
|
|
categoryOptionsList.innerHTML = '';
|
|
|
|
editFilteredCategories.forEach(category => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = category;
|
|
if (category === editSelectedCategory) {
|
|
option.classList.add('selected');
|
|
}
|
|
option.onclick = () => {
|
|
document.querySelectorAll('#editCategoryOptionsList .select-item').forEach(item => {
|
|
item.classList.remove('selected');
|
|
});
|
|
option.classList.add('selected');
|
|
editSelectedCategory = category;
|
|
};
|
|
option.ondblclick = () => {
|
|
editSelectedCategory = category;
|
|
confirmEditCategorySelection();
|
|
};
|
|
categoryOptionsList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 过滤编辑种类选项
|
|
function filterEditCategoryOptions() {
|
|
const searchInput = document.getElementById('editCategorySearchInput');
|
|
const searchTerm = searchInput.value.toLowerCase();
|
|
|
|
editFilteredCategories = editAllCategories.filter(category => {
|
|
return category.toLowerCase().includes(searchTerm);
|
|
});
|
|
|
|
generateEditCategoryOptions();
|
|
}
|
|
|
|
// 确认编辑种类选择
|
|
function confirmEditCategorySelection() {
|
|
if (editSelectedCategory) {
|
|
document.getElementById('editCategoryDisplayText').textContent = editSelectedCategory;
|
|
document.getElementById('editCategory').value = editSelectedCategory;
|
|
}
|
|
hideEditCategorySelectModal();
|
|
}
|
|
|
|
// 编辑商品名称选择功能
|
|
// 显示编辑商品名称选择弹窗
|
|
function showEditProductNameSelectModal() {
|
|
const productNameSelectModal = document.getElementById('editProductNameSelectModal');
|
|
productNameSelectModal.classList.add('active');
|
|
document.getElementById('editProductNameSearchInput').value = '';
|
|
editFilteredProductNames = [...editAllProductNames];
|
|
generateEditProductNameOptions();
|
|
}
|
|
|
|
// 隐藏编辑商品名称选择弹窗
|
|
function hideEditProductNameSelectModal() {
|
|
const productNameSelectModal = document.getElementById('editProductNameSelectModal');
|
|
productNameSelectModal.classList.remove('active');
|
|
}
|
|
|
|
// 生成编辑商品名称选项
|
|
function generateEditProductNameOptions() {
|
|
const productNameOptionsList = document.getElementById('editProductNameOptionsList');
|
|
productNameOptionsList.innerHTML = '';
|
|
|
|
editFilteredProductNames.forEach(productName => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = productName;
|
|
if (productName === editSelectedProductName) {
|
|
option.classList.add('selected');
|
|
}
|
|
option.onclick = () => {
|
|
document.querySelectorAll('#editProductNameOptionsList .select-item').forEach(item => {
|
|
item.classList.remove('selected');
|
|
});
|
|
option.classList.add('selected');
|
|
editSelectedProductName = productName;
|
|
};
|
|
option.ondblclick = () => {
|
|
editSelectedProductName = productName;
|
|
confirmEditProductNameSelection();
|
|
};
|
|
productNameOptionsList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 过滤编辑商品名称选项
|
|
function filterEditProductNameOptions() {
|
|
const searchInput = document.getElementById('editProductNameSearchInput');
|
|
const searchTerm = searchInput.value.toLowerCase();
|
|
|
|
editFilteredProductNames = editAllProductNames.filter(productName => {
|
|
return productName.toLowerCase().includes(searchTerm);
|
|
});
|
|
|
|
generateEditProductNameOptions();
|
|
}
|
|
|
|
// 确认编辑商品名称选择
|
|
function confirmEditProductNameSelection() {
|
|
if (editSelectedProductName) {
|
|
document.getElementById('editProductNameDisplayText').textContent = editSelectedProductName;
|
|
document.getElementById('editProductName').value = editSelectedProductName;
|
|
}
|
|
hideEditProductNameSelectModal();
|
|
}
|
|
|
|
// 编辑蛋黄类型选择功能
|
|
// 显示编辑蛋黄类型选择弹窗
|
|
function showEditYolkSelectModal() {
|
|
const yolkSelectModal = document.getElementById('editYolkSelectModal');
|
|
yolkSelectModal.classList.add('active');
|
|
document.getElementById('editYolkSearchInput').value = '';
|
|
editFilteredYolkTypes = [...editAllYolkTypes];
|
|
generateEditYolkOptions();
|
|
}
|
|
|
|
// 隐藏编辑蛋黄类型选择弹窗
|
|
function hideEditYolkSelectModal() {
|
|
const yolkSelectModal = document.getElementById('editYolkSelectModal');
|
|
yolkSelectModal.classList.remove('active');
|
|
}
|
|
|
|
// 生成编辑蛋黄类型选项
|
|
function generateEditYolkOptions() {
|
|
const yolkOptionsList = document.getElementById('editYolkOptionsList');
|
|
yolkOptionsList.innerHTML = '';
|
|
|
|
editFilteredYolkTypes.forEach(yolk => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = yolk;
|
|
if (yolk === editSelectedYolk) {
|
|
option.classList.add('selected');
|
|
}
|
|
option.onclick = () => {
|
|
document.querySelectorAll('#editYolkOptionsList .select-item').forEach(item => {
|
|
item.classList.remove('selected');
|
|
});
|
|
option.classList.add('selected');
|
|
editSelectedYolk = yolk;
|
|
};
|
|
option.ondblclick = () => {
|
|
editSelectedYolk = yolk;
|
|
confirmEditYolkSelection();
|
|
};
|
|
yolkOptionsList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 过滤编辑蛋黄类型选项
|
|
function filterEditYolkOptions() {
|
|
const searchInput = document.getElementById('editYolkSearchInput');
|
|
const searchTerm = searchInput.value.toLowerCase();
|
|
|
|
editFilteredYolkTypes = editAllYolkTypes.filter(yolk => {
|
|
return yolk.toLowerCase().includes(searchTerm);
|
|
});
|
|
|
|
generateEditYolkOptions();
|
|
}
|
|
|
|
// 确认编辑蛋黄类型选择
|
|
function confirmEditYolkSelection() {
|
|
if (editSelectedYolk) {
|
|
document.getElementById('editYolkDisplayText').textContent = editSelectedYolk;
|
|
document.getElementById('editYolk').value = editSelectedYolk;
|
|
}
|
|
hideEditYolkSelectModal();
|
|
}
|
|
|
|
// 编辑联系人选择功能
|
|
// 显示编辑联系人选择弹窗
|
|
function showEditContactIdSelectModal() {
|
|
const contactIdSelectModal = document.getElementById('editContactIdSelectModal');
|
|
contactIdSelectModal.classList.add('active');
|
|
document.getElementById('editContactIdSearchInput').value = '';
|
|
editFilteredContacts = [...contacts];
|
|
generateEditContactIdOptions();
|
|
}
|
|
|
|
// 隐藏编辑联系人选择弹窗
|
|
function hideEditContactIdSelectModal() {
|
|
const contactIdSelectModal = document.getElementById('editContactIdSelectModal');
|
|
contactIdSelectModal.classList.remove('active');
|
|
}
|
|
|
|
// 生成编辑联系人选项
|
|
function generateEditContactIdOptions() {
|
|
const contactIdOptionsList = document.getElementById('editContactIdOptionsList');
|
|
contactIdOptionsList.innerHTML = '';
|
|
|
|
editFilteredContacts.forEach(contact => {
|
|
const option = document.createElement('div');
|
|
option.className = 'select-item';
|
|
option.textContent = `${contact.name} (${contact.phoneNumber})`;
|
|
if (String(contact.id) === String(editSelectedContactId)) {
|
|
option.classList.add('selected');
|
|
}
|
|
option.onclick = () => {
|
|
document.querySelectorAll('#editContactIdOptionsList .select-item').forEach(item => {
|
|
item.classList.remove('selected');
|
|
});
|
|
option.classList.add('selected');
|
|
editSelectedContactId = contact.id;
|
|
};
|
|
option.ondblclick = () => {
|
|
editSelectedContactId = contact.id;
|
|
confirmEditContactIdSelection();
|
|
};
|
|
contactIdOptionsList.appendChild(option);
|
|
});
|
|
}
|
|
|
|
// 过滤编辑联系人选项
|
|
function filterEditContactIdOptions() {
|
|
const searchInput = document.getElementById('editContactIdSearchInput');
|
|
const searchTerm = searchInput.value.toLowerCase();
|
|
|
|
editFilteredContacts = contacts.filter(contact => {
|
|
return contact.name.toLowerCase().includes(searchTerm) ||
|
|
contact.phoneNumber.toLowerCase().includes(searchTerm);
|
|
});
|
|
|
|
generateEditContactIdOptions();
|
|
}
|
|
|
|
// 确认编辑联系人选择
|
|
function confirmEditContactIdSelection() {
|
|
if (editSelectedContactId) {
|
|
const contact = contacts.find(c => String(c.id) === String(editSelectedContactId));
|
|
if (contact) {
|
|
document.getElementById('editContactIdDisplayText').textContent = `${contact.name} (${contact.phoneNumber})`;
|
|
}
|
|
document.getElementById('editContactId').value = editSelectedContactId;
|
|
}
|
|
hideEditContactIdSelectModal();
|
|
}
|
|
|
|
// 设置编辑货源状态
|
|
function setEditSupplyStatus(status) {
|
|
// 更新按钮样式
|
|
const preSaleBtn = document.getElementById('editPreSaleBtn');
|
|
const inStockBtn = document.getElementById('editInStockBtn');
|
|
|
|
if (status === '预售') {
|
|
preSaleBtn.style.borderColor = '#1677ff';
|
|
preSaleBtn.style.backgroundColor = '#e6f7ff';
|
|
preSaleBtn.style.color = '#1677ff';
|
|
inStockBtn.style.borderColor = '#d9d9d9';
|
|
inStockBtn.style.backgroundColor = 'white';
|
|
inStockBtn.style.color = '#666';
|
|
} else {
|
|
inStockBtn.style.borderColor = '#1677ff';
|
|
inStockBtn.style.backgroundColor = '#e6f7ff';
|
|
inStockBtn.style.color = '#1677ff';
|
|
preSaleBtn.style.borderColor = '#d9d9d9';
|
|
preSaleBtn.style.backgroundColor = 'white';
|
|
preSaleBtn.style.color = '#666';
|
|
}
|
|
|
|
// 更新隐藏字段值
|
|
document.getElementById('editSupplyStatus').value = status;
|
|
}
|
|
|
|
// 保存编辑货源
|
|
async function saveEditSupply() {
|
|
if (!currentEditSupplyId) {
|
|
alert('货源ID不存在');
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const formData = {
|
|
productName: document.getElementById('editProductName').value,
|
|
sourceType: document.getElementById('editSourceType').value,
|
|
category: document.getElementById('editCategory').value,
|
|
price: document.getElementById('editPrice').value,
|
|
quantity: document.getElementById('editQuantity').value,
|
|
grossWeight: document.getElementById('editGrossWeight').value,
|
|
yolk: document.getElementById('editYolk').value,
|
|
specification: document.getElementById('editSpecValue').value,
|
|
supplyStatus: document.getElementById('editSupplyStatus').value,
|
|
description: document.getElementById('editDescription').value,
|
|
region: document.getElementById('editRegionValue').value,
|
|
contactId: document.getElementById('editContactId').value
|
|
};
|
|
|
|
// 验证表单
|
|
if (!formData.productName) {
|
|
alert('请选择商品名称');
|
|
return;
|
|
}
|
|
if (!formData.price) {
|
|
alert('请输入价格');
|
|
return;
|
|
}
|
|
if (!formData.quantity) {
|
|
alert('请输入件数');
|
|
return;
|
|
}
|
|
|
|
const response = await fetch(`/api/supplies/${currentEditSupplyId}/edit`, {
|
|
method: 'PUT',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify(formData)
|
|
});
|
|
|
|
const result = await response.json();
|
|
if (result.success) {
|
|
alert('编辑成功');
|
|
hideEditSupplyModal();
|
|
loadSupplies();
|
|
} else {
|
|
alert('编辑失败: ' + (result.message || '未知错误'));
|
|
}
|
|
} catch (error) {
|
|
console.error('编辑失败:', error);
|
|
alert('编辑失败: 网络错误');
|
|
}
|
|
}
|
|
|
|
// 隐藏编辑货源模态框
|
|
function hideEditSupplyModal() {
|
|
document.getElementById('editSupplyModal').style.display = 'none';
|
|
currentEditSupplyId = null;
|
|
}
|
|
|
|
// 处理点击模态框外部关闭
|
|
window.onclick = function(event) {
|
|
const modals = document.querySelectorAll('.modal');
|
|
modals.forEach(modal => {
|
|
if (event.target === modal) {
|
|
modal.style.display = 'none';
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|