diff --git a/src/pages/product/select.vue b/src/pages/product/select.vue
index 1ed1d0a..4dd5996 100644
--- a/src/pages/product/select.vue
+++ b/src/pages/product/select.vue
@@ -1,38 +1,52 @@
-
-
-
+
+
+
+
+
-
-
-
-
- {{ item.name }}
- {{ item.spec || '-' }}
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.name }}
+ {{ item.spec || '-' }}
+
+
+ ¥{{ item.price }}
+ {{ item.unit || '个' }}
+
+
+
+
+
+ 暂无商品
+
+
+
+
@@ -43,6 +57,8 @@ export default {
data() {
return {
keyword: '',
+ categoryId: '',
+ categories: [],
productList: [],
page: 1,
pageSize: 50,
@@ -50,14 +66,24 @@ export default {
}
},
onLoad() {
+ this.loadCategories()
this.getProducts()
},
methods: {
+ async loadCategories() {
+ try {
+ const categories = await productApi.getCategories()
+ this.categories = categories || []
+ } catch (e) {
+ console.error(e)
+ }
+ },
async getProducts() {
this.loading = true
try {
const res = await productApi.getProducts({
keyword: this.keyword,
+ categoryId: this.categoryId,
page: this.page,
pageSize: this.pageSize
})
@@ -68,12 +94,16 @@ export default {
this.loading = false
}
},
+ selectCategory(id) {
+ this.categoryId = id
+ this.page = 1
+ this.getProducts()
+ },
search() {
this.page = 1
this.getProducts()
},
selectProduct(item) {
- // 返回上一页并传递选中的商品
const pages = getCurrentPages()
const prevPage = pages[pages.length - 2]
prevPage.$vm.addProduct(item)
@@ -83,48 +113,81 @@ export default {
}
-
+
+.empty-text {
+ font-size: 28rpx;
+ color: #999;
+ margin-top: 20rpx;
+}
+
\ No newline at end of file