fix: resolve 8 bugs and add admin features
Miniprogram: - Profile "我的设备": show unbind option when device bound, scan when not - Add device status indicator (已绑定/未绑定) to profile menu Admin console: - Login: add @confirm to inputs so Enter key submits the form - Record detail: wire up 详情 link with modal showing full record info - Dashboard: add subscription stats row (月卡/年卡/试用/收入) - Subscription: add 取消 action for active subscriptions - Format: fix -8h timezone display for UTC ISO date strings Server: - POST /api/v1/admin/subscriptions/cancel: cancel active subscriptions - Dashboard API: include sub_stats (plan counts + monthly revenue) - IP extraction: add X-Forwarded-For fallback for logging
这个提交包含在:
@@ -23,6 +23,25 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="stat-grid secondary-stats" v-if="subStats.monthly_count != null">
|
||||
<view class="stat-card">
|
||||
<text class="stat-value">{{ subStats.monthly_count || 0 }}</text>
|
||||
<text class="stat-label">月卡会员</text>
|
||||
</view>
|
||||
<view class="stat-card">
|
||||
<text class="stat-value">{{ subStats.yearly_count || 0 }}</text>
|
||||
<text class="stat-label">年卡会员</text>
|
||||
</view>
|
||||
<view class="stat-card">
|
||||
<text class="stat-value">{{ subStats.trial_count || 0 }}</text>
|
||||
<text class="stat-label">试用中</text>
|
||||
</view>
|
||||
<view class="stat-card">
|
||||
<text class="stat-value">¥{{ subStats.monthly_revenue || 0 }}</text>
|
||||
<text class="stat-label">本月收入</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="main-row">
|
||||
<view class="card table-card">
|
||||
<view class="card-header">
|
||||
@@ -91,6 +110,7 @@
|
||||
|
||||
<script>
|
||||
import { get } from '../../utils/request'
|
||||
import { formatDate as formatDateUtil } from '../../utils/format'
|
||||
import AdminLayout from '../../components/AdminLayout.vue'
|
||||
|
||||
export default {
|
||||
@@ -98,6 +118,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
stats: {},
|
||||
subStats: {},
|
||||
recentTreatments: []
|
||||
}
|
||||
},
|
||||
@@ -117,11 +138,12 @@ export default {
|
||||
} catch (e) {
|
||||
this.recentTreatments = []
|
||||
}
|
||||
try {
|
||||
const subData = await get('/api/v1/admin/subscriptions', { page: 1, page_size: 1, tab: 'all' })
|
||||
if (subData.stats) this.subStats = subData.stats
|
||||
} catch (e) {}
|
||||
},
|
||||
formatDate(d) {
|
||||
if (!d) return '--'
|
||||
return String(d).slice(0, 19).replace('T', ' ')
|
||||
},
|
||||
formatDate: formatDateUtil,
|
||||
onNav(path) {
|
||||
uni.redirectTo({ url: path })
|
||||
}
|
||||
@@ -324,4 +346,8 @@ export default {
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.secondary-stats {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
v-model="form.username"
|
||||
placeholder="请输入管理员账号"
|
||||
placeholder-class="input-placeholder"
|
||||
@confirm="onLogin"
|
||||
/>
|
||||
</view>
|
||||
|
||||
@@ -23,6 +24,7 @@
|
||||
placeholder="请输入密码"
|
||||
:password="true"
|
||||
placeholder-class="input-placeholder"
|
||||
@confirm="onLogin"
|
||||
/>
|
||||
</view>
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<text class="t-td flex1">{{ Math.floor((item.total_duration_ms || 0) / 60000) }}分</text>
|
||||
<text class="t-td flex2">{{ formatDate(item.start_time) }}</text>
|
||||
<text class="t-td flex1">
|
||||
<text class="action-link">详情</text>
|
||||
<text class="action-link" @click="onDetail(item)">详情</text>
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -127,6 +127,22 @@ export default {
|
||||
}
|
||||
return names.join(',') || '-'
|
||||
},
|
||||
onDetail(item) {
|
||||
var regions = this.formatRegions(item.regions)
|
||||
var mode = item.mode === 1 ? '智能模式' : '普通模式'
|
||||
var duration = Math.floor((item.total_duration_ms || 0) / 60000)
|
||||
var content = '用户: ' + (item.nickname || item.user_id || '-') +
|
||||
'\n设备: ' + (item.device_id || '-') +
|
||||
'\n模式: ' + mode +
|
||||
'\n区域: ' + regions +
|
||||
'\n时长: ' + duration + '分钟' +
|
||||
'\n时间: ' + this.formatDate(item.start_time)
|
||||
uni.showModal({
|
||||
title: '护理记录详情 #' + (item.record_id || ''),
|
||||
content: content,
|
||||
showCancel: false
|
||||
})
|
||||
},
|
||||
formatDate: formatDateUtil,
|
||||
async onExport() {
|
||||
try {
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
<text class="t-td flex1">
|
||||
<text class="action-link" @click="onDetail(item)">详情</text>
|
||||
<text class="action-link" v-if="item.status === 1" @click="onExtend(item)">延期</text>
|
||||
<text class="action-link" v-if="item.status === 1" @click="onCancel(item)">取消</text>
|
||||
<text class="action-link" v-if="item.status === 2 || item.status === 3" @click="onRenew(item)">续费</text>
|
||||
</text>
|
||||
</view>
|
||||
@@ -193,6 +194,26 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
onCancel(item) {
|
||||
var self = this
|
||||
uni.showModal({
|
||||
title: '取消订阅',
|
||||
content: '确定要取消用户 #' + item.user_id + ' 的订阅吗?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
await post('/api/v1/admin/subscriptions/cancel', {
|
||||
subscription_id: item.subscription_id
|
||||
})
|
||||
uni.showToast({ title: '已取消', icon: 'success' })
|
||||
self.loadSubscriptions()
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '操作失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
onRenew(item) {
|
||||
this.createForm.user_id = String(item.user_id || '')
|
||||
this.createForm.plan = item.plan || 'monthly'
|
||||
|
||||
在新工单中引用
屏蔽一个用户