|
|
@@ -19,21 +19,21 @@
|
|
|
<text class="text-[#333]" :class="{ 'text-[var(--primary-color)] font-500': searchType == 'all' }"
|
|
|
@click="searchTypeFn('all')">综合排序</text>
|
|
|
<view class="flex items-center text-[#333]"
|
|
|
- :class="{ 'text-[var(--primary-color)] font-500': searchType == 'sale_num' }"
|
|
|
- @click="searchTypeFn('sale_num')">
|
|
|
- <text class="mr-[4rpx]">销量</text>
|
|
|
- <text v-if="sale_num == 'asc'" class="text-[16rpx] nc-iconfont nc-icon-a-xiangshangV6xx1"
|
|
|
- :class="{ 'text-[var(--primary-color)]': searchType == 'sale_num' }"></text>
|
|
|
- <text v-else class="text-[16rpx] nc-iconfont nc-icon-a-xiangxiaV6xx1"
|
|
|
- :class="{ 'text-[var(--primary-color)]': searchType == 'sale_num' }"></text>
|
|
|
+ :class="{ 'text-[var(--primary-color)] font-500': searchType == 'stock' }"
|
|
|
+ @click="searchTypeFn('stock')">
|
|
|
+ <text class="mr-[4rpx]">库存</text>
|
|
|
+ <text v-if="searchType === 'stock' && currentSortOrder === 'Asc'" class="text-[16rpx] nc-iconfont nc-icon-a-xiangshangV6xx1"
|
|
|
+ :class="{ 'text-[var(--primary-color)]': searchType == 'stock' }"></text>
|
|
|
+ <text v-else-if="searchType === 'stock'" class="text-[16rpx] nc-iconfont nc-icon-a-xiangxiaV6xx1"
|
|
|
+ :class="{ 'text-[var(--primary-color)]': searchType == 'stock' }"></text>
|
|
|
</view>
|
|
|
<view class="flex items-center text-[#333]"
|
|
|
:class="{ 'text-[var(--primary-color)] font-500': searchType == 'price' }"
|
|
|
@click="searchTypeFn('price')">
|
|
|
<text class="mr-[4rpx]">价格</text>
|
|
|
- <text v-if="price == 'asc'" class="text-[16rpx] nc-iconfont nc-icon-a-xiangshangV6xx1"
|
|
|
+ <text v-if="searchType === 'price' && currentSortOrder === 'Asc'" class="text-[16rpx] nc-iconfont nc-icon-a-xiangshangV6xx1"
|
|
|
:class="{ 'text-[var(--primary-color)]': searchType == 'price' }"></text>
|
|
|
- <text v-else class="text-[16rpx] nc-iconfont nc-icon-a-xiangxiaV6xx1"
|
|
|
+ <text v-else-if="searchType === 'price'" class="text-[16rpx] nc-iconfont nc-icon-a-xiangxiaV6xx1"
|
|
|
:class="{ 'text-[var(--primary-color)]': searchType == 'price' }"></text>
|
|
|
</view>
|
|
|
<view class="flex items-center"
|
|
|
@@ -86,7 +86,7 @@
|
|
|
</view>
|
|
|
<view class="flex flex-wrap">
|
|
|
<view class="base-tag" :style="diyGoods.baseTagStyle()">
|
|
|
- {{ item.productNo }}
|
|
|
+ 起订{{ item.minOrderQuantity || 1 }}{{ item.unitName || '件' }}
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="mt-auto flex justify-between items-baseline">
|
|
|
@@ -100,7 +100,7 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<text class="text-[22rpx] mt-[20rpx] text-[var(--text-color-light9)]">
|
|
|
- 起订{{ item.minOrderQuantity || 1 }}{{ item.unitName || '件' }}
|
|
|
+ 库存:{{ item.totalInventory || 0 }}
|
|
|
</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -126,7 +126,7 @@
|
|
|
{{ item.itemName }}
|
|
|
</view>
|
|
|
<view class="flex flex-wrap">
|
|
|
- <view class="base-tag" :style="diyGoods.baseTagStyle()">{{ item.productNo }}
|
|
|
+ <view class="base-tag" :style="diyGoods.baseTagStyle()">起订{{ item.minOrderQuantity || 1 }}{{ item.unitName || '件' }}
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="flex justify-between flex-wrap items-end">
|
|
|
@@ -139,8 +139,7 @@
|
|
|
diyGoods.goodsPrice(item).toFixed(2).split('.')[1] }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <text class="text-[22rpx] text-[var(--text-color-light9)] mt-[20rpx]"> 起订{{
|
|
|
- item.minOrderQuantity || 1 }}{{ item.unitName || '件' }}</text>
|
|
|
+ <text class="text-[22rpx] text-[var(--text-color-light9)] mt-[20rpx]"> 库存:{{ item.totalInventory || 0 }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -165,7 +164,7 @@
|
|
|
</view>
|
|
|
<view class="flex flex-wrap">
|
|
|
<view class="base-tag" :style="diyGoods.baseTagStyle()">
|
|
|
- {{ item.productNo }}
|
|
|
+ 起订{{ item.minOrderQuantity || 1 }}{{ item.unitName || '件' }}
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="flex justify-between flex-wrap items-baseline">
|
|
|
@@ -178,8 +177,7 @@
|
|
|
diyGoods.goodsPrice(item).toFixed(2).split('.')[1] }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <text class="mt-[20rpx] text-[22rpx] text-[var(--text-color-light9)]">起订{{
|
|
|
- item.minOrderQuantity || 1 }}{{ item.unitName || '件' }}</text>
|
|
|
+ <text class="mt-[20rpx] text-[22rpx] text-[var(--text-color-light9)]">库存:{{ item.totalInventory || 0 }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -210,18 +208,19 @@ const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, on
|
|
|
const diyGoods = useGoods();
|
|
|
const categoryList = ref<Array<Object>>([]);
|
|
|
const goodsList = ref<Array<any>>([]);
|
|
|
-const coupon_id = ref<number | string>('');
|
|
|
const currGoodsCategory = ref<number | string>('');
|
|
|
const mescrollRef = ref(null);
|
|
|
const loading = ref<boolean>(false);
|
|
|
// 标签
|
|
|
const labelPopup = ref(false);
|
|
|
const goods_name = ref("");
|
|
|
-const price = ref("");
|
|
|
-const sale_num = ref("");
|
|
|
const searchType = ref('all');
|
|
|
//列表类型
|
|
|
const listType = ref(true)
|
|
|
+
|
|
|
+// 新增:用于存储当前排序方式(Asc / Desc)
|
|
|
+const currentSortOrder = ref('Asc');
|
|
|
+
|
|
|
onLoad(async (option: any) => {
|
|
|
// #ifdef MP-WEIXIN
|
|
|
// 处理小程序场景值参数
|
|
|
@@ -229,7 +228,6 @@ onLoad(async (option: any) => {
|
|
|
// #endif
|
|
|
currGoodsCategory.value = option.curr_goods_category || ''
|
|
|
goods_name.value = option.goods_name ? decodeURIComponent(option.goods_name) : ''
|
|
|
- coupon_id.value = option.coupon_id || ''
|
|
|
await getGoodsCategoryTree().then((res: any) => {
|
|
|
const initData = { category_name: "全部", category_id: '' };
|
|
|
categoryList.value.push(initData);
|
|
|
@@ -246,15 +244,30 @@ interface mescrollStructure {
|
|
|
|
|
|
const getAllAppListFn = (mescroll: mescrollStructure) => {
|
|
|
loading.value = false;
|
|
|
+
|
|
|
+ let sortField = '';
|
|
|
+ let sortOrder = '';
|
|
|
+
|
|
|
+ if (searchType.value === 'all') {
|
|
|
+ sortField = '1'; // 智能排序
|
|
|
+ sortOrder = 'Asc';
|
|
|
+ } else if (searchType.value === 'stock') {
|
|
|
+ sortField = '2'; // 库存匹配
|
|
|
+ sortOrder = currentSortOrder.value;
|
|
|
+ } else if (searchType.value === 'price') {
|
|
|
+ sortField = '3'; // 价格排序
|
|
|
+ sortOrder = currentSortOrder.value;
|
|
|
+ }
|
|
|
+
|
|
|
let data: object = {
|
|
|
goods_category: currGoodsCategory.value,
|
|
|
- page: mescroll.num,
|
|
|
- limit: mescroll.size,
|
|
|
- keyword: goods_name.value,
|
|
|
- coupon_id: coupon_id.value,
|
|
|
- order: searchType.value === 'all' ? '' : searchType.value,
|
|
|
- sort: searchType.value == 'price' ? price.value : sale_num.value
|
|
|
+ pageNum: mescroll.num,
|
|
|
+ pageSize: mescroll.size,
|
|
|
+ searchKeyword: goods_name.value,
|
|
|
+ sortField,
|
|
|
+ sortOrder
|
|
|
};
|
|
|
+
|
|
|
getGoodsComponents(data).then((res: any) => {
|
|
|
let newArr = (res.rows as Array<Object>);
|
|
|
console.log(newArr, 'newArrnewArrnewArrnewArr')
|
|
|
@@ -284,37 +297,23 @@ const loadCategory = (id: string) => {
|
|
|
|
|
|
// 搜索
|
|
|
const searchTypeFn = (type: any) => {
|
|
|
- searchType.value = type;
|
|
|
- if (type == 'all') {
|
|
|
- sale_num.value = '';
|
|
|
- price.value = '';
|
|
|
- }
|
|
|
- if (type == 'price') {
|
|
|
- sale_num.value = '';
|
|
|
- if (price.value) {
|
|
|
- price.value = price.value == 'asc' ? 'desc' : 'asc';
|
|
|
- } else {
|
|
|
- price.value = 'asc';
|
|
|
- }
|
|
|
- }
|
|
|
- if (type == 'sale_num') {
|
|
|
- price.value = '';
|
|
|
- if (sale_num.value) {
|
|
|
- sale_num.value = sale_num.value == 'asc' ? 'desc' : 'asc';
|
|
|
- } else {
|
|
|
- sale_num.value = 'asc';
|
|
|
- }
|
|
|
- }
|
|
|
- if (type == 'label') {
|
|
|
- sale_num.value = 'asc';
|
|
|
- price.value = 'asc';
|
|
|
+ if (type === 'label') {
|
|
|
labelPopup.value = true;
|
|
|
- } else {
|
|
|
- labelPopup.value = false;
|
|
|
- goodsList.value = [];
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- getMescroll().resetUpScroll();
|
|
|
+ // 切换排序类型时重置顺序为 Asc
|
|
|
+ if (searchType.value !== type) {
|
|
|
+ currentSortOrder.value = 'Asc';
|
|
|
+ } else {
|
|
|
+ // 同一类型点击切换升降序
|
|
|
+ currentSortOrder.value = currentSortOrder.value === 'Asc' ? 'Desc' : 'Asc';
|
|
|
}
|
|
|
+
|
|
|
+ searchType.value = type;
|
|
|
+ labelPopup.value = false;
|
|
|
+ goodsList.value = [];
|
|
|
+ getMescroll().resetUpScroll();
|
|
|
}
|
|
|
|
|
|
//列表样式切换
|