chat.vue 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  1. <template>
  2. <view class="container" :class="{ 'panel-active': activePanel !== 'none' }">
  3. <!-- 状态栏占位(微信小程序用 JS 获取真实高度)-->
  4. <view class="status-bar" :style="{ height: statusBarHeight + 'px' }"></view>
  5. <!-- 导航栏 -->
  6. <view class="nav-bar">
  7. <view class="back-btn" @click="goBack">
  8. <text class="back-arrow">‹</text>
  9. </view>
  10. <view class="nav-center">
  11. <text class="nav-title-text">{{ sessionUserName || '在线咨询' }}</text>
  12. <view class="online-dot"></view>
  13. </view>
  14. <view class="nav-right"></view>
  15. </view>
  16. <!-- 聊天内容区域 -->
  17. <scroll-view
  18. class="chat-body"
  19. scroll-y
  20. :scroll-into-view="lastMessageId"
  21. :style="{ height: chatBodyHeight }"
  22. :show-scrollbar="false"
  23. :enhanced="true"
  24. >
  25. <view class="message-list">
  26. <!-- 加载中 -->
  27. <view v-if="loading" class="tip-row">
  28. <text class="tip-text">加载中...</text>
  29. </view>
  30. <!-- 静态初始卡片区(每次进入均显示) -->
  31. <view v-if="!loading" class="init-cards">
  32. <!-- 测评卡片(动态渲染,内容来自 URL 参数)-->
  33. <view v-if="chatType === 'assessment'" class="msg-row left">
  34. <image :src="waiterAvatar" class="avatar" mode="aspectFill"></image>
  35. <view class="msg-content assessment-card-msg">
  36. <view class="card-left">
  37. <image
  38. :src="assessmentCover || '/static/images/assess_cover.svg'"
  39. class="a-cover"
  40. mode="aspectFill"
  41. ></image>
  42. </view>
  43. <view class="card-right">
  44. <text class="a-title">{{ assessmentTitle || '测评咨询' }}</text>
  45. <view class="a-tags">
  46. <text v-if="assessmentLevel" class="a-tag">{{ assessmentLevel }}</text>
  47. <text class="a-tag">职业技能测评</text>
  48. </view>
  49. <text class="a-price">{{ assessmentPrice ? '¥' + assessmentPrice : '咨询获取' }}</text>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 培训报名卡片 -->
  54. <view v-else-if="chatType === 'training'" class="msg-row left">
  55. <image :src="waiterAvatar" class="avatar" mode="aspectFill"></image>
  56. <view class="msg-content training-reg-card shadow">
  57. <view class="t-card-header">
  58. <text class="t-card-title">{{ trainingTitle || '审计员线下培训' }}</text>
  59. <text class="t-card-subtitle">线下培训 | 职业能力提升</text>
  60. </view>
  61. <view class="t-card-body">
  62. <view class="t-item"><text class="t-label">主办单位:</text><text class="t-val">AAAAA单位</text></view>
  63. <view class="t-item"><text class="t-label">培训时间:</text><text class="t-val">2025-12-12/13/14</text></view>
  64. </view>
  65. <view class="t-card-footer">
  66. <button class="reg-btn" @click="confirmReg">确认报名</button>
  67. </view>
  68. </view>
  69. </view>
  70. <!-- 招聘卡片(默认) -->
  71. <view v-else class="msg-row left">
  72. <image :src="waiterAvatar" class="avatar" mode="aspectFill"></image>
  73. <view class="msg-content job-card-msg">
  74. <view class="card-header">
  75. <view class="ch-left">
  76. <text class="card-title">{{ jobName || '审计员' }}</text>
  77. <text class="urgent-tag">急招</text>
  78. </view>
  79. <text class="card-salary">{{ salaryRange || '13K-23K' }}</text>
  80. </view>
  81. <view class="card-tags">
  82. <text class="c-tag">实习</text>
  83. <text class="c-tag">五险一金</text>
  84. <text class="c-tag">985</text>
  85. </view>
  86. <view class="card-meta">
  87. <view class="m-item"><image src="/static/icons/user.svg" class="m-icon"></image><text>招录 1 人</text></view>
  88. <view class="m-item"><image src="/static/icons/time.svg" class="m-icon"></image><text>截止时间:2025-12-12 24:00</text></view>
  89. </view>
  90. <view class="card-company">
  91. <image src="/static/images/logo1.png" class="c-logo" mode="aspectFit"></image>
  92. <view class="c-info">
  93. <text class="c-name">{{ companyName || '华财仁合' }}</text>
  94. <image src="/static/icons/verified.svg" class="v-icon"></image>
  95. </view>
  96. <text class="c-loc">{{ workCity ? '上海市·' + workCity : '上海市·黄浦区' }}</text>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <!-- 无后续消息提示(不覆盖初始卡片)-->
  102. <view v-if="!loading && messages.length === 0" class="tip-row">
  103. <text class="tip-text">快发一条消息开始吧~</text>
  104. </view>
  105. <!-- 消息列表(全部来自真实API) -->
  106. <block v-for="(msg, index) in messages" :key="msg.id || index">
  107. <!-- 每隔5分钟显示时间戳 -->
  108. <view v-if="shouldShowTime(msg, index)" class="time-stamp-row">
  109. <text class="time-stamp">{{ formatTime(msg.sendTime) }}</text>
  110. </view>
  111. <view
  112. :id="'msg-' + (msg.id || index)"
  113. class="msg-row"
  114. :class="msg.senderType === 1 ? 'right' : 'left'"
  115. >
  116. <image
  117. v-if="msg.senderType !== 1"
  118. :src="resolveAvatarUrl(msg.senderAvatar) || waiterAvatar"
  119. class="avatar"
  120. mode="aspectFill"
  121. ></image>
  122. <!-- 文本消息 -->
  123. <view
  124. v-if="msg.msgType === 'text'"
  125. class="msg-content text-msg"
  126. :class="msg.senderType === 1 ? 'user-bubble' : 'shadow'"
  127. >{{ msg.content }}</view>
  128. <!-- 图片消息 -->
  129. <view v-else-if="msg.msgType === 'image'" class="msg-content img-msg">
  130. <image
  131. :src="msg.fileUrl"
  132. mode="widthFix"
  133. class="chat-img"
  134. @click="previewImg(msg.fileUrl)"
  135. ></image>
  136. </view>
  137. <!-- 文件消息 -->
  138. <view v-else-if="msg.msgType === 'file'" class="msg-content file-msg shadow">
  139. <text class="file-icon-txt">📄</text>
  140. <view class="file-info">
  141. <text class="file-name">{{ msg.fileName || '文件' }}</text>
  142. <text class="file-size">{{ formatFileSize(msg.fileSize) }}</text>
  143. </view>
  144. </view>
  145. <view v-else-if="msg.msgType === 'order_card'" class="msg-content deposit-card">
  146. <view class="deposit-header">
  147. <view class="d-header-left">
  148. <text class="d-title">您有一笔待付款项</text>
  149. <text class="d-subtitle">项目费用及定金支付通知</text>
  150. </view>
  151. <view v-if="!msg.isPaid && msg.countdown > 0" class="d-countdown">
  152. <text class="c-time">{{ msg.countdown }}s</text>
  153. <text class="c-txt">后取消</text>
  154. </view>
  155. <view v-if="msg.isPaid" class="d-paid-tag">已支付</view>
  156. </view>
  157. <view class="deposit-body">
  158. <view class="d-row">
  159. <text class="label">项目名称:</text>
  160. <text class="val">{{ msg.payload && msg.payload.name || '—' }}</text>
  161. </view>
  162. <view class="d-row">
  163. <text class="label">支付金额:</text>
  164. <text class="price">¥{{ formatAmount(msg.payload && msg.payload.amount) }}</text>
  165. </view>
  166. </view>
  167. <view
  168. class="deposit-action"
  169. :class="{ paid: msg.isPaid }"
  170. @click="handlePay(msg)"
  171. >{{ msg.isPaid ? '已支付' : '立即支付' }}</view>
  172. </view>
  173. <!-- 客服推送的岗位卡片 -->
  174. <view v-else-if="msg.msgType === 'job_card'" class="msg-content api-job-card shadow">
  175. <view class="jc-header">
  176. <text class="jc-title">{{ msg.payload && msg.payload.title || '岗位推荐' }}</text>
  177. <text class="jc-salary">{{ msg.payload && msg.payload.salaryRange || '' }}</text>
  178. </view>
  179. <text class="jc-city" v-if="msg.payload && msg.payload.workCity">{{ msg.payload.workCity }}</text>
  180. </view>
  181. <!-- 系统消息 -->
  182. <view v-else-if="msg.senderType === 3" class="system-msg">
  183. <text>{{ msg.content }}</text>
  184. </view>
  185. <!-- 其他未知类型 -->
  186. <view v-else class="msg-content text-msg shadow">{{ msg.content || '[消息]' }}</view>
  187. <image
  188. v-if="msg.senderType === 1"
  189. :src="resolveAvatarUrl(msg.senderAvatar) || userAvatarUrl"
  190. class="avatar"
  191. mode="aspectFill"
  192. ></image>
  193. </view>
  194. </block>
  195. <view id="bottom-anchor" style="height: 40rpx;"></view>
  196. </view>
  197. </scroll-view>
  198. <!-- 底部输入栏 -->
  199. <view class="footer-wrap">
  200. <view class="input-bar">
  201. <image
  202. :src="inputMode === 'text' ? '/static/icons/audio_thin.svg' : '/static/icons/keyboard.svg'"
  203. class="bar-icon"
  204. mode="aspectFit"
  205. @click="toggleInputMode"
  206. ></image>
  207. <view class="center-area">
  208. <input
  209. v-if="inputMode === 'text'"
  210. v-model="inputValue"
  211. class="chat-input"
  212. placeholder="请输入内容..."
  213. confirm-type="send"
  214. @confirm="sendMessage"
  215. @focus="onInputFocus"
  216. />
  217. <view v-else class="voice-press-btn" @touchstart="onVoiceStart" @touchend="onVoiceEnd">按住 说话</view>
  218. </view>
  219. <image
  220. src="/static/icons/emoji_thin.svg"
  221. class="bar-icon"
  222. :class="{ active: activePanel === 'emoji' }"
  223. mode="aspectFit"
  224. @click="togglePanel('emoji')"
  225. ></image>
  226. <image
  227. :src="activePanel === 'plus' ? '/static/icons/plus_active.svg' : '/static/icons/plus_thin.svg'"
  228. class="bar-icon"
  229. mode="aspectFit"
  230. @click="togglePanel('plus')"
  231. ></image>
  232. </view>
  233. <view class="panel-section" :class="{ show: activePanel !== 'none' }">
  234. <view class="emoji-panel" v-if="activePanel === 'emoji'">
  235. <scroll-view scroll-y class="emoji-scroll">
  236. <view class="emoji-grid">
  237. <text v-for="e in emojiList" :key="e" class="emoji-item" @click="addEmoji(e)">{{e}}</text>
  238. </view>
  239. </scroll-view>
  240. </view>
  241. <view class="plus-panel" v-if="activePanel === 'plus'">
  242. <view class="panel-item" @click="chooseImage">
  243. <view class="icon-box shadow-sm">
  244. <image src="/static/icons/album_color.svg" mode="aspectFit"></image>
  245. </view>
  246. <text>相册</text>
  247. </view>
  248. <view class="panel-item" @click="sendMockOrderCard">
  249. <view class="icon-box shadow-sm">
  250. <image src="/static/icons/order_color.svg" mode="aspectFit"></image>
  251. </view>
  252. <text>订单</text>
  253. </view>
  254. </view>
  255. </view>
  256. </view>
  257. </view>
  258. </template>
  259. <script setup lang="js">
  260. import { ref, computed, nextTick } from 'vue';
  261. import { onLoad, onUnload } from '@dcloudio/uni-app';
  262. import { getChatHistory, sendTextMessage, sendImageMessage, markChatRead, payOrderCard, createOrderByOrderCard, createWxPayOrder, autoCreateOrderCard } from '../../api/message.js';
  263. import { getStudent } from '../../api/student.js';
  264. import { connectChat, sendTextByWs, disconnectChat, subscribe, unsubscribe, generateMsgNo, isSocketConnected } from '../../utils/chatSocket.js';
  265. import { BASE_URL } from '../../utils/request.js';
  266. // ---- 状态 ----
  267. const loading = ref(true);
  268. const messages = ref([]);
  269. const inputValue = ref('');
  270. const inputMode = ref('text');
  271. const activePanel = ref('none');
  272. const lastMessageId = ref('bottom-anchor');
  273. const statusBarHeight = ref(20); // 状态栏高度,微信小程序动态获取
  274. // ---- 会话信息(从URL参数传入)----
  275. const sessionId = ref(null);
  276. const fromUserId = ref(null);
  277. const sessionUserName = ref('');
  278. const jobName = ref('');
  279. const chatType = ref('job');
  280. const trainingTitle = ref('');
  281. // ---- 测评信息(咨询时从URL参数传入)----
  282. const assessmentTitle = ref('');
  283. const assessmentCover = ref('');
  284. const assessmentLevel = ref('');
  285. const assessmentId = ref('');
  286. const assessmentPrice = ref('');
  287. // ---- 岗位信息(咨询时从URL参数传入)----
  288. const positionId = ref(null);
  289. const salaryRange = ref('');
  290. const companyName = ref('');
  291. const workCity = ref('');
  292. // ---- 头像 ----
  293. const waiterAvatar = ref('/static/images/hr_avatar.svg');
  294. // 将 OSS ID 或无效头像转为可访问的 URL
  295. function resolveAvatarUrl(url) {
  296. if (!url || url === '' || url === 'undefined') return '';
  297. const str = String(url).trim();
  298. // 已经是有效 HTTP URL(后端 ossService.selectUrlByIds 已转为真实 URL)
  299. if (str.startsWith('http://') || str.startsWith('https://')) return str;
  300. // 纯数字 → OSS 文件 URL(后端接口)
  301. if (/^\d+$/.test(str)) {
  302. return `${BASE_URL}/resource/oss/file/${str}`;
  303. }
  304. // 本地路径 → 空值
  305. if (str.startsWith('/static/')) return '';
  306. return str;
  307. }
  308. // 判断是否为有效的可访问URL
  309. function isValidAvatar(url) {
  310. if (!url || url === '' || url === 'undefined') return false;
  311. const str = String(url).trim();
  312. if (str.startsWith('/static/')) return false;
  313. // 纯数字是 OSS ID,不是可访问的图片 URL
  314. if (/^\d+$/.test(str)) return false;
  315. return true;
  316. }
  317. const userAvatarUrl = ref('/static/images/user_avatar.png');
  318. const emojiList = ['😀','😃','😄','😁','😆','😅','😂','🤣','😊','😇','🙂','🙃','😉','😌','😍','🥰','😘','😗','😙','😚','😋','😛','😝','😜','🤪','🤨','🧐','🤓','😎','🤩','🥳'];
  319. let wsSubId = null; // WebSocket 订阅 ID
  320. // ---- 生命周期 ----
  321. onLoad(async (options) => {
  322. // 获取状态栏高度(微信小程序中 env(safe-area-inset-top) 为0,需要通过 JS 获取)
  323. // #ifdef MP-WEIXIN
  324. try {
  325. const sysInfo = uni.getSystemInfoSync();
  326. statusBarHeight.value = sysInfo.statusBarHeight || 20;
  327. } catch (e) {}
  328. // #endif
  329. if (options.sessionId) sessionId.value = options.sessionId;
  330. if (options.fromUserId) fromUserId.value = options.fromUserId;
  331. if (options.userName) sessionUserName.value = decodeURIComponent(options.userName);
  332. if (options.jobName) jobName.value = decodeURIComponent(options.jobName);
  333. if (options.type) chatType.value = options.type;
  334. // 培训标题
  335. if (options.title) trainingTitle.value = decodeURIComponent(options.title || '');
  336. // 测评参数解析
  337. if (options.title && options.type === 'assessment') {
  338. assessmentTitle.value = decodeURIComponent(options.title || '');
  339. }
  340. if (options.cover) assessmentCover.value = decodeURIComponent(options.cover || '');
  341. if (options.level) assessmentLevel.value = decodeURIComponent(options.level || '');
  342. if (options.assessmentId) assessmentId.value = options.assessmentId;
  343. if (options.price) assessmentPrice.value = options.price;
  344. // 岗位参数解析
  345. if (options.positionId) positionId.value = options.positionId;
  346. if (options.salaryRange) salaryRange.value = decodeURIComponent(options.salaryRange);
  347. if (options.companyName) companyName.value = decodeURIComponent(options.companyName);
  348. if (options.workCity) workCity.value = decodeURIComponent(options.workCity);
  349. const storedInfo = uni.getStorageSync('userInfo') || {};
  350. // 用户头像:优先用存储的 avatarUrl,再尝试 avatar(可能是 OSS ID)
  351. const rawUserAvatar = storedInfo.avatarUrl || storedInfo.avatar || '/static/images/user_avatar.png';
  352. userAvatarUrl.value = resolveAvatarUrl(rawUserAvatar) || '/static/images/user_avatar.png';
  353. if (!fromUserId.value && storedInfo.studentId) fromUserId.value = storedInfo.studentId;
  354. if (!sessionId.value) {
  355. loading.value = false;
  356. uni.showToast({ title: '会话参数缺失', icon: 'none' });
  357. return;
  358. }
  359. await loadHistory();
  360. // 建立 WebSocket 连接,实时接收消息
  361. connectWebSocket();
  362. // 自动创建结算单(不管有没有历史消息,后端会防重复)
  363. if (chatType.value === 'assessment') {
  364. setTimeout(async () => {
  365. try {
  366. const userInfo = uni.getStorageSync('userInfo') || {};
  367. const res = await autoCreateOrderCard({
  368. sessionId: sessionId.value,
  369. studentId: userInfo.studentId || fromUserId.value,
  370. orderName: assessmentTitle.value || (jobName.value + '-测评服务费'),
  371. orderPrice: assessmentPrice.value || '0',
  372. orderType: '测评咨询'
  373. });
  374. if (res.code === 200 && res.data) {
  375. pushOrderCardMsg(res.data);
  376. } else {
  377. console.error('自动创建结算单失败:', res);
  378. }
  379. } catch (err) {
  380. console.error('自动创建结算单异常:', err);
  381. }
  382. }, 800);
  383. } else if (chatType.value === 'job' && positionId.value) {
  384. try {
  385. const { getAssessmentList } = require('../../api/assessment.js');
  386. const evalRes = await getAssessmentList({ positionId: positionId.value, pageNum: 1, pageSize: 1 });
  387. if (evalRes.code === 200 && evalRes.rows && evalRes.rows.length > 0) {
  388. const firstEval = evalRes.rows[0];
  389. // 🔴 关键修复:将岗位关联的第一个测评ID赋给assessmentId
  390. // 这样支付成功后写入的 storage key(audit_paid_${assessmentId})
  391. // 才能与 jobdetail/checkState 读取的 key 一致
  392. if (!assessmentId.value) {
  393. assessmentId.value = String(firstEval.id);
  394. console.log('[Chat] 岗位关联测评ID:', assessmentId.value);
  395. }
  396. setTimeout(async () => {
  397. try {
  398. const userInfo = uni.getStorageSync('userInfo') || {};
  399. const res = await autoCreateOrderCard({
  400. sessionId: sessionId.value,
  401. studentId: userInfo.studentId || fromUserId.value,
  402. orderName: (firstEval.evaluationName || jobName.value) + '-测评服务费',
  403. orderPrice: firstEval.price || assessmentPrice.value || '0',
  404. orderType: '岗位测评'
  405. });
  406. if (res.code === 200 && res.data) {
  407. pushOrderCardMsg(res.data);
  408. }
  409. } catch (err) { console.error('岗位结算单异常:', err); }
  410. }, 800);
  411. } else {
  412. console.log('[Chat] 该岗位无关联测评,不发送结算单');
  413. }
  414. } catch (e) {
  415. console.error('[Chat] 查询关联测评失败:', e);
  416. }
  417. }
  418. });
  419. let orderTimer = null;
  420. function startOrderTimer() {
  421. if (orderTimer) return;
  422. orderTimer = setInterval(() => {
  423. messages.value.forEach(m => {
  424. if (m.msgType === 'order_card' && !m.isPaid && m.countdown > 0) {
  425. m.countdown--;
  426. }
  427. });
  428. }, 1000);
  429. }
  430. onUnload(() => {
  431. if (wsSubId) {
  432. unsubscribe(wsSubId);
  433. wsSubId = null;
  434. }
  435. disconnectChat();
  436. if (orderTimer) clearInterval(orderTimer);
  437. });
  438. // ---- 加载历史消息 ----
  439. async function loadHistory() {
  440. try {
  441. const res = await getChatHistory({ sessionId: sessionId.value, pageNum: 1, pageSize: 50 });
  442. if (res.rows) {
  443. messages.value = res.rows.slice().reverse().map(normalizeMsg);
  444. scrollToBottom();
  445. // 从历史消息中提取客服真实头像(取第一条客服消息的 senderAvatar)
  446. const firstWaiterMsg = res.rows.find(m => m.senderType === 2);
  447. if (firstWaiterMsg && firstWaiterMsg.senderAvatar) {
  448. const resolvedWaiterAvatar = resolveAvatarUrl(firstWaiterMsg.senderAvatar);
  449. if (resolvedWaiterAvatar) {
  450. waiterAvatar.value = resolvedWaiterAvatar;
  451. }
  452. }
  453. // 标记已读
  454. if (messages.value.length > 0) {
  455. const lastMsg = messages.value[messages.value.length - 1];
  456. if (lastMsg.id && !lastMsg.id.toString().startsWith('temp')) {
  457. markChatRead({ sessionId: sessionId.value, lastReadMsgId: lastMsg.id });
  458. }
  459. }
  460. }
  461. } catch (e) {
  462. console.error('[Chat] 加载历史消息失败:', e);
  463. } finally {
  464. loading.value = false;
  465. }
  466. // 异步加载用户真实头像(从学员表获取OSS永久URL)
  467. if (fromUserId.value) {
  468. try {
  469. const stuRes = await getStudent(fromUserId.value);
  470. if (stuRes.code === 200 && stuRes.data) {
  471. const stu = stuRes.data;
  472. // 学员表 avatar/avatarUrl 可能是 OSS URL 或 OSS ID
  473. const resolvedUrl = resolveAvatarUrl(stu.avatarUrl || stu.avatar);
  474. if (resolvedUrl) {
  475. userAvatarUrl.value = resolvedUrl;
  476. }
  477. }
  478. } catch (e) {
  479. console.warn('[Chat] 获取学员头像失败:', e);
  480. }
  481. }
  482. }
  483. // ---- WebSocket 实时消息 ----
  484. function connectWebSocket() {
  485. const token = uni.getStorageSync('token');
  486. connectChat({
  487. token,
  488. onConnect: () => {
  489. console.log('[Chat] WebSocket 已连接,订阅会话消息');
  490. // 订阅当前会话的消息频道
  491. if (sessionId.value) {
  492. wsSubId = subscribe(`/topic/session/${sessionId.value}`, (data) => {
  493. console.log('[Chat] 收到 WebSocket 消息:', data);
  494. onWsMessage(data);
  495. });
  496. }
  497. },
  498. onDisconnect: () => {
  499. console.log('[Chat] WebSocket 已断开');
  500. }
  501. });
  502. }
  503. /**
  504. * 处理 WebSocket 推送的消息
  505. */
  506. function onWsMessage(data) {
  507. if (!data) return;
  508. // 如果是数组(批量消息),逐条处理
  509. const msgList = Array.isArray(data) ? data : [data];
  510. msgList.forEach(msgData => {
  511. const normalized = normalizeMsg(msgData);
  512. // 去重:按 id 判断,同时按 msgNo 判断(解决乐观更新临时消息与服务端回传的重复问题)
  513. const existIdx = messages.value.findIndex(m =>
  514. (m.id && normalized.id && m.id === normalized.id) ||
  515. (m.msgNo && normalized.msgNo && m.msgNo === normalized.msgNo)
  516. );
  517. if (existIdx >= 0) {
  518. // 更新已有消息(临时消息被服务端确认,用真实数据替换)
  519. messages.value[existIdx] = { ...messages.value[existIdx], ...normalized };
  520. } else {
  521. // 追加新消息
  522. messages.value.push(normalized);
  523. }
  524. });
  525. scrollToBottom();
  526. // 标记已读
  527. const lastMsg = messages.value[messages.value.length - 1];
  528. if (lastMsg && lastMsg.id && !String(lastMsg.id).startsWith('temp')) {
  529. markChatRead({ sessionId: sessionId.value, lastReadMsgId: lastMsg.id });
  530. }
  531. }
  532. // ---- 规范化消息(后端字段 → 前端渲染字段)----
  533. function normalizeMsg(msg) {
  534. let payload = null;
  535. if (msg.payload) {
  536. try { payload = typeof msg.payload === 'string' ? JSON.parse(msg.payload) : msg.payload; } catch (e) {}
  537. }
  538. return {
  539. id: msg.msgId,
  540. msgNo: msg.msgNo,
  541. senderType: msg.senderType, // 1=用户 2=客服 3=系统
  542. senderName: msg.senderName,
  543. senderAvatar: msg.senderAvatar,
  544. msgType: msg.msgType || 'text',
  545. content: msg.content,
  546. fileUrl: msg.fileUrl,
  547. fileName: msg.fileName,
  548. fileSize: msg.fileSize,
  549. payload,
  550. sendTime: msg.sendTime,
  551. isPaid: payload && (payload.status === 'paid' || payload.status === '已支付' || payload.paid === true)
  552. };
  553. }
  554. // ---- 发送文本消息 ----
  555. async function sendMessage() {
  556. const content = inputValue.value.trim();
  557. if (!content || !sessionId.value) return;
  558. const msgNo = generateMsgNo();
  559. const tempId = 'temp_' + Date.now();
  560. // 乐观展示
  561. messages.value.push({
  562. id: tempId, msgNo, senderType: 1, msgType: 'text',
  563. content, sendTime: new Date().toISOString(), payload: null
  564. });
  565. inputValue.value = '';
  566. scrollToBottom();
  567. try {
  568. // 优先通过 WebSocket 发送
  569. if (isSocketConnected()) {
  570. const sent = sendTextByWs(sessionId.value, content, 'text', msgNo, fromUserId.value);
  571. if (sent) return; // WebSocket 发送成功,消息会通过订阅回调回来替换临时消息
  572. }
  573. // WebSocket 不可用时,降级为 HTTP 发送
  574. await sendTextMessage({
  575. sessionId: sessionId.value,
  576. msgNo,
  577. content,
  578. msgType: 'text',
  579. senderId: fromUserId.value || undefined
  580. });
  581. } catch (e) {
  582. messages.value = messages.value.filter(m => m.id !== tempId);
  583. uni.showToast({ title: '发送失败,请重试', icon: 'none' });
  584. }
  585. }
  586. // ---- 发送图片 ----
  587. async function chooseImage() {
  588. activePanel.value = 'none';
  589. uni.chooseImage({
  590. count: 1,
  591. success: async (res) => {
  592. const filePath = res.tempFilePaths[0];
  593. const tempId = 'temp_img_' + Date.now();
  594. messages.value.push({
  595. id: tempId, senderType: 1, msgType: 'image',
  596. fileUrl: filePath, sendTime: new Date().toISOString(), payload: null
  597. });
  598. scrollToBottom();
  599. try {
  600. const msgNo = 'MSG_' + Date.now() + '_' + Math.random().toString(36).slice(2, 6);
  601. await sendImageMessage({ sessionId: sessionId.value, msgNo, filePath, senderId: fromUserId.value });
  602. } catch (e) {
  603. messages.value = messages.value.filter(m => m.id !== tempId);
  604. uni.showToast({ title: '图片发送失败', icon: 'none' });
  605. }
  606. }
  607. });
  608. }
  609. // ---- 发送模拟订单卡片 ----
  610. function sendMockOrderCard() {
  611. activePanel.value = 'none';
  612. messages.value.push({
  613. id: 'manual_order_' + Date.now(),
  614. msgNo: 'ORDER_' + Date.now(),
  615. senderType: 2,
  616. msgType: 'order_card',
  617. content: '为您推送测评费用结算单',
  618. payload: {
  619. id: 1,
  620. name: assessmentTitle.value || '测评费用',
  621. amount: assessmentPrice.value || '680.00'
  622. },
  623. sendTime: new Date().toISOString(),
  624. isPaid: false
  625. });
  626. scrollToBottom();
  627. }
  628. // ---- 推送结算单消息(公共方法,先去重再推送)----
  629. function pushOrderCardMsg(card) {
  630. // 去重检查:如果已有同 orderCardId 的结算单消息,不再重复推送
  631. const hasOrderCard = messages.value.some(m =>
  632. m.msgType === 'order_card' && m.payload && m.payload.orderCardId === card.orderCardId
  633. );
  634. if (hasOrderCard) {
  635. console.log('[Chat] 已存在相同结算单消息,跳过推送');
  636. return;
  637. }
  638. messages.value.push({
  639. id: 'order_' + card.orderCardId,
  640. msgNo: 'ORDER_' + Date.now(),
  641. senderType: card.senderType || 3,
  642. msgType: 'order_card',
  643. content: '项目费用结算单',
  644. countdown: Math.floor((card.countdownSeconds || 1800)),
  645. payload: {
  646. orderCardId: card.orderCardId,
  647. id: card.orderCardId,
  648. name: card.orderName || assessmentTitle.value || jobName.value,
  649. // 同时写入amount和price,兼容后端payload字段
  650. amount: card.orderPrice || assessmentPrice.value || '0',
  651. price: card.orderPrice || assessmentPrice.value || '0',
  652. status: 'pending'
  653. },
  654. sendTime: new Date().toISOString(),
  655. isPaid: false
  656. });
  657. scrollToBottom();
  658. startOrderTimer();
  659. }
  660. // ---- 培训报名确认 ----
  661. function confirmReg() {
  662. uni.showLoading({ title: '预约中...' });
  663. setTimeout(() => {
  664. uni.hideLoading();
  665. uni.showToast({ title: '预约成功', icon: 'success' });
  666. }, 1200);
  667. }
  668. // ---- 支付(客服发送 order_card 后用户点击)----
  669. async function handlePay(msg) {
  670. if (msg.isPaid) return;
  671. const orderCardId = msg.payload ? (msg.payload.orderCardId || msg.payload.id) : null;
  672. const userInfo = uni.getStorageSync('userInfo') || {};
  673. console.log('🔥 开始支付流程');
  674. console.log('🔥 orderCardId:', orderCardId, '类型:', typeof orderCardId);
  675. console.log('🔥 fromUserId:', fromUserId.value, '类型:', typeof fromUserId.value);
  676. console.log('🔥 userInfo:', JSON.stringify(userInfo));
  677. console.log('🔥 msg.payload:', JSON.stringify(msg.payload));
  678. // 临时注释掉模拟支付逻辑,测试真实支付
  679. /*
  680. // 如果是模拟 ID (比如上面的 1),我们直接走模拟逻辑
  681. if (orderCardId === 1) {
  682. uni.showLoading({ title: '发起支付...' });
  683. setTimeout(() => {
  684. msg.isPaid = true;
  685. uni.hideLoading();
  686. uni.showToast({ title: '支付成功', icon: 'success' });
  687. uni.setStorageSync('audit_paid', true);
  688. // 支付成功后自动跳转到培训/测评开始页 (参考初始版)
  689. setTimeout(() => {
  690. uni.navigateTo({ url: `/pages/assessment/training?title=${encodeURIComponent(assessmentTitle.value)}` });
  691. }, 1200);
  692. }, 1000);
  693. return;
  694. }
  695. */
  696. if (!orderCardId) {
  697. uni.showToast({ title: '无效的结算单', icon: 'none' });
  698. return;
  699. }
  700. try {
  701. uni.showLoading({ title: '创建支付订单...' });
  702. // 调用新的微信支付接口
  703. console.log('🔥 调用支付接口,参数:', { orderCardId, userId: fromUserId.value });
  704. const payRes = await createWxPayOrder(orderCardId, fromUserId.value);
  705. console.log('🔥 支付接口响应:', payRes);
  706. if (!(payRes.code === 200 || payRes.code === 0)) {
  707. uni.hideLoading();
  708. uni.showToast({ title: payRes.msg || '创建支付订单失败', icon: 'none' });
  709. console.log('🔥 支付接口调用失败:', payRes);
  710. return;
  711. }
  712. // 检查是否返回了微信支付参数
  713. if (payRes.data && payRes.data.wechatPayParams) {
  714. const wxPayParams = payRes.data.wechatPayParams;
  715. uni.hideLoading();
  716. uni.showLoading({ title: '发起微信支付...' });
  717. // 调用微信支付
  718. uni.requestPayment({
  719. provider: 'wxpay',
  720. timeStamp: wxPayParams.timeStamp,
  721. nonceStr: wxPayParams.nonceStr,
  722. package: wxPayParams.package,
  723. signType: wxPayParams.signType || 'RSA',
  724. paySign: wxPayParams.paySign,
  725. success: (res) => {
  726. uni.hideLoading();
  727. console.log('微信支付成功:', res);
  728. // 支付成功,更新UI
  729. msg.isPaid = true;
  730. uni.showToast({ title: '支付成功', icon: 'success' });
  731. // 标记支付状态到storage(供其他页面检测)
  732. // 按测评ID写入(assessmentId 已在 onLoad 查询关联测评时赋值)
  733. if (assessmentId.value) {
  734. const paidKey = `audit_paid_${assessmentId.value}`;
  735. uni.setStorageSync(paidKey, true);
  736. console.log('[Chat] 支付成功,写入 key:', paidKey);
  737. }
  738. // 🔴 兜底:按 positionId 额外写一条,防止 assessmentId 仍为空
  739. if (chatType.value === 'job' && positionId.value) {
  740. const fallbackKey = `audit_paid_pos_${positionId.value}`;
  741. uni.setStorageSync(fallbackKey, true);
  742. console.log('[Chat] 兜底写入 key:', fallbackKey);
  743. }
  744. // 更新消息payload
  745. msg.payload = {
  746. ...(msg.payload || {}),
  747. orderCardId,
  748. orderId: payRes.data.orderId,
  749. orderNo: payRes.data.orderNo || '',
  750. status: 'paid'
  751. };
  752. uni.$emit('payment_done', {
  753. orderCardId,
  754. orderId: payRes.data.orderId,
  755. assessmentId: assessmentId.value,
  756. positionId: positionId.value,
  757. paid: true
  758. });
  759. // 支付成功后跳转
  760. if (chatType.value === 'assessment') {
  761. setTimeout(() => {
  762. uni.navigateTo({ url: `/pages/assessment/training?title=${encodeURIComponent(assessmentTitle.value)}&assessmentId=${assessmentId.value}` });
  763. }, 1200);
  764. }
  765. },
  766. fail: (err) => {
  767. uni.hideLoading();
  768. console.error('微信支付失败:', err);
  769. if (err.errMsg && err.errMsg.includes('cancel')) {
  770. uni.showToast({ title: '支付已取消', icon: 'none' });
  771. } else {
  772. uni.showToast({ title: '支付失败,请重试', icon: 'none' });
  773. }
  774. }
  775. });
  776. } else {
  777. // 没有微信支付参数,可能是免费订单或其他情况
  778. uni.hideLoading();
  779. if (payRes.data && payRes.data.success) {
  780. msg.isPaid = true;
  781. uni.showToast({ title: payRes.data.message || '支付成功', icon: 'success' });
  782. } else {
  783. uni.showToast({ title: '支付处理异常', icon: 'none' });
  784. }
  785. }
  786. } catch (e) {
  787. uni.hideLoading();
  788. console.error('支付失败:', e);
  789. uni.showToast({ title: '支付失败:' + (e.message || '网络错误'), icon: 'none' });
  790. }
  791. }
  792. // ---- 工具 ----
  793. const chatBodyHeight = computed(() => {
  794. const navH = 100;
  795. const footerH = activePanel.value === 'none' ? 120 : 520;
  796. return `calc(100vh - ${navH}rpx - ${footerH}rpx - env(safe-area-inset-top) - env(safe-area-inset-bottom))`;
  797. });
  798. function scrollToBottom() {
  799. nextTick(() => { lastMessageId.value = ''; nextTick(() => { lastMessageId.value = 'bottom-anchor'; }); });
  800. }
  801. function goBack() { uni.navigateBack(); }
  802. function toggleInputMode() {
  803. inputMode.value = inputMode.value === 'text' ? 'voice' : 'text';
  804. activePanel.value = 'none';
  805. }
  806. function togglePanel(panel) {
  807. activePanel.value = activePanel.value === panel ? 'none' : panel;
  808. if (activePanel.value !== 'none') inputMode.value = 'text';
  809. scrollToBottom();
  810. }
  811. function onInputFocus() { activePanel.value = 'none'; scrollToBottom(); }
  812. function addEmoji(e) { inputValue.value += e; }
  813. function previewImg(url) { uni.previewImage({ urls: [url], current: url }); }
  814. function formatFileSize(size) {
  815. if (!size) return '';
  816. if (size < 1024) return size + 'B';
  817. if (size < 1024 * 1024) return (size / 1024).toFixed(1) + 'KB';
  818. return (size / 1024 / 1024).toFixed(1) + 'MB';
  819. }
  820. function formatTime(timeStr) {
  821. if (!timeStr) return '';
  822. const d = new Date(timeStr);
  823. if (isNaN(d)) return timeStr;
  824. const pad = n => n.toString().padStart(2, '0');
  825. return `${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
  826. }
  827. function shouldShowTime(msg, index) {
  828. if (index === 0) return true;
  829. const prev = messages.value[index - 1];
  830. if (!prev.sendTime || !msg.sendTime) return false;
  831. return (new Date(msg.sendTime) - new Date(prev.sendTime)) > 5 * 60 * 1000;
  832. }
  833. // 格式化金额显示
  834. function formatAmount(amount) {
  835. if (!amount && amount !== 0) return '—';
  836. // 如果是字符串,尝试转换为数字
  837. const num = typeof amount === 'string' ? parseFloat(amount) : amount;
  838. if (isNaN(num)) return '—';
  839. // 保留两位小数,去掉不必要的0
  840. return num.toFixed(2).replace(/\.?0+$/, '');
  841. }
  842. const onVoiceStart = () => uni.showToast({ title: '录音中...', icon: 'none' });
  843. const onVoiceEnd = () => uni.showToast({ title: '语音功能暂未开放', icon: 'none' });
  844. </script>
  845. <style lang="scss" scoped>
  846. .container { width: 100%; height: 100vh; background-color: #F4F5F7; display: flex; flex-direction: column; overflow: hidden; }
  847. /* 状态栏占位:高度由 JS 动态注入 */
  848. .status-bar { background: #FFF; flex-shrink: 0; }
  849. /* 导航栏 */
  850. .nav-bar {
  851. height: 100rpx; background: #FFF; display: flex; align-items: center;
  852. padding: 0 30rpx; border-bottom: 1rpx solid #F0F0F0; flex-shrink: 0;
  853. .back-btn { width: 60rpx; display: flex; align-items: center;
  854. .back-arrow { font-size: 56rpx; color: #333; line-height: 1; margin-top: -6rpx; }
  855. }
  856. .nav-center { flex: 1; display: flex; align-items: center; justify-content: center; gap: 12rpx;
  857. .nav-title-text { font-size: 32rpx; font-weight: bold; color: #1A1A1A; }
  858. .online-dot { width: 14rpx; height: 14rpx; border-radius: 50%; background: #10B981; }
  859. }
  860. .nav-right { width: 60rpx; }
  861. }
  862. .chat-body { flex: 1; }
  863. .message-list { padding: 24rpx 30rpx 160rpx; }
  864. .tip-row { padding: 60rpx 0; text-align: center;
  865. .tip-text { font-size: 26rpx; color: #CCC; }
  866. }
  867. .time-stamp-row { display: flex; justify-content: center; margin: 20rpx 0 30rpx; }
  868. .time-stamp { font-size: 22rpx; color: #BBB; background: rgba(0,0,0,0.05); padding: 4rpx 18rpx; border-radius: 8rpx; }
  869. .msg-row {
  870. display: flex; margin-bottom: 44rpx;
  871. .avatar { width: 80rpx; height: 80rpx; border-radius: 50%; flex-shrink: 0; }
  872. &.left { .avatar { margin-right: 18rpx; } }
  873. &.right { justify-content: flex-end; .avatar { margin-left: 18rpx; } }
  874. }
  875. .msg-content { max-width: 520rpx; border-radius: 16rpx; padding: 22rpx 26rpx; font-size: 30rpx; line-height: 1.6; word-break: break-all; }
  876. .text-msg { background: #FFF; color: #333; &.shadow { box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.04); } &.user-bubble { background: #FFB700; color: #FFF; } }
  877. .img-msg { padding: 8rpx; background: #FFF; border-radius: 12rpx; box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.06);
  878. .chat-img { width: 360rpx; border-radius: 8rpx; display: block; }
  879. }
  880. .file-msg { display: flex; align-items: center; gap: 20rpx; background: #FFF; min-width: 300rpx;
  881. .file-icon-txt { font-size: 56rpx; flex-shrink: 0; }
  882. .file-info { flex: 1;
  883. .file-name { display: block; font-size: 28rpx; color: #333; margin-bottom: 6rpx; word-break: break-all; }
  884. .file-size { font-size: 22rpx; color: #999; }
  885. }
  886. }
  887. /* 订单卡片 */
  888. .deposit-card {
  889. background: #FFF; width: 500rpx; border-radius: 20rpx; overflow: hidden; padding: 0; box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
  890. .deposit-header { padding: 28rpx 28rpx 16rpx; display: flex; justify-content: space-between; align-items: flex-start;
  891. .d-header-left { flex: 1;
  892. .d-title { font-size: 32rpx; font-weight: bold; color: #333; }
  893. .d-subtitle { font-size: 22rpx; color: #BBB; margin-top: 6rpx; display: block; }
  894. }
  895. .d-countdown {
  896. display: flex; gap: 4rpx; align-items: center; justify-content: flex-end;
  897. .c-time { color: #FF9500; font-size: 26rpx; font-weight: bold; }
  898. .c-txt { color: #999; font-size: 22rpx; }
  899. }
  900. .d-paid-tag { color: #52C41A; font-size: 24rpx; font-weight: bold; }
  901. }
  902. .deposit-body { padding: 8rpx 28rpx 24rpx;
  903. .d-row { margin-bottom: 10rpx; font-size: 26rpx; display: flex;
  904. .label { color: #AAA; width: 140rpx; } .val { color: #333; flex: 1; } .price { color: #FF3B30; font-size: 34rpx; font-weight: bold; }
  905. }
  906. }
  907. .deposit-action { margin: 0 28rpx 28rpx; height: 76rpx; font-size: 28rpx; background: #FFB700; color: #FFF; border-radius: 38rpx; display: flex; align-items: center; justify-content: center; font-weight: bold; &.paid { background: #EEE; color: #999; } }
  908. }
  909. /* 招聘初始卡片(静态展示用) */
  910. .job-card-msg {
  911. background: #FFF; border-radius: 20rpx; width: 500rpx; padding: 30rpx; box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.04);
  912. .card-header { display: flex; justify-content: space-between; margin-bottom: 20rpx;
  913. .ch-left { display: flex; align-items: center; gap: 10rpx;
  914. .card-title { font-weight: bold; font-size: 34rpx; }
  915. .urgent-tag { border: 1rpx solid #FF4D4F; color: #FF4D4F; font-size: 20rpx; padding: 2rpx 10rpx; border-radius: 6rpx; }
  916. }
  917. .card-salary { color: #1F6CFF; font-weight: bold; font-size: 32rpx; }
  918. }
  919. .card-tags { display: flex; gap: 12rpx; margin-bottom: 24rpx;
  920. .c-tag { background: #F5F7FA; color: #888; font-size: 22rpx; padding: 6rpx 16rpx; border-radius: 8rpx; }
  921. }
  922. .card-meta { display: flex; flex-direction: column; gap: 10rpx; margin-bottom: 24rpx;
  923. .m-item { display: flex; align-items: center; gap: 10rpx;
  924. .m-icon { width: 24rpx; height: 24rpx; opacity: 0.4; }
  925. text { font-size: 24rpx; color: #666; }
  926. }
  927. }
  928. .card-company { display: flex; align-items: center; border-top: 1rpx solid #F5F5F5; padding-top: 24rpx;
  929. .c-logo { width: 80rpx; height: 80rpx; border-radius: 12rpx; margin-right: 16rpx; }
  930. .c-info { flex: 1; display: flex; align-items: center; gap: 8rpx;
  931. .c-name { font-size: 28rpx; font-weight: bold; }
  932. .v-icon { width: 28rpx; height: 28rpx; }
  933. }
  934. .c-loc { font-size: 24rpx; color: #999; }
  935. }
  936. }
  937. /* 测评初始卡片 */
  938. .assessment-card-msg {
  939. background: #FFF; width: 480rpx; padding: 24rpx; display: flex; box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.04);
  940. border-radius: 16rpx;
  941. .card-left { width: 140rpx; height: 140rpx; margin-right: 20rpx;
  942. .a-cover { width: 100%; height: 100%; border-radius: 12rpx; }
  943. }
  944. .card-right { flex: 1; display: flex; flex-direction: column; justify-content: space-between;
  945. .a-title { font-weight: bold; font-size: 30rpx; color: #1A1A1A; }
  946. .a-tags { display: flex; gap: 10rpx; flex-wrap: wrap;
  947. .a-tag { font-size: 20rpx; color: #999; background: #F5F7FA; padding: 4rpx 12rpx; border-radius: 6rpx; }
  948. }
  949. .a-price { color: #FF4D4F; font-weight: bold; font-size: 32rpx; }
  950. }
  951. }
  952. /* 培训报名初始卡片 */
  953. .training-reg-card {
  954. background: #FFF; width: 480rpx; padding: 30rpx; border-radius: 20rpx;
  955. .t-card-header { margin-bottom: 24rpx;
  956. .t-card-title { font-weight: bold; font-size: 32rpx; color: #1A1A1A; display: block; margin-bottom: 8rpx; }
  957. .t-card-subtitle { font-size: 24rpx; color: #999; }
  958. }
  959. .t-card-body { margin-bottom: 30rpx;
  960. .t-item { display: flex; font-size: 26rpx; margin-bottom: 10rpx;
  961. .t-label { color: #888; width: 140rpx; } .t-val { color: #333; }
  962. }
  963. }
  964. .t-card-footer {
  965. .reg-btn { width: 100%; height: 72rpx; line-height: 72rpx; background: #1F6CFF; color: #FFF; border-radius: 36rpx; font-size: 28rpx; font-weight: bold; &::after { border: none; } }
  966. }
  967. }
  968. /* API 推送的岗位卡片(客服消息循环中使用)*/
  969. .api-job-card {
  970. background: #FFF; width: 460rpx; padding: 28rpx; border-radius: 16rpx;
  971. .jc-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12rpx;
  972. .jc-title { font-size: 30rpx; font-weight: bold; color: #1A1A1A; flex: 1; }
  973. .jc-salary { font-size: 28rpx; color: #1F6CFF; font-weight: bold; }
  974. }
  975. .jc-city { font-size: 24rpx; color: #888; }
  976. }
  977. /* 系统消息 */
  978. .system-msg { width: 100%; text-align: center; font-size: 24rpx; color: #BBB; padding: 8rpx 20rpx; background: rgba(0,0,0,0.04); border-radius: 8rpx; }
  979. /* 底部输入栏 */
  980. .footer-wrap { position: fixed; bottom: 0; left: 0; right: 0; background: #FFF; border-top: 1rpx solid #EEE; padding-bottom: env(safe-area-inset-bottom); z-index: 1001; }
  981. .input-bar { height: 120rpx; display: flex; align-items: center; padding: 0 24rpx; gap: 20rpx;
  982. .bar-icon { width: 60rpx; height: 60rpx; transition: transform 0.2s; &.active { transform: scale(1.1); } }
  983. .center-area { flex: 1;
  984. .chat-input { background: #F7F8FA; height: 80rpx; border-radius: 12rpx; border: 1rpx solid #EEE; padding: 0 24rpx; font-size: 28rpx; }
  985. .voice-press-btn { height: 80rpx; background: #F7F8FA; border: 1rpx solid #DDD; border-radius: 12rpx; display: flex; align-items: center; justify-content: center; font-size: 28rpx; color: #666; &:active { background: #E0E0E0; } }
  986. }
  987. }
  988. .panel-section { height: 0; overflow: hidden; transition: height 0.3s; &.show { height: 400rpx; border-top: 1rpx solid #F2F2F2; } }
  989. .emoji-panel { height: 100%; .emoji-scroll { height: 100%; } .emoji-grid { display: flex; flex-wrap: wrap; padding: 30rpx; gap: 20rpx; .emoji-item { font-size: 50rpx; width: 84rpx; text-align: center; } } }
  990. .plus-panel { height: 100%; display: flex; padding: 40rpx 60rpx; gap: 80rpx;
  991. .panel-item { display: flex; flex-direction: column; align-items: center;
  992. .icon-box { width: 116rpx; height: 116rpx; background: #FFF; border: 1rpx solid #F0F0F0; border-radius: 28rpx; display: flex; align-items: center; justify-content: center; margin-bottom: 20rpx; box-shadow: 0 4rpx 10rpx rgba(0,0,0,0.03); image { width: 60rpx; height: 60rpx; } }
  993. text { font-size: 26rpx; color: #777; }
  994. }
  995. }
  996. </style>