2
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
|
||||
<!-- 业务类型侧边切换:销售/进货/收款/资金/盘点 -->
|
||||
<!-- 业务类型侧边切换:销售/进货/收款/资金 -->
|
||||
<view class="content">
|
||||
<view class="biz-tabs">
|
||||
<view v-for="b in bizList" :key="b.key" :class="['biz', biz===b.key && 'active']" @click="switchBiz(b.key)">{{ b.name }}</view>
|
||||
@@ -42,8 +42,10 @@
|
||||
<view class="amount" :class="{ in: Number(it.amount||0) >= 0, out: Number(it.amount||0) < 0 }">¥ {{ (it.amount || 0).toFixed(2) }}</view>
|
||||
<view class="arrow">›</view>
|
||||
</view>
|
||||
</block>
|
||||
<view v-else class="empty">暂无数据</view>
|
||||
</block>
|
||||
<view v-else class="empty">暂无数据</view>
|
||||
<view v-if="items.length && !finished" class="loading" v-show="loading">加载中...</view>
|
||||
<view v-if="finished && items.length" class="finished">没有更多了</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 右下角新增按钮:根据业务类型跳转对应开单页或创建页 -->
|
||||
@@ -60,8 +62,7 @@ const API_OF = {
|
||||
sale: '/api/orders',
|
||||
purchase: '/api/purchase-orders',
|
||||
collect: '/api/payments',
|
||||
fund: '/api/other-transactions',
|
||||
stock: '/api/inventories/logs'
|
||||
fund: '/api/other-transactions'
|
||||
}
|
||||
|
||||
export default {
|
||||
@@ -72,18 +73,19 @@ export default {
|
||||
{ key: 'sale', name: '出货' },
|
||||
{ key: 'purchase', name: '进货' },
|
||||
{ key: 'collect', name: '收款' },
|
||||
{ key: 'fund', name: '资金' },
|
||||
{ key: 'stock', name: '盘点' }
|
||||
{ key: 'fund', name: '资金' }
|
||||
],
|
||||
range: 'month',
|
||||
query: { kw: '' },
|
||||
items: [],
|
||||
page: 1,
|
||||
size: 20,
|
||||
size: 15,
|
||||
finished: false,
|
||||
loading: false,
|
||||
startDate: '',
|
||||
endDate: ''
|
||||
endDate: '',
|
||||
nonVipRetentionDays: 0,
|
||||
isVip: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -124,7 +126,7 @@ export default {
|
||||
async loadMore() {
|
||||
if (this.loading || this.finished) return
|
||||
this.loading = true
|
||||
try {
|
||||
try {
|
||||
const path = API_OF[this.biz] || '/api/orders'
|
||||
const params = { kw: this.query.kw, page: this.page, size: this.size, startDate: this.startDate, endDate: this.endDate, biz: this.biz }
|
||||
if (this.biz === 'sale') params.type = 'out'
|
||||
@@ -133,12 +135,37 @@ export default {
|
||||
this.items = this.items.concat(list)
|
||||
if (list.length < this.size) this.finished = true
|
||||
this.page += 1
|
||||
await this.hintIfNonVipOutOfWindow()
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally { this.loading = false }
|
||||
},
|
||||
async hintIfNonVipOutOfWindow(){
|
||||
try {
|
||||
if (this.isVip && this.isVip === true) return
|
||||
// 缓存一轮,避免每次调用
|
||||
if (!this.nonVipRetentionDays) {
|
||||
const v = await get('/api/vip/status')
|
||||
this.isVip = !!v?.isVip
|
||||
this.nonVipRetentionDays = Number(v?.nonVipRetentionDays || 60)
|
||||
if (this.isVip) return
|
||||
}
|
||||
if (!this.startDate) return
|
||||
const start = new Date(this.startDate).getTime()
|
||||
const threshold = Date.now() - this.nonVipRetentionDays * 24 * 3600 * 1000
|
||||
if (start < threshold) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `普通用户仅显示近${this.nonVipRetentionDays}天数据,开通VIP可查看全部历史。`,
|
||||
confirmText: '去开通VIP',
|
||||
cancelText: '我知道了',
|
||||
success: (r) => { if (r.confirm) uni.navigateTo({ url: '/pages/my/vip' }) }
|
||||
})
|
||||
}
|
||||
} catch (e) {}
|
||||
},
|
||||
formatDate(s) { if (!s) return ''; try { const d = new Date(s); const pad = n => String(n).padStart(2, '0'); return `${d.getFullYear()}-${pad(d.getMonth()+1)}-${pad(d.getDate())}` } catch (_) { return String(s).slice(0,10) } },
|
||||
onCreate() { if (this.biz === 'sale') { uni.switchTab({ url: '/pages/order/create' }); return } uni.showToast({ title: '该类型创建页待实现', icon: 'none' }) },
|
||||
onCreate() { if (this.biz === 'sale') { uni.switchTab({ url: '/pages/order/create' }); return } uni.showToast({ title: '该类型创建页待实现', icon: 'none' }) },
|
||||
openDetail(it) { uni.showToast({ title: '详情开发中', icon: 'none' }) }
|
||||
}
|
||||
}
|
||||
@@ -154,18 +181,21 @@ export default {
|
||||
.biz { flex:0 0 120rpx; display:flex; align-items:center; justify-content:center; color:$uni-color-primary; }
|
||||
.biz.active { background:rgba(76,141,255,0.10); color:$uni-color-primary; font-weight:700; }
|
||||
|
||||
.panel { flex:1; display:flex; flex-direction: column; background:#fff; margin: 16rpx; border-radius: 16rpx; padding: 12rpx; border:2rpx solid $uni-border-color; }
|
||||
.panel { flex:1; display:flex; flex-direction: column; background:#fff; margin: 16rpx; border-radius: 16rpx; padding: 12rpx; }
|
||||
.toolbar { display:flex; flex-direction: column; gap: 10rpx; padding: 10rpx 6rpx 6rpx; border-bottom:2rpx solid $uni-border-color; }
|
||||
.period-group { display:flex; align-items:center; gap: 8rpx; background:#f6f8fb; border:2rpx solid #e6ebf2; border-radius: 10rpx; padding: 8rpx 10rpx; }
|
||||
.period-group { display:flex; align-items:center; gap: 8rpx; background:#f6f8fb; border-radius: 10rpx; padding: 8rpx 10rpx; }
|
||||
.period-label { color:#6b778c; }
|
||||
.date-chip { padding: 8rpx 12rpx; background:#fff; border:2rpx solid #e6ebf2; border-radius: 8rpx; }
|
||||
.sep { color:#99a2b3; padding: 0 6rpx; }
|
||||
.search-row { display:flex; align-items:center; gap: 10rpx; }
|
||||
.search { flex:1; }
|
||||
.search-input { width:100%; background:#fff; border-radius: 12rpx; padding: 12rpx; color:$uni-text-color; border:2rpx solid #e6ebf2; }
|
||||
.btn { background:$uni-color-primary; color:#fff; border: none; }
|
||||
.search-row { display:flex; align-items:center; gap: 16rpx; }
|
||||
.search { flex:1; min-width:0; display:flex; }
|
||||
.search-input { flex:1; height: 72rpx; line-height: 72rpx; padding: 0 24rpx; box-sizing:border-box; background:#fff; border-radius: 12rpx; color:$uni-text-color; border:2rpx solid #e6ebf2; font-size: 26rpx; }
|
||||
.btn { flex-shrink:0; display:flex; align-items:center; justify-content:center; height: 72rpx; padding: 0 32rpx; margin-left: 4rpx; border-radius: 12rpx; background:$uni-color-primary; color:#fff; border:none; font-size: 26rpx; box-sizing:border-box; }
|
||||
.btn::after { border:none; }
|
||||
.total { color:$uni-color-primary; font-weight: 700; padding: 10rpx 6rpx 12rpx; background:#fff; }
|
||||
.list { flex:1; }
|
||||
.loading { text-align:center; padding: 20rpx 0; color:$uni-text-color-grey; }
|
||||
.finished { text-align:center; padding: 20rpx 0; color:$uni-text-color-grey; }
|
||||
.item { display:grid; grid-template-columns: 1fr auto auto; align-items:center; gap: 8rpx; padding: 18rpx 12rpx; border-bottom: 1rpx solid $uni-border-color; }
|
||||
.item-left { display:flex; flex-direction: column; }
|
||||
.date { color:$uni-text-color-grey; font-size: 24rpx; }
|
||||
|
||||
Reference in New Issue
Block a user