微信登录修复: - 根因:manifest.json 的 mp-weixin.appid 为空 → 开发者工具用测试号,code 与服务端 appid 不匹配 - 修复:填入 wx40ca4b02d4d1cb58 - WxLogin 增加错误码语义映射(40029 appid 不一致 / 40125 secret 错 / 45011 频繁 / 40226 风控) - 登录页新增手机号登录兜底通道(微信不可用时业务不被卡住) 商家(企业账号): - 新表 fa_merchant / fa_merchant_order / fa_invoice(纯新增,DB 40→45 表) - Merchant 控制器:apply/info/update/bills/invoices/invoice/bindBatch 入驻含企业信息+营业执照+开票信息+结算方式(预付/月结) 账单按月汇总、开票额度按已付-已开票校验、批量下单按批次归属 - Auth::switchRole 支持 merchant(2001/2002/2003 语义码 + redirect) - Auth::profile 增加 is_merchant / merchant 前端: - 登录页角色扩为 业主/师傅/商家 三类 - pages/merchant/apply 企业入驻;workbench 商家工作台(经营数据+按月账单+近期订单+六宫格) - pages/merchant/batch 批量下单(多地址×多数量)→ 逐单建单支付 → 绑定批次 - pages/merchant/invoice 开票申请与记录 - pages/mine 增加商家入驻/切换商家端入口;角色徽章三态 验证:163 项断言全通过(page_flow 47 + e2e 65 + phase2 27 + phase3 24)
146 行
7.4 KiB
Vue
146 行
7.4 KiB
Vue
<template>
|
||
<view class="page">
|
||
<view class="header">
|
||
<view class="deco"></view>
|
||
<view class="h-top">
|
||
<view class="h-l">
|
||
<text class="h-name">{{ info ? info.name : '商家' }}</text>
|
||
<text class="h-meta">{{ info ? ('结算方式:' + (info.settle_type === 'monthly' ? '月结' : '预付')) : '加载中...' }}</text>
|
||
</view>
|
||
<view class="h-badge">{{ verifyText }}</view>
|
||
</view>
|
||
<view class="stats">
|
||
<view class="stat"><text class="stat-n">{{ info ? info.order_count : 0 }}</text><text class="stat-l">累计订单</text></view>
|
||
<view class="stat"><text class="stat-n">{{ info ? info.total_amount : 0 }}</text><text class="stat-l">累计金额</text></view>
|
||
<view class="stat"><text class="stat-n">{{ info ? info.invoiceable : 0 }}</text><text class="stat-l">可开票</text></view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="grid">
|
||
<view class="gi" v-for="g in entries" :key="g.key" @tap="g.action">
|
||
<view class="gi-icon" :style="{ background: g.bg }"><text class="gi-t" :style="{ color: g.color }">{{ g.icon }}</text></view>
|
||
<text class="gi-name">{{ g.name }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="card">
|
||
<view class="card-head"><text class="card-title">按月账单</text><text class="card-more" @tap="load">刷新</text></view>
|
||
<view class="m-row" v-for="(m, i) in months" :key="i">
|
||
<text class="m-month">{{ m.month }}</text>
|
||
<text class="m-cnt">{{ m.cnt }} 单</text>
|
||
<text class="m-amt">¥{{ m.amount }}</text>
|
||
</view>
|
||
<view class="empty" v-if="!months.length">暂无账单</view>
|
||
</view>
|
||
|
||
<view class="card">
|
||
<view class="card-head"><text class="card-title">近期订单</text><text class="card-more" @tap="go('/pages/order/list')">全部 ›</text></view>
|
||
<view class="o-row" v-for="o in orders" :key="o.id">
|
||
<view class="o-l">
|
||
<text class="o-name">{{ o.service_name }}</text>
|
||
<text class="o-no">{{ o.order_no }} · {{ o.time_text }}</text>
|
||
</view>
|
||
<view class="o-r">
|
||
<text class="o-amt">¥{{ o.pay_amount }}</text>
|
||
<text class="o-status">{{ o.status_text }}</text>
|
||
</view>
|
||
</view>
|
||
<view class="empty" v-if="!orders.length">暂无订单</view>
|
||
</view>
|
||
|
||
<view class="back" @tap="backToUser">切换到业主身份</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref, computed } from 'vue';
|
||
import { onShow } from '@dcloudio/uni-app';
|
||
import api from '@/utils/api.js';
|
||
import { isLogin, toLogin } from '@/utils/request.js';
|
||
import { setRole } from '@/utils/role.js';
|
||
|
||
const info = ref(null);
|
||
const months = ref([]);
|
||
const orders = ref([]);
|
||
|
||
const verifyText = computed(() => {
|
||
if (!info.value) return '';
|
||
return { pending: '审核中', pass: '已认证', reject: '未通过' }[info.value.verify_status] || '';
|
||
});
|
||
|
||
const entries = [
|
||
{ key: 'batch', name: '批量下单', icon: '批', bg: '#FFF1E0', color: '#E07A2E', action: () => go('/pages/merchant/batch') },
|
||
{ key: 'orders', name: '企业订单', icon: '单', bg: '#EAF2FF', color: '#4A7CFF', action: () => go('/pages/order/list') },
|
||
{ key: 'invoice', name: '开具发票', icon: '票', bg: '#E8F7EE', color: '#2FA84F', action: () => go('/pages/merchant/invoice') },
|
||
{ key: 'profile', name: '企业资料', icon: '档', bg: '#F0EBFF', color: '#7A5AF8', action: () => go('/pages/merchant/apply') },
|
||
{ key: 'address', name: '服务地址', icon: '址', bg: '#FFF0F0', color: '#E8331B', action: () => uni.showToast({ title: '地址管理开发中', icon: 'none' }) },
|
||
{ key: 'service', name: '联系客服', icon: '服', bg: '#EAF6FF', color: '#2A8FD8', action: () => uni.makePhoneCall({ phoneNumber: '4000000000' }) }
|
||
];
|
||
|
||
function go(url) { uni.navigateTo({ url: url }); }
|
||
|
||
async function load() {
|
||
if (!isLogin()) { toLogin(); return; }
|
||
try {
|
||
const res = await api.merchantInfo();
|
||
if (!res.applied || res.merchant.verify_status !== 'pass') {
|
||
uni.redirectTo({ url: '/pages/merchant/apply' });
|
||
return;
|
||
}
|
||
info.value = res.merchant;
|
||
} catch (e) { return; }
|
||
try {
|
||
const b = await api.merchantBills();
|
||
months.value = b.months || [];
|
||
orders.value = b.orders || [];
|
||
} catch (e) {}
|
||
}
|
||
|
||
function backToUser() {
|
||
api.switchRole({ role: 'user' }).then((res) => {
|
||
setRole('user');
|
||
uni.reLaunch({ url: res.redirect || '/YJYF/YJYF' });
|
||
}).catch(() => {});
|
||
}
|
||
|
||
onShow(() => load());
|
||
</script>
|
||
|
||
<style scoped>
|
||
.page { min-height: 100vh; background: #F5F6F8; padding-bottom: 60rpx; }
|
||
.header { position: relative; padding: 34rpx 30rpx 26rpx; overflow: hidden; background: linear-gradient(160deg,#FFB85C 0%,#F98D25 55%,#ED6F0E 100%); }
|
||
.deco { position: absolute; width: 320rpx; height: 320rpx; right: -120rpx; top: -130rpx; border-radius: 50%; background: rgba(255,255,255,.13); }
|
||
.h-top { position: relative; display: flex; align-items: center; justify-content: space-between; }
|
||
.h-l { flex: 1; min-width: 0; display: flex; flex-direction: column; }
|
||
.h-name { font-size: 36rpx; font-weight: 700; color: #fff; }
|
||
.h-meta { margin-top: 8rpx; font-size: 22rpx; color: rgba(255,255,255,.9); }
|
||
.h-badge { flex-shrink: 0; padding: 0 22rpx; line-height: 52rpx; border-radius: 26rpx; background: #fff; color: #E36B0C; font-size: 22rpx; font-weight: 700; }
|
||
.stats { position: relative; display: flex; margin-top: 26rpx; padding-top: 22rpx; border-top: 1rpx solid rgba(255,255,255,.25); }
|
||
.stat { flex: 1; display: flex; flex-direction: column; align-items: center; }
|
||
.stat-n { font-size: 34rpx; font-weight: 700; color: #fff; }
|
||
.stat-l { margin-top: 4rpx; font-size: 20rpx; color: rgba(255,255,255,.88); }
|
||
.grid { display: flex; flex-wrap: wrap; margin: 22rpx 28rpx 0; padding: 16rpx 0; background: #fff; border-radius: 22rpx; box-shadow: 0 6rpx 20rpx rgba(240,129,31,.06); }
|
||
.gi { width: 33.33%; display: flex; flex-direction: column; align-items: center; padding: 18rpx 0; }
|
||
.gi-icon { width: 84rpx; height: 84rpx; border-radius: 24rpx; display: flex; align-items: center; justify-content: center; }
|
||
.gi-t { font-size: 30rpx; font-weight: 700; }
|
||
.gi-name { margin-top: 12rpx; font-size: 22rpx; color: #333; }
|
||
.card { margin: 22rpx 28rpx 0; padding: 24rpx; background: #fff; border-radius: 22rpx; box-shadow: 0 6rpx 20rpx rgba(240,129,31,.06); }
|
||
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8rpx; }
|
||
.card-title { font-size: 28rpx; font-weight: 700; color: #1F1F1F; }
|
||
.card-more { font-size: 22rpx; color: #9A9A9A; }
|
||
.m-row { display: flex; align-items: center; padding: 16rpx 0; border-bottom: 1rpx solid #F4F4F4; }
|
||
.m-month { flex: 1; font-size: 26rpx; color: #333; }
|
||
.m-cnt { width: 120rpx; text-align: right; font-size: 22rpx; color: #9A9A9A; }
|
||
.m-amt { width: 160rpx; text-align: right; font-size: 28rpx; font-weight: 700; color: #F0710D; }
|
||
.o-row { display: flex; align-items: center; justify-content: space-between; padding: 16rpx 0; border-bottom: 1rpx solid #F4F4F4; }
|
||
.o-l { flex: 1; min-width: 0; display: flex; flex-direction: column; }
|
||
.o-name { font-size: 26rpx; color: #333; }
|
||
.o-no { margin-top: 4rpx; font-size: 20rpx; color: #B5B5B5; }
|
||
.o-r { display: flex; flex-direction: column; align-items: flex-end; }
|
||
.o-amt { font-size: 28rpx; font-weight: 700; color: #F0710D; }
|
||
.o-status { margin-top: 4rpx; font-size: 20rpx; color: #9A9A9A; }
|
||
.empty { padding: 40rpx 0; text-align: center; font-size: 24rpx; color: #9A9A9A; }
|
||
.back { margin: 26rpx 28rpx 0; height: 92rpx; display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 46rpx; font-size: 28rpx; color: #F0710D; font-weight: 600; }
|
||
</style>
|
||
|