chathistory.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. <template>
  2. <view class="task">
  3. <!-- 搜索板块 -->
  4. <view class="index-header">
  5. <view class="">
  6. <!-- 搜索板块 -->
  7. <view class="tui-header">
  8. <view class="tui-search" style="height: 60upx; width: 600upx;">
  9. <input type="text" class="text-search" v-model="search" placeholder="请输入搜索内容" />
  10. </view>
  11. <view @tap='rtBubble' style="color: #000000;font-size: 15px;">搜索</view>
  12. <view></view>
  13. </view>
  14. </view>
  15. </view>
  16. <view style="width: 100%;padding-bottom: 140rpx;background: #F5F5F5;color: #FFFFFF;margin-top: 80rpx;">
  17. <view style="display: flex;flex-direction: column;" v-for="(item,index) in ListItem">
  18. <view style="margin-top: 15rpx;width: 100%;text-align: center;font-size: 26rpx;color: #999999;">
  19. {{item.createTime}}
  20. </view>
  21. <view v-if="item.userId && userId != item.userId" style="width: 83%;margin-right: 15%;">
  22. <view class="chat-listitem" style="float: left;margin-left: 10rpx;">
  23. <view>
  24. <image @tap="goGuanZhu(item)" :src="item.avatar ? item.avatar : '/static/logo.png'"
  25. class="chat-listitem-image"></image>
  26. </view>
  27. <view v-if="item.content && item.messageType === 1" class="chat-listitem-text"
  28. style="margin-left: 20rpx;">{{item.content}}</view>
  29. <view v-if="item.messageType === 20" class="chat-listitem-text flex align-center"
  30. style="margin-left: 20rpx;color: #000000;background-color: #ffffff;">
  31. 视频通话
  32. <image src="../../static/im/historyVideo_black.png"
  33. style="width: 50rpx;height: 50rpx;margin-left: 20rpx;" mode=""></image>
  34. </view>
  35. <view v-if="item.messageType === 21" class="chat-listitem-text flex align-center"
  36. style="margin-left: 20rpx;color: #000000;background-color: #ffffff;">
  37. 语音通话
  38. <image src="../../static/im/historyAudio_black.png"
  39. style="width: 50rpx;height: 50rpx;margin-left: 20rpx;" mode=""></image>
  40. </view>
  41. <image @tap="viewImg(item.content)" v-if="item.content && item.messageType === 2"
  42. :src="item.content" style="height: 200rpx;width: 200rpx;margin-left: 20rpx;"></image>
  43. <image class="chat-listitem-text"
  44. v-if="item.content && item.messageType === 4"
  45. :src="ossUrl +item.content"
  46. style="height: 80rpx;width: 80rpx;margin-left: 20rpx;"></image>
  47. <view v-if="item.content && item.messageType === 3" class="chat-listitem-text bubble voice"
  48. :class="playMsgid == index?'play':''"
  49. style="margin-left: 20rpx;display: flex;align-items: center;"
  50. @tap="playVoice(item.content,index)">
  51. <image v-if="playMsgid != index" src="../../static/im/laba.png"
  52. style="width: 35upx;height: 40upx;margin-right: 10rpx;"></image>
  53. <image v-if="playMsgid == index" src="../../static/im/labagif.gif"
  54. style="width: 35upx;height: 40upx;margin-right: 10rpx;"></image>
  55. <!-- <view class="icon other-voice"></view> -->
  56. <view class="length">{{item.width ? item.width : 0}}</view>
  57. </view>
  58. <!-- 互换手机号 -->
  59. <view v-if="item.content && item.messageType === 5 && item.content=='手机号请求'"
  60. @longpress="copy(item.content)" class="chat-listitem-text"
  61. style="padding-bottom: 20rpx;;padding-top: 20rpx;margin-left: 20rpx;color: #000000;background-color: #ffffff;border: 1rpx solid #c6fee7;background: linear-gradient(to bottom, #D9FEED, #ffffff);">
  62. <view class="flex align-center">
  63. <image src="../../static/im/mobilePhone.png"
  64. style="width: 60rpx;height: 60rpx;margin-right: 10rpx;" mode=""></image>
  65. 我想跟你交换手机号,是否同意?
  66. </view>
  67. <view class="flex justify-between" style="margin-top: 30rpx;font-size: 24rpx;">
  68. <view @click.stop="refuseFun(item.chatContentId)"
  69. class="flex justify-center align-center"
  70. style="width: 40%;height: 50rpx;background-color: #F5F5F5;border-radius: 12rpx;">
  71. 拒绝
  72. </view>
  73. <view @click.stop="tongyi(item.messageType,item.chatContentId)"
  74. class="flex justify-center align-center"
  75. style="width: 40%;height: 50rpx;background-color: #D9FEED;border-radius: 12rpx;">
  76. 同意
  77. </view>
  78. </view>
  79. </view>
  80. <view v-if="item.content && item.messageType === 5 && item.content!='手机号请求'"
  81. class="chat-listitem-text"
  82. style="margin-left: 20rpx;color: #000000;background-color: #ffffff;">
  83. 已同意交换手机号
  84. </view>
  85. <view v-if="item.content && item.messageType === 7"
  86. @longpress="copyss(item.content,item.userType,'phone')" class="chat-listitem-text"
  87. style="margin-left: 20rpx;color: #000000;background-color: #ffffff;">
  88. <view class="" v-if="item.userType==1">
  89. 我的手机号为:{{JSON.parse(item.content).companyPhone}}
  90. </view>
  91. <view class="" v-else>
  92. 我的手机号为:{{JSON.parse(item.content).userPhone}}
  93. </view>
  94. </view>
  95. <!-- 互换微信号 -->
  96. <view v-if="item.content && item.messageType === 6 && item.content=='微信号请求'"
  97. @longpress="copy(item.content)" class="chat-listitem-text"
  98. style="padding-bottom: 20rpx;;padding-top: 20rpx;margin-left: 20rpx;color: #000000;background-color: #ffffff;border: 1rpx solid #c6fee7;background: linear-gradient(to bottom, #D9FEED, #ffffff);">
  99. <view class="flex align-center">
  100. <image src="../../static/im/weiChat.png"
  101. style="width: 60rpx;height: 60rpx;margin-right: 10rpx;" mode=""></image>
  102. 我想跟你交换微信号,是否同意?
  103. </view>
  104. <view class="flex justify-between" style="margin-top: 30rpx;font-size: 24rpx;">
  105. <view @click.stop="refuseFun(item.chatContentId)"
  106. class="flex justify-center align-center"
  107. style="width: 40%;height: 50rpx;background-color: #F5F5F5;border-radius: 12rpx;">
  108. 拒绝
  109. </view>
  110. <view @click.stop="tongyi(item.messageType,item.chatContentId)"
  111. class="flex justify-center align-center"
  112. style="width: 40%;height: 50rpx;background-color: #D9FEED;border-radius: 12rpx;">
  113. 同意
  114. </view>
  115. </view>
  116. </view>
  117. <view v-if="item.content && item.messageType === 6 && item.content!='微信号请求'"
  118. class="chat-listitem-text"
  119. style="margin-left: 20rpx;color: #000000;background-color: #ffffff;">
  120. 已同意交换微信号
  121. </view>
  122. <view v-if="item.content && item.messageType === 8"
  123. @longpress="copyss(item.content,item.userType,'wx')" class="chat-listitem-text"
  124. style="margin-left: 20rpx;color: #000000;background-color: #ffffff;">
  125. <view class="" v-if="item.userType==1">
  126. 我的微信号为:{{JSON.parse(item.content).companyWx}}
  127. </view>
  128. <view class="" v-else>
  129. 我的微信号为:{{JSON.parse(item.content).userWx}}
  130. </view>
  131. </view>
  132. <view
  133. v-if="item.content && item.messageType === 9 && item.content=='简历请求' && isSendResumes==false"
  134. @longpress="copy(item.content)" class="chat-listitem-text"
  135. style="padding-bottom: 20rpx;;padding-top: 20rpx;margin-left: 20rpx;color: #000000;background-color: #ffffff;border: 1rpx solid #c6fee7;background: linear-gradient(to bottom, #D9FEED, #ffffff);">
  136. <view class="flex align-center">
  137. <image src="../../static/im/orderInfo.png"
  138. style="width: 60rpx;height: 60rpx;margin-right: 10rpx;" mode=""></image>
  139. 我想要你的一份简历,是否同意?
  140. </view>
  141. <view class="flex justify-between" style="margin-top: 30rpx;font-size: 24rpx;">
  142. <view @click.stop="refuseFun(item.chatContentId)"
  143. class="flex justify-center align-center"
  144. style="width: 40%;height: 50rpx;background-color: #F5F5F5;border-radius: 12rpx;">
  145. 拒绝
  146. </view>
  147. <view @click.stop="resumesTy()" class="flex justify-center align-center"
  148. style="width: 40%;height: 50rpx;background-color: #D9FEED;border-radius: 12rpx;">
  149. 同意
  150. </view>
  151. </view>
  152. </view>
  153. <view
  154. v-if="item.content && item.messageType === 9 && item.content=='简历请求' && isSendResumes==true"
  155. @longpress="copy(item.content)" class="chat-listitem-text"
  156. style="padding-bottom: 20rpx;;padding-top: 20rpx;margin-left: 20rpx;color: #000000;background-color: #ffffff;border: 1rpx solid #c6fee7;background: linear-gradient(to bottom, #D9FEED, #ffffff);">
  157. <view class="flex align-center">
  158. <image src="../../static/im/orderInfo.png"
  159. style="width: 60rpx;height: 60rpx;margin-right: 10rpx;" mode=""></image>
  160. 简历请求已同意
  161. </view>
  162. </view>
  163. <view v-if="item.content && item.messageType === 9 && item.content!='简历请求'"
  164. @longpress="copy(item.content)" class="chat-listitem-text"
  165. style="padding-bottom: 20rpx;;padding-top: 20rpx;margin-left: 20rpx;color: #000000;background-color: #ffffff;border: 1rpx solid #c6fee7;background: linear-gradient(to bottom, #D9FEED, #ffffff);">
  166. <view class="flex align-center">
  167. <image src="../../static/im/orderInfo.png"
  168. style="width: 60rpx;height: 60rpx;margin-right: 10rpx;" mode=""></image>
  169. {{item.content}}
  170. </view>
  171. </view>
  172. <view v-if="item.content && item.messageType === 10" class="chat-listitem-text"
  173. style="margin-left: 20rpx;color: #000000;background-color: #ffffff;">
  174. {{item.content}}
  175. </view>
  176. <view v-if="item.content && item.messageType === 12" class="chat-listitem-text"
  177. style="margin-left: 20rpx;color: #000000;background-color: #ffffff;">
  178. {{item.content}}已拒绝
  179. </view>
  180. <view class="chat-listitem-text "
  181. style="margin-left: 20rpx;color: #000000;background-color: #ffffff;"
  182. v-if="item.content && item.messageType === 18"
  183. @click="openMapss(item.content.latitude,item.content.longitude,item.content.address)">
  184. <view class="padding-sm flex">
  185. <!-- #ifdef APP -->
  186. <u-icon name="map-fill" color="#ffffff" size="28" style="margin-right: 10rpx;"></u-icon>
  187. <!-- #endif -->
  188. {{item.content.address}}
  189. </view>
  190. <!-- #ifndef APP -->
  191. <map style="width: 100%; height: 120px;" scale="14" :latitude="item.content.latitude"
  192. :longitude="item.content.longitude"
  193. @tap="openMapss(item.content.latitude,item.content.longitude,item.content.address)"
  194. :markers="item.markers">
  195. </map>
  196. <!-- #endif -->
  197. </view>
  198. </view>
  199. </view>
  200. <view v-if="item.userId && userId == item.userId" style="width: 83%;margin-left: 15%;">
  201. <view class="chat-listitem" style="float: right;">
  202. <!-- <view v-if="item.content && item.messageType === 1" @longpress="copy(item.content)"
  203. class="chat-listitem-text" style="margin-right: 20rpx;">{{item.content}}</view> -->
  204. <image @tap="viewImg(item.content)" v-if="item.content && item.messageType === 2"
  205. :src="item.content" style="height: 200rpx;width: 200rpx;margin-right: 20rpx;"></image>
  206. <image class="chat-listitem-text"
  207. v-if="item.content && item.messageType === 4"
  208. :src="ossUrl +item.content"
  209. style="height: 80rpx;width: 80rpx;margin-right: 20rpx;">
  210. </image>
  211. <view v-if="item.messageType === 20" class="chat-listitem-text textColor flex align-center"
  212. style="margin-right: 20rpx;">
  213. 视频通话
  214. <image src="../../static/im/historyVideo_white.png"
  215. style="width: 50rpx;height: 50rpx;margin-left: 20rpx;" mode=""></image>
  216. </view>
  217. <view v-if="item.messageType === 21" class="chat-listitem-text textColor flex align-center"
  218. style="margin-right: 20rpx;">
  219. 语音通话
  220. <image src="../../static/im/historyAudio_white.png"
  221. style="width: 50rpx;height: 50rpx;margin-left: 20rpx;" mode=""></image>
  222. </view>
  223. <view v-if="item.content && item.messageType === 3" class="chat-listitem-text bubble voice"
  224. :class="playMsgid == index?'play':''"
  225. style="margin-right: 20rpx;display: flex;align-items: center;"
  226. @tap="playVoice(item.content,index)">
  227. <view class="length">{{item.width ? item.width : 0}}</view>
  228. <image v-if="playMsgid != index" src="../../static/im/labaleft.png"
  229. style="width: 35upx;height: 40upx;margin-left: 10rpx;"></image>
  230. <image v-if="playMsgid == index" src="../../static/im/labaleft.png"
  231. style="width: 35upx;height: 40upx;margin-left: 10rpx;"></image>
  232. <!-- <view class="icon other-voice"></view> -->
  233. </view>
  234. <view v-if="item.content && item.messageType === 1" @longpress="caozuoActive(item,1)"
  235. class="chat-listitem-text textColor" style="margin-right: 20rpx;">{{item.content}}</view>
  236. <view v-if="item.content && item.messageType === 5" class="chat-listitem-text textColor"
  237. style="margin-right: 20rpx;">
  238. 交换手机号请求已发送,等待对方同意
  239. </view>
  240. <view v-if="item.content && item.messageType === 7"
  241. @longpress="copyss(item.content,item.userType,'phone')" class="chat-listitem-text textColor"
  242. style="margin-right: 20rpx;">
  243. <view class="" v-if="item.userType==1">
  244. 我的手机号为:{{JSON.parse(item.content).companyPhone}}
  245. </view>
  246. <view class="" v-else>
  247. 我的手机号为:{{JSON.parse(item.content).userPhone}}
  248. </view>
  249. </view>
  250. <view v-if="item.content && item.messageType === 6" class="chat-listitem-text textColor"
  251. style="margin-right: 20rpx;">
  252. 交换微信号请求已发送,等待对方同意
  253. </view>
  254. <view v-if="item.content && item.messageType === 8"
  255. @longpress="copyss(item.content,item.userType,'wx')" class="chat-listitem-text textColor"
  256. style="margin-right: 20rpx;">
  257. <view class="" v-if="item.userType==1">
  258. 我的微信号为:{{JSON.parse(item.content).companyWx}}
  259. </view>
  260. <view class="" v-else>
  261. 我的微信号为:{{JSON.parse(item.content).userWx}}
  262. </view>
  263. </view>
  264. <view v-if="item.content && item.messageType === 9" class="chat-listitem-text textColor"
  265. style="margin-right: 20rpx;">
  266. 简历请求已发送,等待对方同意
  267. </view>
  268. <view v-if="item.content && item.messageType === 10" class="chat-listitem-text textColor"
  269. style="margin-right: 20rpx;">
  270. {{item.content}}
  271. </view>
  272. <view v-if="item.content && item.messageType === 12" class="chat-listitem-text textColor"
  273. style="margin-right: 20rpx;">
  274. {{item.content}}已拒绝
  275. </view>
  276. <view class="chat-listitem-text textColor" style="margin-right: 20rpx;"
  277. v-if="item.content && item.messageType === 18"
  278. @click="openMapss(item.content.latitude,item.content.longitude,item.content.address)">
  279. <view class="padding-sm flex">
  280. <!-- #ifdef APP -->
  281. <u-icon name="map-fill" color="#ffffff" size="28" style="margin-right: 10rpx;"></u-icon>
  282. <!-- #endif -->
  283. {{item.content.address}}
  284. </view>
  285. <!-- #ifndef APP -->
  286. <map style="width:520upx; height: 120px;" scale="14" :latitude="item.content.latitude"
  287. :longitude="item.content.longitude"
  288. @tap="openMapss(item.content.latitude,item.content.longitude,item.content.address)"
  289. :markers='item.markers'>
  290. </map>
  291. <!-- #endif -->
  292. </view>
  293. <view>
  294. <image :src="imageUrl" class="chat-listitem-image"></image>
  295. </view>
  296. </view>
  297. </view>
  298. </view>
  299. </view>
  300. </view>
  301. </template>
  302. <script>
  303. import configData from '../../common/config.js'
  304. export default {
  305. components: {},
  306. data() {
  307. return {
  308. recordLength: 0,
  309. initPoint: {
  310. identifier: 0,
  311. Y: 0
  312. },
  313. //播放语音相关参数
  314. AUDIO: uni.createInnerAudioContext(),
  315. playMsgid: null,
  316. VoiceTimer: null,
  317. //文字消息
  318. textMsg: '',
  319. //消息列表
  320. isHistoryLoading: false,
  321. scrollAnimation: false,
  322. scrollTop: 0,
  323. scrollToView: '',
  324. msgList: [],
  325. msgImgList: [],
  326. myuid: 0,
  327. //录音相关参数
  328. // #ifndef H5
  329. //H5不能录音
  330. RECORDER: uni.getRecorderManager(),
  331. // #endif
  332. isVoice: false,
  333. voiceTis: '按住 说话',
  334. recordTis: "手指上滑 取消发送",
  335. recording: false,
  336. willStop: false,
  337. initPoint: {
  338. identifier: 0,
  339. Y: 0
  340. },
  341. recordTimer: null,
  342. recordLength: 0,
  343. //播放语音相关参数
  344. AUDIO: uni.createInnerAudioContext(),
  345. playMsgid: null,
  346. VoiceTimer: null,
  347. // 抽屉参数
  348. popupLayerClass: '',
  349. // more参数
  350. hideMore: true,
  351. page: 1,
  352. size: 100,
  353. byUserId: 0,
  354. playMsgid: 0,
  355. imageUrl: '/static/logo.png',
  356. chatConversationId: 0,
  357. userId: 0,
  358. ListItem: [],
  359. search: '',
  360. ossUrl:configData.ossUrl
  361. };
  362. },
  363. onLoad(d) {
  364. this.userId = this.$queue.getData('userId');
  365. this.chatConversationId = d.chatConversationId;
  366. this.getTimeOrListItem1();
  367. let image_url = this.$queue.getData('avatar');
  368. if (image_url && image_url !== 'undefined') {
  369. this.imageUrl = image_url;
  370. } else {
  371. this.imageUrl = '/static/logo.png';
  372. }
  373. //语音自然播放结束
  374. this.AUDIO.onEnded((res) => {
  375. this.playMsgid = null;
  376. });
  377. // #ifndef H5
  378. //录音开始事件
  379. this.RECORDER.onStart((e) => {
  380. this.recordBegin(e);
  381. })
  382. //录音结束事件
  383. this.RECORDER.onStop((e) => {
  384. this.recordEnd(e);
  385. })
  386. // #endif
  387. },
  388. onBackPress() {
  389. this.AUDIO.stop();
  390. this.playMsgid = null;
  391. },
  392. onHide() {
  393. this.AUDIO.stop();
  394. this.playMsgid = null;
  395. },
  396. methods: {
  397. openMapss(latitude, longitude, name) {
  398. uni.openLocation({
  399. latitude: latitude - 0, //要去的纬度-地址
  400. longitude: longitude - 0, //要去的经度-地址
  401. name: name, //地址名称
  402. address: name, //详细地址名称
  403. success: function() {
  404. console.log('导航成功');
  405. },
  406. fail: function(error) {
  407. console.log(error)
  408. }
  409. });
  410. },
  411. /**
  412. * @param {Object} info 内容
  413. * @param {Object} userType 用户类型
  414. * @param {Object} type 参数类型
  415. */
  416. copyss(info, userType, type) {
  417. let content = ''
  418. switch (type) {
  419. //复制手机号
  420. case 'phone':
  421. if (userType == 1) {
  422. content = JSON.parse(info).companyPhone
  423. } else {
  424. content = JSON.parse(info).userPhone
  425. }
  426. break;
  427. //复制微信号
  428. case 'wx':
  429. if (userType == 1) {
  430. content = JSON.parse(info).companyWx
  431. } else {
  432. content = JSON.parse(info).userWx
  433. }
  434. break;
  435. default:
  436. break;
  437. }
  438. this.copy(content)
  439. },
  440. goGuanZhu(item) {
  441. //去关注页面
  442. uni.navigateTo({
  443. url: '/my/gird/guanzhuDetail?userId=' + item.userId
  444. });
  445. // uni.navigateTo({
  446. // url: '/package/pages/task/followUser?userId=' + item.userId
  447. // });
  448. },
  449. // 播放语音
  450. playVoice(msg, index) {
  451. this.playMsgid = index;
  452. this.AUDIO.src = msg;
  453. this.$nextTick(function() {
  454. this.AUDIO.play();
  455. });
  456. },
  457. //查看大图
  458. viewImg(item) {
  459. let imgsArray = [];
  460. imgsArray[0] = item;
  461. uni.previewImage({
  462. current: 0,
  463. urls: imgsArray
  464. });
  465. },
  466. getTimeOrListItem1() {
  467. this.$queue.showLoading('加载中...');
  468. let userId = this.$queue.getData('userId')
  469. this.$Request.getT('/app/chat/selectChatContent?page=' + this.page + '&limit=' + this.size +
  470. '&chatConversationId=' + this.chatConversationId + '&userId=' + userId + '&content=' + this.search)
  471. .then(
  472. res => {
  473. this.ListItem = [];
  474. if (res.data) {
  475. var time = '';
  476. res.data.list.forEach(d => {
  477. d.createTime = this.getDateDiff(d.createTime);
  478. if (d.createTime === time) {
  479. d.createTime = '';
  480. } else {
  481. time = d.createTime;
  482. }
  483. if (d.type === 4) {
  484. let data = d.content.split(',');
  485. d.content = data;
  486. }
  487. if (d.type === 3) {
  488. let data = d.content.split(',');
  489. d.content = data;
  490. }
  491. if (d.messageType === 18) {
  492. d.content = JSON.parse(d.content);
  493. d.markers = [{
  494. id: 1,
  495. latitude: d.content.latitude,
  496. longitude: d.content.longitude,
  497. width: 20,
  498. height: 20,
  499. iconPath: '../../static/images/mapMarker.png',
  500. callout: {
  501. content: d.content.name,
  502. color: '#000', //文字颜色
  503. fontSize: 10, //文本大小
  504. padding: 10, //附近留白
  505. borderRadius: 24, //边框圆角
  506. bgColor: '#FFFFFF', //背景颜色
  507. display: 'ALWAYS', //常显
  508. }
  509. }]
  510. }
  511. this.ListItem.push(d);
  512. });
  513. this.ListItem.reverse();
  514. }
  515. uni.hideLoading();
  516. });
  517. },
  518. copy(content) {
  519. uni.showModal({
  520. title: '温馨提示',
  521. content: '确认要复制此文字吗?',
  522. showCancel: true,
  523. cancelText: '取消',
  524. confirmText: '确认',
  525. success: res => {
  526. if (res.confirm) {
  527. uni.setClipboardData({
  528. data: content,
  529. success: r => {
  530. this.$queue.showToast('复制成功');
  531. }
  532. });
  533. }
  534. }
  535. });
  536. },
  537. h5Copy(content) {
  538. if (!document.queryCommandSupported('copy')) {
  539. // 不支持
  540. return false
  541. }
  542. let textarea = document.createElement("textarea")
  543. textarea.value = content
  544. textarea.readOnly = "readOnly"
  545. document.body.appendChild(textarea)
  546. textarea.select() // 选择对象
  547. textarea.setSelectionRange(0, content.length) //核心
  548. let result = document.execCommand("copy") // 执行浏览器复制命令
  549. textarea.remove()
  550. return result
  551. },
  552. getDateDiff(data) {
  553. // 传进来的data必须是日期格式,不能是时间戳
  554. //var str = data;
  555. //将字符串转换成时间格式
  556. var timePublish = new Date(data);
  557. var timeNow = new Date();
  558. var minute = 1000 * 60;
  559. var hour = minute * 60;
  560. var day = hour * 24;
  561. var month = day * 30;
  562. var result = "2";
  563. var diffValue = timeNow - timePublish;
  564. var diffMonth = diffValue / month;
  565. var diffWeek = diffValue / (7 * day);
  566. var diffDay = diffValue / day;
  567. var diffHour = diffValue / hour;
  568. var diffMinute = diffValue / minute;
  569. if (diffMonth > 3) {
  570. result = timePublish.getFullYear() + "-";
  571. result += timePublish.getMonth() + "-";
  572. result += timePublish.getDate();
  573. } else if (diffMonth > 1) { //月
  574. result = data.substring(0, 10);
  575. } else if (diffWeek > 1) { //周
  576. result = data.substring(0, 10);
  577. } else if (diffDay > 1) { //天
  578. result = data.substring(0, 10);
  579. } else if (diffHour > 1) { //小时
  580. result = parseInt(diffHour) + "小时前";
  581. } else if (diffMinute > 1) { //分钟
  582. result = parseInt(diffMinute) + "分钟前";
  583. } else {
  584. result = "刚刚";
  585. }
  586. return result;
  587. },
  588. navBack() {
  589. uni.navigateBack();
  590. },
  591. rtBubble() {
  592. this.getTimeOrListItem1();
  593. }
  594. }
  595. };
  596. </script>
  597. <style lang="scss">
  598. @import '../../static/less/index.less';
  599. @import '../../static/css/index.css';
  600. @import "../msg/css/style.scss";
  601. page {
  602. background: #F5F5F5;
  603. color: #FFFFFF;
  604. }
  605. .chat-listitem {
  606. display: flex;
  607. margin-top: 20rpx;
  608. padding: 10rpx;
  609. }
  610. .chat-listitem-text {
  611. color: #ffffff;
  612. background: #016BF6;
  613. margin-top: 10rpx;
  614. width: fit-content;
  615. padding: 15rpx;
  616. font-size: 30rpx;
  617. height: max-content;
  618. word-wrap: break-word;
  619. word-break: break-all;
  620. border-radius: 10rpx;
  621. }
  622. .chat-listitem-image-type4 {
  623. color: #000000;
  624. background: #FFFFFF;
  625. width: fit-content;
  626. font-size: 30rpx;
  627. height: max-content;
  628. word-wrap: break-word;
  629. word-break: break-all;
  630. border-top-left-radius: 20rpx;
  631. border-top-right-radius: 20rpx;
  632. }
  633. .chat-listitem-image {
  634. margin-top: 5rpx;
  635. width: 75rpx;
  636. height: 75rpx;
  637. border-radius: 5rpx;
  638. }
  639. .save {
  640. width: 130rpx;
  641. text-align: center;
  642. border-radius: 10rpx;
  643. height: 70rpx;
  644. background: #FFFFFF;
  645. margin: 5rpx 10rpx 0;
  646. line-height: 70rpx;
  647. }
  648. .text-search {
  649. margin-left: 20upx;
  650. font-size: 14px;
  651. height: 60upx;
  652. line-height: 60upx;
  653. width: 95%;
  654. color: #000000;
  655. }
  656. .item-text-title {
  657. color: #000000;
  658. font-size: 15px;
  659. font-weight: bold;
  660. }
  661. .item {
  662. display: flex;
  663. flex-direction: row;
  664. flex-wrap: wrap;
  665. }
  666. .item-text {
  667. margin-left: 20upx;
  668. border-radius: 50upx;
  669. margin: 10upx;
  670. border: 1px solid #dee0de;
  671. padding: 5upx;
  672. padding-left: 20upx;
  673. padding-right: 20upx;
  674. font-size: 13px;
  675. color: #555555;
  676. }
  677. </style>