chathistory.vue 24 KB

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