- 新增 /merchant/orders,按主账号+关联账号聚合订单并支持状态筛选 - 新增企业订单页,展示订单归属账号(主账号/关联账号) - 工作台企业订单入口改到聚合列表,近期订单可点击查看 - 订单详情允许同商家账号查看,非下单账号隐藏操作按钮 - 报价选择仅下单账号可操作,防止关联账号/主账号误操作
251 行
12 KiB
Vue
251 行
12 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" v-if="info && info.is_owner" @tap="openBind">+ 绑定账号</text>
|
||
</view>
|
||
<view class="member" v-for="m in members" :key="m.user_id">
|
||
<view class="member-avatar"><text class="member-avatar-t">{{ (m.nickname || '用').slice(0, 1) }}</text></view>
|
||
<view class="member-main">
|
||
<view class="member-head">
|
||
<text class="member-name">{{ m.nickname }}</text>
|
||
<text class="member-role" :class="{ owner: m.is_owner }">{{ m.role_text }}</text>
|
||
</view>
|
||
<text class="member-meta">{{ m.mobile }} · {{ m.order_count }} 单 · ¥{{ m.total_amount }}</text>
|
||
</view>
|
||
<text class="member-unbind" v-if="info && info.is_owner && !m.is_owner" @tap.stop="unbindMember(m)">解除</text>
|
||
</view>
|
||
<view class="empty" v-if="!members.length">暂无关联账号</view>
|
||
<text class="member-tip">关联账号的下单、账单、开票数据与主账号实时同步</text>
|
||
</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" @tap="goOrder(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 class="mask" v-if="showBind" @tap="showBind = false">
|
||
<view class="sheet" @tap.stop>
|
||
<view class="sheet-head">
|
||
<text class="sheet-title">绑定关联账号</text>
|
||
<text class="sheet-close" @tap="showBind = false">关闭</text>
|
||
</view>
|
||
<text class="sheet-tip">输入对方已注册手机号。绑定后,对方可进入商家工作台,下单、账单、开票数据与主账号实时同步。</text>
|
||
<input class="sheet-input" v-model="bindMobile" type="number" maxlength="11" placeholder="请输入关联账号手机号" />
|
||
<view class="sheet-btn" :class="{ disabled: binding }" @tap="doBind">{{ binding ? '绑定中...' : '确认绑定' }}</view>
|
||
</view>
|
||
</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 members = ref([]);
|
||
const showBind = ref(false);
|
||
const bindMobile = ref('');
|
||
const binding = ref(false);
|
||
|
||
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/merchant/orders') },
|
||
{ 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: () => go('/pages/address/list') },
|
||
{ key: 'service', name: '联系客服', icon: '服', bg: '#EAF6FF', color: '#2A8FD8', action: () => uni.makePhoneCall({ phoneNumber: '4000000000' }) }
|
||
];
|
||
|
||
function go(url) { uni.navigateTo({ url: url }); }
|
||
function goOrder(id) { uni.navigateTo({ url: '/pages/order/detail?id=' + id }); }
|
||
|
||
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) {}
|
||
await loadMembers();
|
||
}
|
||
|
||
async function loadMembers() {
|
||
try {
|
||
const res = await api.merchantMembers();
|
||
members.value = res.list || [];
|
||
} catch (e) {}
|
||
}
|
||
|
||
function openBind() {
|
||
showBind.value = true;
|
||
bindMobile.value = '';
|
||
}
|
||
|
||
async function doBind() {
|
||
if (binding.value) return;
|
||
const mobile = (bindMobile.value || '').trim();
|
||
if (!/^1\d{10}$/.test(mobile)) {
|
||
uni.showToast({ title: '请输入正确的手机号', icon: 'none' });
|
||
return;
|
||
}
|
||
binding.value = true;
|
||
try {
|
||
await api.merchantBindMember({ mobile: mobile });
|
||
showBind.value = false;
|
||
uni.showToast({ title: '绑定成功' });
|
||
await load();
|
||
} catch (e) {
|
||
} finally {
|
||
binding.value = false;
|
||
}
|
||
}
|
||
|
||
function unbindMember(m) {
|
||
uni.showModal({
|
||
title: '解除关联',
|
||
content: `确认解除 ${m.nickname}(${m.mobile})?解除后对方将无法查看商家数据`,
|
||
success: async (r) => {
|
||
if (!r.confirm) return;
|
||
try {
|
||
await api.merchantUnbindMember({ member_id: m.id });
|
||
uni.showToast({ title: '已解除关联' });
|
||
await load();
|
||
} 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; }
|
||
.member { display: flex; align-items: center; padding: 16rpx 0; border-bottom: 1rpx solid #F4F4F4; }
|
||
.member:last-of-type { border-bottom: none; }
|
||
.member-avatar { width: 64rpx; height: 64rpx; border-radius: 50%; flex-shrink: 0; background: #FFF1E3; display: flex; align-items: center; justify-content: center; }
|
||
.member-avatar-t { font-size: 26rpx; font-weight: 700; color: #E88A2C; }
|
||
.member-main { flex: 1; min-width: 0; margin-left: 14rpx; display: flex; flex-direction: column; }
|
||
.member-head { display: flex; align-items: center; }
|
||
.member-name { font-size: 27rpx; font-weight: 600; color: #222; }
|
||
.member-role { margin-left: 10rpx; padding: 0 10rpx; line-height: 30rpx; border-radius: 8rpx; background: #F0F0F0; color: #888; font-size: 18rpx; }
|
||
.member-role.owner { background: #FFF1E0; color: #E07A2E; }
|
||
.member-meta { margin-top: 4rpx; font-size: 20rpx; color: #9A9A9A; }
|
||
.member-unbind { flex-shrink: 0; margin-left: 12rpx; padding: 0 16rpx; line-height: 44rpx; border-radius: 22rpx; background: #FFF0F0; color: #E8331B; font-size: 20rpx; }
|
||
.member-tip { display: block; margin-top: 12rpx; font-size: 20rpx; color: #B5B5B5; line-height: 30rpx; }
|
||
.mask { position: fixed; left: 0; right: 0; top: 0; bottom: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; z-index: 50; }
|
||
.sheet { width: 100%; background: #fff; border-radius: 28rpx 28rpx 0 0; padding: 26rpx 28rpx; padding-bottom: calc(26rpx + env(safe-area-inset-bottom)); }
|
||
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
|
||
.sheet-title { font-size: 32rpx; font-weight: 700; color: #1F1F1F; }
|
||
.sheet-close { font-size: 24rpx; color: #9A9A9A; }
|
||
.sheet-tip { display: block; margin: 14rpx 0 18rpx; font-size: 22rpx; color: #9A9A9A; line-height: 34rpx; }
|
||
.sheet-input { height: 84rpx; padding: 0 22rpx; background: #F7F7F7; border-radius: 14rpx; font-size: 28rpx; color: #222; }
|
||
.sheet-btn { height: 88rpx; margin-top: 20rpx; display: flex; align-items: center; justify-content: center; border-radius: 44rpx; color: #fff; font-size: 30rpx; font-weight: 600; background: linear-gradient(135deg,#FFA93F 0%,#F0710D 100%); }
|
||
.sheet-btn.disabled { opacity: .7; }
|
||
.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>
|
||
|