chat.vue 43 KB

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