chat.vue 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110
  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 || '上海市') + '·' + (workDistrict || '黄浦区') }}</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. const workDistrict = ref('');
  293. // ---- 头像 ----
  294. const waiterAvatar = ref('/static/images/hr_avatar.svg');
  295. // 将 OSS ID 或无效头像转为可访问的 URL
  296. function resolveAvatarUrl(url) {
  297. if (!url || url === '' || url === 'undefined') return '';
  298. const str = String(url).trim();
  299. // 已经是有效 HTTP URL(后端 ossService.selectUrlByIds 已转为真实 URL)
  300. if (str.startsWith('http://') || str.startsWith('https://')) return str;
  301. // 纯数字 → OSS 文件 URL(后端接口)
  302. if (/^\d+$/.test(str)) {
  303. return `${BASE_URL}/resource/oss/file/${str}`;
  304. }
  305. // 本地路径 → 空值
  306. if (str.startsWith('/static/')) return '';
  307. return str;
  308. }
  309. // 判断是否为有效的可访问URL
  310. function isValidAvatar(url) {
  311. if (!url || url === '' || url === 'undefined') return false;
  312. const str = String(url).trim();
  313. if (str.startsWith('/static/')) return false;
  314. // 纯数字是 OSS ID,不是可访问的图片 URL
  315. if (/^\d+$/.test(str)) return false;
  316. return true;
  317. }
  318. const userAvatarUrl = ref('/static/images/user_avatar.png');
  319. const emojiList = ['😀','😃','😄','😁','😆','😅','😂','🤣','😊','😇','🙂','🙃','😉','😌','😍','🥰','😘','😗','😙','😚','😋','😛','😝','😜','🤪','🤨','🧐','🤓','😎','🤩','🥳'];
  320. let wsSubId = null; // WebSocket 订阅 ID
  321. // ---- 生命周期 ----
  322. onLoad(async (options) => {
  323. // 获取状态栏高度(微信小程序中 env(safe-area-inset-top) 为0,需要通过 JS 获取)
  324. // #ifdef MP-WEIXIN
  325. try {
  326. const sysInfo = uni.getSystemInfoSync();
  327. statusBarHeight.value = sysInfo.statusBarHeight || 20;
  328. } catch (e) {}
  329. // #endif
  330. if (options.sessionId) sessionId.value = options.sessionId;
  331. if (options.fromUserId) fromUserId.value = options.fromUserId;
  332. if (options.userName) sessionUserName.value = decodeURIComponent(options.userName);
  333. if (options.jobName) jobName.value = decodeURIComponent(options.jobName);
  334. if (options.type) chatType.value = options.type;
  335. // 培训标题
  336. if (options.title) trainingTitle.value = decodeURIComponent(options.title || '');
  337. // 测评参数解析
  338. if (options.title && options.type === 'assessment') {
  339. assessmentTitle.value = decodeURIComponent(options.title || '');
  340. }
  341. if (options.cover) assessmentCover.value = decodeURIComponent(options.cover || '');
  342. if (options.level) assessmentLevel.value = decodeURIComponent(options.level || '');
  343. if (options.assessmentId) assessmentId.value = options.assessmentId;
  344. if (options.price) assessmentPrice.value = options.price;
  345. // 岗位参数解析
  346. if (options.positionId) positionId.value = options.positionId;
  347. if (options.salaryRange) salaryRange.value = decodeURIComponent(options.salaryRange);
  348. if (options.companyName) companyName.value = decodeURIComponent(options.companyName);
  349. if (options.workCity) workCity.value = decodeURIComponent(options.workCity);
  350. if (options.workDistrict) workDistrict.value = decodeURIComponent(options.workDistrict);
  351. const storedInfo = uni.getStorageSync('userInfo') || {};
  352. // 用户头像:优先用存储的 avatarUrl,再尝试 avatar(可能是 OSS ID)
  353. const rawUserAvatar = storedInfo.avatarUrl || storedInfo.avatar || '/static/images/user_avatar.png';
  354. userAvatarUrl.value = resolveAvatarUrl(rawUserAvatar) || '/static/images/user_avatar.png';
  355. if (!fromUserId.value && storedInfo.studentId) fromUserId.value = storedInfo.studentId;
  356. if (!sessionId.value) {
  357. loading.value = false;
  358. uni.showToast({ title: '会话参数缺失', icon: 'none' });
  359. return;
  360. }
  361. await loadHistory();
  362. // 建立 WebSocket 连接,实时接收消息
  363. connectWebSocket();
  364. // 自动创建结算单(不管有没有历史消息,后端会防重复)
  365. if (chatType.value === 'assessment') {
  366. setTimeout(async () => {
  367. try {
  368. const userInfo = uni.getStorageSync('userInfo') || {};
  369. const res = await autoCreateOrderCard({
  370. sessionId: sessionId.value,
  371. studentId: userInfo.studentId || fromUserId.value,
  372. orderName: assessmentTitle.value || (jobName.value + '-测评服务费'),
  373. orderPrice: assessmentPrice.value || '0',
  374. orderType: '测评咨询'
  375. });
  376. if (res.code === 200 && res.data) {
  377. pushOrderCardMsg(res.data);
  378. } else {
  379. console.error('自动创建结算单失败:', res);
  380. }
  381. } catch (err) {
  382. console.error('自动创建结算单异常:', err);
  383. }
  384. }, 800);
  385. } else if (chatType.value === 'job' && positionId.value) {
  386. try {
  387. const { getAssessmentList } = require('../../api/assessment.js');
  388. const evalRes = await getAssessmentList({ positionId: positionId.value, pageNum: 1, pageSize: 1 });
  389. if (evalRes.code === 200 && evalRes.rows && evalRes.rows.length > 0) {
  390. const firstEval = evalRes.rows[0];
  391. // 🔴 关键修复:将岗位关联的第一个测评ID赋给assessmentId
  392. // 这样支付成功后写入的 storage key(audit_paid_${assessmentId})
  393. // 才能与 jobdetail/checkState 读取的 key 一致
  394. if (!assessmentId.value) {
  395. assessmentId.value = String(firstEval.id);
  396. console.log('[Chat] 岗位关联测评ID:', assessmentId.value);
  397. }
  398. setTimeout(async () => {
  399. try {
  400. const userInfo = uni.getStorageSync('userInfo') || {};
  401. const res = await autoCreateOrderCard({
  402. sessionId: sessionId.value,
  403. studentId: userInfo.studentId || fromUserId.value,
  404. orderName: (firstEval.evaluationName || jobName.value) + '-测评服务费',
  405. orderPrice: firstEval.price || assessmentPrice.value || '0',
  406. orderType: '岗位测评'
  407. });
  408. if (res.code === 200 && res.data) {
  409. pushOrderCardMsg(res.data);
  410. }
  411. } catch (err) { console.error('岗位结算单异常:', err); }
  412. }, 800);
  413. } else {
  414. console.log('[Chat] 该岗位无关联测评,不发送结算单');
  415. }
  416. } catch (e) {
  417. console.error('[Chat] 查询关联测评失败:', e);
  418. }
  419. }
  420. });
  421. let orderTimer = null;
  422. function startOrderTimer() {
  423. if (orderTimer) return;
  424. orderTimer = setInterval(() => {
  425. messages.value.forEach(m => {
  426. if (m.msgType === 'order_card' && !m.isPaid && m.countdown > 0) {
  427. m.countdown--;
  428. }
  429. });
  430. }, 1000);
  431. }
  432. onUnload(() => {
  433. if (wsSubId) {
  434. unsubscribe(wsSubId);
  435. wsSubId = null;
  436. }
  437. disconnectChat();
  438. if (orderTimer) clearInterval(orderTimer);
  439. });
  440. // ---- 加载历史消息 ----
  441. async function loadHistory() {
  442. try {
  443. const res = await getChatHistory({ sessionId: sessionId.value, pageNum: 1, pageSize: 50 });
  444. if (res.rows) {
  445. messages.value = res.rows.slice().reverse().map(normalizeMsg);
  446. scrollToBottom();
  447. // 从历史消息中提取客服真实头像(取第一条客服消息的 senderAvatar)
  448. const firstWaiterMsg = res.rows.find(m => m.senderType === 2);
  449. if (firstWaiterMsg && firstWaiterMsg.senderAvatar) {
  450. const resolvedWaiterAvatar = resolveAvatarUrl(firstWaiterMsg.senderAvatar);
  451. if (resolvedWaiterAvatar) {
  452. waiterAvatar.value = resolvedWaiterAvatar;
  453. }
  454. }
  455. // 标记已读
  456. if (messages.value.length > 0) {
  457. const lastMsg = messages.value[messages.value.length - 1];
  458. if (lastMsg.id && !lastMsg.id.toString().startsWith('temp')) {
  459. markChatRead({ sessionId: sessionId.value, lastReadMsgId: lastMsg.id });
  460. }
  461. }
  462. }
  463. } catch (e) {
  464. console.error('[Chat] 加载历史消息失败:', e);
  465. } finally {
  466. loading.value = false;
  467. }
  468. // 异步加载用户真实头像(从学员表获取OSS永久URL)
  469. if (fromUserId.value) {
  470. try {
  471. const stuRes = await getStudent(fromUserId.value);
  472. if (stuRes.code === 200 && stuRes.data) {
  473. const stu = stuRes.data;
  474. // 学员表 avatar/avatarUrl 可能是 OSS URL 或 OSS ID
  475. const resolvedUrl = resolveAvatarUrl(stu.avatarUrl || stu.avatar);
  476. if (resolvedUrl) {
  477. userAvatarUrl.value = resolvedUrl;
  478. }
  479. }
  480. } catch (e) {
  481. console.warn('[Chat] 获取学员头像失败:', e);
  482. }
  483. }
  484. }
  485. // ---- WebSocket 实时消息 ----
  486. function connectWebSocket() {
  487. const token = uni.getStorageSync('token');
  488. connectChat({
  489. token,
  490. onConnect: () => {
  491. console.log('[Chat] WebSocket 已连接,订阅会话消息');
  492. // 订阅当前会话的消息频道
  493. if (sessionId.value) {
  494. wsSubId = subscribe(`/topic/session/${sessionId.value}`, (data) => {
  495. console.log('[Chat] 收到 WebSocket 消息:', data);
  496. onWsMessage(data);
  497. });
  498. }
  499. },
  500. onDisconnect: () => {
  501. console.log('[Chat] WebSocket 已断开');
  502. }
  503. });
  504. }
  505. /**
  506. * 处理 WebSocket 推送的消息
  507. */
  508. function onWsMessage(data) {
  509. if (!data) return;
  510. // 如果是数组(批量消息),逐条处理
  511. const msgList = Array.isArray(data) ? data : [data];
  512. msgList.forEach(msgData => {
  513. const normalized = normalizeMsg(msgData);
  514. // 去重:按 id 判断,同时按 msgNo 判断(解决乐观更新临时消息与服务端回传的重复问题)
  515. const existIdx = messages.value.findIndex(m =>
  516. (m.id && normalized.id && m.id === normalized.id) ||
  517. (m.msgNo && normalized.msgNo && m.msgNo === normalized.msgNo)
  518. );
  519. if (existIdx >= 0) {
  520. // 更新已有消息(临时消息被服务端确认,用真实数据替换)
  521. messages.value[existIdx] = { ...messages.value[existIdx], ...normalized };
  522. } else {
  523. // 追加新消息
  524. messages.value.push(normalized);
  525. }
  526. });
  527. scrollToBottom();
  528. // 标记已读
  529. const lastMsg = messages.value[messages.value.length - 1];
  530. if (lastMsg && lastMsg.id && !String(lastMsg.id).startsWith('temp')) {
  531. markChatRead({ sessionId: sessionId.value, lastReadMsgId: lastMsg.id });
  532. }
  533. }
  534. // ---- 规范化消息(后端字段 → 前端渲染字段)----
  535. function normalizeMsg(msg) {
  536. let payload = null;
  537. if (msg.payload) {
  538. try { payload = typeof msg.payload === 'string' ? JSON.parse(msg.payload) : msg.payload; } catch (e) {}
  539. }
  540. return {
  541. id: msg.msgId,
  542. msgNo: msg.msgNo,
  543. senderType: msg.senderType, // 1=用户 2=客服 3=系统
  544. senderName: msg.senderName,
  545. senderAvatar: msg.senderAvatar,
  546. msgType: msg.msgType || 'text',
  547. content: msg.content,
  548. fileUrl: msg.fileUrl,
  549. fileName: msg.fileName,
  550. fileSize: msg.fileSize,
  551. payload,
  552. sendTime: msg.sendTime,
  553. isPaid: payload && (payload.status === 'paid' || payload.status === '已支付' || payload.paid === true)
  554. };
  555. }
  556. // ---- 发送文本消息 ----
  557. async function sendMessage() {
  558. const content = inputValue.value.trim();
  559. if (!content || !sessionId.value) return;
  560. const msgNo = generateMsgNo();
  561. const tempId = 'temp_' + Date.now();
  562. // 乐观展示
  563. messages.value.push({
  564. id: tempId, msgNo, senderType: 1, msgType: 'text',
  565. content, sendTime: new Date().toISOString(), payload: null
  566. });
  567. inputValue.value = '';
  568. scrollToBottom();
  569. try {
  570. // 优先通过 WebSocket 发送
  571. if (isSocketConnected()) {
  572. const sent = sendTextByWs(sessionId.value, content, 'text', msgNo, fromUserId.value);
  573. if (sent) return; // WebSocket 发送成功,消息会通过订阅回调回来替换临时消息
  574. }
  575. // WebSocket 不可用时,降级为 HTTP 发送
  576. await sendTextMessage({
  577. sessionId: sessionId.value,
  578. msgNo,
  579. content,
  580. msgType: 'text',
  581. senderId: fromUserId.value || undefined
  582. });
  583. } catch (e) {
  584. messages.value = messages.value.filter(m => m.id !== tempId);
  585. uni.showToast({ title: '发送失败,请重试', icon: 'none' });
  586. }
  587. }
  588. // ---- 发送图片 ----
  589. async function chooseImage() {
  590. activePanel.value = 'none';
  591. uni.chooseImage({
  592. count: 1,
  593. success: async (res) => {
  594. const filePath = res.tempFilePaths[0];
  595. const tempId = 'temp_img_' + Date.now();
  596. messages.value.push({
  597. id: tempId, senderType: 1, msgType: 'image',
  598. fileUrl: filePath, sendTime: new Date().toISOString(), payload: null
  599. });
  600. scrollToBottom();
  601. try {
  602. const msgNo = 'MSG_' + Date.now() + '_' + Math.random().toString(36).slice(2, 6);
  603. await sendImageMessage({ sessionId: sessionId.value, msgNo, filePath, senderId: fromUserId.value });
  604. } catch (e) {
  605. messages.value = messages.value.filter(m => m.id !== tempId);
  606. uni.showToast({ title: '图片发送失败', icon: 'none' });
  607. }
  608. }
  609. });
  610. }
  611. // ---- 发送模拟订单卡片 ----
  612. function sendMockOrderCard() {
  613. activePanel.value = 'none';
  614. messages.value.push({
  615. id: 'manual_order_' + Date.now(),
  616. msgNo: 'ORDER_' + Date.now(),
  617. senderType: 2,
  618. msgType: 'order_card',
  619. content: '为您推送测评费用结算单',
  620. payload: {
  621. id: 1,
  622. name: assessmentTitle.value || '测评费用',
  623. amount: assessmentPrice.value || '680.00'
  624. },
  625. sendTime: new Date().toISOString(),
  626. isPaid: false
  627. });
  628. scrollToBottom();
  629. }
  630. // ---- 推送结算单消息(公共方法,先去重再推送)----
  631. function pushOrderCardMsg(card) {
  632. // 去重检查:如果已有同 orderCardId 的结算单消息,不再重复推送
  633. const hasOrderCard = messages.value.some(m =>
  634. m.msgType === 'order_card' && m.payload && m.payload.orderCardId === card.orderCardId
  635. );
  636. if (hasOrderCard) {
  637. console.log('[Chat] 已存在相同结算单消息,跳过推送');
  638. return;
  639. }
  640. messages.value.push({
  641. id: 'order_' + card.orderCardId,
  642. msgNo: 'ORDER_' + Date.now(),
  643. senderType: card.senderType || 3,
  644. msgType: 'order_card',
  645. content: '项目费用结算单',
  646. countdown: Math.floor((card.countdownSeconds || 1800)),
  647. payload: {
  648. orderCardId: card.orderCardId,
  649. id: card.orderCardId,
  650. name: card.orderName || assessmentTitle.value || jobName.value,
  651. // 同时写入amount和price,兼容后端payload字段
  652. amount: card.orderPrice || assessmentPrice.value || '0',
  653. price: card.orderPrice || assessmentPrice.value || '0',
  654. status: 'pending'
  655. },
  656. sendTime: new Date().toISOString(),
  657. isPaid: false
  658. });
  659. scrollToBottom();
  660. startOrderTimer();
  661. }
  662. // ---- 培训报名确认 ----
  663. function confirmReg() {
  664. uni.showLoading({ title: '预约中...' });
  665. setTimeout(() => {
  666. uni.hideLoading();
  667. uni.showToast({ title: '预约成功', icon: 'success' });
  668. }, 1200);
  669. }
  670. // ---- 支付(客服发送 order_card 后用户点击)----
  671. async function handlePay(msg) {
  672. if (msg.isPaid) return;
  673. const orderCardId = msg.payload ? (msg.payload.orderCardId || msg.payload.id) : null;
  674. const userInfo = uni.getStorageSync('userInfo') || {};
  675. console.log('🔥 开始支付流程');
  676. console.log('🔥 orderCardId:', orderCardId, '类型:', typeof orderCardId);
  677. console.log('🔥 fromUserId:', fromUserId.value, '类型:', typeof fromUserId.value);
  678. console.log('🔥 userInfo:', JSON.stringify(userInfo));
  679. console.log('🔥 msg.payload:', JSON.stringify(msg.payload));
  680. // 临时注释掉模拟支付逻辑,测试真实支付
  681. /*
  682. // 如果是模拟 ID (比如上面的 1),我们直接走模拟逻辑
  683. if (orderCardId === 1) {
  684. uni.showLoading({ title: '发起支付...' });
  685. setTimeout(() => {
  686. msg.isPaid = true;
  687. uni.hideLoading();
  688. uni.showToast({ title: '支付成功', icon: 'success' });
  689. uni.setStorageSync('audit_paid', true);
  690. // 支付成功后自动跳转到培训/测评开始页 (参考初始版)
  691. setTimeout(() => {
  692. uni.navigateTo({ url: `/pages/assessment/training?title=${encodeURIComponent(assessmentTitle.value)}` });
  693. }, 1200);
  694. }, 1000);
  695. return;
  696. }
  697. */
  698. if (!orderCardId) {
  699. uni.showToast({ title: '无效的结算单', icon: 'none' });
  700. return;
  701. }
  702. try {
  703. uni.showLoading({ title: '创建支付订单...' });
  704. // 调用新的微信支付接口
  705. console.log('🔥 调用支付接口,参数:', { orderCardId, userId: fromUserId.value });
  706. const payRes = await createWxPayOrder(orderCardId, fromUserId.value);
  707. console.log('🔥 支付接口响应:', payRes);
  708. if (!(payRes.code === 200 || payRes.code === 0)) {
  709. uni.hideLoading();
  710. uni.showToast({ title: payRes.msg || '创建支付订单失败', icon: 'none' });
  711. console.log('🔥 支付接口调用失败:', payRes);
  712. return;
  713. }
  714. // 检查是否返回了微信支付参数
  715. if (payRes.data && payRes.data.wechatPayParams) {
  716. const wxPayParams = payRes.data.wechatPayParams;
  717. uni.hideLoading();
  718. uni.showLoading({ title: '发起微信支付...' });
  719. // 调用微信支付
  720. uni.requestPayment({
  721. provider: 'wxpay',
  722. timeStamp: wxPayParams.timeStamp,
  723. nonceStr: wxPayParams.nonceStr,
  724. package: wxPayParams.package,
  725. signType: wxPayParams.signType || 'RSA',
  726. paySign: wxPayParams.paySign,
  727. success: (res) => {
  728. uni.hideLoading();
  729. console.log('微信支付成功:', res);
  730. // 支付成功,更新UI
  731. msg.isPaid = true;
  732. uni.showToast({ title: '支付成功', icon: 'success' });
  733. // 标记支付状态到storage(供其他页面检测)
  734. // 按测评ID写入(assessmentId 已在 onLoad 查询关联测评时赋值)
  735. if (assessmentId.value) {
  736. const paidKey = `audit_paid_${assessmentId.value}`;
  737. uni.setStorageSync(paidKey, true);
  738. console.log('[Chat] 支付成功,写入 key:', paidKey);
  739. }
  740. // 🔴 兜底:按 positionId 额外写一条,防止 assessmentId 仍为空
  741. if (chatType.value === 'job' && positionId.value) {
  742. const fallbackKey = `audit_paid_pos_${positionId.value}`;
  743. uni.setStorageSync(fallbackKey, true);
  744. console.log('[Chat] 兜底写入 key:', fallbackKey);
  745. }
  746. // 更新消息payload
  747. msg.payload = {
  748. ...(msg.payload || {}),
  749. orderCardId,
  750. orderId: payRes.data.orderId,
  751. orderNo: payRes.data.orderNo || '',
  752. status: 'paid'
  753. };
  754. uni.$emit('payment_done', {
  755. orderCardId,
  756. orderId: payRes.data.orderId,
  757. assessmentId: assessmentId.value,
  758. positionId: positionId.value,
  759. paid: true
  760. });
  761. // 支付成功后跳转
  762. if (chatType.value === 'assessment') {
  763. setTimeout(() => {
  764. uni.navigateTo({ url: `/pages/assessment/training?title=${encodeURIComponent(assessmentTitle.value)}&assessmentId=${assessmentId.value}` });
  765. }, 1200);
  766. }
  767. },
  768. fail: (err) => {
  769. uni.hideLoading();
  770. console.error('微信支付失败:', err);
  771. if (err.errMsg && err.errMsg.includes('cancel')) {
  772. uni.showToast({ title: '支付已取消', icon: 'none' });
  773. } else {
  774. uni.showToast({ title: '支付失败,请重试', icon: 'none' });
  775. }
  776. }
  777. });
  778. } else {
  779. // 没有微信支付参数,可能是免费订单或其他情况
  780. uni.hideLoading();
  781. if (payRes.data && payRes.data.success) {
  782. msg.isPaid = true;
  783. uni.showToast({ title: payRes.data.message || '支付成功', icon: 'success' });
  784. } else {
  785. uni.showToast({ title: '支付处理异常', icon: 'none' });
  786. }
  787. }
  788. } catch (e) {
  789. uni.hideLoading();
  790. console.error('支付失败:', e);
  791. uni.showToast({ title: '支付失败:' + (e.message || '网络错误'), icon: 'none' });
  792. }
  793. }
  794. // ---- 工具 ----
  795. const chatBodyHeight = computed(() => {
  796. const navH = 100;
  797. const footerH = activePanel.value === 'none' ? 120 : 520;
  798. return `calc(100vh - ${navH}rpx - ${footerH}rpx - env(safe-area-inset-top) - env(safe-area-inset-bottom))`;
  799. });
  800. function scrollToBottom() {
  801. nextTick(() => { lastMessageId.value = ''; nextTick(() => { lastMessageId.value = 'bottom-anchor'; }); });
  802. }
  803. function goBack() { uni.navigateBack(); }
  804. function toggleInputMode() {
  805. inputMode.value = inputMode.value === 'text' ? 'voice' : 'text';
  806. activePanel.value = 'none';
  807. }
  808. function togglePanel(panel) {
  809. activePanel.value = activePanel.value === panel ? 'none' : panel;
  810. if (activePanel.value !== 'none') inputMode.value = 'text';
  811. scrollToBottom();
  812. }
  813. function onInputFocus() { activePanel.value = 'none'; scrollToBottom(); }
  814. function addEmoji(e) { inputValue.value += e; }
  815. function previewImg(url) { uni.previewImage({ urls: [url], current: url }); }
  816. function formatFileSize(size) {
  817. if (!size) return '';
  818. if (size < 1024) return size + 'B';
  819. if (size < 1024 * 1024) return (size / 1024).toFixed(1) + 'KB';
  820. return (size / 1024 / 1024).toFixed(1) + 'MB';
  821. }
  822. function formatTime(timeStr) {
  823. if (!timeStr) return '';
  824. const d = new Date(timeStr);
  825. if (isNaN(d)) return timeStr;
  826. const pad = n => n.toString().padStart(2, '0');
  827. return `${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
  828. }
  829. function shouldShowTime(msg, index) {
  830. if (index === 0) return true;
  831. const prev = messages.value[index - 1];
  832. if (!prev.sendTime || !msg.sendTime) return false;
  833. return (new Date(msg.sendTime) - new Date(prev.sendTime)) > 5 * 60 * 1000;
  834. }
  835. // 格式化金额显示
  836. function formatAmount(amount) {
  837. if (!amount && amount !== 0) return '—';
  838. // 如果是字符串,尝试转换为数字
  839. const num = typeof amount === 'string' ? parseFloat(amount) : amount;
  840. if (isNaN(num)) return '—';
  841. // 保留两位小数,去掉不必要的0
  842. return num.toFixed(2).replace(/\.?0+$/, '');
  843. }
  844. const onVoiceStart = () => uni.showToast({ title: '录音中...', icon: 'none' });
  845. const onVoiceEnd = () => uni.showToast({ title: '语音功能暂未开放', icon: 'none' });
  846. </script>
  847. <style lang="scss" scoped>
  848. .container { width: 100%; height: 100vh; background-color: #F4F5F7; display: flex; flex-direction: column; overflow: hidden; }
  849. /* 状态栏占位:高度由 JS 动态注入 */
  850. .status-bar { background: #FFF; flex-shrink: 0; }
  851. /* 导航栏 */
  852. .nav-bar {
  853. height: 100rpx; background: #FFF; display: flex; align-items: center;
  854. padding: 0 30rpx; border-bottom: 1rpx solid #F0F0F0; flex-shrink: 0;
  855. .back-btn { width: 60rpx; display: flex; align-items: center;
  856. .back-arrow { font-size: 56rpx; color: #333; line-height: 1; margin-top: -6rpx; }
  857. }
  858. .nav-center { flex: 1; display: flex; align-items: center; justify-content: center; gap: 12rpx;
  859. .nav-title-text { font-size: 32rpx; font-weight: bold; color: #1A1A1A; }
  860. .online-dot { width: 14rpx; height: 14rpx; border-radius: 50%; background: #10B981; }
  861. }
  862. .nav-right { width: 60rpx; }
  863. }
  864. .chat-body { flex: 1; }
  865. .message-list { padding: 24rpx 30rpx 160rpx; }
  866. .tip-row { padding: 60rpx 0; text-align: center;
  867. .tip-text { font-size: 26rpx; color: #CCC; }
  868. }
  869. .time-stamp-row { display: flex; justify-content: center; margin: 20rpx 0 30rpx; }
  870. .time-stamp { font-size: 22rpx; color: #BBB; background: rgba(0,0,0,0.05); padding: 4rpx 18rpx; border-radius: 8rpx; }
  871. .msg-row {
  872. display: flex; margin-bottom: 44rpx;
  873. .avatar { width: 80rpx; height: 80rpx; border-radius: 50%; flex-shrink: 0; }
  874. &.left { .avatar { margin-right: 18rpx; } }
  875. &.right { justify-content: flex-end; .avatar { margin-left: 18rpx; } }
  876. }
  877. .msg-content { max-width: 520rpx; border-radius: 16rpx; padding: 22rpx 26rpx; font-size: 30rpx; line-height: 1.6; word-break: break-all; }
  878. .text-msg { background: #FFF; color: #333; &.shadow { box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.04); } &.user-bubble { background: #FFB700; color: #FFF; } }
  879. .img-msg { padding: 8rpx; background: #FFF; border-radius: 12rpx; box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.06);
  880. .chat-img { width: 360rpx; border-radius: 8rpx; display: block; }
  881. }
  882. .file-msg { display: flex; align-items: center; gap: 20rpx; background: #FFF; min-width: 300rpx;
  883. .file-icon-txt { font-size: 56rpx; flex-shrink: 0; }
  884. .file-info { flex: 1;
  885. .file-name { display: block; font-size: 28rpx; color: #333; margin-bottom: 6rpx; word-break: break-all; }
  886. .file-size { font-size: 22rpx; color: #999; }
  887. }
  888. }
  889. /* 订单卡片 */
  890. .deposit-card {
  891. background: #FFF; width: 500rpx; border-radius: 20rpx; overflow: hidden; padding: 0; box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
  892. .deposit-header { padding: 28rpx 28rpx 16rpx; display: flex; justify-content: space-between; align-items: flex-start;
  893. .d-header-left { flex: 1;
  894. .d-title { font-size: 32rpx; font-weight: bold; color: #333; }
  895. .d-subtitle { font-size: 22rpx; color: #BBB; margin-top: 6rpx; display: block; }
  896. }
  897. .d-countdown {
  898. display: flex; gap: 4rpx; align-items: center; justify-content: flex-end;
  899. .c-time { color: #FF9500; font-size: 26rpx; font-weight: bold; }
  900. .c-txt { color: #999; font-size: 22rpx; }
  901. }
  902. .d-paid-tag { color: #52C41A; font-size: 24rpx; font-weight: bold; }
  903. }
  904. .deposit-body { padding: 8rpx 28rpx 24rpx;
  905. .d-row { margin-bottom: 10rpx; font-size: 26rpx; display: flex;
  906. .label { color: #AAA; width: 140rpx; } .val { color: #333; flex: 1; } .price { color: #FF3B30; font-size: 34rpx; font-weight: bold; }
  907. }
  908. }
  909. .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; } }
  910. }
  911. /* 招聘初始卡片(静态展示用) */
  912. .job-card-msg {
  913. background: #FFF; border-radius: 20rpx; width: 500rpx; padding: 30rpx; box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.04);
  914. .card-header { display: flex; justify-content: space-between; margin-bottom: 20rpx;
  915. .ch-left { display: flex; align-items: center; gap: 10rpx;
  916. .card-title { font-weight: bold; font-size: 34rpx; }
  917. .urgent-tag { border: 1rpx solid #FF4D4F; color: #FF4D4F; font-size: 20rpx; padding: 2rpx 10rpx; border-radius: 6rpx; }
  918. }
  919. .card-salary { color: #1F6CFF; font-weight: bold; font-size: 32rpx; }
  920. }
  921. .card-tags { display: flex; gap: 12rpx; margin-bottom: 24rpx;
  922. .c-tag { background: #F5F7FA; color: #888; font-size: 22rpx; padding: 6rpx 16rpx; border-radius: 8rpx; }
  923. }
  924. .card-meta { display: flex; flex-direction: column; gap: 10rpx; margin-bottom: 24rpx;
  925. .m-item { display: flex; align-items: center; gap: 10rpx;
  926. .m-icon { width: 24rpx; height: 24rpx; opacity: 0.4; }
  927. text { font-size: 24rpx; color: #666; }
  928. }
  929. }
  930. .card-company { display: flex; align-items: center; border-top: 1rpx solid #F5F5F5; padding-top: 24rpx;
  931. .c-logo { width: 80rpx; height: 80rpx; border-radius: 12rpx; margin-right: 16rpx; }
  932. .c-info { flex: 1; display: flex; align-items: center; gap: 8rpx;
  933. .c-name { font-size: 28rpx; font-weight: bold; }
  934. .v-icon { width: 28rpx; height: 28rpx; }
  935. }
  936. .c-loc { font-size: 24rpx; color: #999; }
  937. }
  938. }
  939. /* 测评初始卡片 */
  940. .assessment-card-msg {
  941. background: #FFF; width: 480rpx; padding: 24rpx; display: flex; box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.04);
  942. border-radius: 16rpx;
  943. .card-left { width: 140rpx; height: 140rpx; margin-right: 20rpx;
  944. .a-cover { width: 100%; height: 100%; border-radius: 12rpx; }
  945. }
  946. .card-right { flex: 1; display: flex; flex-direction: column; justify-content: space-between;
  947. .a-title { font-weight: bold; font-size: 30rpx; color: #1A1A1A; }
  948. .a-tags { display: flex; gap: 10rpx; flex-wrap: wrap;
  949. .a-tag { font-size: 20rpx; color: #999; background: #F5F7FA; padding: 4rpx 12rpx; border-radius: 6rpx; }
  950. }
  951. .a-price { color: #FF4D4F; font-weight: bold; font-size: 32rpx; }
  952. }
  953. }
  954. /* 培训报名初始卡片 */
  955. .training-reg-card {
  956. background: #FFF; width: 480rpx; padding: 30rpx; border-radius: 20rpx;
  957. .t-card-header { margin-bottom: 24rpx;
  958. .t-card-title { font-weight: bold; font-size: 32rpx; color: #1A1A1A; display: block; margin-bottom: 8rpx; }
  959. .t-card-subtitle { font-size: 24rpx; color: #999; }
  960. }
  961. .t-card-body { margin-bottom: 30rpx;
  962. .t-item { display: flex; font-size: 26rpx; margin-bottom: 10rpx;
  963. .t-label { color: #888; width: 140rpx; } .t-val { color: #333; }
  964. }
  965. }
  966. .t-card-footer {
  967. .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; } }
  968. }
  969. }
  970. /* API 推送的岗位卡片(客服消息循环中使用)*/
  971. .api-job-card {
  972. background: #FFF; width: 460rpx; padding: 28rpx; border-radius: 16rpx;
  973. .jc-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12rpx;
  974. .jc-title { font-size: 30rpx; font-weight: bold; color: #1A1A1A; flex: 1; }
  975. .jc-salary { font-size: 28rpx; color: #1F6CFF; font-weight: bold; }
  976. }
  977. .jc-city { font-size: 24rpx; color: #888; }
  978. }
  979. /* 系统消息 */
  980. .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; }
  981. /* 底部输入栏 */
  982. .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; }
  983. .input-bar { height: 120rpx; display: flex; align-items: center; padding: 0 24rpx; gap: 20rpx;
  984. .bar-icon { width: 60rpx; height: 60rpx; transition: transform 0.2s; &.active { transform: scale(1.1); } }
  985. .center-area { flex: 1;
  986. .chat-input { background: #F7F8FA; height: 80rpx; border-radius: 12rpx; border: 1rpx solid #EEE; padding: 0 24rpx; font-size: 28rpx; }
  987. .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; } }
  988. }
  989. }
  990. .panel-section { height: 0; overflow: hidden; transition: height 0.3s; &.show { height: 400rpx; border-top: 1rpx solid #F2F2F2; } }
  991. .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; } } }
  992. .plus-panel { height: 100%; display: flex; padding: 40rpx 60rpx; gap: 80rpx;
  993. .panel-item { display: flex; flex-direction: column; align-items: center;
  994. .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; } }
  995. text { font-size: 26rpx; color: #777; }
  996. }
  997. }
  998. </style>