最低价格
This commit is contained in:
parent
87148ac038
commit
2a736f0aae
|
|
@ -3,7 +3,8 @@
|
|||
{
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
"navigationStyle": "custom",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -65,6 +65,9 @@
|
|||
<view v-if="loading" class="loading-tip">
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
<view v-else-if="products.length > 0 && !hasMore" class="loading-tip">
|
||||
<text>没有更多了</text>
|
||||
</view>
|
||||
|
||||
<!-- 客服二维码弹窗 -->
|
||||
<CustomerServiceBtn v-if="showQrcode" mode="qrcode" @close="showQrcode = false" />
|
||||
|
|
@ -73,6 +76,7 @@
|
|||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
||||
import type { Product, Category } from '../../types'
|
||||
import { getProducts, getCategories } from '../../api/product'
|
||||
import { BASE_URL } from '../../utils/request'
|
||||
|
|
@ -114,8 +118,11 @@
|
|||
} catch { /* handled */ }
|
||||
}
|
||||
|
||||
const hasMore = ref(true)
|
||||
|
||||
async function loadProducts(reset = false) {
|
||||
if (reset) { page.value = 1; products.value = [] }
|
||||
if (reset) { page.value = 1; products.value = []; hasMore.value = true }
|
||||
if (!hasMore.value) return
|
||||
loading.value = true
|
||||
try {
|
||||
const params : Record<string, unknown> = { page: page.value, pageSize }
|
||||
|
|
@ -123,6 +130,7 @@
|
|||
if (keyword.value) params.keyword = keyword.value
|
||||
const data = await getProducts(params as any)
|
||||
if (reset) { products.value = data.list } else { products.value.push(...data.list) }
|
||||
if (data.list.length < pageSize) hasMore.value = false
|
||||
} catch { /* handled */ }
|
||||
finally { loading.value = false }
|
||||
}
|
||||
|
|
@ -143,6 +151,18 @@
|
|||
}
|
||||
|
||||
onMounted(() => { loadCategories(); loadProducts(true) })
|
||||
|
||||
onPullDownRefresh(async () => {
|
||||
await Promise.all([loadCategories(), loadProducts(true)])
|
||||
uni.stopPullDownRefresh()
|
||||
})
|
||||
|
||||
onReachBottom(() => {
|
||||
if (!loading.value && hasMore.value) {
|
||||
page.value++
|
||||
loadProducts()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
|||
|
|
@ -97,9 +97,9 @@ export async function adminCreateProduct(req: Request, res: Response): Promise<v
|
|||
const categoryIdStr = Array.isArray(categoryId) ? JSON.stringify(categoryId) : (categoryId ? JSON.stringify([categoryId]) : null)
|
||||
|
||||
const [result] = await conn.execute<ResultSetHeader>(
|
||||
`INSERT INTO products (name, base_price, style_no, stock, total_stock, loss, labor_cost, category_id, banner_images, banner_video, detail_images, thumb, side_stone, style, setting, status)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
[name, basePrice || 0, styleNo || '', stock || 0, totalStock || 0, loss || 0, laborCost || 0, categoryIdStr, JSON.stringify(bannerImages || []), JSON.stringify(bannerVideo || []), JSON.stringify(detailImages || []), thumb || null, sideStone || '', style || '', setting || '', status || 'on']
|
||||
`INSERT INTO products (name, style_no, total_stock, loss, labor_cost, category_id, banner_images, banner_video, detail_images, thumb, side_stone, style, setting, status)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
[name, styleNo || '', totalStock || 0, loss || 0, laborCost || 0, categoryIdStr, JSON.stringify(bannerImages || []), JSON.stringify(bannerVideo || []), JSON.stringify(detailImages || []), thumb || null, sideStone || '', style || '', setting || '', status || 'on']
|
||||
)
|
||||
const productId = result.insertId
|
||||
|
||||
|
|
@ -165,9 +165,9 @@ export async function adminUpdateProduct(req: Request, res: Response): Promise<v
|
|||
const categoryIdStr = Array.isArray(categoryId) ? JSON.stringify(categoryId) : (categoryId ? JSON.stringify([categoryId]) : null)
|
||||
|
||||
await conn.execute(
|
||||
`UPDATE products SET name=?, base_price=?, style_no=?, stock=?, total_stock=?, loss=?, labor_cost=?, category_id=?, banner_images=?, banner_video=?, detail_images=?, thumb=?, side_stone=?, style=?, setting=?, status=?
|
||||
`UPDATE products SET name=?, style_no=?, total_stock=?, loss=?, labor_cost=?, category_id=?, banner_images=?, banner_video=?, detail_images=?, thumb=?, side_stone=?, style=?, setting=?, status=?
|
||||
WHERE id=?`,
|
||||
[name, basePrice || 0, styleNo || '', stock || 0, totalStock || 0, loss || 0, laborCost || 0, categoryIdStr, JSON.stringify(bannerImages || []), JSON.stringify(bannerVideo || []), JSON.stringify(detailImages || []), thumb || null, sideStone || '', style || '', setting || '', status || 'on', id]
|
||||
[name, styleNo || '', totalStock || 0, loss || 0, laborCost || 0, categoryIdStr, JSON.stringify(bannerImages || []), JSON.stringify(bannerVideo || []), JSON.stringify(detailImages || []), thumb || null, sideStone || '', style || '', setting || '', status || 'on', id]
|
||||
)
|
||||
|
||||
// Update detail parameter config
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user