feat(merchant): 商家关联账号绑定与数据同步

- 新增 fa_merchant_member 关联账号表,主账号可绑定/解绑已注册用户
- 关联账号可切换商家端,订单、账单、开票、批量归属按主账号+关联账号聚合
- 商家工作台新增关联账号列表、绑定弹层、解除入口与个人订单统计
- 关联账号在商家入驻页显示只读企业资料与同步说明
- 我的页面区分主账号/关联商家身份;修复 merchant 角色本地存储
- 绑定/解绑仅主账号可操作,关联账号操作返回 403
- 新增 schema_phase7.sql 迁移脚本
这个提交包含在:
linda
2026-10-28 19:21:54 +08:00
父节点 7f62823334
当前提交 5a34d87eee
共有 8 个文件被更改,包括 361 次插入 和 16 次删除

20
db/schema_phase7.sql 普通文件
查看文件

@@ -0,0 +1,20 @@
-- ============================================================================
-- 优匠优服 · Phase 7 商家关联账号
-- 主账号可绑定其他已注册用户,关联账号与主账号共享商家数据:
-- 订单 / 账单 / 开票 / 批量下单归属统一按商家聚合
-- ============================================================================
SET NAMES utf8mb4;
CREATE TABLE IF NOT EXISTS `fa_merchant_member` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`merchant_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '商家ID',
`user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '关联用户ID',
`remark` varchar(50) NOT NULL DEFAULT '' COMMENT '备注/岗位',
`createtime` bigint(16) DEFAULT NULL,
`updatetime` bigint(16) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `user_id` (`user_id`),
KEY `merchant_id` (`merchant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商家关联账号';
-- 回滚:DROP TABLE IF EXISTS `fa_merchant_member`;

查看文件

@@ -6,7 +6,7 @@
</view>
<view class="status" v-if="info">
<text class="st-t">当前状态:{{ statusText }}</text>
<text class="st-t">{{ info.merchant.is_owner === false ? '关联账号' : '主账号' }} · 当前状态:{{ statusText }}</text>
<text class="st-m" v-if="info.merchant.audit_msg">审核意见:{{ info.merchant.audit_msg }}</text>
</view>
@@ -42,6 +42,7 @@
<view class="li"><text class="k">经营地址</text><text class="v">{{ info.merchant.address }}</text></view>
<view class="li"><text class="k">累计订单</text><text class="v">{{ info.merchant.order_count }} 单</text></view>
<view class="li"><text class="k">累计金额</text><text class="v">¥{{ info.merchant.total_amount }}</text></view>
<view class="hint" v-if="info.merchant.is_owner === false">当前账号为关联账号,企业资料由主账号维护;订单、账单、开票数据与主账号实时同步。</view>
<view class="go" @tap="goWorkbench">进入商家工作台 ›</view>
</view>
</view>

查看文件

@@ -23,6 +23,26 @@
</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">
@@ -49,6 +69,18 @@
</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>
@@ -62,6 +94,10 @@
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 '';
@@ -94,6 +130,53 @@
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() {
@@ -140,6 +223,27 @@
.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>

查看文件

@@ -91,7 +91,9 @@
const avatarText = computed(() => (user.value && user.value.nickname ? user.value.nickname.slice(0, 1) : '我'));
const roleText = computed(() => {
if (master.value && master.value.verify_status === 'pass') return '认证师傅';
if (merchant.value && merchant.value.verify_status === 'pass') return '认证商家';
if (merchant.value && merchant.value.verify_status === 'pass') {
return merchant.value.is_owner === false ? '关联商家' : '认证商家';
}
return '个人用户';
});
@@ -120,6 +122,9 @@
if (m.verify_status === 'reject') {
return { title: '商家资质未通过', desc: m.audit_msg || '请补充资料后重新提交', btn: '重新提交', action: () => go('/pages/merchant/apply') };
}
if (m.is_owner === false) {
return { title: m.name || '关联商家账号', desc: '已绑定企业账号,订单 / 账单 / 开票数据与主账号同步', btn: '切换商家端', action: switchToMerchant };
}
return { title: m.name || '我的企业账号', desc: '进入商家工作台:批量下单 / 账单 / 开票', btn: '切换商家端', action: switchToMerchant };
});

查看文件

@@ -92,7 +92,9 @@ class Auth extends Base
];
}
$merchant = Db::name('merchant')->where('user_id', $uid)->find();
$merchantRel = $this->merchantOf($uid);
$merchant = $merchantRel ? $merchantRel['merchant'] : null;
$merchantRole = $merchantRel ? $merchantRel['role'] : null;
$merchantInfo = null;
if ($merchant) {
$merchantInfo = [
@@ -101,6 +103,8 @@ class Auth extends Base
'verify_status' => $merchant['verify_status'],
'audit_msg' => $merchant['audit_msg'],
'settle_type' => $merchant['settle_type'],
'role' => $merchantRole,
'is_owner' => $merchantRole === 'owner',
'can_order' => $merchant['verify_status'] === 'pass',
];
}
@@ -179,7 +183,8 @@ class Auth extends Base
}
if ($role === 'merchant') {
$merchant = Db::name('merchant')->where('user_id', $this->uid())->find();
$merchantRel = $this->merchantOf($this->uid());
$merchant = $merchantRel ? $merchantRel['merchant'] : null;
if (!$merchant) {
$this->error('请先完成商家入驻', ['need_apply' => 1], 2001);
}
@@ -200,4 +205,24 @@ class Auth extends Base
$this->success('切换成功', ['role' => $role, 'redirect' => $redirect]);
}
/**
* 当前用户的商家归属:主账号 / 关联账号
* 返回 ['merchant' => 商家行, 'role' => owner|member]
*/
protected function merchantOf($uid)
{
$merchant = Db::name('merchant')->where('user_id', $uid)->find();
if ($merchant) {
return ['merchant' => $merchant, 'role' => 'owner'];
}
$bind = Db::name('merchant_member')->where('user_id', $uid)->find();
if ($bind) {
$merchant = Db::name('merchant')->where('id', (int)$bind['merchant_id'])->find();
if ($merchant) {
return ['merchant' => $merchant, 'role' => 'member'];
}
}
return null;
}
}

查看文件

@@ -43,6 +43,11 @@ class Merchant extends Base
$data['settle_type'] = 'prepay';
}
// 已被商家绑定的关联账号,企业资料由主账号维护
if (Db::name('merchant_member')->where('user_id', $this->uid())->find()) {
$this->error('当前账号已绑定商家,企业资料请由主账号维护');
}
$exist = Db::name('merchant')->where('user_id', $this->uid())->find();
if ($exist && $exist['verify_status'] === 'pass') {
$this->error('您已是认证商家,无需重复入驻');
@@ -77,13 +82,16 @@ class Merchant extends Base
return;
}
$uid = $this->uid();
$orderCount = (int)Db::name('order')->where('user_id', $uid)->where('pay_status', 1)->count();
$totalAmount = (float)Db::name('order')->where('user_id', $uid)->where('pay_status', 1)->sum('pay_amount');
$uids = $this->merchantUserIds($merchant);
$isOwner = (int)$merchant['user_id'] === $this->uid();
$orderCount = (int)Db::name('order')->where('user_id', 'in', $uids)->where('pay_status', 1)->count();
$totalAmount = (float)Db::name('order')->where('user_id', 'in', $uids)->where('pay_status', 1)->sum('pay_amount');
$invoiced = (float)Db::name('invoice')->where('merchant_id', $merchant['id'])->where('status', 'issued')->sum('amount');
$this->success('', [
'applied' => true,
'is_owner' => $isOwner,
'role' => $isOwner ? 'owner' : 'member',
'merchant' => [
'id' => (int)$merchant['id'],
'name' => $merchant['name'],
@@ -97,6 +105,10 @@ class Merchant extends Base
'settle_type' => $merchant['settle_type'],
'verify_status' => $merchant['verify_status'],
'audit_msg' => $merchant['audit_msg'],
'role' => $isOwner ? 'owner' : 'member',
'is_owner' => $isOwner,
'owner_user_id' => (int)$merchant['user_id'],
'member_count' => max(0, count($uids) - 1),
'order_count' => $orderCount,
'total_amount' => round($totalAmount, 2),
'invoiced_amount' => round($invoiced, 2),
@@ -112,6 +124,7 @@ class Merchant extends Base
public function update()
{
$merchant = $this->requireMerchant();
$this->requireMerchantOwner($merchant);
$fields = ['contact', 'mobile', 'province', 'city', 'district', 'address',
'invoice_title', 'invoice_tax_no', 'invoice_bank', 'invoice_account'];
$data = ['updatetime' => time()];
@@ -133,12 +146,12 @@ class Merchant extends Base
*/
public function bills()
{
$this->requireMerchant();
$uid = $this->uid();
$merchant = $this->requireMerchant();
$uids = $this->merchantUserIds($merchant);
$months = Db::name('order')
->field("FROM_UNIXTIME(createtime,'%Y-%m') as month, count(*) as cnt, sum(pay_amount) as amount")
->where('user_id', $uid)->where('pay_status', 1)
->where('user_id', 'in', $uids)->where('pay_status', 1)
->group('month')->order('month desc')->limit(12)->select();
foreach ($months as &$m) {
$m['amount'] = round((float)$m['amount'], 2);
@@ -147,7 +160,7 @@ class Merchant extends Base
unset($m);
$orders = Db::name('order')->field('id,order_no,service_name,pay_amount,status,createtime')
->where('user_id', $uid)->order('id desc')->limit(20)->select();
->where('user_id', 'in', $uids)->order('id desc')->limit(20)->select();
foreach ($orders as &$o) {
$o['pay_amount'] = (float)$o['pay_amount'];
$o['status_text'] = \app\common\library\OrderStatus::label($o['status']);
@@ -194,7 +207,7 @@ class Merchant extends Base
$this->error('发票类型错误');
}
$paid = (float)Db::name('order')->where('user_id', $this->uid())->where('pay_status', 1)->sum('pay_amount');
$paid = (float)Db::name('order')->where('user_id', 'in', $this->merchantUserIds($merchant))->where('pay_status', 1)->sum('pay_amount');
$used = (float)Db::name('invoice')->where('merchant_id', $merchant['id'])->where('status', 'in', ['wait', 'issued'])->sum('amount');
$available = round(max(0, $paid - $used), 2);
if ($amount > $available) {
@@ -217,6 +230,144 @@ class Merchant extends Base
$this->success('开票申请已提交,3 个工作日内开具');
}
/**
* 商家关联账号列表(主账号 + 已绑定账号)
*/
public function members()
{
$merchant = $this->requireMerchant();
$uids = $this->merchantUserIds($merchant);
$isOwner = (int)$merchant['user_id'] === $this->uid();
$users = Db::name('user')->where('id', 'in', $uids)->column('id,nickname,mobile,avatar', 'id');
$bindRows = Db::name('merchant_member')->where('merchant_id', (int)$merchant['id'])->select();
$bindMap = [];
foreach ($bindRows as $b) {
$bindMap[(int)$b['user_id']] = $b;
}
$stats = Db::name('order')->field('user_id,count(*) as cnt,sum(pay_amount) as amount')
->where('user_id', 'in', $uids)->where('pay_status', 1)
->group('user_id')->select();
$statMap = [];
foreach ($stats as $s) {
$statMap[(int)$s['user_id']] = $s;
}
$list = [];
foreach ($uids as $uid) {
$u = isset($users[$uid]) ? $users[$uid] : null;
$owner = (int)$uid === (int)$merchant['user_id'];
$bind = isset($bindMap[(int)$uid]) ? $bindMap[(int)$uid] : null;
$mobile = $u ? (string)$u['mobile'] : '';
$list[] = [
'id' => $owner ? 0 : (int)$bind['id'],
'user_id' => (int)$uid,
'nickname' => $u ? ($u['nickname'] ?: ('用户' . substr($mobile, -4))) : '用户',
'mobile' => $mobile !== '' ? substr_replace($mobile, '****', 3, 4) : '',
'avatar' => $u ? $u['avatar'] : '',
'role' => $owner ? 'owner' : 'member',
'role_text' => $owner ? '主账号' : '关联账号',
'is_owner' => $owner,
'order_count' => isset($statMap[(int)$uid]) ? (int)$statMap[(int)$uid]['cnt'] : 0,
'total_amount' => isset($statMap[(int)$uid]) ? round((float)$statMap[(int)$uid]['amount'], 2) : 0,
'bind_time_text' => (!$owner && $bind) ? date('Y-m-d H:i', (int)$bind['createtime']) : '',
];
}
// 主账号排在最前
usort($list, function ($a, $b) {
return (int)$b['is_owner'] - (int)$a['is_owner'];
});
$this->success('', [
'list' => $list,
'is_owner' => $isOwner,
'total' => count($list),
]);
}
/**
* 绑定关联账号(仅主账号)
* @ApiMethod (POST)
*/
public function bindMember()
{
$merchant = $this->requireMerchant();
$this->requireMerchantOwner($merchant);
$mobile = trim((string)$this->request->post('mobile'));
if (!preg_match('/^1\d{10}$/', $mobile)) {
$this->error('请输入正确的关联账号手机号');
}
$user = Db::name('user')->where('mobile', $mobile)->find();
if (!$user) {
$this->error('该手机号尚未注册,请对方先登录小程序');
}
if ((int)$user['id'] === $this->uid()) {
$this->error('不能绑定当前主账号');
}
if (Db::name('merchant')->where('user_id', $user['id'])->find()) {
$this->error('该账号已是商家主账号,不能重复绑定');
}
if (Db::name('merchant_member')->where('user_id', $user['id'])->find()) {
$this->error('该账号已绑定其他商家');
}
$id = Db::name('merchant_member')->insertGetId([
'merchant_id' => (int)$merchant['id'],
'user_id' => (int)$user['id'],
'remark' => '',
'createtime' => time(),
'updatetime' => time(),
]);
try {
$this->notify('user', (int)$user['id'], '已加入商家账号', '您的账号已关联到商家「' . $merchant['name'] . '」,下单、账单、开票数据将实时同步', 'system', 0);
} catch (\Exception $e) {}
$this->success('绑定成功,关联账号数据将实时同步', [
'member_id' => (int)$id,
'user_id' => (int)$user['id'],
'nickname' => $user['nickname'] ?: ('用户' . substr($mobile, -4)),
]);
}
/**
* 解除关联账号(仅主账号)
* @ApiMethod (POST)
*/
public function unbindMember()
{
$merchant = $this->requireMerchant();
$this->requireMerchantOwner($merchant);
$memberId = (int)$this->request->post('member_id');
$userId = (int)$this->request->post('user_id');
$query = Db::name('merchant_member')->where('merchant_id', (int)$merchant['id']);
if ($memberId > 0) {
$query->where('id', $memberId);
} elseif ($userId > 0) {
$query->where('user_id', $userId);
} else {
$this->error('缺少关联账号参数');
}
$row = $query->find();
if (!$row) {
$this->error('关联账号不存在或已解除');
}
if ((int)$row['user_id'] === (int)$merchant['user_id']) {
$this->error('不能解除主账号');
}
Db::name('merchant_member')->where('id', (int)$row['id'])->delete();
try {
$this->notify('user', (int)$row['user_id'], '商家关联已解除', '您已与商家「' . $merchant['name'] . '」解除关联,对方商家数据不再同步', 'system', 0);
} catch (\Exception $e) {}
$this->success('已解除关联,对方将不再同步商家数据');
}
/**
* 批量下单后绑定批次(订单本身走已验收的 /order/create)
* @ApiMethod (POST)
@@ -224,6 +375,7 @@ class Merchant extends Base
public function bindBatch()
{
$merchant = $this->requireMerchant();
$uids = $this->merchantUserIds($merchant);
// 兼容三种入参:数组 / 逗号串 / 混合
$raw = $this->request->post('order_ids');
$orderIds = [];
@@ -247,7 +399,7 @@ class Merchant extends Base
$ok = 0;
foreach ($orderIds as $oid) {
$oid = (int)$oid;
if (!Db::name('order')->where('id', $oid)->where('user_id', $this->uid())->find()) {
if (!Db::name('order')->where('id', $oid)->where('user_id', 'in', $uids)->find()) {
continue;
}
if (Db::name('merchant_order')->where('order_id', $oid)->find()) {
@@ -265,11 +417,45 @@ class Merchant extends Base
}
/**
* 当前用户商家档案
* 当前用户商家档案:主账号直接匹配,关联账号通过绑定关系匹配
*/
protected function merchantInfo()
{
return Db::name('merchant')->where('user_id', $this->uid())->find();
$merchant = Db::name('merchant')->where('user_id', $this->uid())->find();
if ($merchant) {
return $merchant;
}
$bind = Db::name('merchant_member')->where('user_id', $this->uid())->find();
if ($bind) {
return Db::name('merchant')->where('id', (int)$bind['merchant_id'])->find();
}
return null;
}
/**
* 商家数据归属用户集合:主账号 + 所有关联账号
*/
protected function merchantUserIds($merchant)
{
$ids = [(int)$merchant['user_id']];
$rows = Db::name('merchant_member')->where('merchant_id', (int)$merchant['id'])->column('user_id');
foreach ($rows as $id) {
$id = (int)$id;
if ($id > 0 && !in_array($id, $ids, true)) {
$ids[] = $id;
}
}
return $ids;
}
/**
* 仅商家主账号可执行敏感操作
*/
protected function requireMerchantOwner($merchant)
{
if ((int)$merchant['user_id'] !== $this->uid()) {
$this->error('仅主账号可执行此操作', null, 403);
}
}
/**

查看文件

@@ -76,5 +76,8 @@ export default {
merchantBills: () => get('/merchant/bills'),
merchantInvoices: () => get('/merchant/invoices'),
merchantInvoice: (data) => post('/merchant/invoice', data),
merchantMembers: () => get('/merchant/members'),
merchantBindMember: (data) => post('/merchant/bindMember', data),
merchantUnbindMember: (data) => post('/merchant/unbindMember', data),
merchantBindBatch: (data) => post('/merchant/bindBatch', data)
};

查看文件

@@ -12,7 +12,8 @@ export function getRole() {
}
export function setRole(role) {
uni.setStorageSync(ROLE_KEY, role === 'master' ? 'master' : 'user');
const valid = ['user', 'master', 'merchant'];
uni.setStorageSync(ROLE_KEY, valid.indexOf(role) > -1 ? role : 'user');
}
export function clearRole() {