feat: 添加页面刷新功能
This commit is contained in:
@@ -158,7 +158,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
import { onShow } from '@dcloudio/uni-app';
|
import { onPullDownRefresh, onShow } from '@dcloudio/uni-app';
|
||||||
import modeSwitch from '@/components/mode_switch/mode_switch.vue';
|
import modeSwitch from '@/components/mode_switch/mode_switch.vue';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import OrderStoreApi from '@/sheep/api/trade/orderStore';
|
import OrderStoreApi from '@/sheep/api/trade/orderStore';
|
||||||
@@ -236,7 +236,7 @@
|
|||||||
return storeIds;
|
return storeIds;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ensureStoreList = async () => {
|
const ensureStoreList = async (force = false) => {
|
||||||
const storeIds = await getUserStoreIds();
|
const storeIds = await getUserStoreIds();
|
||||||
if (!storeIds) {
|
if (!storeIds) {
|
||||||
storeList.value = [];
|
storeList.value = [];
|
||||||
@@ -245,7 +245,7 @@
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
if (storeLoading.value) return storeIds;
|
if (storeLoading.value) return storeIds;
|
||||||
if (storeIdsKey.value === storeIds && storeList.value.length) return storeIds;
|
if (!force && storeIdsKey.value === storeIds && storeList.value.length) return storeIds;
|
||||||
storeLoading.value = true;
|
storeLoading.value = true;
|
||||||
try {
|
try {
|
||||||
const { code, data } = await StoreApi.getStoreListByStoreIds(storeIds);
|
const { code, data } = await StoreApi.getStoreListByStoreIds(storeIds);
|
||||||
@@ -281,7 +281,10 @@
|
|||||||
return params;
|
return params;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getList = async () => {
|
const getList = async (force = false) => {
|
||||||
|
while (force && loading.value) {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||||
|
}
|
||||||
if (loading.value) return;
|
if (loading.value) return;
|
||||||
const storeId = await ensurePickUpStoreId();
|
const storeId = await ensurePickUpStoreId();
|
||||||
if (!(storeId > 0)) {
|
if (!(storeId > 0)) {
|
||||||
@@ -318,6 +321,18 @@
|
|||||||
await getList();
|
await getList();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onPullDownRefresh(async () => {
|
||||||
|
try {
|
||||||
|
expandedMap.value = {};
|
||||||
|
await ensureStoreList(true);
|
||||||
|
const current = Number(selectedStoreId.value || 0);
|
||||||
|
if (current > 0) uni.setStorageSync(STORE_SELECTED_KEY, current);
|
||||||
|
await getList(true);
|
||||||
|
} finally {
|
||||||
|
uni.stopPullDownRefresh();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let searchTimer = null;
|
let searchTimer = null;
|
||||||
watch(
|
watch(
|
||||||
[currentTab, keyword, selectedStoreId],
|
[currentTab, keyword, selectedStoreId],
|
||||||
|
|||||||
@@ -74,18 +74,18 @@
|
|||||||
<view class="store-code c_999">编号:{{ row.code || '--' }}</view>
|
<view class="store-code c_999">编号:{{ row.code || '--' }}</view>
|
||||||
<view class="store-contact c_999 lineOne">联系电话:{{ row.phone || '--' }}</view>
|
<view class="store-contact c_999 lineOne">联系电话:{{ row.phone || '--' }}</view>
|
||||||
<view class="store-address c_999">{{ row.address || '--' }}</view>
|
<view class="store-address c_999">{{ row.address || '--' }}</view>
|
||||||
<!-- <view class="store-capacity">
|
<view class="store-progress">
|
||||||
<view class="store-capacity__head flex-center ju-between">
|
<view class="store-progress__head flex-center ju-between">
|
||||||
<view class="store-capacity__label">库存容量</view>
|
<view class="store-progress__label">销量 / 库存</view>
|
||||||
<view class="store-capacity__value">{{ row.capacityText }}</view>
|
<view class="store-progress__value">{{ row.progressText }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="store-capacity__bar">
|
<view class="store-progress__bar">
|
||||||
<view
|
<view
|
||||||
class="store-capacity__fill"
|
class="store-progress__fill"
|
||||||
:style="{ width: `${row.capacityPercent}%` }"
|
:style="{ width: `${row.progressPercent}%` }"
|
||||||
></view>
|
></view>
|
||||||
</view>
|
</view>
|
||||||
</view> -->
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="store-actions flex-center ju-flex-end">
|
<view class="store-actions flex-center ju-flex-end">
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { onShow } from '@dcloudio/uni-app';
|
import { onPullDownRefresh, onShow } from '@dcloudio/uni-app';
|
||||||
import modeSwitch from '@/components/mode_switch/mode_switch.vue';
|
import modeSwitch from '@/components/mode_switch/mode_switch.vue';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import OrderStoreApi from '@/sheep/api/trade/orderStore';
|
import OrderStoreApi from '@/sheep/api/trade/orderStore';
|
||||||
@@ -215,20 +215,16 @@
|
|||||||
return Number.isFinite(n) ? n : -1;
|
return Number.isFinite(n) ? n : -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getCapacityInfo = (store) => {
|
const getStoreProgressInfo = (store) => {
|
||||||
const stock = Math.max(0, Number(store?.stock) || 0);
|
const sales = Math.max(0, Number(store?.sales ?? store?.salesCount) || 0);
|
||||||
const minSales = Math.max(0, Number(store?.minSales) || 0);
|
const stock = Math.max(0, Number(store?.stock ?? store?.stocks) || 0);
|
||||||
if (!(stock > 0)) {
|
const ratio = stock > 0 ? Math.round((sales / stock) * 100) : 0;
|
||||||
|
const progressPercent = Math.max(0, Math.min(100, ratio));
|
||||||
return {
|
return {
|
||||||
percent: 0,
|
sales,
|
||||||
text: '--',
|
stock,
|
||||||
};
|
progressPercent,
|
||||||
}
|
progressText: `${sales} / ${stock}`,
|
||||||
// 当前接口仅返回 stock,没有总容量字段,这里用一个可读的梯度进度来表达库存量级
|
|
||||||
const percent = Math.max(8, Math.min(100, Math.round((stock / Math.max(stock, 100)) * 100)));
|
|
||||||
return {
|
|
||||||
percent,
|
|
||||||
text: minSales > 0 ? `${stock} / 最低销量${minSales}` : `${stock}`,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -236,7 +232,7 @@
|
|||||||
const status = getStoreStatus(store);
|
const status = getStoreStatus(store);
|
||||||
const statusConfig = statusMap[status] || { text: '--', className: '' };
|
const statusConfig = statusMap[status] || { text: '--', className: '' };
|
||||||
const toggleActionText = status === 1 ? '停用' : status === 2 || status === 3 ? '启用' : '';
|
const toggleActionText = status === 1 ? '停用' : status === 2 || status === 3 ? '启用' : '';
|
||||||
const capacityInfo = getCapacityInfo(store);
|
const progressInfo = getStoreProgressInfo(store);
|
||||||
return {
|
return {
|
||||||
id: Number(store?.id || 0),
|
id: Number(store?.id || 0),
|
||||||
name: getStoreName(store),
|
name: getStoreName(store),
|
||||||
@@ -244,8 +240,10 @@
|
|||||||
phone: getStorePhone(store),
|
phone: getStorePhone(store),
|
||||||
address: getStoreAddress(store),
|
address: getStoreAddress(store),
|
||||||
coverImage: getStoreCoverImage(store),
|
coverImage: getStoreCoverImage(store),
|
||||||
capacityPercent: capacityInfo.percent,
|
sales: progressInfo.sales,
|
||||||
capacityText: capacityInfo.text,
|
stock: progressInfo.stock,
|
||||||
|
progressPercent: progressInfo.progressPercent,
|
||||||
|
progressText: progressInfo.progressText,
|
||||||
status,
|
status,
|
||||||
statusText: statusConfig.text,
|
statusText: statusConfig.text,
|
||||||
statusClass: statusConfig.className,
|
statusClass: statusConfig.className,
|
||||||
@@ -291,7 +289,10 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getList = async () => {
|
const getList = async (force = false) => {
|
||||||
|
while (force && loading.value) {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||||
|
}
|
||||||
if (loading.value) return;
|
if (loading.value) return;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
@@ -357,6 +358,14 @@
|
|||||||
onShow(() => {
|
onShow(() => {
|
||||||
getList();
|
getList();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onPullDownRefresh(async () => {
|
||||||
|
try {
|
||||||
|
await getList(true);
|
||||||
|
} finally {
|
||||||
|
uni.stopPullDownRefresh();
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -549,21 +558,21 @@
|
|||||||
line-height: 34rpx;
|
line-height: 34rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-capacity {
|
.store-progress {
|
||||||
margin-top: 14rpx;
|
margin-top: 14rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-capacity__head {
|
.store-progress__head {
|
||||||
margin-bottom: 8rpx;
|
margin-bottom: 8rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-capacity__label,
|
.store-progress__label,
|
||||||
.store-capacity__value {
|
.store-progress__value {
|
||||||
font-size: 22rpx;
|
font-size: 22rpx;
|
||||||
color: #667085;
|
color: #667085;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-capacity__bar {
|
.store-progress__bar {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 12rpx;
|
height: 12rpx;
|
||||||
border-radius: 999rpx;
|
border-radius: 999rpx;
|
||||||
@@ -571,7 +580,7 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-capacity__fill {
|
.store-progress__fill {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
border-radius: 999rpx;
|
border-radius: 999rpx;
|
||||||
background: linear-gradient(90deg, #2556ec 0%, #5b8cff 100%);
|
background: linear-gradient(90deg, #2556ec 0%, #5b8cff 100%);
|
||||||
|
|||||||
@@ -14,12 +14,21 @@
|
|||||||
:style="{ width: `${state.qrcodeSize}px`, height: `${state.qrcodeSize}px` }"
|
:style="{ width: `${state.qrcodeSize}px`, height: `${state.qrcodeSize}px` }"
|
||||||
:show-menu-by-longpress="true"
|
:show-menu-by-longpress="true"
|
||||||
/>
|
/>
|
||||||
|
<view v-if="isVerifyCompleted" class="verify-mask">
|
||||||
|
<view class="verify-mask__icon">
|
||||||
|
<uni-icons type="checkmarkempty" size="40" color="#ffffff" />
|
||||||
|
</view>
|
||||||
|
<view class="verify-mask__text">已核销</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="gear">
|
<view class="gear">
|
||||||
<image :src="sheep.$url.static('/static/img/shop/writeOff.png')"></image>
|
<image :src="sheep.$url.static('/static/img/shop/writeOff.png')"></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="num-wrap" @tap="copyVerifyCode">
|
<view v-if="isVerifyCompleted" class="num-wrap">
|
||||||
|
<view class="num num--done">该商品券已完成核销</view>
|
||||||
|
</view>
|
||||||
|
<view v-else class="num-wrap" @tap="copyVerifyCode">
|
||||||
<view class="num">{{ orderInfo.pickUpVerifyCode }}</view>
|
<view class="num">{{ orderInfo.pickUpVerifyCode }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="rules">
|
<view class="rules">
|
||||||
@@ -187,6 +196,18 @@
|
|||||||
return sheep.$url.cdn(raw);
|
return sheep.$url.cdn(raw);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isVerifyCompleted = computed(() => {
|
||||||
|
const info = props.orderInfo || {};
|
||||||
|
const status = Number(info?.status);
|
||||||
|
return Boolean(
|
||||||
|
info?.pickUpVerifyTime ||
|
||||||
|
info?.verifyTime ||
|
||||||
|
info?.completedTime ||
|
||||||
|
status === 30 ||
|
||||||
|
status === 3,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
const addressText = computed(() => {
|
const addressText = computed(() => {
|
||||||
const s = props.systemStore || {};
|
const s = props.systemStore || {};
|
||||||
const province = s.province || '';
|
const province = s.province || '';
|
||||||
@@ -309,6 +330,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.order-details .writeOff .grayBg .pictrue {
|
.order-details .writeOff .grayBg .pictrue {
|
||||||
|
position: relative;
|
||||||
width: 290rpx;
|
width: 290rpx;
|
||||||
height: 290rpx;
|
height: 290rpx;
|
||||||
}
|
}
|
||||||
@@ -318,6 +340,35 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.order-details .writeOff .grayBg .pictrue .verify-mask {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(255, 255, 255, 0.82);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.order-details .writeOff .grayBg .pictrue .verify-mask__icon {
|
||||||
|
width: 112rpx;
|
||||||
|
height: 112rpx;
|
||||||
|
border-radius: 56rpx;
|
||||||
|
background: #56c33b;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
box-shadow: 0 8rpx 20rpx rgba(86, 195, 59, 0.24);
|
||||||
|
}
|
||||||
|
|
||||||
|
.order-details .writeOff .grayBg .pictrue .verify-mask__text {
|
||||||
|
margin-top: 18rpx;
|
||||||
|
font-size: 40rpx;
|
||||||
|
line-height: 56rpx;
|
||||||
|
color: #2a7c1f;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
.order-details .writeOff .gear {
|
.order-details .writeOff .gear {
|
||||||
width: 590rpx;
|
width: 590rpx;
|
||||||
height: 30rpx;
|
height: 30rpx;
|
||||||
@@ -345,6 +396,19 @@
|
|||||||
padding-top: 4rpx;
|
padding-top: 4rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.order-details .writeOff .num--done {
|
||||||
|
height: auto;
|
||||||
|
min-height: 84rpx;
|
||||||
|
padding-top: 0;
|
||||||
|
padding: 22rpx 24rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-radius: 0 0 20rpx 20rpx;
|
||||||
|
background: #ffffff;
|
||||||
|
color: #b5b5b5;
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.order-details .writeOff .rules {
|
.order-details .writeOff .rules {
|
||||||
margin: 46rpx 30rpx 0 30rpx;
|
margin: 46rpx 30rpx 0 30rpx;
|
||||||
border-top: 1px solid #f0f0f0;
|
border-top: 1px solid #f0f0f0;
|
||||||
|
|||||||
@@ -133,13 +133,12 @@
|
|||||||
if (data?.pickUpVerifyTime || data?.verifyTime || data?.completedTime || rawStatus === 30 || rawStatus === 3) {
|
if (data?.pickUpVerifyTime || data?.verifyTime || data?.completedTime || rawStatus === 30 || rawStatus === 3) {
|
||||||
return 'done';
|
return 'done';
|
||||||
}
|
}
|
||||||
if (rawStatus === 1) return 'wait';
|
if (rawStatus === 1 || rawStatus === 2) return 'wait';
|
||||||
if (
|
if (
|
||||||
data?.deliveryTime ||
|
data?.deliveryTime ||
|
||||||
data?.arriveStoreTime ||
|
data?.arriveStoreTime ||
|
||||||
data?.deliveredTime ||
|
data?.deliveredTime ||
|
||||||
rawStatus === 20 ||
|
rawStatus === 20
|
||||||
rawStatus === 2
|
|
||||||
) {
|
) {
|
||||||
return 'delivered';
|
return 'delivered';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user