chat.vue 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421
  1. <!-- 店铺客服聊天 -->
  2. <template>
  3. <view class="wanl-chat">
  4. <view class="edgeInsetTop"></view>
  5. <view @touchstart="hideDrawer">
  6. <scroll-view class="cu-chat" scroll-y="true" :scroll-with-animation="scrollAnimation" :scroll-top="scrollTop"
  7. :scroll-into-view="scrollToView" @scrolltoupper="loadHistory" upper-threshold="50">
  8. <view class="loading" v-show="isHistoryLoading">
  9. <view class="spinner">
  10. <view class="rect1"></view>
  11. <view class="rect2"></view>
  12. <view class="rect3"></view>
  13. <view class="rect4"></view>
  14. <view class="rect5"></view>
  15. </view>
  16. </view>
  17. <view v-for="(row, index) in msgList" :key="index" :id="'msg' + row.id">
  18. <view v-if="row.type == 'chat'">
  19. <view class="cu-item self" v-if="parseInt(row.form.id) === user_id">
  20. <view class="main" v-if="row.message.type == 'text'">
  21. <view class="content bg-green">
  22. <rich-text :nodes="row.message.content.text"></rich-text>
  23. </view>
  24. </view>
  25. <view class="main" v-if="row.message.type == 'img'">
  26. <image :src="row.message.content.url" @tap="showPic(row.message)"
  27. :style="{ width: row.message.content.w + 'px', height: row.message.content.h + 'px' }"></image>
  28. </view>
  29. <view class="main" v-if="row.message.type == 'voice'" @tap="playVoice(row.message)"
  30. :class="playMsgid == row.message.id ? 'play' : ''">
  31. <view class="action text-bold text-grey" style="padding-right: 2rpx;">
  32. {{ row.message.content.length }}
  33. <text class="wlIcon-miao"></text>
  34. </view>
  35. <view class="content bg-green">
  36. <text :style="{ width: row.message.content.length * 6 + 'rpx' }"></text>
  37. <text class="wlIcon-yuyinyou text-xxl padding-left-xl"></text>
  38. </view>
  39. </view>
  40. <view class="main goods" v-if="row.message.type == 'goods'">
  41. <view class="content" @tap="onGoods(row.message.content.id)">
  42. <image :src="$appKit.oss(row.message.content.image, 100, 0)" mode="widthFix"></image>
  43. <view class="text-price text-orange text-lg margin-tb-xs">
  44. {{ row.message.content.price }}
  45. </view>
  46. <view>
  47. {{ row.message.content.title }}
  48. </view>
  49. </view>
  50. </view>
  51. <view class="main order" v-if="row.message.type == 'order'">
  52. <view class="content" @tap="orderDetails(row.message.content.id)">
  53. <view>
  54. <text>{{ $t('chat.order-details') }}</text>
  55. </view>
  56. <view class="margin-tb-bj radius product padding-sm">
  57. <view class="item" v-for="(item, idx) in row.message.content.goods" :key="idx">
  58. <view class="image">
  59. <image :src="$appKit.oss(item.image, 50, 50)" mode="aspectFill"></image>
  60. </view>
  61. <view class="details text-sm">
  62. <view class="text-cut wanl-gray-dark">
  63. <text>{{ item.title }}</text>
  64. </view>
  65. <view class="wanl-gray-light flex justify-between" style="width: 100%;">
  66. <view class="text-price text-orange">
  67. {{ item.price * item.number }}
  68. </view>
  69. <view>
  70. <text>{{ item.difference }} x {{ item.number }}</text>
  71. <text v-if="item.refund_status != 0">({{ refundStatusText[item.refund_status] }})</text>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. <view class="text-sm flex justify-between">
  78. <view>
  79. <text>{{ stateText[row.message.content.state - 1] }}</text>
  80. </view>
  81. <view>
  82. <text>{{ $t('chat.order-number') }}:</text>
  83. <text>{{ row.message.content.order_no }}</text>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="cu-avatar radius"
  89. :style="{ backgroundImage: 'url(' + $appKit.oss(row.form.avatar, 100, 100) + ')' }"></view>
  90. <view class="date">{{ $appKit.timeToChat(row.createtime) }}</view>
  91. </view>
  92. <view class="cu-item" v-else>
  93. <view class="cu-avatar radius"
  94. :style="{ backgroundImage: 'url(' + $appKit.oss(row.form.avatar, 100, 100) + ')' }"></view>
  95. <view class="main" v-if="row.message.type == 'text'">
  96. <view class="content">
  97. <rich-text :nodes="row.message.content.text"></rich-text>
  98. </view>
  99. </view>
  100. <view class="main" v-if="row.message.type == 'img'">
  101. <image :src="row.message.content.url" @tap="showPic(row.message)"
  102. :style="{ width: row.message.content.w + 'px', height: row.message.content.h + 'px' }"></image>
  103. </view>
  104. <view class="main" v-if="row.message.type == 'voice'" @tap="playVoice(row.message)"
  105. :class="playMsgid == row.message.id ? 'play' : ''">
  106. <view class="content">
  107. <text class="wlIcon-yuyinzuo text-xxl padding-right-xl"></text>
  108. <text :style="{ width: row.message.content.length * 6 + 'rpx' }"></text>
  109. </view>
  110. <view class="action text-bold text-grey">
  111. {{ row.message.content.length }}
  112. <text class="wlIcon-miao"></text>
  113. </view>
  114. </view>
  115. <view class="date">{{ $appKit.timeToChat(row.createtime) }}</view>
  116. </view>
  117. </view>
  118. <view v-if="row.type == 'sys'">
  119. <view class="cu-info round">{{ $t('chat.system-message-withdrawn') }}</view>
  120. </view>
  121. </view>
  122. </scroll-view>
  123. </view>
  124. <view class="popup-layer" :class="{ showLayer: popupLayerClass }" @touchmove.stop.prevent="discard">
  125. <view :class="{ hidden: hideEmoji }">
  126. <view class="emoji">
  127. <scroll-view class="emojinav" scroll-x scroll-with-animation>
  128. <view class="item">
  129. <view :class="item == TabCur ? 'emojibg' : ''" v-for="(item, index) in emojiList.categories" :key="index"
  130. @tap="tabSelect" :data-id="item"
  131. :style="{ backgroundImage: 'url(' + emojiList.groups[item][0].url + ')' }"></view>
  132. </view>
  133. </scroll-view>
  134. <scroll-view v-for="(emoji, groups) in emojiList.groups" :key="groups" v-if="TabCur == groups" class="subject"
  135. scroll-y scroll-with-animation>
  136. <view class="item grid margin-bottom text-center col-5">
  137. <view v-for="(item, index) in emoji" :key="index" @tap="addEmoji(item.value)"
  138. :style="{ backgroundImage: 'url(' + item.url + ')' }"></view>
  139. </view>
  140. </scroll-view>
  141. </view>
  142. </view>
  143. <view class="solid-top" :class="{ hidden: hideMore }">
  144. <view class="opmenu solid-top">
  145. <view class="box" @tap="browsing">
  146. <view class="icon wanl-gray"><text class="wlIcon-shangpin"></text></view>
  147. <text class="text-sm">{{ $t('chat.button.goods') }}</text>
  148. </view>
  149. <view class="box" @tap="order">
  150. <view class="icon wanl-gray"><text class="wlIcon-dingdan1"></text></view>
  151. <text class="text-sm">{{ $t('chat.button.order') }}</text>
  152. </view>
  153. <!-- #ifndef H5 -->
  154. <view class="box" @tap="camera">
  155. <view class="icon wanl-gray"><text class="wlIcon-31paishexuanzhong"></text></view>
  156. <text class="text-sm">{{ $t('chat.button.camera') }}</text>
  157. </view>
  158. <!-- #endif -->
  159. <view class="box" @tap="chooseImage">
  160. <view class="icon wanl-gray"><text class="wlIcon-tupian1"></text></view>
  161. <text class="text-sm">{{ $t('chat.button.photo') }}</text>
  162. </view>
  163. <view class="box" @tap="complaint">
  164. <view class="icon wanl-gray"><text class="wlIcon-zhuyidapx"></text></view>
  165. <text class="text-sm">{{ $t('chat.button.complaint') }}</text>
  166. </view>
  167. </view>
  168. </view>
  169. </view>
  170. <view class="input-box" :class="{ emptybottom: emptybottom, showLayer: popupLayerClass }"
  171. @touchmove.stop.prevent="discard">
  172. <!-- #ifndef H5 -->
  173. <view class="voice">
  174. <view :class="isVoice ? 'wlIcon-jianpanqiehuan' : 'wlIcon-yuyin'" @tap="switchVoice"></view>
  175. </view>
  176. <!-- #endif -->
  177. <!-- #ifdef H5 -->
  178. <view class="more" @tap="showMore">
  179. <view class="wlIcon-yuanquanjiahao"></view>
  180. </view>
  181. <!-- #endif -->
  182. <view class="textbox">
  183. <view class="voice-mode" :class="[isVoice ? '' : 'hidden', recording ? 'recording' : '']"
  184. @touchstart="voiceBegin" @touchmove.stop.prevent="voiceIng" @touchend="voiceEnd" @touchcancel="voiceCancel">
  185. {{ voiceTis }}
  186. </view>
  187. <view class="text-mode" :class="isVoice ? 'hidden' : ''">
  188. <view class="box">
  189. <textarea auto-height="true" maxlength="300" :show-confirm-bar="false" cursor-spacing="90" v-model="textMsg"
  190. @focus="textareaFocus" @blur="textareaBlur" @confirm="sendText" />
  191. </view>
  192. <view class="em" @tap="chooseEmoji">
  193. <view class="wlIcon-biaoqing2"></view>
  194. </view>
  195. </view>
  196. </view>
  197. <!-- #ifndef H5 -->
  198. <view class="more" @tap="showMore" style="margin-right: -12rpx;">
  199. <view class="wlIcon-yuanquanjiahao"></view>
  200. </view>
  201. <!-- #endif -->
  202. <view class="send" :class="isVoice ? 'hidden' : ''" @tap="sendText">
  203. <text class="wlIcon-zhifeiji" v-if="textMsg"></text>
  204. <text class="wlIcon-fasong" v-else></text>
  205. </view>
  206. </view>
  207. <view class="chatTips bg-white radius-bock margin-lr-bj padding-sm" v-if="goods && isGoods">
  208. <image class="radius" :src="$appKit.oss(goods.image, 100, 100)" mode="aspectFill"></image>
  209. <view class="details">
  210. <view class="flex justify-between margin-bottom-sm">
  211. <view class="text-cut title">
  212. <text>{{ goods.title }}</text>
  213. </view>
  214. <view @tap="closeTips()">
  215. <text class="wlIcon-31guanbi"></text>
  216. </view>
  217. </view>
  218. <view class="flex justify-between">
  219. <view class="text-lg text-orange">
  220. <text class="text-price">{{ goods.price }}</text>
  221. </view>
  222. <view>
  223. <button class="cu-btn round bg-orange sm" @tap="sendGoods(goods)">{{ $t('chat.send-merchant') }}</button>
  224. </view>
  225. </view>
  226. </view>
  227. </view>
  228. <view class="record" :class="recording ? '' : 'hidden'">
  229. <view class="ing" :class="willStop ? 'hidden' : ''">
  230. <view class="wlIcon-huatong01"></view>
  231. </view>
  232. <view class="cancel" :class="willStop ? '' : 'hidden'">
  233. <view class="wlIcon-shanchu2"></view>
  234. </view>
  235. <view class="tis" :class="willStop ? 'change' : ''">{{ recordTis }}</view>
  236. </view>
  237. <view class="WANL-MODAL">
  238. <view class="cu-modal bottom-modal" :class="modalName == 'goods' ? 'show' : ''" @tap="hideModal">
  239. <view class="cu-dialog bg-white" @tap.stop="">
  240. <view class="wanl-modal">
  241. <view class="head padding-bj">
  242. <view class="content">
  243. <view class="text-lg">{{ $t('chat.modal.browsed-goods') }}</view>
  244. </view>
  245. <view class="close wlIcon-31guanbi" @tap="hideModal"></view>
  246. </view>
  247. <scroll-view class="scroll-y" scroll-y="true">
  248. <view class="item goods" v-for="(item, index) in goodsData" :key="index">
  249. <block v-if="item.goods !== null">
  250. <image class="radius" :src="$appKit.oss(item.goods.image, 100, 100)" mode="aspectFill"></image>
  251. <view class="details">
  252. <view class="text-cut-2 title">
  253. <text>{{ item.goods.title }}</text>
  254. </view>
  255. <view class="flex justify-between info">
  256. <view class="text-lg text-orange">
  257. <text class="text-price">{{ item.goods.price }}</text>
  258. </view>
  259. <button class="cu-btn round line-orange sm" @tap="sendGoods(item.goods)">{{ $t('chat.send-goods')
  260. }}</button>
  261. </view>
  262. </view>
  263. </block>
  264. </view>
  265. </scroll-view>
  266. <view class="foot padding-lr-bj"><button class="cu-btn bg-gradual-orange round text-bold complete"
  267. @tap="hideModal">Complete</button></view>
  268. </view>
  269. </view>
  270. </view>
  271. <view class="cu-modal bottom-modal" :class="modalName == 'order' ? 'show' : ''" @tap="hideModal">
  272. <view class="cu-dialog bg-bgcolor" @tap.stop="">
  273. <view class="wanl-modal">
  274. <view class="head padding-bj">
  275. <view class="content">
  276. <view class="text-lg">{{ $t('chat.modal.purchased-orders') }}</view>
  277. </view>
  278. <view class="close wlIcon-31guanbi" @tap="hideModal"></view>
  279. </view>
  280. <scroll-view class="scroll-y" scroll-y="true">
  281. <view class="item order-list-item bg-white radius-bock margin-tb-sm padding-bj"
  282. v-for="(item, index) in orderData" :key="item.id" @tap="sendOrder(item)">
  283. <view class="order-list-item-head">
  284. <view><text>{{ $t('chat.order-number') }}:{{ item.order_no }}</text></view>
  285. <view><text class="wanl-gray-dark text-sm">{{ stateText[item.state - 1] }}</text></view>
  286. </view>
  287. <view class="order-list-item-goods" v-for="(gd, key) in item.goods" :key="key">
  288. <image class="radius" :src="$appKit.oss(gd.image, 100, 100)" mode="aspectFill"></image>
  289. <view class="order-list-item-details">
  290. <view class="text-cut-2 title wanl-gray-dark">{{ gd.title }}</view>
  291. <view class="flex justify-between info">
  292. <view class="text-lg text-orange">
  293. <text class="text-price">{{ gd.price }}</text>
  294. </view>
  295. </view>
  296. </view>
  297. </view>
  298. <view class="order-list-item-foot">
  299. <button class="cu-btn round sm line-orange">{{ $t('chat.send-order') }}</button>
  300. </view>
  301. </view>
  302. </scroll-view>
  303. <view class="foot padding-lr-bj"><button class="cu-btn bg-gradual-orange round text-bold complete"
  304. @tap="hideModal">{{ $t('chat.complete') }}</button></view>
  305. </view>
  306. </view>
  307. </view>
  308. </view>
  309. </view>
  310. </template>
  311. <script>
  312. const emotions = require('@/static/json/emotions.json')
  313. import { mapMutations } from 'vuex'
  314. import { getShopChat, getChatHistory, getBrowsingToShop, getOrderListToShop, getUploadConfig } from '@/features/mall/gateway/im'
  315. import { setChat } from '@/common/chat-utils.js'
  316. import { STORAGE } from '@/core/constants/storage-keys'
  317. export default {
  318. data() {
  319. return {
  320. user_id: parseInt(this.$store.state.user.id) || 0,
  321. avatar: this.$store.state.user.avatar,
  322. username: this.$store.state.user.username,
  323. nickname: this.$store.state.user.nickname,
  324. to_id: 0,
  325. shop_id: 0,
  326. shop_name: null,
  327. shop_avatar: null,
  328. textMsg: '',
  329. isHistoryLoading: false,
  330. reload: false,
  331. current_page: 1,
  332. scrollAnimation: false,
  333. scrollTop: 0,
  334. scrollToView: '',
  335. msgList: [],
  336. msgImgList: [],
  337. goods: null,
  338. isGoods: true,
  339. goodsData: [],
  340. orderData: [],
  341. emptybottom: false,
  342. // #ifndef H5
  343. RECORDER: uni.getRecorderManager(),
  344. // #endif
  345. isVoice: false,
  346. voiceTis: this.$t('chat.voice.hold-to-speak'),
  347. recordTis: this.$t('chat.voice.slide-up-to-cancel'),
  348. recording: false,
  349. willStop: false,
  350. initPoint: { identifier: 0, Y: 0 },
  351. recordTimer: null,
  352. recordLength: 0,
  353. AUDIO: uni.createInnerAudioContext(),
  354. playMsgid: null,
  355. VoiceTimer: null,
  356. popupLayerClass: false,
  357. hideMore: true,
  358. modalName: null,
  359. stateText: [this.$t('chat.state.waiting-payment'), this.$t('chat.state.payment-successful'), this.$t('chat.state.waiting-receipt'), this.$t('chat.state.waiting-review'), this.$t('chat.state.refund-order'), this.$t('chat.state.order-completed'), this.$t('chat.state.transaction-closed')],
  360. refundStatusText: [this.$t('chat.refund-status.not-refunded'), this.$t('chat.refund-status.refunding'), this.$t('chat.refund-status.to-be-returned'), this.$t('chat.refund-status.refund-completed'), this.$t('chat.refund-status.refund-closed'), this.$t('chat.refund-status.refund-rejected')],
  361. TabCur: this.$t('chat.emoji.default'),
  362. hideEmoji: true,
  363. emojiList: this.emojiData(),
  364. QnUrl: '',
  365. Sysmodel: ''
  366. }
  367. },
  368. created() {
  369. this.Sysmodel = (this.$wanlshop && this.$wanlshop.wanlsys) ? this.$wanlshop.wanlsys().model : ''
  370. },
  371. async onLoad(option) {
  372. if (option.hasOwnProperty('goods')) {
  373. this.goods = JSON.parse(option.goods)
  374. setTimeout(() => {
  375. this.isGoods = false
  376. }, 5000)
  377. }
  378. try {
  379. const res = await getShopChat({ id: option.shop_id, type: 'chat' })
  380. this.to_id = res.data.user_id
  381. this.shop_id = res.data.id
  382. this.shop_name = res.data.shopname
  383. this.shop_avatar = res.data.avatar
  384. uni.setNavigationBarTitle({ title: res.data.shopname + (res.data.isOnline == 1 ? '-' + this.$t('chat.online') : '-' + this.$t('chat.offline')) })
  385. this.getMsgList(res.data.user_id)
  386. // 進入聊天頁:暫停全局角标提示,並清零該會話未讀
  387. this.setIschat({ notice: false })
  388. this.$store.dispatch('chat/update', { type: 'del', id: res.data.user_id }).catch(() => {})
  389. setTimeout(() => {
  390. this.loadHistory({ bootstrap: true })
  391. }, 500)
  392. } catch (e) {
  393. console.error('[chat] getShopChat failed:', e)
  394. }
  395. this.AUDIO.onEnded(() => {
  396. this.playMsgid = null
  397. })
  398. // #ifndef H5
  399. this.RECORDER.onStart(e => {
  400. this.recordBegin(e)
  401. })
  402. this.RECORDER.onStop(e => {
  403. this.recordEnd(e)
  404. })
  405. // #endif
  406. uni.$on('onMessage', this.onSend)
  407. },
  408. onNavigationBarButtonTap() {
  409. uni.navigateTo({ url: '/pages/shop/index?id=' + this.shop_id })
  410. },
  411. onUnload() {
  412. uni.$off('onMessage', this.onSend)
  413. if (this.to_id) {
  414. this.$store.dispatch('chat/update', { type: 'del', id: this.to_id }).catch(() => {})
  415. }
  416. this.setIschat({ notice: true, number: 0 })
  417. },
  418. onShow() {
  419. if (this.msgList.length) {
  420. this.scrollToLatest()
  421. }
  422. },
  423. methods: {
  424. ...mapMutations({
  425. setIschat: 'chat/setIschat'
  426. }),
  427. /** 滚到最新消息(强制变更 scrollTop,避免同值不生效) */
  428. scrollToLatest() {
  429. if (!this.msgList.length) return
  430. const last = this.msgList[this.msgList.length - 1]
  431. this.scrollAnimation = false
  432. this.scrollToView = ''
  433. this.scrollTop = 0
  434. this.$nextTick(() => {
  435. this.scrollTop = 9999999 + (Date.now() % 1000)
  436. this.scrollToView = 'msg' + last.id
  437. this.$nextTick(() => {
  438. this.scrollAnimation = true
  439. })
  440. })
  441. },
  442. getMsgList(id) {
  443. const primary = STORAGE.chatMsgPrefix + id
  444. const legacy = 'wanlchat:message_' + id
  445. let list = uni.getStorageSync(primary)
  446. if (!Array.isArray(list) || !list.length) {
  447. list = uni.getStorageSync(legacy)
  448. // 旧 key 有数据时迁移到统一前缀
  449. if (Array.isArray(list) && list.length) {
  450. uni.setStorageSync(primary, list)
  451. }
  452. }
  453. if (!Array.isArray(list) || !list.length) return
  454. for (let i = 0; i < list.length; i++) {
  455. if (list[i].type == 'chat' && list[i].message && list[i].message.type == 'img') {
  456. list[i].message.content = this.setPicSize(list[i].message.content)
  457. this.msgImgList.push(list[i].message.content.url)
  458. }
  459. if (list[i].type == 'chat' && list[i].message && list[i].message.type == 'text') {
  460. list[i].message.content.text = this.replaceEmoji(list[i].message.content.text)
  461. }
  462. }
  463. this.msgList = list
  464. this.$nextTick(() => {
  465. this.scrollToLatest()
  466. })
  467. },
  468. async loadHistory(options) {
  469. // scrolltoupper 传入事件对象;进页引导传 { bootstrap: true }
  470. const bootstrap = !!(options && options.bootstrap)
  471. if (this.isHistoryLoading || this.reload || !this.to_id) return
  472. this.isHistoryLoading = true
  473. this.scrollAnimation = false
  474. const hadLocal = this.msgList.length > 0
  475. // 上拉加载更多时锚定原第一条;首次进页要滚到最新,不能锚到顶部
  476. const view_id = (!bootstrap && hadLocal) ? this.msgList[0].id : null
  477. try {
  478. const res = await getChatHistory({ to_id: this.to_id, page: this.current_page })
  479. const page = res && res.data
  480. let list = []
  481. let currentPage = 1
  482. let lastPage = 1
  483. if (Array.isArray(page)) {
  484. list = page
  485. } else if (page && typeof page === 'object') {
  486. list = page.data || page.rows || page.list || []
  487. currentPage = Number(page.current_page) || 1
  488. lastPage = Number(page.last_page) || currentPage
  489. }
  490. if (!Array.isArray(list)) list = []
  491. // 先拷贝一份用于本地缓存(避免把表情 HTML 写回)
  492. const forStore = currentPage == 1 ? JSON.parse(JSON.stringify(list)) : null
  493. for (let i = 0; i < list.length; i++) {
  494. if (list[i].type == 'chat' && list[i].message && list[i].message.type == 'img') {
  495. list[i].message.content = this.setPicSize(list[i].message.content)
  496. this.msgImgList.unshift(list[i].message.content.url)
  497. }
  498. if (list[i].type == 'chat' && list[i].message && list[i].message.type == 'text') {
  499. list[i].message.content.text = this.replaceEmoji(list[i].message.content.text)
  500. }
  501. }
  502. list.sort(function (a, b) {
  503. return (a.updatetime || a.createtime || 0) - (b.updatetime || b.createtime || 0)
  504. })
  505. if (currentPage == 1) {
  506. // 本地已有且服务端本页为空时,保留本地,避免被清空
  507. if (list.length || !hadLocal) {
  508. this.msgList = list
  509. }
  510. if (forStore && forStore.length && this.to_id) {
  511. uni.setStorageSync(STORAGE.chatMsgPrefix + this.to_id, forStore)
  512. }
  513. } else {
  514. this.msgList = list.concat(this.msgList)
  515. }
  516. this.$nextTick(() => {
  517. if (bootstrap || !view_id) {
  518. this.scrollToLatest()
  519. } else {
  520. this.scrollToView = 'msg' + view_id
  521. this.$nextTick(() => {
  522. this.scrollAnimation = true
  523. })
  524. }
  525. })
  526. if (currentPage >= lastPage || list.length === 0) {
  527. this.reload = true
  528. } else {
  529. this.current_page = currentPage + 1
  530. }
  531. } catch (e) {
  532. console.error('[chat] loadHistory failed:', e)
  533. }
  534. this.isHistoryLoading = false
  535. },
  536. onChat(msg) {
  537. if (msg.type == 'system') {
  538. if (msg.msg.type == 'text') this.addSystemTextMsg(msg)
  539. } else if (msg.type == 'chat') {
  540. if (msg.message.type == 'text') this.addTextMsg(msg)
  541. if (msg.message.type == 'voice') this.addVoiceMsg(msg)
  542. if (msg.message.type == 'img') this.addImgMsg(msg)
  543. if (msg.message.type == 'goods') this.addGoodsMsg(msg)
  544. if (msg.message.type == 'order') this.addOrderMsg(msg)
  545. }
  546. this.$nextTick(() => {
  547. this.scrollToView = 'msg' + msg.id
  548. })
  549. },
  550. onSend(msg) {
  551. if (msg.form.id == this.to_id) {
  552. setChat(msg, 'receive')
  553. if (msg.type == 'system') {
  554. if (msg.msg.type == 'text') this.addSystemTextMsg(msg)
  555. } else if (msg.type == 'chat') {
  556. if (msg.message.type == 'text') this.addTextMsg(msg)
  557. if (msg.message.type == 'voice') this.addVoiceMsg(msg)
  558. if (msg.message.type == 'img') this.addImgMsg(msg)
  559. if (msg.message.type == 'goods') this.addGoodsMsg(msg)
  560. if (msg.message.type == 'order') this.addOrderMsg(msg)
  561. }
  562. this.$nextTick(() => {
  563. this.scrollToView = 'msg' + msg.id
  564. })
  565. }
  566. },
  567. sendMsg(content, type) {
  568. let lastid = 1
  569. if (this.msgList.length) {
  570. lastid = this.msgList[this.msgList.length - 1].id
  571. lastid++
  572. }
  573. let data = {
  574. id: lastid,
  575. type: 'chat',
  576. to_id: this.to_id,
  577. form: {
  578. id: this.user_id,
  579. avatar: this.avatar,
  580. name: this.nickname
  581. },
  582. message: {
  583. type: type,
  584. content: content
  585. },
  586. createtime: parseInt(new Date().getTime() / 1000)
  587. }
  588. this.onChat(JSON.parse(JSON.stringify(data)))
  589. setChat(data, 'send')
  590. this.$store.dispatch('chat/update', {
  591. type: 'send',
  592. data,
  593. shop: {
  594. id: this.shop_id,
  595. user_id: this.to_id,
  596. name: this.shop_name,
  597. avatar: this.shop_avatar
  598. }
  599. }).catch(() => {})
  600. this.$appKit.send(data)
  601. },
  602. addTextMsg(msg) {
  603. msg.message.content.text = this.replaceEmoji(msg.message.content.text)
  604. this.msgList.push(msg)
  605. },
  606. addVoiceMsg(msg) {
  607. this.msgList.push(msg)
  608. },
  609. addImgMsg(msg) {
  610. msg.message.content = this.setPicSize(msg.message.content)
  611. this.msgImgList.push(msg.message.content.url)
  612. this.msgList.push(msg)
  613. },
  614. addGoodsMsg(msg) {
  615. this.msgList.push(msg)
  616. },
  617. addOrderMsg(msg) {
  618. this.msgList.push(msg)
  619. },
  620. addSystemTextMsg(msg) {
  621. this.msgList.push(msg)
  622. },
  623. emojiData() {
  624. var groups = {},
  625. categories = [],
  626. map = {}
  627. emotions.forEach(emotion => {
  628. var cate = emotion.category.length > 0 ? emotion.category : this.$t('chat.emoji.default')
  629. if (!groups[cate]) {
  630. groups[cate] = []
  631. categories.push(cate)
  632. }
  633. groups[cate].push(emotion)
  634. map[emotion.phrase] = emotion.icon
  635. })
  636. return { groups, categories, map }
  637. },
  638. replaceEmoji(str) {
  639. if (!str) return ''
  640. let replacedStr = str
  641. Object.keys(this.emojiList.map).forEach(key => {
  642. if (str.indexOf(key) !== -1) {
  643. const url = this.emojiList.map[key]
  644. if (url) {
  645. replacedStr = replacedStr.split(key).join('<img src="' + url + '" style="width:18px;vertical-align:middle;">')
  646. }
  647. }
  648. })
  649. return replacedStr.replace(/(\r\n)|(\n)/g, '<br>')
  650. },
  651. tabSelect(e) {
  652. this.TabCur = e.currentTarget.dataset.id
  653. },
  654. setPicSize(content) {
  655. let maxW = uni.upx2px(350)
  656. let maxH = uni.upx2px(350)
  657. if (content.w > maxW || content.h > maxH) {
  658. let scale = content.w / content.h
  659. content.w = scale > 1 ? maxW : maxH * scale
  660. content.h = scale > 1 ? maxW / scale : maxH
  661. }
  662. return content
  663. },
  664. showMore() {
  665. this.isVoice = false
  666. this.hideEmoji = true
  667. if (this.hideMore) {
  668. this.hideMore = false
  669. this.openDrawer()
  670. } else {
  671. this.hideDrawer()
  672. }
  673. },
  674. openDrawer() {
  675. this.emptybottom = true
  676. this.popupLayerClass = true
  677. },
  678. hideDrawer() {
  679. this.emptybottom = false
  680. this.popupLayerClass = false
  681. setTimeout(() => {
  682. this.hideMore = true
  683. this.hideEmoji = true
  684. }, 150)
  685. },
  686. chooseImage() {
  687. this.getImage('album')
  688. },
  689. camera() {
  690. this.getImage('camera')
  691. },
  692. getImage(type) {
  693. this.hideDrawer()
  694. uni.chooseImage({
  695. sourceType: [type],
  696. sizeType: ['original', 'compressed'],
  697. success: res => {
  698. uni.showLoading({ title: this.$t('chat.voice.sending-voice'), mask: true })
  699. const total = res.tempFilePaths.length
  700. let done = 0
  701. const tryHide = () => {
  702. done++
  703. if (done >= total) uni.hideLoading()
  704. }
  705. getUploadConfig().then(updata => {
  706. for (let i = 0; i < total; i++) {
  707. uni.getImageInfo({
  708. src: res.tempFilePaths[i],
  709. success: image => {
  710. uni.uploadFile({
  711. url: updata.uploadurl,
  712. filePath: image.path,
  713. name: 'file',
  714. formData: updata.storage == 'local' ? null : updata.multipart,
  715. success: data => {
  716. this.sendMsg({ url: JSON.parse(data.data).data.fullurl, w: image.width, h: image.height }, 'img')
  717. tryHide()
  718. },
  719. fail: error => {
  720. uni.showToast({ title: JSON.parse(error.data).msg, icon: 'error', position: true })
  721. tryHide()
  722. }
  723. })
  724. },
  725. fail: () => tryHide()
  726. })
  727. }
  728. }).catch(() => {
  729. uni.hideLoading()
  730. })
  731. }
  732. })
  733. },
  734. showPic(message) {
  735. uni.previewImage({
  736. indicator: 'none',
  737. current: message.content.url,
  738. urls: this.msgImgList
  739. })
  740. },
  741. chooseEmoji() {
  742. this.hideMore = true
  743. if (this.hideEmoji) {
  744. this.hideEmoji = false
  745. this.openDrawer()
  746. } else {
  747. this.hideDrawer()
  748. }
  749. },
  750. addEmoji(em) {
  751. this.textMsg += em
  752. },
  753. textareaFocus() {
  754. this.emptybottom = true
  755. this.closeTips()
  756. if (this.popupLayerClass && this.hideMore == false) {
  757. this.hideDrawer()
  758. }
  759. },
  760. textareaBlur() {
  761. this.emptybottom = false
  762. },
  763. sendText() {
  764. this.hideDrawer()
  765. if (!this.textMsg) return
  766. let msg = { text: this.textMsg }
  767. this.sendMsg(msg, 'text')
  768. this.textMsg = ''
  769. },
  770. sendGoods(data) {
  771. this.sendMsg(data, 'goods')
  772. this.closeTips()
  773. this.hideModal()
  774. },
  775. sendOrder(data) {
  776. this.sendMsg({ id: data.id, order_no: data.order_no, goods: data.goods, state: data.state }, 'order')
  777. this.closeTips()
  778. this.hideModal()
  779. },
  780. closeTips() {
  781. this.isGoods = false
  782. },
  783. complaint() {
  784. this.$appKit.to(`/pages/account/complaint?id=${this.shop_id}&type=2`)
  785. this.hideDrawer()
  786. },
  787. async browsing() {
  788. this.hideDrawer()
  789. try {
  790. const res = await getBrowsingToShop({ shop_id: this.shop_id })
  791. this.goodsData = res.data
  792. this.modalName = 'goods'
  793. } catch (e) {
  794. console.error('[chat] browsing failed:', e)
  795. }
  796. },
  797. async order() {
  798. this.hideDrawer()
  799. try {
  800. const res = await getOrderListToShop({ shop_id: this.shop_id })
  801. this.orderData = res.data
  802. this.modalName = 'order'
  803. } catch (e) {
  804. console.error('[chat] order failed:', e)
  805. }
  806. },
  807. hideModal() {
  808. this.modalName = null
  809. },
  810. playVoice(message) {
  811. this.playMsgid = message.id
  812. this.AUDIO.src = message.content.url
  813. this.$nextTick(() => {
  814. this.AUDIO.play()
  815. })
  816. },
  817. voiceBegin(e) {
  818. if (e.touches.length > 1) return
  819. this.initPoint.Y = e.touches[0].clientY
  820. this.initPoint.identifier = e.touches[0].identifier
  821. this.RECORDER.start({ format: 'mp3' })
  822. },
  823. recordBegin() {
  824. this.recording = true
  825. this.voiceTis = this.$t('chat.voice.release-to-end')
  826. this.recordLength = 0
  827. this.recordTimer = setInterval(() => {
  828. this.recordLength++
  829. }, 1000)
  830. },
  831. voiceCancel() {
  832. this.recording = false
  833. this.voiceTis = this.$t('chat.voice.hold-to-speak')
  834. this.recordTis = this.$t('chat.voice.slide-up-to-cancel')
  835. this.willStop = true
  836. this.RECORDER.stop()
  837. },
  838. voiceIng(e) {
  839. if (!this.recording) return
  840. let touche = e.touches[0]
  841. if (this.initPoint.Y - touche.clientY >= uni.upx2px(200)) {
  842. this.willStop = true
  843. this.recordTis = this.$t('chat.voice.release-finger-to-cancel')
  844. } else {
  845. this.willStop = false
  846. this.recordTis = this.$t('chat.voice.slide-up-to-cancel')
  847. }
  848. },
  849. voiceEnd() {
  850. if (!this.recording) return
  851. this.recording = false
  852. this.voiceTis = this.$t('chat.voice.hold-to-speak')
  853. this.recordTis = this.$t('chat.voice.slide-up-to-cancel')
  854. this.RECORDER.stop()
  855. },
  856. recordEnd(e) {
  857. clearInterval(this.recordTimer)
  858. if (!this.willStop) {
  859. uni.showLoading({ title: this.$t('chat.voice.sending-voice'), mask: true })
  860. getUploadConfig().then(updata => {
  861. uni.uploadFile({
  862. url: updata.uploadurl,
  863. filePath: e.tempFilePath,
  864. name: 'file',
  865. formData: updata.storage == 'local' ? null : updata.multipart,
  866. success: data => {
  867. uni.hideLoading()
  868. let msg = { length: 0, url: JSON.parse(data.data).data.fullurl }
  869. msg.length = this.recordLength % 60
  870. if (msg.length > 0) this.sendMsg(msg, 'voice')
  871. },
  872. fail: error => {
  873. uni.hideLoading()
  874. this.$appKit.msg(JSON.parse(error.data).msg)
  875. }
  876. })
  877. }).catch(() => {
  878. uni.hideLoading()
  879. })
  880. }
  881. this.willStop = false
  882. },
  883. switchVoice() {
  884. this.hideDrawer()
  885. this.isVoice = !this.isVoice
  886. },
  887. discard() {
  888. return
  889. }
  890. }
  891. }
  892. </script>
  893. <style>
  894. .cu-btn.sm {
  895. font-size: 26rpx;
  896. }
  897. .cu-modal {
  898. z-index: 2001;
  899. }
  900. .chatTips {
  901. display: inline-flex;
  902. align-items: center;
  903. position: absolute;
  904. z-index: 101;
  905. right: 0;
  906. left: 0;
  907. bottom: 120rpx;
  908. bottom: calc(120rpx + env(safe-area-inset-bottom));
  909. }
  910. .chatTips image {
  911. width: 100rpx;
  912. height: 100rpx;
  913. margin-right: 20rpx;
  914. flex-shrink: 0;
  915. }
  916. .chatTips .details {
  917. width: calc(100% - 100rpx - 20rpx);
  918. }
  919. .chatTips .details .title {
  920. width: 90%;
  921. }
  922. .cu-chat .cu-item>.main.goods .content,
  923. .cu-chat .cu-item>.main.order .content {
  924. display: block;
  925. }
  926. .cu-chat .cu-item>.main.order {
  927. max-width: calc(100% - 200rpx);
  928. }
  929. .cu-chat .cu-item>.main.order .product {
  930. background-color: #f9f9f9;
  931. }
  932. .cu-chat .cu-item>.main.order .product .item {
  933. display: flex;
  934. justify-content: space-between;
  935. margin-bottom: 25rpx;
  936. }
  937. .cu-chat .cu-item>.main.order .product .item:last-of-type {
  938. margin-bottom: 0;
  939. }
  940. .cu-chat .cu-item>.main.order .product .item .image,
  941. .product .item .image image {
  942. width: 100rpx;
  943. height: 100rpx;
  944. border-radius: 10rpx;
  945. }
  946. .cu-chat .cu-item>.main.order .product .item .details {
  947. display: flex;
  948. flex-wrap: wrap;
  949. width: calc(100% - 120rpx);
  950. align-content: space-between;
  951. }
  952. .wanl-modal .goods {
  953. display: flex;
  954. padding: 20rpx 0;
  955. }
  956. .wanl-modal .goods:last-of-type {
  957. padding-bottom: 0;
  958. }
  959. .wanl-modal .goods image {
  960. width: 180rpx;
  961. height: 180rpx;
  962. margin-right: 20rpx;
  963. flex-shrink: 0;
  964. }
  965. .wanl-modal .goods .details {
  966. flex-wrap: wrap;
  967. display: flex;
  968. flex: 1;
  969. align-content: space-between;
  970. }
  971. .wanl-modal .goods .details .info {
  972. width: 100%;
  973. }
  974. .order-list-item {
  975. display: flex;
  976. flex-direction: column;
  977. align-items: stretch;
  978. box-sizing: border-box;
  979. overflow: hidden;
  980. }
  981. .order-list-item-head {
  982. display: flex;
  983. flex-direction: column;
  984. gap: 8rpx;
  985. margin-bottom: 16rpx;
  986. font-size: 28rpx;
  987. }
  988. .order-list-item-goods {
  989. display: flex;
  990. align-items: flex-start;
  991. margin-bottom: 20rpx;
  992. min-width: 0;
  993. }
  994. .order-list-item-goods image {
  995. width: 160rpx;
  996. height: 160rpx;
  997. border-radius: 10rpx;
  998. flex-shrink: 0;
  999. margin-right: 20rpx;
  1000. }
  1001. .order-list-item-details {
  1002. flex: 1;
  1003. min-width: 0;
  1004. display: flex;
  1005. flex-direction: column;
  1006. justify-content: space-between;
  1007. }
  1008. .order-list-item-details .title {
  1009. font-size: 26rpx;
  1010. line-height: 1.4;
  1011. margin-bottom: 8rpx;
  1012. word-break: break-all;
  1013. }
  1014. .order-list-item-details .info {
  1015. align-items: center;
  1016. }
  1017. .order-list-item-foot {
  1018. flex-shrink: 0;
  1019. display: flex;
  1020. justify-content: flex-end;
  1021. padding-top: 8rpx;
  1022. }
  1023. .opmenu {
  1024. display: flex;
  1025. flex-wrap: wrap;
  1026. margin-top: 2rpx;
  1027. color: #4c4c4c;
  1028. }
  1029. .opmenu .box {
  1030. padding-top: 35rpx;
  1031. padding-left: 50rpx;
  1032. text-align: center;
  1033. }
  1034. .opmenu .box .icon {
  1035. height: 120rpx;
  1036. width: 120rpx;
  1037. display: flex;
  1038. align-items: center;
  1039. justify-content: center;
  1040. justify-items: center;
  1041. background-color: #ffffff;
  1042. border-radius: 20rpx;
  1043. font-size: 68rpx;
  1044. margin-bottom: 10rpx;
  1045. }
  1046. .emptybottom {
  1047. padding-bottom: 0 !important;
  1048. }
  1049. .hidden {
  1050. display: none !important;
  1051. }
  1052. .cu-chat .cu-item>.main .content {
  1053. font-size: 30rpx;
  1054. border-radius: 17rpx;
  1055. }
  1056. .cu-chat .cu-item [class*='wlIcon-'] {
  1057. font-size: 34rpx;
  1058. }
  1059. .popup-layer {
  1060. transition: all 0.15s linear;
  1061. width: 100%;
  1062. height: 480rpx;
  1063. background-color: #f5f5f5;
  1064. position: fixed;
  1065. z-index: 2000;
  1066. top: 100%;
  1067. }
  1068. .popup-layer.showLayer {
  1069. transform: translate3d(0, -480rpx, 0);
  1070. }
  1071. .popup-layer .emoji .emojinav {
  1072. background-color: #f8f8f8;
  1073. }
  1074. .popup-layer .emoji .emojinav .item {
  1075. display: flex;
  1076. align-items: center;
  1077. height: 100rpx;
  1078. padding-left: 10rpx;
  1079. }
  1080. .popup-layer .emoji .emojinav .item .emojibg {
  1081. background-color: #dedede;
  1082. }
  1083. .popup-layer .emoji .emojinav .item>view {
  1084. margin: 0 25rpx;
  1085. width: 60rpx;
  1086. height: 60rpx;
  1087. border-radius: 18rpx;
  1088. background-repeat: no-repeat;
  1089. background-size: 80%;
  1090. background-position: center;
  1091. }
  1092. .popup-layer .emoji .subject {
  1093. height: 380rpx;
  1094. background-color: #f1f1f1;
  1095. }
  1096. .popup-layer .emoji .subject .item {
  1097. padding: 25rpx;
  1098. }
  1099. .popup-layer .emoji .subject .item>view {
  1100. background-repeat: no-repeat;
  1101. background-size: 56%;
  1102. background-position: center;
  1103. width: 12.5%;
  1104. height: 100rpx;
  1105. }
  1106. .input-box {
  1107. width: 100%;
  1108. min-height: 100rpx;
  1109. padding-bottom: env(safe-area-inset-bottom);
  1110. background-color: #f2f2f2;
  1111. display: flex;
  1112. align-items: flex-end;
  1113. position: fixed;
  1114. z-index: 2000;
  1115. bottom: -2rpx;
  1116. transition: all 0.15s linear;
  1117. }
  1118. .input-box [class*='wlIcon-'] {
  1119. font-size: 50rpx;
  1120. color: #323232;
  1121. }
  1122. .input-box .wlIcon-zhifeiji {
  1123. color: #fe6600;
  1124. }
  1125. .input-box.showLayer {
  1126. transform: translate3d(0, -480rpx, 0);
  1127. }
  1128. .input-box .voice,
  1129. .input-box .more {
  1130. flex-shrink: 0;
  1131. width: 90rpx;
  1132. height: 100rpx;
  1133. display: flex;
  1134. justify-content: center;
  1135. align-items: center;
  1136. }
  1137. .input-box .send {
  1138. flex-shrink: 0;
  1139. width: 90rpx;
  1140. height: 100rpx;
  1141. display: flex;
  1142. justify-content: center;
  1143. align-items: center;
  1144. }
  1145. .input-box .send .btn {
  1146. width: 110rpx;
  1147. height: 70rpx;
  1148. display: flex;
  1149. justify-content: center;
  1150. align-items: center;
  1151. border-radius: 16rpx;
  1152. font-size: 32rpx;
  1153. }
  1154. .input-box .textbox {
  1155. width: 100%;
  1156. }
  1157. .input-box .textbox .voice-mode {
  1158. width: calc(100% - 2upx);
  1159. height: 80rpx;
  1160. margin: 10rpx 0;
  1161. border-radius: 16rpx;
  1162. display: flex;
  1163. justify-content: center;
  1164. align-items: center;
  1165. font-size: 28rpx;
  1166. background-color: #fff;
  1167. color: #555;
  1168. }
  1169. .input-box .textbox .voice-mode.recording {
  1170. background-color: #e5e5e5;
  1171. }
  1172. .input-box .textbox .text-mode {
  1173. width: 100%;
  1174. min-height: 80rpx;
  1175. margin: 10rpx 0;
  1176. display: flex;
  1177. background-color: #ffffff;
  1178. border-radius: 16rpx;
  1179. }
  1180. .input-box .textbox .text-mode .box {
  1181. width: 100%;
  1182. padding-left: 30rpx;
  1183. min-height: 80rpx;
  1184. display: flex;
  1185. align-items: center;
  1186. }
  1187. .input-box .textbox .text-mode .box textarea {
  1188. width: 100%;
  1189. }
  1190. .input-box .textbox .text-mode .em {
  1191. flex-shrink: 0;
  1192. width: 80rpx;
  1193. padding-left: 10rpx;
  1194. height: 80rpx;
  1195. display: flex;
  1196. justify-content: center;
  1197. align-items: center;
  1198. }
  1199. .record {
  1200. width: 39vw;
  1201. height: 39vw;
  1202. position: fixed;
  1203. top: 35%;
  1204. left: 30%;
  1205. background-color: rgba(0, 0, 0, 0.8);
  1206. border-radius: 40rpx;
  1207. }
  1208. .record .ing {
  1209. width: 100%;
  1210. height: 30vw;
  1211. display: flex;
  1212. justify-content: center;
  1213. align-items: center;
  1214. }
  1215. @keyframes volatility {
  1216. 0% {
  1217. background-position: 0% 130%;
  1218. }
  1219. 20% {
  1220. background-position: 0% 150%;
  1221. }
  1222. 30% {
  1223. background-position: 0% 155%;
  1224. }
  1225. 40% {
  1226. background-position: 0% 160%;
  1227. }
  1228. 50% {
  1229. background-position: 0% 145%;
  1230. }
  1231. 70% {
  1232. background-position: 0% 150%;
  1233. }
  1234. 80% {
  1235. background-position: 0% 170%;
  1236. }
  1237. 90% {
  1238. background-position: 0% 160%;
  1239. }
  1240. 100% {
  1241. background-position: 0% 135%;
  1242. }
  1243. }
  1244. .record .ing [class*='wlIcon'] {
  1245. background-image: linear-gradient(to bottom, #ffffff, #565656 50%);
  1246. background-size: 100% 200%;
  1247. animation: volatility 1.5s ease-in-out -1.5s infinite alternate;
  1248. -webkit-background-clip: text;
  1249. -webkit-text-fill-color: transparent;
  1250. font-size: 140rpx;
  1251. padding-top: 40rpx;
  1252. color: #f09b37;
  1253. }
  1254. .record .cancel {
  1255. width: 100%;
  1256. height: 30vw;
  1257. display: flex;
  1258. justify-content: center;
  1259. align-items: center;
  1260. }
  1261. .record .cancel [class*='wlIcon'] {
  1262. color: #fff;
  1263. font-size: 150rpx;
  1264. }
  1265. .record .tis {
  1266. width: 100%;
  1267. height: 10vw;
  1268. display: flex;
  1269. justify-content: center;
  1270. font-size: 24rpx;
  1271. color: #fff;
  1272. }
  1273. .record .tis.change {
  1274. color: #f09b37;
  1275. }
  1276. .content {
  1277. width: 100%;
  1278. }
  1279. page {
  1280. background-color: #ececec;
  1281. }
  1282. .content .msg-list,
  1283. .cu-chat {
  1284. position: absolute;
  1285. top: 0;
  1286. bottom: 100rpx;
  1287. bottom: calc(env(safe-area-inset-bottom) + 100rpx);
  1288. background-color: #ececec;
  1289. }
  1290. .loading {
  1291. display: flex;
  1292. justify-content: center;
  1293. }
  1294. @keyframes stretchdelay {
  1295. 0%,
  1296. 40%,
  1297. 100% {
  1298. transform: scaleY(0.6);
  1299. }
  1300. 20% {
  1301. transform: scaleY(1);
  1302. }
  1303. }
  1304. .loading .spinner {
  1305. margin: 20upx 0;
  1306. width: 60upx;
  1307. height: 100upx;
  1308. display: flex;
  1309. align-items: center;
  1310. justify-content: space-between;
  1311. }
  1312. .loading .spinner view {
  1313. background-color: #dadada;
  1314. height: 50upx;
  1315. width: 6upx;
  1316. border-radius: 6upx;
  1317. animation: stretchdelay 1.2s infinite ease-in-out;
  1318. }
  1319. .loading .spinner .rect2 {
  1320. animation-delay: -1.1s;
  1321. }
  1322. .loading .spinner .rect3 {
  1323. animation-delay: -1s;
  1324. }
  1325. .loading .spinner .rect4 {
  1326. animation-delay: -0.9s;
  1327. }
  1328. .loading .spinner .rect5 {
  1329. animation-delay: -0.8s;
  1330. }
  1331. </style>