fix: H5客户端接口全链路修复 — 登录状态/首页key/账户字段/膳食类型
This commit is contained in:
@@ -31,7 +31,7 @@ class AuthController extends Controller
|
||||
return $this->error('手机号或密码错误', 40100, 401);
|
||||
}
|
||||
|
||||
if ($customer->status !== 1) {
|
||||
if (in_array($customer->status, [4, 5])) {
|
||||
return $this->error('账号已停用,请联系门店', 40101, 403);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,12 +69,12 @@ class HomeController extends Controller
|
||||
$nannyOrder->load('nanny:id,name,level,phone');
|
||||
}
|
||||
|
||||
return $this->success(compact(
|
||||
'customerInfo',
|
||||
'careRecords',
|
||||
'todayMeals',
|
||||
'contract',
|
||||
'nannyOrder'
|
||||
));
|
||||
return $this->success([
|
||||
'customer' => $customerInfo,
|
||||
'care_records' => $careRecords,
|
||||
'today_meals' => $todayMeals,
|
||||
'contract' => $contract,
|
||||
'nanny_order' => $nannyOrder,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ const todayMeals = computed(() => homeData.value?.today_meals || [])
|
||||
const latestRecords = computed(() => homeData.value?.care_records || [])
|
||||
const nannyOrder = computed(() => homeData.value?.nanny_order)
|
||||
|
||||
const mealTypeLabel = { 1: '早餐', 2: '上午茶', 3: '午餐', 4: '下午茶', 5: '晚餐', 6: '宵夜' }
|
||||
const mealTypeLabel = { 1: '早餐', 2: '午餐', 3: '下午茶', 4: '晚餐', 5: '宵夜' }
|
||||
|
||||
const features = [
|
||||
{ label: '月子餐', bg: '#fff0f4', color: '#f43f5e', icon: 'food-o', path: '/meal' },
|
||||
|
||||
@@ -10,9 +10,9 @@ const currentPlan = ref(null)
|
||||
const reviewForm = ref({ rating: 5, content: '' })
|
||||
const submitting = ref(false)
|
||||
|
||||
const mealTypeLabel = { 1: '早餐', 2: '上午茶', 3: '午餐', 4: '下午茶', 5: '晚餐', 6: '宵夜' }
|
||||
const mealTypeBg = { 1: '#fff0f4', 2: '#fffbeb', 3: '#f0fdf4', 4: '#f0f9ff', 5: '#eff6ff', 6: '#faf5ff' }
|
||||
const mealTypeColor = { 1: '#f43f5e', 2: '#f59e0b', 3: '#10b981', 4: '#0ea5e9', 5: '#3b82f6', 6: '#8b5cf6' }
|
||||
const mealTypeLabel = { 1: '早餐', 2: '午餐', 3: '下午茶', 4: '晚餐', 5: '宵夜' }
|
||||
const mealTypeBg = { 1: '#fff0f4', 2: '#f0fdf4', 3: '#f0f9ff', 4: '#eff6ff', 5: '#faf5ff' }
|
||||
const mealTypeColor = { 1: '#f43f5e', 2: '#10b981', 3: '#0ea5e9', 4: '#3b82f6', 5: '#8b5cf6' }
|
||||
|
||||
onMounted(fetchList)
|
||||
|
||||
|
||||
@@ -1,50 +1,67 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { accountApi } from '@/api/index'
|
||||
|
||||
const router = useRouter()
|
||||
const accounts = ref([])
|
||||
const account = ref(null)
|
||||
const loading = ref(true)
|
||||
|
||||
const typeLabel = { 1: '会员账户', 2: '押金账户', 3: '预存卡', 4: '服务卡' }
|
||||
const typeColor = { 1: '#e8718d', 2: '#5b8ff9', 3: '#06c755', 4: '#f59e0b' }
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const res = await accountApi.index()
|
||||
accounts.value = res.data?.data || []
|
||||
const list = res.data?.data || []
|
||||
account.value = list[0] || null
|
||||
} catch { } finally { loading.value = false }
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page">
|
||||
<van-nav-bar title="我的账户" left-arrow @click-left="router.back()" />
|
||||
<van-nav-bar title="账户余额" left-arrow @click-left="router.back()" />
|
||||
<div class="content">
|
||||
<van-loading v-if="loading" vertical color="#e8718d" class="center-load" />
|
||||
<van-empty v-else-if="!accounts.length" description="暂无账户信息" />
|
||||
<van-loading v-if="loading" vertical color="#f43f5e" class="center-load" />
|
||||
<van-empty v-else-if="!account" description="暂无账户信息" />
|
||||
<div v-else>
|
||||
<div v-for="acc in accounts" :key="acc.id" class="acc-card" :style="{ background: `linear-gradient(135deg, ${typeColor[acc.account_type]}dd, ${typeColor[acc.account_type]}88)` }">
|
||||
<div class="acc-type">{{ typeLabel[acc.account_type] || '账户' }}</div>
|
||||
<div class="acc-balance">¥ {{ (acc.balance || 0).toFixed(2) }}</div>
|
||||
<div class="acc-footer">
|
||||
<span>总充值: ¥{{ (acc.total_deposit || 0).toFixed(2) }}</span>
|
||||
<span>总消费: ¥{{ (acc.total_consumed || 0).toFixed(2) }}</span>
|
||||
</div>
|
||||
<!-- 现金余额 -->
|
||||
<div class="bal-card rose">
|
||||
<p class="bal-label">现金余额</p>
|
||||
<p class="bal-val">¥ {{ (account.cash_balance || 0).toFixed(2) }}</p>
|
||||
</div>
|
||||
<van-button block round plain style="margin-top:8px; color:#e8718d; border-color:#e8718d" @click="router.push('/account/transactions')">查看流水记录</van-button>
|
||||
<!-- 储值卡余额 -->
|
||||
<div class="bal-card blue">
|
||||
<p class="bal-label">储值卡余额</p>
|
||||
<p class="bal-val">¥ {{ (account.card_balance || 0).toFixed(2) }}</p>
|
||||
</div>
|
||||
<!-- 积分 -->
|
||||
<div class="bal-card amber">
|
||||
<p class="bal-label">积分</p>
|
||||
<p class="bal-val pts">{{ account.points || 0 }} <span>pts</span></p>
|
||||
</div>
|
||||
<van-button
|
||||
block round plain
|
||||
style="margin-top:12px; color:#f43f5e; border-color:#fecdd3; background:#fff8fc;"
|
||||
@click="router.push('/account/transactions')"
|
||||
>查看流水记录</van-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.page { background: #f8f0f5; min-height: 100vh; }
|
||||
.page { background: #fff8fc; min-height: 100vh; }
|
||||
.content { padding: 16px; }
|
||||
.center-load { display: flex; justify-content: center; padding: 60px 0; }
|
||||
.acc-card { border-radius: 16px; padding: 20px; margin-bottom: 12px; color: white; box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
|
||||
.acc-type { font-size: 13px; opacity: 0.9; }
|
||||
.acc-balance { font-size: 32px; font-weight: 700; margin: 8px 0; }
|
||||
.acc-footer { display: flex; gap: 16px; font-size: 12px; opacity: 0.85; }
|
||||
.bal-card {
|
||||
border-radius: 22px; padding: 22px 20px;
|
||||
margin-bottom: 12px;
|
||||
box-shadow: 0 2px 14px rgba(0,0,0,0.06);
|
||||
}
|
||||
.bal-card.rose { background: linear-gradient(135deg, #f87171, #f43f5e); }
|
||||
.bal-card.blue { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
|
||||
.bal-card.amber { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
|
||||
.bal-label { font-size: 13px; color: rgba(255,255,255,0.85); margin: 0 0 8px; }
|
||||
.bal-val { font-size: 34px; font-weight: 700; color: white; margin: 0; }
|
||||
.bal-val.pts { font-size: 30px; }
|
||||
.bal-val span { font-size: 14px; font-weight: 500; margin-left: 4px; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user