fix: 恢复选择商品页面正确版本,修复模板标签平衡
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -14,42 +14,67 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 分类侧栏 + 商品列表 -->
|
<!-- 分类行 -->
|
||||||
<view class="content-wrapper">
|
<view class="category-row">
|
||||||
<!-- 左侧分类 -->
|
<view class="category-item" :class="{ active: !categoryId }" @click="selectCategory('')">
|
||||||
<scroll-view scroll-y class="category-sidebar">
|
全部
|
||||||
<view class="category-item" :class="{ active: !categoryId }" @click="selectCategory('')">
|
</view>
|
||||||
全部
|
<view v-for="cat in categories" :key="cat.categoryId" class="category-item" :class="{ active: categoryId === cat.categoryId }" @click="selectCategory(cat.categoryId)">
|
||||||
</view>
|
{{ cat.name }}
|
||||||
<view v-for="cat in categories" :key="cat.categoryId" class="category-item" :class="{ active: categoryId === cat.categoryId }" @click="selectCategory(cat.categoryId)">
|
</view>
|
||||||
{{ cat.name }}
|
|
||||||
</view>
|
|
||||||
</scroll-view>
|
|
||||||
|
|
||||||
<!-- 右侧商品列表 -->
|
|
||||||
<scroll-view scroll-y class="product-scroll">
|
|
||||||
<view class="product-list">
|
|
||||||
<view v-for="item in productList" :key="item.productId" class="product-item" @click="selectProduct(item)">
|
|
||||||
<view class="product-info">
|
|
||||||
<text class="product-name">{{ item.name }}</text>
|
|
||||||
<view class="product-row">
|
|
||||||
<text class="product-spec">{{ item.spec || '-' }}</text>
|
|
||||||
<text class="product-size" v-if="item.length && item.width">{{ item.length }} x {{ item.width }} = {{ item.area }} m²</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="product-price">
|
|
||||||
<text class="price">¥{{ item.price }}</text>
|
|
||||||
<text class="unit">{{ item.unit || '个' }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view v-if="productList.length === 0" class="empty">
|
|
||||||
<Icon name="product" :size="80" color="#ccc" />
|
|
||||||
<text class="empty-text">暂无商品</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</scroll-view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 商品列表 -->
|
||||||
|
<scroll-view scroll-y class="product-scroll">
|
||||||
|
<view class="product-list">
|
||||||
|
<view v-for="item in productList" :key="item.productId" class="product-item" @click="openProductDetail(item)">
|
||||||
|
<view class="product-info">
|
||||||
|
<text class="product-name">{{ item.name }}</text>
|
||||||
|
<text class="product-spec">{{ item.spec || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="product-price">
|
||||||
|
<text class="price">¥{{ item.price }}</text>
|
||||||
|
<text class="unit">{{ item.unit || '个' }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-if="productList.length === 0" class="empty">
|
||||||
|
<Icon name="product" :size="80" color="#ccc" />
|
||||||
|
<text class="empty-text">暂无商品</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
|
||||||
|
<!-- 商品详情/选择弹窗 -->
|
||||||
|
<view class="modal-mask" v-if="showModal" @click="closeModal">
|
||||||
|
<view class="modal-content" @click.stop>
|
||||||
|
<view class="modal-header">
|
||||||
|
<text class="modal-title">{{ selectedProduct.name }}</text>
|
||||||
|
<text class="modal-close" @click="closeModal">×</text>
|
||||||
|
</view>
|
||||||
|
<view class="modal-body">
|
||||||
|
<view class="size-row">
|
||||||
|
<view class="size-item">
|
||||||
|
<text class="size-label">长度(cm)</text>
|
||||||
|
<input class="size-input" type="digit" v-model="selectedProduct.length" placeholder="非必填" />
|
||||||
|
</view>
|
||||||
|
<view class="size-item">
|
||||||
|
<text class="size-label">宽度(cm)</text>
|
||||||
|
<input class="size-input" type="digit" v-model="selectedProduct.width" placeholder="非必填" />
|
||||||
|
</view>
|
||||||
|
<view class="size-item">
|
||||||
|
<text class="size-label">面积(m²)</text>
|
||||||
|
<input class="size-input" type="digit" v-model="selectedProduct.area" disabled />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="modal-footer">
|
||||||
|
<button class="cancel-btn" @click="closeModal">取消</button>
|
||||||
|
<button class="confirm-btn" @click="confirmProduct">确认</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -64,7 +89,26 @@ export default {
|
|||||||
productList: [],
|
productList: [],
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 50,
|
pageSize: 50,
|
||||||
loading: false
|
loading: false,
|
||||||
|
showModal: false,
|
||||||
|
selectedProduct: {
|
||||||
|
productId: '',
|
||||||
|
name: '',
|
||||||
|
spec: '',
|
||||||
|
unit: '',
|
||||||
|
price: 0,
|
||||||
|
length: '',
|
||||||
|
width: '',
|
||||||
|
area: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'selectedProduct.length'(val) {
|
||||||
|
this.calcArea()
|
||||||
|
},
|
||||||
|
'selectedProduct.width'(val) {
|
||||||
|
this.calcArea()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
@@ -72,6 +116,12 @@ export default {
|
|||||||
this.getProducts()
|
this.getProducts()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
calcArea() {
|
||||||
|
const length = parseFloat(this.selectedProduct.length) || 0
|
||||||
|
const width = parseFloat(this.selectedProduct.width) || 0
|
||||||
|
// 长度(cm) * 宽度(cm) / 10000 = 面积(m²)
|
||||||
|
this.selectedProduct.area = length && width ? (length * width / 10000).toFixed(2) : ''
|
||||||
|
},
|
||||||
async loadCategories() {
|
async loadCategories() {
|
||||||
try {
|
try {
|
||||||
const categories = await productApi.getCategories()
|
const categories = await productApi.getCategories()
|
||||||
@@ -105,10 +155,31 @@ export default {
|
|||||||
this.page = 1
|
this.page = 1
|
||||||
this.getProducts()
|
this.getProducts()
|
||||||
},
|
},
|
||||||
selectProduct(item) {
|
openProductDetail(item) {
|
||||||
|
this.selectedProduct = {
|
||||||
|
productId: item.productId,
|
||||||
|
name: item.name,
|
||||||
|
spec: item.spec,
|
||||||
|
unit: item.unit,
|
||||||
|
price: item.price,
|
||||||
|
length: '',
|
||||||
|
width: '',
|
||||||
|
area: ''
|
||||||
|
}
|
||||||
|
this.showModal = true
|
||||||
|
},
|
||||||
|
closeModal() {
|
||||||
|
this.showModal = false
|
||||||
|
},
|
||||||
|
confirmProduct() {
|
||||||
const pages = getCurrentPages()
|
const pages = getCurrentPages()
|
||||||
const prevPage = pages[pages.length - 2]
|
const prevPage = pages[pages.length - 2]
|
||||||
prevPage.$vm.addProduct(item)
|
prevPage.$vm.addProduct({
|
||||||
|
...this.selectedProduct,
|
||||||
|
length: this.selectedProduct.length,
|
||||||
|
width: this.selectedProduct.width,
|
||||||
|
area: this.selectedProduct.area
|
||||||
|
})
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,37 +217,32 @@ export default {
|
|||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 内容区域:侧栏+列表 */
|
/* 分类行 */
|
||||||
.content-wrapper {
|
.category-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
height: calc(100vh - 130rpx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 分类侧栏 */
|
|
||||||
.category-sidebar {
|
|
||||||
width: 160rpx;
|
|
||||||
background: #fff;
|
background: #fff;
|
||||||
flex-shrink: 0;
|
padding: 20rpx;
|
||||||
border-right: 1rpx solid #eee;
|
overflow-x: auto;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.category-sidebar .category-item {
|
.category-row .category-item {
|
||||||
padding: 28rpx 16rpx;
|
display: inline-block;
|
||||||
|
padding: 16rpx 32rpx;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
color: #666;
|
color: #666;
|
||||||
text-align: center;
|
border-radius: 30rpx;
|
||||||
border-left: 6rpx solid transparent;
|
margin-right: 16rpx;
|
||||||
|
background: #f5f5f5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.category-sidebar .category-item.active {
|
.category-row .category-item.active {
|
||||||
background: #f8f9fa;
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
color: #667eea;
|
color: #fff;
|
||||||
font-weight: bold;
|
|
||||||
border-left-color: #667eea;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.product-scroll {
|
.product-scroll {
|
||||||
flex: 1;
|
height: calc(100vh - 260rpx);
|
||||||
background: #f8f9fa;
|
background: #f8f9fa;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,21 +278,6 @@ export default {
|
|||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.product-row {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.product-size {
|
|
||||||
font-size: 22rpx;
|
|
||||||
color: #667eea;
|
|
||||||
background: #f0f0ff;
|
|
||||||
padding: 2rpx 8rpx;
|
|
||||||
border-radius: 4rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.product-price {
|
.product-price {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user