feat: 纯打手端入口,无邀请码自动绑定默认管事
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
4b064c6303
commit
283133473a
10 files changed
+168
-30
No files matched your search
@@ -3,6 +3,7 @@ import GoEasy from './static/lib/goeasy-2.13.24.esm.min';
|
||||
const ChatCore = require('./utils/chat-core');
|
||||
import { ensurePhoneAuth } from './utils/phone-auth';
|
||||
import { getPrimaryRole, lockPrimaryRole, migrateLegacyCenterRole, PRIMARY_DEFAULT_PAGES } from './utils/primary-role';
|
||||
import { isFighterOnly, resolveFighterOnlyLaunchUrl } from './utils/fighter-only';
|
||||
import { setClubId, getConfiguredClubId, buildClubHeaders, getClubId } from './utils/club-context';
|
||||
import { CLUB_ID, WX_APP_ID } from './config/club-config';
|
||||
import { applyMiniappAssetsFromConfig, warmupPindaoConfig } from './utils/miniapp-icons.js';
|
||||
@@ -201,7 +202,7 @@ App({
|
||||
}
|
||||
|
||||
migrateLegacyCenterRole(this);
|
||||
const savedRole = getPrimaryRole(this);
|
||||
const savedRole = isFighterOnly() ? 'dashou' : getPrimaryRole(this);
|
||||
lockPrimaryRole(savedRole, this);
|
||||
|
||||
// ②b 冷启动:有 token 时先问后端是否需要手机号认证
|
||||
@@ -215,8 +216,11 @@ App({
|
||||
refreshDashouMembership(this).catch(() => {});
|
||||
}
|
||||
|
||||
const targetPage = roleDefaultPage[savedRole] || '/pages/index/index';
|
||||
if (savedRole !== 'normal') {
|
||||
// 纯打手端:始终 reLaunch 到抢单池或注册页;不再停在点单商城
|
||||
const targetPage = isFighterOnly()
|
||||
? resolveFighterOnlyLaunchUrl()
|
||||
: (roleDefaultPage[savedRole] || '/pages/index/index');
|
||||
if (isFighterOnly() || savedRole !== 'normal') {
|
||||
setTimeout(() => {
|
||||
wx.reLaunch({ url: targetPage });
|
||||
}, 0);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index",
|
||||
"pages/category/category",
|
||||
"pages/messages/messages",
|
||||
"pages/mine/mine",
|
||||
"pages/accept-order/accept-order",
|
||||
"pages/team-hall/team-hall",
|
||||
"pages/fighter-orders/fighter-orders",
|
||||
"pages/fighter/fighter",
|
||||
"pages/messages/messages",
|
||||
"pages/index/index",
|
||||
"pages/category/category",
|
||||
"pages/mine/mine",
|
||||
"pages/merchant-home/merchant-home",
|
||||
"pages/merchant-orders/merchant-orders",
|
||||
"pages/merchant/merchant",
|
||||
|
||||
@@ -12,6 +12,7 @@ import { fetchGonggaoLunbo, isGonggaoCacheValid, getCachedGonggaoLunbo } from '.
|
||||
import { checkPenaltyForGrab } from '../../utils/grab-order-gate.js';
|
||||
import { ensureRoleAgreement } from '../../utils/role-agreement-gate.js';
|
||||
import { fetchMyZhidingOrders, submitZhidingResponse, processZhidingList, filterZhidingBannerList, ZHIDING_HF_MAP } from '../../utils/zhiding-order.js';
|
||||
import { isFighterOnly, FIGHTER_MINE, isDashouCertified } from '../../utils/fighter-only.js';
|
||||
|
||||
/** 抢单池轮播 page_key(勿与点单页 order_pool 混用) */
|
||||
const ACCEPT_ORDER_PAGE_KEY = 'accept_order';
|
||||
@@ -156,6 +157,12 @@ Page({
|
||||
},
|
||||
|
||||
async onShow() {
|
||||
// 纯打手端:未认证时引导到「我的」完成自动注册,不在抢单池空转
|
||||
if (isFighterOnly() && !isDashouCertified()) {
|
||||
wx.reLaunch({ url: FIGHTER_MINE });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!app.globalData._dashouPhoneChecked) {
|
||||
const phoneOk = await ensurePhoneAuth({ redirect: true, role: 'dashou' });
|
||||
if (!phoneOk) return;
|
||||
|
||||
@@ -18,8 +18,10 @@ import {
|
||||
} from '../../utils/miniapp-icons.js'
|
||||
import { getDefaultAvatarUrl } from '../../utils/avatar.js'
|
||||
import { ensureRoleAgreement } from '../../utils/role-agreement-gate.js'
|
||||
import { isFighterOnly, FIGHTER_ONLY_DEFAULT_INVITE, FIGHTER_HOME } from '../../utils/fighter-only.js'
|
||||
import { ensureLogin } from '../../utils/login.js'
|
||||
|
||||
const PLATFORM_INVITE_CODE = '0000008RffVgKHMj7kQC'
|
||||
const PLATFORM_INVITE_CODE = FIGHTER_ONLY_DEFAULT_INVITE || '0000008VfJKPu4Spmcjt'
|
||||
const app = getApp()
|
||||
|
||||
Page(createPage({
|
||||
@@ -174,6 +176,11 @@ Page(createPage({
|
||||
this.handleInviteCodeWithLoginCheck(inviteCode);
|
||||
}, 500);
|
||||
}
|
||||
} else if (isFighterOnly()) {
|
||||
// 无邀请码进入:自动用硬编码管事邀请码注册(有邀请链路不受影响)
|
||||
setTimeout(() => {
|
||||
this.tryAutoRegisterDefaultInvite();
|
||||
}, 600);
|
||||
}
|
||||
this.checkColdStartPopup('dashouduan');
|
||||
this.syncConfiguredAssets();
|
||||
@@ -269,6 +276,10 @@ Page(createPage({
|
||||
this.handleInviteCodeWithLoginCheck(options.inviteCode);
|
||||
}, 300);
|
||||
}
|
||||
} else if (isFighterOnly() && !isCenterPageActive(this, 'isDashou', 'dashoustatus')) {
|
||||
setTimeout(() => {
|
||||
this.tryAutoRegisterDefaultInvite();
|
||||
}, 400);
|
||||
}
|
||||
if (app.startImWhenReady) app.startImWhenReady();
|
||||
},
|
||||
@@ -397,8 +408,11 @@ Page(createPage({
|
||||
push('goToAuth', '接单员认证', img.iconDashouAuth, { authType: 'dashou' });
|
||||
}
|
||||
|
||||
push('switchToNormal', '返回点单端', img.iconSwitch);
|
||||
push('clearCache', '退出登录', img.iconClear);
|
||||
if (!isFighterOnly()) {
|
||||
push('switchToNormal', '返回点单端', img.iconSwitch);
|
||||
}
|
||||
push('handleWechatLogin', '一键登录', img.iconRefresh);
|
||||
push('clearCache', '清除缓存/退出', img.iconClear);
|
||||
|
||||
this.setData({ moreFuncList: list });
|
||||
},
|
||||
@@ -913,12 +927,15 @@ Page(createPage({
|
||||
const that = this;
|
||||
const token = wx.getStorageSync('token');
|
||||
const uid = wx.getStorageSync('uid');
|
||||
if (inviteCode) {
|
||||
this.setData({ inviteCode });
|
||||
}
|
||||
if (!token || !uid) {
|
||||
this.loginAndRegisterWithInviteCode(inviteCode);
|
||||
} else {
|
||||
if (!that.data.isDashou) {
|
||||
wx.showLoading({ title: '自动注册中...', mask: true });
|
||||
that.setData({ isAutoRegistering: true });
|
||||
that.setData({ isAutoRegistering: true, inviteCode: inviteCode || that.data.inviteCode });
|
||||
that.onRegister();
|
||||
} else {
|
||||
wx.showToast({ title: '您已是接单员', icon: 'success', duration: 2000 });
|
||||
@@ -926,6 +943,41 @@ Page(createPage({
|
||||
}
|
||||
},
|
||||
|
||||
/** 纯打手端:无邀请码时自动绑定默认管事 */
|
||||
tryAutoRegisterDefaultInvite() {
|
||||
if (!isFighterOnly()) return;
|
||||
if (this.data.isDashou || this.data.isGuanshi || this.data.isZuzhang || this.data.isKaoheguan) return;
|
||||
if (this.data.isAutoRegistering) return;
|
||||
if (Number(wx.getStorageSync('dashoustatus')) === 1) return;
|
||||
const code = PLATFORM_INVITE_CODE;
|
||||
this.setData({ inviteCode: code, isAutoRegistering: true });
|
||||
this.handleInviteCodeWithLoginCheck(code);
|
||||
},
|
||||
|
||||
handleWechatLogin() {
|
||||
ensureLogin({ silent: false, page: this })
|
||||
.then(() => {
|
||||
this.checkDashouStatus();
|
||||
this.checkRoleStatuses();
|
||||
if (!this.data.isDashou && isFighterOnly()) {
|
||||
this.tryAutoRegisterDefaultInvite();
|
||||
} else if (this.data.isDashou) {
|
||||
this.refreshAllInfo(false);
|
||||
}
|
||||
wx.showToast({ title: '登录成功', icon: 'success' });
|
||||
})
|
||||
.catch(() => {
|
||||
wx.showToast({ title: '登录失败', icon: 'none' });
|
||||
});
|
||||
},
|
||||
|
||||
_goFighterHomeAfterRegister() {
|
||||
if (!isFighterOnly()) return;
|
||||
setTimeout(() => {
|
||||
wx.reLaunch({ url: FIGHTER_HOME });
|
||||
}, 800);
|
||||
},
|
||||
|
||||
loginAndRegisterWithInviteCode(inviteCode) {
|
||||
const that = this;
|
||||
wx.showLoading({ title: '登录注册中...', mask: true });
|
||||
@@ -941,7 +993,7 @@ Page(createPage({
|
||||
fail: () => {
|
||||
wx.hideLoading();
|
||||
console.error('微信登录失败');
|
||||
wx.reLaunch({ url: '/pages/mine/mine' });
|
||||
wx.reLaunch({ url: isFighterOnly() ? '/pages/fighter/fighter' : '/pages/mine/mine' });
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -1009,6 +1061,7 @@ Page(createPage({
|
||||
lockPrimaryRole('dashou');
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: '登录注册成功!', icon: 'success', duration: 2000 });
|
||||
that._goFighterHomeAfterRegister();
|
||||
} else {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: (res.data && res.data.msg) || '登录注册失败', icon: 'none' });
|
||||
@@ -1176,6 +1229,7 @@ Page(createPage({
|
||||
lockPrimaryRole('dashou');
|
||||
wx.showToast({ title: '注册成功!', icon: 'success', duration: 2000 });
|
||||
this._updateTotalAssets();
|
||||
this._goFighterHomeAfterRegister();
|
||||
} else {
|
||||
this.setData({ isLoading: false, isAutoRegistering: false });
|
||||
wx.showToast({ title: (res.data && res.data.message) || '注册失败', icon: 'error', duration: 2000 });
|
||||
@@ -1472,7 +1526,9 @@ Page(createPage({
|
||||
const that = this;
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '使用此功能后,您将不属于任何管事,确认注册吗?',
|
||||
content: isFighterOnly()
|
||||
? '将使用默认管事邀请码完成注册,确认继续吗?'
|
||||
: '使用此功能后,您将不属于任何管事,确认注册吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
that.setData({ inviteCode: PLATFORM_INVITE_CODE });
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
</view>
|
||||
<view class="unreg-area">
|
||||
<view class="panel shadow unreg-card">
|
||||
<text class="unreg-title">接单员认证</text>
|
||||
<input class="unreg-input" type="text" placeholder="输入邀请码" maxlength="100" value="{{inviteCode}}" bindinput="onInviteCodeInput" placeholder-class="ph" />
|
||||
<text class="unreg-title">{{isAutoRegistering ? '正在自动注册...' : '接单员认证'}}</text>
|
||||
<input class="unreg-input" type="text" placeholder="输入邀请码(有邀请请填写)" maxlength="100" value="{{inviteCode}}" bindinput="onInviteCodeInput" placeholder-class="ph" />
|
||||
<view class="btn-bg unreg-btn" bindtap="onRegister"><text class="unreg-btn-text">立即注册</text></view>
|
||||
<view class="unreg-btn-secondary" bindtap="quickRegisterAsPlatform"><text>平台直签注册</text></view>
|
||||
<view class="unreg-link" bindtap="switchToNormal"><text>返回点单端</text></view>
|
||||
<view class="unreg-link" bindtap="clearCache"><text>退出登录</text></view>
|
||||
<view class="unreg-btn-secondary" bindtap="handleWechatLogin"><text>一键登录</text></view>
|
||||
<view class="unreg-btn-secondary" bindtap="quickRegisterAsPlatform"><text>默认管事注册</text></view>
|
||||
<view class="unreg-link" bindtap="clearCache"><text>清除缓存 / 退出</text></view>
|
||||
</view>
|
||||
</view>
|
||||
<tab-bar/>
|
||||
|
||||
+8
-4
@@ -1,6 +1,7 @@
|
||||
// tab-bar/index.js — 三端固定,无身份切换
|
||||
// tab-bar/index.js — 纯打手端固定 Tab(点单/商家配置保留但不启用)
|
||||
const app = getApp();
|
||||
import { getTabRole } from '../utils/primary-role.js';
|
||||
import { isFighterOnly } from '../utils/fighter-only.js';
|
||||
|
||||
const roleCfg = {
|
||||
normal: {
|
||||
@@ -118,7 +119,10 @@ Component({
|
||||
refresh() {
|
||||
const token = wx.getStorageSync('token');
|
||||
let role = getTabRole(app);
|
||||
if (!token) {
|
||||
// 纯打手端:无 token 也固定打手 Tab,绝不回落点单端
|
||||
if (isFighterOnly()) {
|
||||
role = 'dashou';
|
||||
} else if (!token) {
|
||||
role = 'normal';
|
||||
}
|
||||
app.globalData.currentRole = role;
|
||||
@@ -126,8 +130,8 @@ Component({
|
||||
|
||||
let cfg = roleCfg[role];
|
||||
if (!cfg) {
|
||||
cfg = roleCfg.normal;
|
||||
role = 'normal';
|
||||
cfg = isFighterOnly() ? roleCfg.dashou : roleCfg.normal;
|
||||
role = isFighterOnly() ? 'dashou' : 'normal';
|
||||
}
|
||||
|
||||
const list = cfg.tabList.map((v, i) => ({ ...v, index: i }));
|
||||
|
||||
+19
-2
@@ -134,17 +134,34 @@ const BASE_METHODS = {
|
||||
|
||||
// ---------- 清除缓存 ----------
|
||||
clearCache() {
|
||||
const fighterOnly = (() => {
|
||||
try {
|
||||
return require('./fighter-only.js').isFighterOnly();
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
wx.showModal({
|
||||
title: '清除缓存',
|
||||
content: '将清除所有登录与身份数据,并回到点单端,确定继续?',
|
||||
content: fighterOnly
|
||||
? '将清除所有登录与身份数据,并回到打手端「我的」,确定继续?'
|
||||
: '将清除所有登录与身份数据,并回到点单端,确定继续?',
|
||||
confirmText: '确定',
|
||||
cancelText: '取消',
|
||||
success: (r) => { if (r.confirm) clearCacheAndEnterNormal(this); },
|
||||
});
|
||||
},
|
||||
|
||||
// ---------- 返回点单端 ----------
|
||||
// ---------- 返回点单端(纯打手端禁用) ----------
|
||||
switchToNormal() {
|
||||
try {
|
||||
const { isFighterOnly, FIGHTER_MINE } = require('./fighter-only.js');
|
||||
if (isFighterOnly()) {
|
||||
wx.showToast({ title: '当前为打手端小程序', icon: 'none' });
|
||||
wx.reLaunch({ url: FIGHTER_MINE });
|
||||
return;
|
||||
}
|
||||
} catch (e) {}
|
||||
lockPrimaryRole('normal');
|
||||
wx.reLaunch({ url: '/pages/mine/mine' });
|
||||
},
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 纯打手端开关:点单端页面保留但不作为入口/回落目标。
|
||||
* 回退:git checkout backup/before-fighter-only-20260727
|
||||
* 或:git reset --hard backup-fighter-only-20260727
|
||||
*/
|
||||
export const FIGHTER_ONLY = true
|
||||
|
||||
/** 无邀请码搜索进入时,自动注册绑定的管事邀请码(前端硬编码) */
|
||||
export const FIGHTER_ONLY_DEFAULT_INVITE = '0000008VfJKPu4Spmcjt'
|
||||
|
||||
/** 已认证打手冷启动默认页 */
|
||||
export const FIGHTER_HOME = '/pages/accept-order/accept-order'
|
||||
|
||||
/** 未登录 / 未认证 / 清缓存后的落地页(注册 + 我的) */
|
||||
export const FIGHTER_MINE = '/pages/fighter/fighter'
|
||||
|
||||
export function isFighterOnly() {
|
||||
return FIGHTER_ONLY === true
|
||||
}
|
||||
|
||||
export function isDashouCertified() {
|
||||
return Number(wx.getStorageSync('dashoustatus')) === 1
|
||||
}
|
||||
|
||||
/** 冷启动应去的页面 */
|
||||
export function resolveFighterOnlyLaunchUrl() {
|
||||
const token = wx.getStorageSync('token')
|
||||
if (token && isDashouCertified()) {
|
||||
return FIGHTER_HOME
|
||||
}
|
||||
return FIGHTER_MINE
|
||||
}
|
||||
+10
-4
@@ -2,6 +2,7 @@
|
||||
|
||||
import { isStaffMode } from './staff-api.js';
|
||||
import { ensurePhoneAuth } from './phone-auth.js';
|
||||
import { isFighterOnly, FIGHTER_HOME, FIGHTER_MINE } from './fighter-only.js';
|
||||
|
||||
const VALID = ['normal', 'dashou', 'shangjia'];
|
||||
const LEGACY_CENTER_ROLES = ['guanshi', 'zuzhang', 'kaoheguan'];
|
||||
@@ -34,6 +35,10 @@ export function isRoleStatusActive(status) {
|
||||
/** 读取主端(兼容旧 currentRole / 管事组长落地页) */
|
||||
export function getPrimaryRole(app) {
|
||||
app = app || getApp();
|
||||
// 纯打手端:始终锁定 dashou,不进入点单/商家主端
|
||||
if (isFighterOnly()) {
|
||||
return 'dashou';
|
||||
}
|
||||
const stored = wx.getStorageSync('primaryRole');
|
||||
if (VALID.includes(stored)) {
|
||||
return stored;
|
||||
@@ -83,13 +88,14 @@ export function getTabRole(app) {
|
||||
export function clearPrimaryRole(app) {
|
||||
app = app || getApp();
|
||||
wx.removeStorageSync('primaryRole');
|
||||
lockPrimaryRole('normal', app);
|
||||
// 纯打手端清缓存后仍锁定打手端,避免回落点单
|
||||
lockPrimaryRole(isFighterOnly() ? 'dashou' : 'normal', app);
|
||||
}
|
||||
|
||||
export const PRIMARY_DEFAULT_PAGES = {
|
||||
normal: '/pages/mine/mine',
|
||||
dashou: '/pages/accept-order/accept-order',
|
||||
shangjia: '/pages/merchant-home/merchant-home',
|
||||
normal: isFighterOnly() ? FIGHTER_MINE : '/pages/mine/mine',
|
||||
dashou: FIGHTER_HOME,
|
||||
shangjia: isFighterOnly() ? FIGHTER_HOME : '/pages/merchant-home/merchant-home',
|
||||
};
|
||||
|
||||
/** 锁定主端并跳转到该端默认首页,同时建立 IM 长连接 */
|
||||
|
||||
+14
-2
@@ -142,9 +142,16 @@ export function syncProfileFields(data) {
|
||||
});
|
||||
}
|
||||
|
||||
/** 清除缓存:清空登录与身份,回到点单端「我的」 */
|
||||
/** 清除缓存:清空登录与身份;纯打手端回到打手「我的」,否则点单「我的」 */
|
||||
export function clearCacheAndEnterNormal(page) {
|
||||
resetGuestSession(page, { skipPageReset: true });
|
||||
try {
|
||||
const { isFighterOnly, FIGHTER_MINE } = require('./fighter-only.js');
|
||||
if (isFighterOnly()) {
|
||||
wx.reLaunch({ url: FIGHTER_MINE });
|
||||
return;
|
||||
}
|
||||
} catch (e) {}
|
||||
wx.reLaunch({ url: '/pages/mine/mine' });
|
||||
}
|
||||
|
||||
@@ -189,7 +196,12 @@ export function resetGuestSession(page, options = {}) {
|
||||
app.globalData._dashouPhoneChecked = false;
|
||||
app.globalData._shangjiaPhoneChecked = false;
|
||||
|
||||
app.emitEvent('currentRoleChanged', { role: 'normal' });
|
||||
let emitRole = 'normal';
|
||||
try {
|
||||
const { isFighterOnly } = require('./fighter-only.js');
|
||||
if (isFighterOnly()) emitRole = 'dashou';
|
||||
} catch (e) {}
|
||||
app.emitEvent('currentRoleChanged', { role: emitRole });
|
||||
refreshTabBar(page);
|
||||
|
||||
if (!options.skipPageReset && page && page.setData) {
|
||||
|
||||
Reference in new issue
Block a user