| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148 |
- <template>
- <view class="chat-page">
- <view class="chat-header">
- <view class="chat-header__row">
- <view class="fe-nav-btn guide-target guide-target--sidebar" @tap="openSidebar">
- <text class="fe-nav-icon">☰</text>
- </view>
- <text class="chat-header__title">智能用工助手</text>
- <view class="chat-header__actions">
- <view class="fe-nav-btn guide-target guide-target--new-chat" @tap="newChat">
- <text class="fe-nav-icon fe-nav-icon--plus">+</text>
- </view>
- <view class="fe-nav-btn guide-target guide-target--message" @tap="openDrawer('message')">
- <text class="fe-nav-icon">🔔</text>
- <view class="fe-nav-badge">2</view>
- </view>
- <view class="fe-nav-avatar guide-target guide-target--avatar" @tap="openDrawer('profile')">{{ user.avatarText }}</view>
- </view>
- </view>
- </view>
- <!-- Sidebar -->
- <view class="fe-sidebar" :class="{ 'fe-sidebar--open': sidebarOpen }">
- <view class="sidebar-head">
- <text class="sidebar-head__title">对话列表</text>
- <view class="sidebar-head__add" @tap="newChat">+</view>
- </view>
- <scroll-view scroll-y class="sidebar-list" :show-scrollbar="false">
- <view v-if="sessionsLoading" class="sidebar-status">
- <text class="sidebar-status__text">加载中...</text>
- </view>
- <view v-else-if="!sessions.length" class="sidebar-status sidebar-status--action" @tap="newChat">
- <text class="sidebar-status__text sidebar-status__text--action">开启新对话</text>
- </view>
- <block v-else>
- <view
- v-for="(s, sessionIdx) in sessions"
- :key="s.conversationNo"
- class="fe-sidebar-item"
- :class="{ 'fe-sidebar-item--active': currentSession === s.conversationNo }"
- @tap="switchSessionByIndex(sessionIdx)"
- >
- <view class="fe-sidebar-item__title">{{ s.title }}</view>
- <view class="fe-sidebar-item__time">{{ s.time }}</view>
- </view>
- </block>
- </scroll-view>
- </view>
- <!-- Chat Area -->
- <scroll-view
- class="chat-area"
- scroll-y
- :scroll-top="scrollTop"
- :scroll-into-view="scrollIntoView"
- :scroll-with-animation="scrollWithAnimation"
- :show-scrollbar="false"
- :enhanced="true"
- :upper-threshold="80"
- @scroll="onChatScroll"
- @scrolltoupper="onChatScrollToUpper"
- >
- <view class="chat-area__inner">
- <view v-if="showNewChatEmpty" class="chat-empty">
- <view class="chat-empty__icon">💬</view>
- <text class="chat-empty__title">{{ newChatGreeting }}</text>
- <view class="chat-empty__btn" @tap="newChat">开启新对话</view>
- </view>
- <block v-else>
- <view v-if="messagesLoading" class="chat-status">
- <text class="chat-status__text">加载消息中...</text>
- </view>
- <block v-else>
- <view v-if="messagesLoadingMore" class="chat-status chat-status--top">
- <text class="chat-status__text">加载历史消息...</text>
- </view>
- <view v-else-if="!hasMoreHistory && hasMessageHistory" class="chat-status chat-status--top">
- <text class="chat-status__text chat-status__text--muted">没有更多消息了</text>
- </view>
- <view v-for="(msg, idx) in messages" :key="msg.msgKey" class="chat-msg-wrap">
- <!-- Plain text -->
- <view v-if="msg.type === 'text'" class="fe-chat-msg" :class="'fe-chat-msg--' + msg.role" :id="'msg-' + idx">
- <view v-if="msg.role === 'ai'" class="fe-chat-avatar fe-chat-avatar--ai">AI</view>
- <view v-if="msg.role === 'user'" class="fe-chat-avatar fe-chat-avatar--user">{{ user.avatarText }}</view>
- <view class="fe-chat-bubble">
- <view v-if="msg.streaming && !msg.content" class="fe-thinking-dots fe-thinking-dots--inline">
- <view class="fe-thinking-dots__dot" />
- <view class="fe-thinking-dots__dot" />
- <view class="fe-thinking-dots__dot" />
- </view>
- <view v-else class="fe-chat-bubble__text-wrap">
- <FeChatMarkdown v-if="msg.role === 'ai'" :content="msg.content" />
- <text v-else class="fe-chat-bubble__text" user-select>{{ msg.content }}</text>
- </view>
- </view>
- </view>
- <!-- Report card -->
- <view v-else-if="msg.type === 'report'" class="fe-chat-msg fe-chat-msg--ai report-card-anchor" :id="'msg-' + idx">
- <view class="fe-chat-avatar fe-chat-avatar--ai">AI</view>
- <view class="fe-chat-bubble">
- <view class="fe-biz-card fe-biz-card--report" @tap="openSheet('report')">
- <view class="fe-biz-card__header">📊 今日汇报</view>
- <view class="fe-biz-card__row"><text>1. 浦东仓库</text><text class="fe-biz-card__val">8/10 人已登记</text></view>
- <view class="fe-biz-card__row"><text>2. 王五实名失败</text><text class="fe-biz-card__val fe-biz-card__val--danger">已自动提醒</text></view>
- <view class="fe-biz-card__row"><text>3. 结算单待确认</text><text class="fe-biz-card__val">¥12,800</text></view>
- <view class="fe-biz-card__actions">
- <view class="fe-biz-btn" @tap.stop="toast('已发送催办')">一键催办</view>
- <view class="fe-biz-btn" @tap.stop="openProgressOverview">查看进度</view>
- </view>
- </view>
- </view>
- </view>
- <!-- Draft card -->
- <view v-else-if="msg.type === 'draft'" class="fe-chat-msg fe-chat-msg--ai" :id="'msg-' + idx">
- <view class="fe-chat-avatar fe-chat-avatar--ai">AI</view>
- <view class="fe-chat-bubble">
- <view
- class="fe-biz-card fe-biz-card--draft"
- :class="msg.draftRootClass"
- @tap="openDraftByIndex(idx)"
- >
- <view class="fe-biz-card__header">
- <text class="fe-biz-card__header-title">📄 {{ (msg.draft && msg.draft.title) || '用工草稿' }}</text>
- <text class="fe-draft-card-status" :class="msg.draftStatusClass">{{ msg.draftStatusLabel }}</text>
- </view>
- <view class="fe-biz-card__row">
- <text>岗位类型</text>
- <text class="fe-biz-card__val">{{ (msg.draft && msg.draft.workType) || '待补充' }}</text>
- </view>
- <view class="fe-biz-card__row">
- <text>工作地点</text>
- <text class="fe-biz-card__val">{{ (msg.draft && msg.draft.workLocation) || '待补充' }}</text>
- </view>
- <view class="fe-biz-card__row">
- <text>用工人数</text>
- <text class="fe-biz-card__val">{{ (msg.draft && msg.draft.headcountText) || '待补充' }}</text>
- </view>
- <view class="fe-draft-price">
- {{ (msg.draft && msg.draft.estimatedTotalText) || '—' }}
- <text style="font-size:26rpx;font-weight:500;color:#64748B;">预估总价</text>
- </view>
- <view class="fe-biz-card__actions fe-biz-card__actions--draft">
- <view class="fe-biz-btn fe-biz-btn--primary" @tap.stop="openDraftByIndex(idx)">查看详情</view>
- <text class="fe-biz-card__hint">如需修改草稿,请直接在对话中说明</text>
- </view>
- <view v-if="msg.voided" class="fe-draft-void-stamp">已作废</view>
- </view>
- </view>
- </view>
- <!-- QR card(确认方案后) -->
- <view v-else-if="msg.type === 'qr'" class="fe-chat-msg fe-chat-msg--ai" :id="'msg-' + idx">
- <view class="fe-chat-avatar fe-chat-avatar--ai">AI</view>
- <view class="fe-chat-bubble">
- <view class="fe-biz-card fe-biz-card--qr" @tap="openQrByIndex(idx)">
- <view class="fe-biz-card__header">
- <text class="fe-biz-card__header-title">工人登记二维码</text>
- </view>
- <text v-if="qrSubtitleByIndex(idx)" class="fe-qr-card__subtitle">{{ qrSubtitleByIndex(idx) }}</text>
- <image
- v-if="qrImageUrlByIndex(idx)"
- class="fe-qr-card__img"
- :src="qrImageUrlByIndex(idx)"
- mode="aspectFit"
- @tap.stop="openQrByIndex(idx)"
- />
- <view v-else class="fe-qr-card__empty">
- <text class="fe-qr-card__empty-text">二维码加载中,可点此刷新</text>
- </view>
- <text class="fe-qr-card__hint">{{ qrHintByIndex(idx) }}</text>
- <view class="fe-biz-card__actions">
- <view class="fe-biz-btn" @tap.stop="openProgressByQrIndex(idx)">查看进度</view>
- <view class="fe-biz-btn fe-biz-btn--primary" @tap.stop="openQrByIndex(idx)">查看 / 分享</view>
- </view>
- </view>
- </view>
- </view>
- <!-- Orders -->
- <view v-else-if="msg.type === 'orders'" class="fe-chat-msg fe-chat-msg--ai" :id="'msg-' + idx">
- <view class="fe-chat-avatar fe-chat-avatar--ai">AI</view>
- <view class="fe-chat-bubble">
- <view class="fe-biz-card" style="margin-bottom:16rpx;">
- <view class="fe-biz-card__header">📋 订单 #2024-001 · 活动执行</view>
- <view class="fe-biz-card__row"><text>状态</text><text class="fe-biz-card__val" style="color:#10B981;">进行中</text></view>
- <view class="fe-biz-card__row"><text>人数/时间</text><text class="fe-biz-card__val">10人 · 01-20至21</text></view>
- <view class="fe-biz-card__row"><text>已登记</text><text class="fe-biz-card__val">7/10人</text></view>
- </view>
- <view class="fe-biz-card">
- <view class="fe-biz-card__header">📋 订单 #2024-002 · 促销推广</view>
- <view class="fe-biz-card__row"><text>状态</text><text class="fe-biz-card__val" style="color:#F59E0B;">待确认</text></view>
- <view class="fe-biz-card__row"><text>人数/时间</text><text class="fe-biz-card__val">5人 · 01-25至26</text></view>
- </view>
- </view>
- </view>
- <!-- Summary bubbles -->
- <view v-else-if="msg.type === 'summary1'" class="fe-summary-bubble" @tap="openSheet('draft')" :id="'msg-' + idx">
- <text class="fe-summary-bubble__check">✓</text>
- <text><text class="fe-summary-bubble__text">方案A已确认</text> · 合规优先 · ¥12,800</text>
- </view>
- <view v-else-if="msg.type === 'summary2'" class="fe-summary-bubble" @tap="openSheet('settlement')" :id="'msg-' + idx">
- <text class="fe-summary-bubble__check">✓</text>
- <text><text class="fe-summary-bubble__text">结算已支付</text> · ¥50,400 · BATCH-001</text>
- </view>
- <!-- Knowledge actions -->
- <view v-else-if="msg.type === 'knowledge_actions'" class="fe-chat-msg fe-chat-msg--ai" :id="'msg-' + idx">
- <view class="fe-chat-avatar fe-chat-avatar--ai">AI</view>
- <view class="fe-chat-bubble">
- <view class="fe-quick-actions">
- <view class="fe-quick-action" @tap="triggerAI('政策法规')">
- <view class="fe-quick-action__icon" style="background:#DBEAFE;">📜</view>
- <text class="fe-quick-action__label">政策法规</text>
- </view>
- <view class="fe-quick-action" @tap="triggerAI('税务处理')">
- <view class="fe-quick-action__icon" style="background:#FEF3C7;">💰</view>
- <text class="fe-quick-action__label">税务处理</text>
- </view>
- <view class="fe-quick-action" @tap="triggerAI('合同管理')">
- <view class="fe-quick-action__icon" style="background:#D1FAE5;">📄</view>
- <text class="fe-quick-action__label">合同管理</text>
- </view>
- <view class="fe-quick-action" @tap="triggerAI('社保保险')">
- <view class="fe-quick-action__icon" style="background:#FEE2E2;">🛡</view>
- <text class="fe-quick-action__label">社保保险</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view id="chat-bottom-anchor" class="chat-bottom-anchor" />
- </block>
- </block>
- </view>
- </scroll-view>
- <FeReportFloat :visible="showReportFloat" @open="openReportSheet" />
- <!-- Footer: Quick Actions + Input -->
- <view class="chat-footer">
- <view class="fe-quick-actions fe-quick-actions--dock guide-target guide-target--quick-bar">
- <view class="fe-quick-action" @tap="triggerAI('新用工需求')">
- <view class="fe-quick-action__icon" style="background:#FEF3C7;">➕</view>
- <text class="fe-quick-action__label">发布需求</text>
- </view>
- <view class="fe-quick-action" @tap="openConversationCost">
- <view class="fe-quick-action__icon" style="background:#D1FAE5;">💰</view>
- <text class="fe-quick-action__label">成本测算</text>
- </view>
- <view class="fe-quick-action" @tap="openProgressOverview">
- <view class="fe-quick-action__icon" style="background:#DBEAFE;">📈</view>
- <text class="fe-quick-action__label">进度总览</text>
- </view>
- <view class="fe-quick-action" @tap="openSheet('settlement')">
- <view class="fe-quick-action__icon" style="background:#FEE2E2;">💳</view>
- <text class="fe-quick-action__label">历史订单</text>
- </view>
- </view>
- <view
- class="fe-input-bar fe-input-bar--embedded"
- :class="{ 'fe-input-bar--disabled': inputDisabled }"
- >
- <view
- class="fe-input-bar__btn fe-input-bar__btn--voice"
- @tap="onVoiceTap"
- >🎤</view>
- <input
- class="fe-input-bar__field"
- v-model="inputText"
- :disabled="inputDisabled"
- :placeholder="inputPlaceholder"
- confirm-type="send"
- @input="onInput"
- @confirm="sendMsg"
- />
- <view
- class="fe-input-bar__btn fe-input-bar__btn--send"
- :class="{ active: canSend }"
- @tap="sendMsg"
- >➤</view>
- </view>
- </view>
- <!-- Overlay -->
- <view class="fe-overlay" :class="{ 'fe-overlay--active': overlayActive, 'fe-overlay--elevated': sheetElevated }" @tap="closeAll" />
- <!-- Sheets -->
- <FeDraftSheet
- :active="activeSheet === 'draft'"
- :draft="activeDraft"
- @confirm="confirmPlan"
- @updated="onDraftUpdated"
- @view-qr="openDraftQr"
- />
- <FeConversationCostSheet
- :active="activeSheet === 'cost'"
- :conversation-id="currentConversationId"
- :draft-metas="costDraftMetas"
- @confirm="onConversationCostConfirm"
- @updated="onDraftUpdated($event, { sinkToBottom: false })"
- @view-qr="openDraftQr"
- />
- <FeReportSheet :active="activeSheet === 'report'" @progress="openProgressOverview" />
- <FeConversationProgressSheet
- :active="activeSheet === 'progressOverview'"
- :conversation-id="currentConversationId"
- />
- <FeProgressSheet
- :active="activeSheet === 'progress'"
- :elevated="sheetElevated"
- :draft-id="progressDraftId"
- />
- <FeSettlementSheet :active="activeSheet === 'settlement'" @pay="showPayment" />
- <!-- Drawer: Message -->
- <view class="fe-side-drawer" :class="{ 'fe-side-drawer--active': activeDrawer === 'message' }">
- <view class="fe-drawer-header"><view class="fe-drawer-title">🔔 消息与待办</view></view>
- <scroll-view scroll-y class="fe-drawer-body" :show-scrollbar="false">
- <view class="fe-drawer-body__inner">
- <view v-for="(m, i) in inbox" :key="i" class="fe-msg-item">
- <view style="display:flex;justify-content:space-between;margin-bottom:8rpx;">
- <text class="fe-msg-type" :class="'fe-msg-type--' + m.type">{{ m.type === 'pending' ? '待办' : '异常' }}</text>
- <text style="font-size:22rpx;color:#94A3B8;">{{ m.time }}</text>
- </view>
- <view style="font-weight:600;font-size:28rpx;">{{ m.title }}</view>
- <view style="font-size:26rpx;color:#64748B;margin-top:4rpx;">{{ m.desc }}</view>
- </view>
- </view>
- </scroll-view>
- </view>
- <!-- Drawer: 企业管理中枢 -->
- <view class="fe-side-drawer" :class="{ 'fe-side-drawer--active': activeDrawer === 'profile' }">
- <view class="fe-drawer-header"><view class="fe-drawer-title">企业管理中枢</view></view>
- <scroll-view scroll-y class="fe-drawer-body" :show-scrollbar="false">
- <view class="fe-drawer-body__inner">
- <EnterpriseHubPanel ref="hubPanel" show-logout @logout="logout" />
- </view>
- </scroll-view>
- </view>
- <!-- Modal Confirm -->
- <view class="fe-modal-overlay" :class="{ 'fe-modal-overlay--active': modal === 'confirm' || modal === 'payment' || modal === 'paySuccess' }" @tap="closeModal" />
- <view class="fe-modal" :class="{ 'fe-modal--active': modal === 'confirm' }">
- <view class="fe-modal-body">
- <view class="fe-modal-icon fe-modal-icon--success">✓</view>
- <view class="fe-modal-title">{{ confirmModalTitle }}</view>
- <view class="fe-modal-desc">
- <view>{{ confirmModalDescMain }}</view>
- <view>{{ confirmModalDescSub }}</view>
- </view>
- </view>
- <view class="fe-modal-footer">
- <view class="fe-modal-btn fe-modal-btn--cancel" @tap="closeModal">稍后查看</view>
- <view class="fe-modal-btn fe-modal-btn--confirm" @tap="showQR">查看二维码</view>
- </view>
- </view>
- <FeBatchQrModal
- :active="modal === 'qr'"
- :batch="qrBatch"
- @close="closeModal"
- @progress="openQrProgress"
- @progress-loaded="onQrProgressLoaded"
- />
- <!-- Modal Payment -->
- <view class="fe-modal" :class="{ 'fe-modal--active': modal === 'payment' }">
- <view class="fe-modal-body">
- <view class="fe-modal-title">确认支付 ¥52,800</view>
- <view class="fe-modal-desc">将从企业对公账户扣款\n浦东仓库搬运 BATCH-001</view>
- </view>
- <view class="fe-modal-footer">
- <view class="fe-modal-btn fe-modal-btn--cancel" @tap="closeModal">取消</view>
- <view class="fe-modal-btn fe-modal-btn--confirm" @tap="showPaySuccess">确认支付</view>
- </view>
- </view>
- <!-- Modal Pay Success -->
- <view class="fe-modal" :class="{ 'fe-modal--active': modal === 'paySuccess' }">
- <view class="fe-modal-body">
- <view class="fe-modal-icon fe-modal-icon--success">✓</view>
- <view class="fe-modal-title">支付成功</view>
- <view class="fe-modal-desc">¥52,800 已支付\n结算单 BATCH-001</view>
- </view>
- <view class="fe-modal-footer">
- <view class="fe-modal-btn fe-modal-btn--confirm" style="flex:1;" @tap="closeModal">完成</view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import EnterpriseHubPanel from '@/packageA/components/EnterpriseHubPanel.vue'
- import FeDraftSheet from '@/packageA/components/chat/FeDraftSheet.vue'
- import FeConversationCostSheet from '@/packageA/components/chat/FeConversationCostSheet.vue'
- import FeConversationProgressSheet from '@/packageA/components/chat/FeConversationProgressSheet.vue'
- import FeProgressSheet from '@/packageA/components/chat/FeProgressSheet.vue'
- import FeSettlementSheet from '@/packageA/components/chat/FeSettlementSheet.vue'
- import FeReportSheet from '@/packageA/components/chat/FeReportSheet.vue'
- import FeReportFloat from '@/packageA/components/chat/FeReportFloat.vue'
- import FeBatchQrModal from '@/packageA/components/chat/FeBatchQrModal.vue'
- import FeChatMarkdown from '@/packageA/components/chat/FeChatMarkdown.vue'
- import store from '@/common/store.js'
- import { MESSAGES, BATCH_QR, showToast } from '@/common/chat-data.js'
- import { listConversations, createConversation, streamConversationChat, listConversationMessages } from '@/api/conversation.js'
- import { getDraftDetail } from '@/api/draft.js'
- import {
- getNewChatGreeting,
- mapConversationItem,
- mapConversationMessage,
- calcLastMessagePage,
- CONVERSATION_MESSAGE_PAGE_SIZE
- } from '@/utils/conversation.js'
- import {
- shouldFetchDraftCard,
- shouldShowOrderQrcode,
- isDraftCardContentType,
- buildDraftCardMessage,
- mapDraftDetailToCard,
- syncDraftCardViewMeta,
- getDraftStatus,
- pickDraftQrCodeUrl,
- pickDraftQrToken,
- parseChatCardPayload,
- formatDraftMoney
- } from '@/utils/draft.js'
- import {
- buildJobOfferFromDraft,
- saveJobOffer,
- buildJobOfferPageUrl,
- buildJobOfferShareMessage
- } from '@/utils/job-offer.js'
- import { resolveApiAssetUrl } from '@/common/config.js'
- export default {
- name: 'EnterpriseHome',
- options: {
- styleIsolation: 'shared'
- },
- props: {
- active: { type: Boolean, default: true }
- },
- components: {
- EnterpriseHubPanel,
- FeDraftSheet,
- FeConversationCostSheet,
- FeConversationProgressSheet,
- FeProgressSheet,
- FeSettlementSheet,
- FeReportSheet,
- FeReportFloat,
- FeBatchQrModal,
- FeChatMarkdown
- },
- data() {
- return {
- user: {},
- enterprise: {},
- sessions: [],
- sessionsLoading: false,
- creatingSession: false,
- currentSession: '',
- currentConversationId: null,
- messages: [],
- messagesLoading: false,
- messagesLoadingMore: false,
- historyPage: 1,
- hasMoreHistory: false,
- hasMessageHistory: false,
- messagePageSize: CONVERSATION_MESSAGE_PAGE_SIZE,
- inputText: '',
- canSend: false,
- chatStreaming: false,
- abortChat: null,
- scrollTop: 0,
- scrollIntoView: '',
- scrollWithAnimation: true,
- stickToBottom: true,
- sidebarOpen: false,
- activeSheet: '',
- activeDraft: null,
- activeDrawer: '',
- modal: '',
- confirmInfo: null,
- qrBatch: { ...BATCH_QR },
- /** 已处理过「方案已确认 + 二维码」的草稿 id,同会话内只执行一次 */
- orderConfirmHandledIds: {},
- inbox: MESSAGES,
- reportCardVisible: true,
- reportObserver: null,
- _localMsgSeq: 0,
- progressDraftId: null,
- costDraftMetas: []
- }
- },
- computed: {
- overlayActive() {
- return !!(this.sidebarOpen || this.activeSheet || this.activeDrawer)
- },
- confirmModalTitle() {
- const info = this.confirmInfo
- if (!info || !info.title) return '方案已确认'
- return `已确认:${info.title}`
- },
- confirmModalDescMain() {
- const info = this.confirmInfo
- if (!info) return '方案确认成功'
- const parts = []
- if (info.tagsText) parts.push(info.tagsText)
- if (info.total) parts.push(`总支出 ${info.total}`)
- if (info.avgCost) parts.push(`人均 ${info.avgCost}`)
- return parts.length ? parts.join(' · ') : '方案确认成功'
- },
- confirmModalDescSub() {
- const info = this.confirmInfo
- const orderId = info && info.orderId
- if (orderId) return `订单 ${orderId} 已生成,可查看批次二维码`
- return '确认后可查看并分享批次二维码'
- },
- hasReportMessage() {
- return this.messages.some((m) => m.type === 'report')
- },
- showReportFloat() {
- return this.hasReportMessage && !this.reportCardVisible
- },
- showNewChatEmpty() {
- return !this.sessionsLoading && !this.currentSession && !this.sessions.length
- },
- /** 未开启/选中会话时禁止输入 */
- inputDisabled() {
- return !this.currentConversationId || this.chatStreaming
- },
- inputPlaceholder() {
- if (!this.currentConversationId) return '请先开启新对话'
- if (this.chatStreaming) return 'AI 正在回复...'
- return '输入需求或按住说话...'
- },
- newChatGreeting() {
- return getNewChatGreeting()
- },
- sheetElevated() {
- return this.modal === 'qr' && this.activeSheet === 'progress'
- }
- },
- onShow() {
- if (!this.active) return
- this.initHome()
- },
- mounted() {
- if (this.active) this.initHome()
- },
- watch: {
- active(val) {
- if (val) this.initHome()
- }
- },
- onReady() {
- this.setupReportObserver()
- },
- beforeDestroy() {
- this.disconnectReportObserver()
- this.stopChatStream()
- if (this._scrollTimer) clearTimeout(this._scrollTimer)
- },
- methods: {
- toast: showToast,
- async initHome() {
- const s = store.getState()
- this.user = s.user
- this.enterprise = s.enterprise
- await this.fetchSessions({ autoLoad: true })
- },
- async fetchSessions(options = {}) {
- const { autoLoad = false, showError = false } = options
- this.sessionsLoading = true
- try {
- const list = await listConversations({ status: 'active' }, { showError })
- this.sessions = (list || []).map(mapConversationItem)
- if (autoLoad) {
- if (this.sessions.length) {
- const current = this.sessions.find((item) => item.conversationNo === this.currentSession)
- const target = current || this.sessions[0]
- await this.loadSession(target.conversationNo, target.chatType)
- } else if (!this.currentSession) {
- this.messages = []
- }
- }
- } catch (e) {
- if (autoLoad && !this.currentSession) {
- this.messages = []
- }
- } finally {
- this.sessionsLoading = false
- }
- },
- buildWelcomeMessages() {
- return [{
- type: 'text',
- role: 'ai',
- content: getNewChatGreeting(),
- msgKey: this.nextLocalMsgKey()
- }]
- },
- nextLocalMsgKey() {
- this._localMsgSeq += 1
- return -this._localMsgSeq
- },
- resetMessagePagination() {
- this.historyPage = 1
- this.hasMoreHistory = false
- this.hasMessageHistory = false
- this.messagesLoading = false
- this.messagesLoadingMore = false
- },
- async loadSession(conversationNo, chatType) {
- this.abortChatStream()
- this.currentSession = conversationNo
- const session = this.sessions.find((item) => item.conversationNo === conversationNo)
- this.currentConversationId = session ? session.id : null
- this.resetMessagePagination()
- this.messages = []
- this.orderConfirmHandledIds = {}
- this.reportCardVisible = true
- await this.fetchLatestMessages({ scrollBottom: true })
- this.markOrderConfirmHandledFromMessages()
- this.$nextTick(() => {
- this.setupReportObserver()
- setTimeout(() => this.checkReportVisibility(), 120)
- })
- },
- async fetchLatestMessages(options = {}) {
- const { scrollBottom = false } = options
- if (!this.currentConversationId) {
- this.messages = this.buildWelcomeMessages()
- return
- }
- this.messagesLoading = true
- try {
- const probe = await listConversationMessages(
- this.currentConversationId,
- { page: 1, size: this.messagePageSize },
- { showError: true }
- )
- const total = probe.total || 0
- if (!total) {
- this.messages = this.buildWelcomeMessages()
- this.hasMoreHistory = false
- this.hasMessageHistory = false
- return
- }
- const lastPage = calcLastMessagePage(total, this.messagePageSize)
- let pageData = probe
- if (lastPage > 1) {
- pageData = await listConversationMessages(
- this.currentConversationId,
- { page: lastPage, size: this.messagePageSize },
- { showError: true }
- )
- }
- this.historyPage = lastPage
- this.hasMoreHistory = lastPage > 1
- this.hasMessageHistory = true
- this.messages = (pageData.items || []).map(mapConversationMessage)
- await this.hydrateDraftCardsFromMessages()
- if (scrollBottom) {
- this.stickToBottom = true
- this.ensureChatBottom()
- }
- } catch (e) {
- this.messages = this.buildWelcomeMessages()
- this.hasMoreHistory = false
- this.hasMessageHistory = false
- } finally {
- this.messagesLoading = false
- }
- },
- measureChatContentHeight() {
- return new Promise((resolve) => {
- const query = uni.createSelectorQuery().in(this)
- query.select('.chat-area__inner').boundingClientRect()
- query.exec((res) => {
- resolve((res[0] && res[0].height) || 0)
- })
- })
- },
- restoreScrollAfterPrepend(beforeHeight, beforeTop) {
- return new Promise((resolve) => {
- this.$nextTick(() => {
- setTimeout(async () => {
- const afterHeight = await this.measureChatContentHeight()
- const delta = afterHeight - beforeHeight
- this._programmaticScroll = true
- this.scrollWithAnimation = false
- this._scrollBump = (this._scrollBump || 0) + 1
- this.scrollTop = Math.max(0, beforeTop + delta) + this._scrollBump
- setTimeout(() => {
- this._programmaticScroll = false
- resolve()
- }, 60)
- }, 50)
- })
- })
- },
- async loadMoreHistory() {
- if (
- !this.hasMoreHistory ||
- this.messagesLoadingMore ||
- this.messagesLoading ||
- this.chatStreaming ||
- !this.currentConversationId
- ) {
- return
- }
- const olderPage = this.historyPage - 1
- if (olderPage < 1) {
- this.hasMoreHistory = false
- return
- }
- this.messagesLoadingMore = true
- try {
- const beforeHeight = await this.measureChatContentHeight()
- const beforeTop = this._lastScrollTop || 0
- const pageData = await listConversationMessages(
- this.currentConversationId,
- { page: olderPage, size: this.messagePageSize },
- { showError: false }
- )
- const older = (pageData.items || []).map(mapConversationMessage)
- if (!older.length) {
- this.hasMoreHistory = false
- return
- }
- this.messages = [...older, ...this.messages]
- this.historyPage = olderPage
- this.hasMoreHistory = olderPage > 1
- await this.hydrateDraftCardsFromMessages(older)
- await this.restoreScrollAfterPrepend(beforeHeight, beforeTop)
- } catch (e) {
- // 错误提示由 request.js 统一处理
- } finally {
- this.messagesLoadingMore = false
- }
- },
- onChatScrollToUpper() {
- this.loadMoreHistory()
- },
- switchSession(conversationNo) {
- if (this.currentSession === conversationNo) {
- this.sidebarOpen = false
- return
- }
- this.sidebarOpen = false
- const session = this.sessions.find((item) => item.conversationNo === conversationNo)
- this.loadSession(conversationNo, session && session.chatType)
- },
- switchSessionByIndex(index) {
- const session = this.sessions[index]
- if (!session) return
- this.switchSession(session.conversationNo)
- },
- async newChat() {
- if (this.creatingSession) return
- this.creatingSession = true
- this.sidebarOpen = false
- try {
- const created = await createConversation({
- chatType: 'employment',
- title: '新对话'
- })
- const item = mapConversationItem(created)
- this.sessions = [
- item,
- ...this.sessions.filter((session) => session.conversationNo !== item.conversationNo)
- ]
- this.loadSession(item.conversationNo, item.chatType)
- this.toast('已开启新对话')
- } catch (e) {
- // 错误提示由 request.js 统一处理
- } finally {
- this.creatingSession = false
- }
- },
- scrollBottom(animated = true, force = false) {
- if (!force && !this.stickToBottom && !this.chatStreaming) return
- if (this._scrollTimer) clearTimeout(this._scrollTimer)
- this._scrollTimer = setTimeout(() => {
- this._scrollTimer = null
- this.scrollWithAnimation = !!animated
- this._programmaticScroll = true
- this._scrollBump = (this._scrollBump || 0) + 1
- this.scrollTop = 100000 + this._scrollBump
- setTimeout(() => {
- this._programmaticScroll = false
- }, animated ? 300 : 60)
- setTimeout(() => this.checkReportVisibility(), 120)
- }, animated ? 40 : 0)
- },
- scrollToBottomAnchor() {
- this.scrollIntoView = ''
- this.$nextTick(() => {
- this.scrollIntoView = 'chat-bottom-anchor'
- })
- },
- ensureChatBottom() {
- this.stickToBottom = true
- const scroll = () => {
- this.scrollBottom(false, true)
- this.scrollToBottomAnchor()
- }
- this.$nextTick(() => {
- scroll()
- setTimeout(scroll, 60)
- setTimeout(scroll, 180)
- setTimeout(scroll, 360)
- })
- },
- onChatScroll(e) {
- const detail = e.detail || {}
- this._lastScrollTop = detail.scrollTop || 0
- if (this._programmaticScroll) {
- this.checkReportVisibility()
- return
- }
- const gap = (detail.scrollHeight || 0) - (detail.scrollTop || 0) - (detail.clientHeight || 0)
- if (this.chatStreaming) {
- // 流式输出时内容可能突增,仅当明显上滑才取消贴底
- if (gap > 280) this.stickToBottom = false
- } else {
- this.stickToBottom = gap < 120
- }
- if (
- !this.chatStreaming &&
- !this.messagesLoading &&
- !this.messagesLoadingMore &&
- this._lastScrollTop <= 20
- ) {
- this.loadMoreHistory()
- }
- this.checkReportVisibility()
- },
- setupReportObserver() {
- this.disconnectReportObserver()
- if (!this.hasReportMessage) return
- this.$nextTick(() => {
- this.reportObserver = uni.createIntersectionObserver(this, { thresholds: [0, 0.01, 1] })
- this.reportObserver
- .relativeTo('.chat-area', { top: 0, bottom: 0 })
- .observe('.report-card-anchor', (res) => {
- this.reportCardVisible = res.intersectionRatio > 0
- })
- })
- },
- disconnectReportObserver() {
- if (this.reportObserver) {
- this.reportObserver.disconnect()
- this.reportObserver = null
- }
- },
- checkReportVisibility() {
- if (!this.hasReportMessage) {
- this.reportCardVisible = true
- return
- }
- const query = uni.createSelectorQuery().in(this)
- query.select('.chat-area').boundingClientRect()
- query.select('.report-card-anchor').boundingClientRect()
- query.exec((res) => {
- const area = res[0]
- const card = res[1]
- if (!area || !card) return
- this.reportCardVisible = card.bottom > area.top && card.top < area.bottom
- })
- },
- openReportSheet() {
- this.openSheet('report')
- },
- onInput() {
- this.canSend =
- !this.inputDisabled &&
- !!this.currentConversationId &&
- this.inputText.trim().length > 0 &&
- !this.chatStreaming
- },
- onVoiceTap() {
- if (this.inputDisabled) {
- if (!this.currentConversationId) this.toast('请先开启新对话')
- return
- }
- this.toast('按住说话...')
- },
- stopChatStream() {
- if (this.abortChat) {
- this.abortChat()
- this.abortChat = null
- }
- this.chatStreaming = false
- },
- abortChatStream() {
- if (this.abortChat) {
- this.abortChat()
- this.abortChat = null
- }
- },
- sendMsg() {
- if (this.inputDisabled && !this.chatStreaming) {
- if (!this.currentConversationId) this.toast('请先开启新对话')
- return
- }
- const text = this.inputText.trim()
- if (!text || this.chatStreaming) return
- if (!this.currentConversationId) {
- this.toast('请先开启新对话')
- return
- }
- this.abortChatStream()
- this.stickToBottom = true
- this.messages.push({ type: 'text', role: 'user', content: text, msgKey: this.nextLocalMsgKey() })
- const aiIdx = this.messages.length
- this.messages.push({
- type: 'text',
- role: 'ai',
- content: '',
- streaming: true,
- msgKey: this.nextLocalMsgKey()
- })
- this.inputText = ''
- this.canSend = false
- this.chatStreaming = true
- this.scrollBottom()
- this.abortChat = streamConversationChat({
- conversationId: this.currentConversationId,
- message: text,
- onDelta: (assembledText) => {
- const prev = this.messages[aiIdx].content || ''
- this.$set(this.messages[aiIdx], 'content', assembledText || '')
- const force = !!(assembledText && assembledText.length - prev.length > 80)
- this.scrollBottom(false, force)
- if (force) {
- this.$nextTick(() => this.scrollBottom(false, true))
- }
- },
- onDone: async (assembledText, cardMeta) => {
- this.$set(this.messages[aiIdx], 'streaming', false)
- if (assembledText) {
- this.$set(this.messages[aiIdx], 'content', assembledText)
- } else if (!this.messages[aiIdx].content) {
- this.$set(this.messages[aiIdx], 'content', '暂无回复,请稍后重试')
- }
- // 本轮 SSE 带草稿卡:card_draft 作废旧卡并末尾新卡;card_order 仅首次补卡
- if (shouldFetchDraftCard(cardMeta)) {
- await this.handleDraftCardFromChat(cardMeta)
- }
- // next_action=show_order_qrcode:同草稿只生成一次确认文案 + 二维码
- if (shouldShowOrderQrcode(cardMeta)) {
- await this.showOrderConfirmFromChat(cardMeta)
- }
- this.ensureChatBottom()
- this.stopChatStream()
- this.fetchSessions({ showError: false })
- },
- onError: (err) => {
- this.$set(this.messages[aiIdx], 'streaming', false)
- const message = (err && err.message) || '对话失败,请稍后重试'
- if (!this.messages[aiIdx].content) {
- this.$set(this.messages[aiIdx], 'content', message)
- } else {
- this.toast(message)
- }
- this.ensureChatBottom()
- this.stopChatStream()
- }
- })
- },
- triggerAI(text) {
- if (!this.currentConversationId) {
- this.toast('请先开启新对话')
- return
- }
- if (this.chatStreaming) return
- this.inputText = text
- this.canSend = true
- this.sendMsg()
- },
- isDraftVoidedByIndex(idx) {
- const msg = this.messages[idx]
- return !!(msg && msg.type === 'draft' && msg.voided)
- },
- isDraftConfirmedByIndex(idx) {
- const msg = this.messages[idx]
- if (!msg || msg.voided) return false
- return !!(msg.draft && getDraftStatus(msg.draft) === 'confirmed')
- },
- draftCardStatusLabelByIndex(idx) {
- if (this.isDraftVoidedByIndex(idx)) return '已作废'
- return this.isDraftConfirmedByIndex(idx) ? '已确认' : '未确认'
- },
- draftCardStatusClassByIndex(idx) {
- if (this.isDraftVoidedByIndex(idx)) return 'fe-draft-card-status--cancelled'
- return this.isDraftConfirmedByIndex(idx)
- ? 'fe-draft-card-status--confirmed'
- : 'fe-draft-card-status--pending'
- },
- async openDraftByIndex(idx) {
- const msg = this.messages[idx]
- if (!msg || msg.type !== 'draft' || !msg.draft) return
- if (msg.voided) {
- this.toast('该草稿已作废')
- return
- }
- let draft = msg.draft
- this.closeAll()
- this.activeDraft = draft
- setTimeout(() => { this.activeSheet = 'draft' }, 50)
- // 回源刷新状态(确认后缺省字段仍能正确展示)
- const draftId = draft.draftId
- if (draftId == null) return
- try {
- const detail = await getDraftDetail(draftId, { showError: false })
- if (!detail || detail.id == null) return
- const card = mapDraftDetailToCard(detail)
- // 保留本地已确认方案快照,避免刷新后丢失成本展示
- if (draft.costPlans) card.costPlans = draft.costPlans
- if (draft.confirmedPlan) card.confirmedPlan = draft.confirmedPlan
- if (draft.confirmedPlanTitle) card.confirmedPlanTitle = draft.confirmedPlanTitle
- if (draft.orderId && !card.orderId) card.orderId = draft.orderId
- if (draft.qrToken && !card.qrToken) card.qrToken = draft.qrToken
- if (draft.scene && !card.scene) card.scene = draft.scene
- // qrCodeUrl 以详情接口为准;详情暂无时才回退本地
- if (!card.qrCodeUrl && draft.qrCodeUrl) card.qrCodeUrl = draft.qrCodeUrl
- if (card.qrToken && !card.scene) card.scene = card.qrToken
- if (draft.selectedSchemeCode && !card.selectedSchemeCode) {
- card.selectedSchemeCode = draft.selectedSchemeCode
- }
- this.onDraftUpdated(card, { sinkToBottom: false })
- } catch (e) {
- // 静默失败,沿用本地草稿
- }
- },
- /**
- * 移除会话中指定草稿卡片(保留对话文本)
- */
- removeDraftCardById(draftId) {
- if (draftId == null) return
- const id = Number(draftId)
- if (Number.isNaN(id)) return
- const key = String(id)
- for (let i = this.messages.length - 1; i >= 0; i--) {
- const msg = this.messages[i]
- if (msg && msg.type === 'draft' && String(msg.draftId) === key) {
- this.messages.splice(i, 1)
- }
- }
- },
- /**
- * 更新草稿卡片(默认原地更新,不沉底)
- * @param {object} draftCard
- * @param {{ sinkToBottom?: boolean }} [options] 仅显式传 true 时才沉底
- */
- onDraftUpdated(draftCard, options = {}) {
- if (!draftCard || draftCard.draftId == null) return
- this.activeDraft = draftCard
- const sinkToBottom = options.sinkToBottom === true
- const draftKey = String(draftCard.draftId)
- if (!sinkToBottom) {
- for (let i = this.messages.length - 1; i >= 0; i--) {
- const msg = this.messages[i]
- if (
- msg.type === 'draft'
- && String(msg.draftId) === draftKey
- && !msg.voided
- ) {
- this.$set(this.messages[i], 'draft', draftCard)
- syncDraftCardViewMeta(this.messages[i])
- return
- }
- }
- // 仅有已作废同草稿卡时不「复活」新卡(避免普通对话末尾再插一张)
- const hasSameDraft = this.messages.some(
- (m) => m && m.type === 'draft' && String(m.draftId) === draftKey
- )
- if (hasSameDraft) return
- // 会话中尚无该草稿卡时追加一次
- this.messages.push(syncDraftCardViewMeta({
- type: 'draft',
- role: 'ai',
- msgKey: this.nextLocalMsgKey(),
- draftId: draftCard.draftId,
- voided: false,
- draft: draftCard
- }))
- return
- }
- this.removeDraftCardById(draftCard.draftId)
- this.messages.push(syncDraftCardViewMeta({
- type: 'draft',
- role: 'ai',
- msgKey: this.nextLocalMsgKey(),
- draftId: draftCard.draftId,
- voided: false,
- draft: draftCard
- }))
- this.ensureChatBottom()
- },
- /**
- * SSE 草稿卡:
- * - card_draft:作废旧卡并在末尾生成新卡(对话改草稿)
- * - card_order:后端在「已有确认订单+二维码」时每轮都会注入,已有有效卡则跳过,避免普通问答反复插卡
- */
- async handleDraftCardFromChat(cardMeta) {
- if (!shouldFetchDraftCard(cardMeta)) return null
- const draftId = cardMeta.relatedDraftId
- if (cardMeta.contentType === 'card_order') {
- const exists = this.messages.some(
- (m) => m
- && m.type === 'draft'
- && !m.voided
- && String(m.draftId) === String(draftId)
- )
- if (exists) return null
- }
- return this.appendDraftCardFromChat(draftId)
- },
- /**
- * 历史消息:每个 related_draft_id 对应一张草稿卡,插到「提到该 id」的文本之后;其它草稿互不影响
- * @param {Array} [sourceMessages]
- */
- async hydrateDraftCardsFromMessages(sourceMessages) {
- const list = Array.isArray(sourceMessages) ? sourceMessages : this.messages
- const draftIds = []
- for (let i = 0; i < list.length; i++) {
- const msg = list[i]
- if (!msg || msg.type !== 'text') continue
- if (!isDraftCardContentType(msg.contentType) || msg.relatedDraftId == null) continue
- const id = msg.relatedDraftId
- const prev = draftIds.indexOf(id)
- if (prev >= 0) draftIds.splice(prev, 1)
- draftIds.push(id)
- }
- for (let i = 0; i < draftIds.length; i++) {
- const id = draftIds[i]
- this.removeDraftCardById(id)
- await this.appendDraftCardById(id, { afterRelatedText: true })
- }
- },
- /**
- * 根据当前消息中已有的二维码卡 / 已确认草稿,标记对应草稿已处理过确认流程
- */
- markOrderConfirmHandledFromMessages() {
- const map = Object.assign({}, this.orderConfirmHandledIds)
- for (let i = 0; i < this.messages.length; i++) {
- const msg = this.messages[i]
- if (!msg) continue
- if (msg.type === 'qr' && msg.draftId != null) {
- map[String(msg.draftId)] = true
- }
- if (
- msg.type === 'draft'
- && !msg.voided
- && msg.draftId != null
- && msg.draft
- && getDraftStatus(msg.draft) === 'confirmed'
- ) {
- map[String(msg.draftId)] = true
- }
- }
- this.orderConfirmHandledIds = map
- },
- isOrderConfirmHandled(draftId) {
- if (draftId == null) return false
- return !!this.orderConfirmHandledIds[String(draftId)]
- },
- markOrderConfirmHandled(draftId) {
- if (draftId == null) return
- this.$set(this.orderConfirmHandledIds, String(draftId), true)
- },
- /**
- * 将会话中同草稿 / 同订单的有效草稿卡标记为已作废
- */
- voidRelatedDraftCards(options = {}) {
- const draftId = options.draftId
- const orderId = options.orderId
- const draftKey = draftId != null ? String(draftId) : ''
- const orderKey = orderId != null && orderId !== '' ? String(orderId) : ''
- if (!draftKey && !orderKey) return
- for (let i = 0; i < this.messages.length; i++) {
- const msg = this.messages[i]
- if (!msg || msg.type !== 'draft' || msg.voided) continue
- const sameDraft = draftKey && String(msg.draftId) === draftKey
- const msgOrderId = msg.draft && (msg.draft.orderId || msg.draft.order_id)
- const sameOrder = orderKey && msgOrderId != null && String(msgOrderId) === orderKey
- if (sameDraft || sameOrder) {
- this.$set(this.messages[i], 'voided', true)
- syncDraftCardViewMeta(this.messages[i])
- }
- }
- },
- /**
- * SSE 返回草稿卡:作废上方同订单/同草稿旧卡,并在会话末尾生成新卡
- */
- async appendDraftCardFromChat(draftId) {
- if (draftId == null) return null
- const id = Number(draftId)
- if (Number.isNaN(id)) return null
- try {
- const detail = await getDraftDetail(id, { showError: false })
- if (!detail || detail.id == null) return null
- const orderId = detail.orderId || detail.order_id || ''
- this.voidRelatedDraftCards({ draftId: id, orderId })
- const cardMsg = buildDraftCardMessage(detail, this.nextLocalMsgKey())
- cardMsg.voided = false
- this.messages.push(cardMsg)
- this.ensureChatBottom()
- return cardMsg
- } catch (e) {
- return null
- }
- },
- /**
- * 历史消息还原:插到提到该草稿 id 的文本后(不作废链路)
- * @param {number} draftId
- * @param {{ afterRelatedText?: boolean }} [options]
- */
- async appendDraftCardById(draftId, options = {}) {
- if (draftId == null) return null
- const id = Number(draftId)
- if (Number.isNaN(id)) return null
- const exists = this.messages.some((m) => m.type === 'draft' && m.draftId === id && !m.voided)
- if (exists) return null
- try {
- const detail = await getDraftDetail(id, { showError: false })
- if (!detail || detail.id == null) return null
- const cardMsg = buildDraftCardMessage(detail, this.nextLocalMsgKey())
- cardMsg.voided = false
- if (options.afterRelatedText) {
- let insertAt = -1
- for (let i = this.messages.length - 1; i >= 0; i--) {
- const msg = this.messages[i]
- if (
- msg.type === 'text'
- && msg.relatedDraftId === id
- && isDraftCardContentType(msg.contentType)
- ) {
- insertAt = i + 1
- break
- }
- }
- if (insertAt < 0) {
- for (let i = this.messages.length - 1; i >= 0; i--) {
- const msg = this.messages[i]
- if (msg.type === 'text' && msg.relatedDraftId === id) {
- insertAt = i + 1
- break
- }
- }
- }
- if (insertAt < 0) return null
- this.messages.splice(insertAt, 0, cardMsg)
- } else {
- this.messages.push(cardMsg)
- }
- this.ensureChatBottom()
- return cardMsg
- } catch (e) {
- return null
- }
- },
- openSidebar() {
- if (this.sidebarOpen) {
- this.sidebarOpen = false
- return
- }
- this.activeSheet = ''
- this.activeDrawer = ''
- this.sidebarOpen = true
- this.fetchSessions()
- },
- openSheet(name) {
- this.closeAll()
- setTimeout(() => { this.activeSheet = name }, 50)
- },
- openDrawer(name) {
- this.closeAll()
- setTimeout(() => {
- this.activeDrawer = name
- if (name === 'profile' && this.$refs.hubPanel) {
- this.$refs.hubPanel.refreshPasswordStatus()
- }
- }, 50)
- },
- closeAll() {
- this.sidebarOpen = false
- this.activeSheet = ''
- this.activeDrawer = ''
- this.activeDraft = null
- },
- closeModal() {
- this.modal = ''
- this.confirmInfo = null
- },
- /**
- * 用工场景标题:地点+岗位 / 草稿标题
- */
- resolveDraftSceneTitle(draft, fallback) {
- if (!draft) return fallback || '用工批次'
- const title = draft.title && draft.title !== '用工草稿' ? draft.title : ''
- if (title) return title
- const loc = draft.workLocation && draft.workLocation !== '待补充' ? draft.workLocation : ''
- const type = draft.workType && draft.workType !== '待补充' ? draft.workType : ''
- const combined = `${loc}${type}`
- return combined || fallback || '用工批次'
- },
- buildQrBatch(draft, options = {}) {
- const draftId = options.draftId
- || (draft && (draft.draftId != null ? draft.draftId : (draft.detail && draft.detail.id)))
- || null
- const batchId = (draft && draft.draftNo) || (draftId != null ? `draft_${draftId}` : '')
- const sceneTitle = this.resolveDraftSceneTitle(draft, options.schemeTitle)
- const workerCount = draft && draft.workerCount != null ? Number(draft.workerCount) : 0
- const subtitle = batchId ? `${sceneTitle} ${batchId}` : sceneTitle
- const enterpriseName = (this.enterprise && this.enterprise.name) || ''
- const scheme = options.scheme || (draft && draft.confirmedPlan) || null
- const qrCodeUrl = options.qrCodeUrl || pickDraftQrCodeUrl(draft) || ''
- const qrToken = options.qrToken
- || pickDraftQrToken(draft)
- || options.orderId
- || (draft && draft.orderId)
- || ''
- const offer = buildJobOfferFromDraft(draft, {
- batchId,
- draftId,
- scheme,
- schemeTitle: options.schemeTitle || (scheme && scheme.title),
- enterpriseName,
- orderId: options.orderId || (draft && draft.orderId) || '',
- qrToken,
- scene: qrToken || options.scene || (draft && draft.scene) || ''
- })
- saveJobOffer(offer)
- return Object.assign({}, BATCH_QR, {
- modalTitle: '方案已确认',
- title: sceneTitle,
- batchId,
- draftId: offer.draftId,
- orderId: offer.orderId || '',
- qrToken: offer.qrToken || qrToken || '',
- scene: offer.scene || offer.qrToken || qrToken || '',
- subtitle,
- qrCodeUrl,
- total: workerCount > 0 ? workerCount : BATCH_QR.total,
- registered: 0,
- hint: '分享给临时工扫码即可登记',
- shareLink: buildJobOfferPageUrl(offer)
- })
- },
- /**
- * 从草稿详情拉取最新 qrCodeUrl / qrToken,并回写 activeDraft
- */
- async refreshDraftQrFromDetail(draftId) {
- if (draftId == null) return { qrCodeUrl: '', qrToken: '' }
- try {
- const detail = await getDraftDetail(draftId, { showError: false })
- if (!detail || detail.id == null) return { qrCodeUrl: '', qrToken: '' }
- const qrCodeUrl = pickDraftQrCodeUrl(detail)
- const qrToken = pickDraftQrToken(detail)
- const card = mapDraftDetailToCard(detail)
- const prev = this.activeDraft
- if (prev && prev.draftId === detail.id) {
- const merged = Object.assign({}, prev, card, {
- qrCodeUrl,
- qrToken,
- scene: qrToken || prev.scene || '',
- confirmedPlan: prev.confirmedPlan || card.confirmedPlan,
- confirmedPlanTitle: prev.confirmedPlanTitle || card.confirmedPlanTitle,
- costPlans: prev.costPlans || card.costPlans
- })
- this.onDraftUpdated(merged, { sinkToBottom: false })
- }
- return { qrCodeUrl, qrToken }
- } catch (e) {
- return { qrCodeUrl: '', qrToken: '' }
- }
- },
- /**
- * 确认方案后在对话框追加二维码卡片(同 draft 已有则不再追加)
- */
- appendQrCardMessage(batch) {
- if (!batch) return
- const draftId = batch.draftId
- if (draftId != null) {
- const exists = this.messages.some((m) => m && m.type === 'qr' && m.draftId === draftId)
- if (exists) return
- }
- this.messages.push({
- type: 'qr',
- role: 'ai',
- msgKey: this.nextLocalMsgKey(),
- draftId: draftId != null ? draftId : null,
- batch: Object.assign({}, batch)
- })
- this.ensureChatBottom()
- },
- syncQrCardMessage(batch) {
- if (!batch || batch.draftId == null) return
- for (let i = this.messages.length - 1; i >= 0; i--) {
- const m = this.messages[i]
- if (m && m.type === 'qr' && m.draftId === batch.draftId) {
- this.$set(this.messages, i, Object.assign({}, m, {
- batch: Object.assign({}, batch)
- }))
- return
- }
- }
- },
- qrImageUrlByIndex(idx) {
- const msg = this.messages[idx]
- if (!msg || msg.type !== 'qr' || !msg.batch) return ''
- const raw = msg.batch.qrCodeUrl || msg.batch.qr_code_url || ''
- return resolveApiAssetUrl(raw)
- },
- qrSubtitleByIndex(idx) {
- const msg = this.messages[idx]
- if (!msg || !msg.batch) return ''
- return msg.batch.subtitle || msg.batch.title || ''
- },
- qrHintByIndex(idx) {
- const msg = this.messages[idx]
- if (!msg || !msg.batch) return '分享给临时工扫码即可登记'
- return msg.batch.hint || '分享给临时工扫码即可登记'
- },
- openQrByIndex(idx) {
- const msg = this.messages[idx]
- if (!msg || msg.type !== 'qr' || !msg.batch) return
- this.qrBatch = Object.assign({}, msg.batch)
- this.showQR()
- },
- openProgressByQrIndex(idx) {
- const msg = this.messages[idx]
- if (!msg || msg.type !== 'qr') return
- const draftId = msg.draftId
- || (msg.batch && msg.batch.draftId)
- this.openProgressDetail(draftId)
- },
- /**
- * AI 对话 next_action=show_order_qrcode:
- * 同草稿只执行一次:写确认文案 + 二维码卡,草稿卡原地标已确认(不沉底)
- */
- async showOrderConfirmFromChat(cardMeta) {
- const payload = parseChatCardPayload(cardMeta && cardMeta.cardPayload)
- const draftId = (cardMeta && cardMeta.relatedDraftId != null)
- ? cardMeta.relatedDraftId
- : (payload && (payload.draft_id != null ? payload.draft_id : payload.draftId))
- if (this.isOrderConfirmHandled(draftId)) return
- let draft = null
- if (this.activeDraft && String(this.activeDraft.draftId) === String(draftId)) {
- draft = this.activeDraft
- } else if (draftId != null) {
- for (let i = this.messages.length - 1; i >= 0; i--) {
- const msg = this.messages[i]
- if (msg && msg.type === 'draft' && String(msg.draftId) === String(draftId) && msg.draft) {
- draft = msg.draft
- break
- }
- }
- }
- if (!draft && draftId != null) {
- try {
- const detail = await getDraftDetail(draftId, { showError: false })
- if (detail) draft = mapDraftDetailToCard(detail)
- } catch (e) {
- // ignore
- }
- }
- const orderId = (payload && (payload.order_id != null ? payload.order_id : payload.orderId))
- || (draft && draft.orderId)
- || ''
- const title = (payload && payload.title)
- || (draft && draft.title)
- || (draft && draft.confirmedPlanTitle)
- || ''
- let qrCodeUrl = (payload && (payload.qr_code_url || payload.qrCodeUrl))
- || pickDraftQrCodeUrl(draft)
- || ''
- let qrToken = (payload && (payload.qr_token || payload.qrToken))
- || pickDraftQrToken(draft)
- || ''
- const scene = qrToken || orderId || ''
- this.qrBatch = this.buildQrBatch(draft, {
- draftId,
- scheme: draft && draft.confirmedPlan,
- schemeTitle: title,
- qrCodeUrl,
- orderId,
- qrToken,
- scene
- })
- if (draftId != null) {
- const fromDetail = await this.refreshDraftQrFromDetail(draftId)
- if (fromDetail && fromDetail.qrCodeUrl) {
- qrCodeUrl = fromDetail.qrCodeUrl
- this.$set(this.qrBatch, 'qrCodeUrl', fromDetail.qrCodeUrl)
- }
- if (fromDetail && fromDetail.qrToken) {
- qrToken = fromDetail.qrToken
- this.$set(this.qrBatch, 'qrToken', fromDetail.qrToken)
- this.$set(this.qrBatch, 'scene', fromDetail.qrToken)
- }
- }
- this.markOrderConfirmHandled(draftId)
- if (draft && draftId != null) {
- this.onDraftUpdated(Object.assign({}, draft, {
- status: 'confirmed',
- orderId,
- qrToken,
- qrCodeUrl,
- scene: qrToken || orderId || ''
- }), { sinkToBottom: false })
- }
- this.closeAll()
- this.messages.push({
- type: 'text',
- role: 'ai',
- msgKey: this.nextLocalMsgKey(),
- content: '方案已确认。请将下方二维码分享给工人扫码登记。'
- })
- this.appendQrCardMessage(this.qrBatch)
- this.ensureChatBottom()
- },
- async confirmPlan(payload) {
- const scheme = (payload && payload.scheme) || null
- const result = (payload && payload.result) || {}
- const draft = this.activeDraft
- const orderId = result.orderId || result.order_id || ''
- let qrCodeUrl = pickDraftQrCodeUrl(draft)
- let qrToken = pickDraftQrToken(result) || pickDraftQrToken(draft) || ''
- const tags = (scheme && Array.isArray(scheme.compliance) ? scheme.compliance : [])
- .filter(Boolean)
- const draftId = draft && draft.draftId
- const scene = qrToken || orderId || ''
- this.confirmInfo = {
- title: (scheme && scheme.title) || (payload && payload.schemeCode) || '',
- code: (payload && payload.schemeCode) || (scheme && scheme.code) || '',
- total: (scheme && scheme.total) || '',
- avgCost: (scheme && scheme.avgCost) || '',
- tagsText: tags.join('、'),
- orderId,
- qrToken,
- qrCodeUrl,
- draftId
- }
- this.qrBatch = this.buildQrBatch(draft, {
- scheme,
- schemeTitle: scheme && scheme.title,
- qrCodeUrl,
- orderId,
- qrToken,
- scene
- })
- if (draft && draftId != null) {
- this.onDraftUpdated(Object.assign({}, draft, {
- orderId,
- qrToken,
- qrCodeUrl,
- scene,
- status: 'confirmed',
- confirmedPlan: (scheme && {
- id: scheme.id || scheme.code,
- code: scheme.code,
- title: scheme.title,
- total: scheme.total,
- avgCost: scheme.avgCost,
- rows: scheme.rows,
- breakdown: scheme.breakdown,
- compliance: scheme.compliance,
- raw: scheme.raw
- }) || draft.confirmedPlan
- }))
- }
- this.closeAll()
- // 拉最新二维码 / qrToken 后插入对话
- if (draftId != null) {
- const fromDetail = await this.refreshDraftQrFromDetail(draftId)
- if (fromDetail && fromDetail.qrCodeUrl) {
- qrCodeUrl = fromDetail.qrCodeUrl
- this.$set(this.qrBatch, 'qrCodeUrl', fromDetail.qrCodeUrl)
- this.$set(this.confirmInfo, 'qrCodeUrl', fromDetail.qrCodeUrl)
- }
- if (fromDetail && fromDetail.qrToken) {
- qrToken = fromDetail.qrToken
- this.$set(this.qrBatch, 'qrToken', fromDetail.qrToken)
- this.$set(this.qrBatch, 'scene', fromDetail.qrToken)
- this.$set(this.confirmInfo, 'qrToken', fromDetail.qrToken)
- }
- }
- this.messages.push({
- type: 'text',
- role: 'ai',
- msgKey: this.nextLocalMsgKey(),
- content: '方案已确认。请将下方二维码分享给工人扫码登记。'
- })
- this.markOrderConfirmHandled(draftId)
- this.appendQrCardMessage(this.qrBatch)
- setTimeout(() => { this.modal = 'confirm' }, 400)
- },
- async showQR() {
- const draftId = (this.qrBatch && this.qrBatch.draftId)
- || (this.confirmInfo && this.confirmInfo.draftId)
- || (this.activeDraft && this.activeDraft.draftId)
- let qrCodeUrl = pickDraftQrCodeUrl(this.qrBatch)
- || pickDraftQrCodeUrl(this.activeDraft)
- || (this.confirmInfo && this.confirmInfo.qrCodeUrl)
- || ''
- let qrToken = pickDraftQrToken(this.qrBatch)
- || pickDraftQrToken(this.activeDraft)
- || (this.confirmInfo && this.confirmInfo.qrToken)
- || ''
- if (draftId != null) {
- const fromDetail = await this.refreshDraftQrFromDetail(draftId)
- if (fromDetail && fromDetail.qrCodeUrl) qrCodeUrl = fromDetail.qrCodeUrl
- if (fromDetail && fromDetail.qrToken) qrToken = fromDetail.qrToken
- }
- if (!this.qrBatch || !this.qrBatch.subtitle) {
- this.qrBatch = this.buildQrBatch(this.activeDraft, {
- schemeTitle: this.confirmInfo && this.confirmInfo.title,
- draftId,
- qrCodeUrl,
- qrToken
- })
- } else {
- this.$set(this.qrBatch, 'qrCodeUrl', qrCodeUrl)
- if (qrToken) {
- this.$set(this.qrBatch, 'qrToken', qrToken)
- this.$set(this.qrBatch, 'scene', qrToken)
- }
- if (draftId != null && this.qrBatch.draftId == null) {
- this.$set(this.qrBatch, 'draftId', draftId)
- }
- }
- this.syncQrCardMessage(this.qrBatch)
- this.modal = 'qr'
- },
- async openDraftQr(payload) {
- let draft = this.activeDraft
- const payloadDraftId = payload && payload.draftId
- if (payloadDraftId != null) {
- if (!draft || draft.draftId !== payloadDraftId) {
- if (this.activeDraft && this.activeDraft.draftId === payloadDraftId) {
- draft = this.activeDraft
- } else {
- for (let i = this.messages.length - 1; i >= 0; i--) {
- const msg = this.messages[i]
- if (msg && msg.type === 'draft' && msg.draftId === payloadDraftId && msg.draft) {
- draft = msg.draft
- break
- }
- }
- }
- if (draft) this.activeDraft = draft
- }
- }
- const draftId = (draft && draft.draftId) || payloadDraftId
- let qrCodeUrl = pickDraftQrCodeUrl(draft)
- let qrToken = pickDraftQrToken(draft)
- if (draftId != null) {
- const fromDetail = await this.refreshDraftQrFromDetail(draftId)
- if (fromDetail && fromDetail.qrCodeUrl) qrCodeUrl = fromDetail.qrCodeUrl
- if (fromDetail && fromDetail.qrToken) qrToken = fromDetail.qrToken
- }
- this.qrBatch = this.buildQrBatch(this.activeDraft || draft, {
- scheme: (this.activeDraft || draft) && (this.activeDraft || draft).confirmedPlan,
- schemeTitle: (this.activeDraft || draft) && (this.activeDraft || draft).confirmedPlanTitle,
- qrCodeUrl,
- qrToken
- })
- this.modal = 'qr'
- },
- /**
- * 供首页 onShareAppMessage 读取
- * path 参数名仍为 scene,值为 qrToken
- */
- getShareAppMessage() {
- const draftId = (this.qrBatch && this.qrBatch.draftId)
- || (this.activeDraft && this.activeDraft.draftId)
- || ''
- const orderId = (this.qrBatch && this.qrBatch.orderId)
- || (this.activeDraft && this.activeDraft.orderId)
- || (this.confirmInfo && this.confirmInfo.orderId)
- || ''
- const qrToken = (this.qrBatch && this.qrBatch.qrToken)
- || (this.activeDraft && this.activeDraft.qrToken)
- || (this.confirmInfo && this.confirmInfo.qrToken)
- || ''
- const scene = qrToken
- || (this.qrBatch && this.qrBatch.scene)
- || (this.activeDraft && this.activeDraft.scene)
- || orderId
- || ''
- return buildJobOfferShareMessage({ draftId, orderId, scene, qrToken })
- },
- openQrProgress() {
- const draftId = (this.qrBatch && this.qrBatch.draftId)
- || (this.activeDraft && this.activeDraft.draftId)
- || (this.confirmInfo && this.confirmInfo.draftId)
- this.openProgressDetail(draftId)
- },
- onQrProgressLoaded(payload) {
- if (!payload || !this.qrBatch) return
- if (payload.registered != null) {
- this.$set(this.qrBatch, 'registered', payload.registered)
- }
- if (payload.total != null) {
- this.$set(this.qrBatch, 'total', payload.total)
- }
- this.syncQrCardMessage(this.qrBatch)
- },
- openProgressOverview() {
- if (!this.currentConversationId) {
- this.toast('请先开启新对话')
- return
- }
- this.openSheet('progressOverview')
- },
- collectCostDraftMetas() {
- const metas = []
- const seen = {}
- const pushMeta = (draftId, title, workerCount) => {
- if (draftId == null || draftId === '') return
- const key = String(draftId)
- if (seen[key]) return
- seen[key] = true
- metas.push({
- draftId,
- title: title || `用工草稿 #${draftId}`,
- workerCount: workerCount != null ? Number(workerCount) : null
- })
- }
- for (let i = 0; i < this.messages.length; i++) {
- const msg = this.messages[i]
- if (!msg || msg.type !== 'draft' || msg.draftId == null) continue
- const d = msg.draft || {}
- pushMeta(msg.draftId, d.title, d.workerCount)
- }
- if (this.activeDraft && this.activeDraft.draftId != null) {
- pushMeta(
- this.activeDraft.draftId,
- this.activeDraft.title,
- this.activeDraft.workerCount
- )
- }
- return metas
- },
- openConversationCost() {
- if (!this.currentConversationId) {
- this.toast('请先开启新对话')
- return
- }
- this.costDraftMetas = this.collectCostDraftMetas()
- this.openSheet('cost')
- },
- async onConversationCostConfirm(payload) {
- const draftId = payload && payload.draftId
- if (draftId == null) {
- this.confirmPlan(payload)
- return
- }
- let draft = null
- if (this.activeDraft && this.activeDraft.draftId === draftId) {
- draft = this.activeDraft
- } else {
- for (let i = this.messages.length - 1; i >= 0; i--) {
- const msg = this.messages[i]
- if (msg && msg.type === 'draft' && msg.draftId === draftId && msg.draft) {
- draft = msg.draft
- break
- }
- }
- }
- if (!draft) {
- try {
- const detail = await getDraftDetail(draftId, { showError: false })
- if (detail) draft = mapDraftDetailToCard(detail)
- } catch (e) {
- // ignore
- }
- }
- if (draft) {
- this.activeDraft = draft
- this.onDraftUpdated(Object.assign({}, draft, {
- status: 'confirmed',
- selectedSchemeCode: (payload && payload.schemeCode) || draft.selectedSchemeCode,
- confirmedPlan: (payload && payload.scheme) || draft.confirmedPlan
- }), { sinkToBottom: false })
- }
- this.confirmPlan(payload)
- },
- openProgressDetail(draftId) {
- if (draftId == null || draftId === '') {
- showToast('缺少草稿信息,无法查看进度')
- return
- }
- this.progressDraftId = draftId
- this.openSheet('progress')
- },
- showPayment() {
- this.closeAll()
- setTimeout(() => { this.modal = 'payment' }, 300)
- },
- showPaySuccess() {
- this.modal = 'paySuccess'
- },
- logout() {
- store.logout()
- uni.reLaunch({ url: '/packageA/auth/login' })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .chat-page {
- height: 100%;
- overflow: hidden;
- background: $fe-bg;
- }
- .chat-header {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- z-index: 99;
- background: #ffffff;
- border-bottom: 1rpx solid $fe-border-light;
- box-sizing: border-box;
- }
- .chat-header__row {
- height: $fe-h-page-bar;
- display: flex;
- flex-direction: row;
- align-items: center;
- flex-wrap: nowrap;
- padding: 0 24rpx;
- box-sizing: border-box;
- }
- .chat-header__title {
- flex: 1;
- min-width: 0;
- margin: 0 12rpx;
- font-weight: 700;
- font-size: 34rpx;
- color: $fe-foreground;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- line-height: $fe-h-page-bar;
- }
- .chat-header__actions {
- display: flex;
- flex-direction: row;
- align-items: center;
- flex-wrap: nowrap;
- flex-shrink: 0;
- gap: 4rpx;
- }
- .fe-nav-icon {
- font-size: 36rpx;
- line-height: 1;
- color: $fe-gray-500;
- }
- .fe-nav-icon--plus {
- font-size: 44rpx;
- font-weight: 300;
- color: $fe-gray-600;
- }
- .chat-area {
- position: fixed;
- top: $fe-h-page-bar;
- left: 0;
- right: 0;
- bottom: calc(#{$fe-h-input-bar} + #{$fe-h-quick-bar} + #{$fe-h-safe-bottom});
- box-sizing: border-box;
- }
- .chat-footer {
- position: fixed;
- left: 0;
- right: 0;
- bottom: 0;
- z-index: 99;
- background: rgba(255, 255, 255, 0.92);
- border-top: 1rpx solid $fe-border-light;
- padding-bottom: $fe-h-safe-bottom;
- box-sizing: border-box;
- }
- .fe-input-bar--embedded {
- position: relative;
- left: auto;
- right: auto;
- bottom: auto;
- border-top: 1rpx solid $fe-border-light;
- background: transparent;
- padding-bottom: 20rpx;
- }
- .fe-input-bar--disabled {
- opacity: 0.55;
- }
- .fe-input-bar--disabled .fe-input-bar__field {
- background: $fe-gray-100;
- color: $fe-gray-400;
- }
- .fe-input-bar--disabled .fe-input-bar__btn {
- opacity: 0.7;
- }
- .chat-area__inner {
- padding: 32rpx;
- padding-bottom: 48rpx;
- }
- .chat-msg-wrap {
- width: 100%;
- }
- .chat-status {
- display: flex;
- justify-content: center;
- padding: 24rpx 0 8rpx;
- }
- .chat-status--top {
- padding: 8rpx 0 24rpx;
- }
- .chat-status__text {
- font-size: 24rpx;
- color: $fe-gray-500;
- }
- .chat-status__text--muted {
- color: $fe-gray-400;
- }
- .chat-bottom-anchor {
- height: 2rpx;
- width: 100%;
- }
- .sidebar-head {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 28rpx 28rpx 20rpx;
- border-bottom: 1rpx solid $fe-border-light;
- }
- .sidebar-head__title {
- font-size: 30rpx;
- font-weight: 700;
- }
- .sidebar-head__add {
- width: 64rpx;
- height: 64rpx;
- border-radius: $fe-radius-sm;
- background: $fe-primary;
- color: #fff;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 32rpx;
- }
- .sidebar-list {
- height: calc(100% - 120rpx);
- }
- .sidebar-status {
- padding: 48rpx 28rpx;
- text-align: center;
- }
- .sidebar-status__text {
- font-size: 26rpx;
- color: $fe-gray-500;
- }
- .sidebar-status--action {
- cursor: pointer;
- }
- .sidebar-status__text--action {
- color: $fe-primary;
- font-weight: 600;
- }
- .chat-empty {
- min-height: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 80rpx 48rpx;
- text-align: center;
- box-sizing: border-box;
- }
- .chat-empty__icon {
- width: 120rpx;
- height: 120rpx;
- border-radius: 50%;
- background: $fe-primary-bg;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 56rpx;
- margin-bottom: 32rpx;
- }
- .chat-empty__title {
- font-size: 36rpx;
- font-weight: 700;
- color: $fe-foreground;
- margin-bottom: 48rpx;
- line-height: 1.5;
- max-width: 520rpx;
- }
- .chat-empty__btn {
- padding: 24rpx 64rpx;
- border-radius: $fe-radius-full;
- background: $fe-primary;
- color: #fff;
- font-size: 30rpx;
- font-weight: 600;
- }
- /* H5:避开浏览器/WebView 顶栏与安全区,避免头部被遮住 */
- /* #ifdef H5 */
- .chat-header {
- padding-top: constant(safe-area-inset-top);
- padding-top: env(safe-area-inset-top);
- z-index: 200;
- }
- .chat-header__row {
- height: 96rpx;
- padding: 0 32rpx;
- }
- .chat-header__title {
- font-size: 32rpx;
- line-height: 96rpx;
- }
- .chat-area {
- top: calc(96rpx + constant(safe-area-inset-top));
- top: calc(96rpx + env(safe-area-inset-top));
- }
- .fe-sidebar {
- top: calc(96rpx + constant(safe-area-inset-top));
- top: calc(96rpx + env(safe-area-inset-top));
- }
- /* #endif */
- .fe-biz-card--qr {
- border-left: 6rpx solid $fe-primary;
- }
- .fe-qr-card__subtitle {
- display: block;
- font-size: 24rpx;
- color: $fe-muted;
- margin-bottom: 20rpx;
- line-height: 1.4;
- }
- .fe-qr-card__img {
- display: block;
- width: 360rpx;
- height: 360rpx;
- margin: 0 auto 20rpx;
- background: #fff;
- }
- .fe-qr-card__empty {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 360rpx;
- height: 360rpx;
- margin: 0 auto 20rpx;
- background: $fe-primary-bg;
- border-radius: 16rpx;
- }
- .fe-qr-card__empty-text {
- font-size: 24rpx;
- color: $fe-muted;
- text-align: center;
- padding: 0 24rpx;
- }
- .fe-qr-card__hint {
- display: block;
- font-size: 24rpx;
- color: $fe-muted;
- text-align: center;
- margin-bottom: 20rpx;
- line-height: 1.4;
- }
- </style>
|