t-chat-bar.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <template>
  2. <view @touchmove.stop.prevent>
  3. <view class="tui-reply-tabbar" :style="{ paddingBottom: `${keyboardHeight}px` }">
  4. <view class="tui-chat-tabbar">
  5. <view class="tui-icon tui-icon-im_more tui-icon-mr" @tap="showKeyBoard(3)"></view>
  6. <view class="tui-icon tui-icon-im_face tui-icon-mr" @tap="showKeyBoard(2)"></view>
  7. <!-- v-show="showIndex != 2" -->
  8. <!-- <view class="tui-icon tui-icon-im_keyboard tui-icon-mr" @tap="showKeyBoard(1)" v-show="showIndex == 2"></view> -->
  9. <textarea hold-keyboard auto-height class="tui-chat-input" @input="inputReply" :fixed="true"
  10. :adjust-position="false" maxlength="300" :value="content" :show-confirm-bar="false"
  11. placeholder-class="tui-phcolor" @tap.stop="showKeyBoard(1)" ref="textarea"
  12. v-show="!isVoice"></textarea>
  13. <view class="tui-chat-voice_btn" hover-class="tui-opcity" :hover-stay-time="150" v-if="isVoice">按住 说话
  14. </view>
  15. <view class="tui-send-box">
  16. <view class="tui-icon tui-icon-im_voice" v-if="!isVoice && !content" @tap="switchVoice"></view>
  17. <view class="tui-icon tui-icon-im_keyboard" v-if="isVoice && !content" @tap="switchInput"></view>
  18. <view class="tui-btn-send" v-if="content" :style="{ color: color }" hover-class="tui-opcity"
  19. :hover-stay-time="150" @tap="hideKeyboard">{{ sendText }}</view>
  20. </view>
  21. </view>
  22. <view class="tui-reply-more">
  23. <view class="tui-face-box" v-if="showIndex == 2">
  24. <scroll-view scroll-y :style="{ height: replyContainerH + 'px' }">
  25. <view class="tui-face-scroll">
  26. <view class="tui-face-img_box" v-for="(item, index) in faceList" :key="index"
  27. @tap="inputFace(index)">
  28. <image :src="`https://www.thorui.cn/wx/static/images/im_face/${item}.png`"
  29. class="tui-face-img"></image>
  30. </view>
  31. </view>
  32. </scroll-view>
  33. <view class="tui-delete-face_box">
  34. <view class="tui-delete-keybord" :class="{ 'tui-opcity': !content }"><text
  35. class="tui-icon tui-icon-delete_keybord"></text></view>
  36. </view>
  37. </view>
  38. <view class="tui-more-box" :style="{ height: replyContainerH + 'px' }" v-if="showIndex == 3">
  39. <view class="tui-more-item" hover-class="tui-opcity" :hover-stay-time="150">
  40. <view class="tui-more-icon">
  41. <view class="tui-icon tui-icon-photo"></view>
  42. </view>
  43. <text class="tui-more-text">照片</text>
  44. </view>
  45. <view class="tui-more-item" hover-class="tui-opcity" :hover-stay-time="150">
  46. <view class="tui-more-icon">
  47. <view class="tui-icon tui-icon-video"></view>
  48. </view>
  49. <text class="tui-more-text">视频通话</text>
  50. </view>
  51. <view class="tui-more-item" hover-class="tui-opcity" :hover-stay-time="150">
  52. <view class="tui-more-icon">
  53. <view class="tui-icon tui-icon-at"></view>
  54. </view>
  55. <text class="tui-more-text">@好友</text>
  56. </view>
  57. <view class="tui-more-item" hover-class="tui-opcity" :hover-stay-time="150">
  58. <view class="tui-more-icon">
  59. <view class="tui-icon tui-icon-location"></view>
  60. </view>
  61. <text class="tui-more-text">定位</text>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="tui-inner-mask" v-if="isLocked"></view>
  66. </view>
  67. <view class="tui-reply-mask" v-if="mask"
  68. :class="{ 'tui-box-show': showIndex, 'tui-mask-show': showIndex && !maskOpacity }" @touchmove.stop.prevent
  69. @tap="hideKeyboard"></view>
  70. </view>
  71. </template>
  72. <script>
  73. //聊天栏 回复栏
  74. import emoji from '@/utils/emoji.js'
  75. export default {
  76. name: 'tChatBar',
  77. props: {
  78. //禁用聊天栏
  79. isLocked: {
  80. type: Boolean,
  81. default: false
  82. },
  83. //是否显示遮罩
  84. mask: {
  85. type: Boolean,
  86. default: true
  87. },
  88. //true表示遮罩透明
  89. maskOpacity: {
  90. type: Boolean,
  91. default: true
  92. },
  93. sendText: {
  94. type: String,
  95. default: '发送'
  96. },
  97. color: {
  98. type: String,
  99. default: '#5677fc'
  100. }
  101. },
  102. created() {
  103. //键盘高度监听
  104. this.faceList = emoji.en;
  105. let safeH = this.tui.isPhoneX() ? 34 : 0;
  106. uni.onKeyboardHeightChange(res => {
  107. let h = res.height - safeH;
  108. this.keyboardHeight = h > 0 ? h : 0;
  109. //去除 完成那一栏高度影响
  110. setTimeout(() => {
  111. if (this.showIndex == 1 && this.keyboardHeight != 0) {
  112. this.replyContainerH = this.keyboardHeight;
  113. }
  114. }, 100);
  115. });
  116. },
  117. data() {
  118. return {
  119. showIndex: 0, //1-键盘 2-表情 3-其他
  120. keyboardHeight: 0,
  121. replyContainerH: uni.upx2px(500),
  122. faceList: [],
  123. content: '',
  124. isVoice: false
  125. };
  126. },
  127. methods: {
  128. hideKeyboard() {
  129. //隐藏键盘
  130. this.showIndex = 0;
  131. // uni.hideKeyboard();
  132. },
  133. showKeyBoard(index) {
  134. if (this.showIndex == index) return;
  135. this.showIndex = index;
  136. this.isVoice = false;
  137. // if(index==1){
  138. // this.$refs.textarea.focus();
  139. // }
  140. // setTimeout(function() {
  141. // if(index==1){
  142. // this.$refs.textarea.focus();
  143. // }
  144. // }, 150);
  145. },
  146. inputReply(e) {
  147. this.content = e.detail.value;
  148. },
  149. inputFace(index) {
  150. let face = emoji.cn[index];
  151. this.content = this.content + face;
  152. },
  153. switchVoice() {
  154. this.isVoice = true;
  155. this.showIndex = 0;
  156. },
  157. switchInput() {
  158. this.isVoice = false;
  159. }
  160. }
  161. };
  162. </script>
  163. <style lang="scss" scoped>
  164. @font-face {
  165. font-family: 'ticons';
  166. src: url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAtAAA0AAAAAEcQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAALJAAAABoAAAAci1y54UdERUYAAAsEAAAAHgAAAB4AKQAVT1MvMgAAAZwAAABDAAAAVj4mTZRjbWFwAAACAAAAAFMAAAFa2zfTYmdhc3AAAAr8AAAACAAAAAj//wADZ2x5ZgAAAnQAAAapAAAKxGAh9PpoZWFkAAABMAAAAC8AAAA2GNfW1WhoZWEAAAFgAAAAHAAAACQH3gOFaG10eAAAAeAAAAAgAAAAJgygAR1sb2NhAAACVAAAACAAAAAgDwQR8m1heHAAAAF8AAAAHwAAACABJAC0bmFtZQAACSAAAAFJAAACiCnmEVVwb3N0AAAKbAAAAI8AAADgOORb6njaY2BkYGAA4jS+azPi+W2+MnCzMIDArTueOQj6fwsLA3MNkMvBwAQSBQAskgp5AHjaY2BkYGBu+N/AEMPCAAJAkpEBFbAAAEcKAm142mNgZGBg4GdYwcDNAAJMQMwFhAwM/8F8BgAbRAHZAHjaY2BkYWCcwMDKwMDUyXSGgYGhH0IzvmYwYuQAijKwMjNgBQFprikMDs93vF7E3PC/gSGGuYGhASjMCJIDAPZVDTsAeNpjYYAAFihmcGAoADJYGEyAWIGhAUiqMrAAABelAcp42mNgYGBmgGAZBkYGEAgB8hjBfBYGCyDNxcDBwMTA9HzH6wmv575e9P8/AwOYPRXElvAWKREpEMmB6oUCRjYGuAAjE5BgYkAFjAzDHgAABMATOgAAAAAAAAAAAABoAOgBPgGaAfgCWALOAzQDjgSCBQoFYnjalVZdaFxFFJ4zc/fe3Zu9d3N/9u5u1m72L7uNaTbt/tw1pknaJohJNGvbGCtUmzb6UKlGaQUrsYaigk+tP4giGkNEQX2p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6s/Ju0AAAB42n2QPU4DMRCFn/MHJBJCIKhdUQDa/JQpEyn0CKWjSDbekGjXXnmdSDkBLRUHoOUYHIAbINFyCl6WSZMia+3o85uZ57EBnOMbCv/fJe6EFY7xKFzBETLhKvUX4Rr5XbiOFj6FG9R/hJu4VQPhFi7UGx1U7YS7m9JtywpnGAhXcIon4Sr1lXCN/CpcxxU+hBvUv4SbGONXuIVrZakM4WEwQWCcQWOKDeMCMRwskjIG1qE59GYSzExPN3oRO5s4GyjvV2KXAx5oOeeAKe09t2a+Sif+YMuB1JhuHgVLtimNLiJ0KBtfLJzV3ahzsP2e7ba02L9rgTXH7FENbNT8Pdsz0khsDK+QkjXyMrekElOPaGus8btnKdbzXgiJTrzL9IjHmjR1OvduaeLA4ufyjBx9tLmSPfeoHD5jWQh5v91OxCCKXYY/k9hxGQAAAHjaXYtbDoMwDARx+uRVehHOFLnBLW4gjkJA6u2rBsFH98OaWduZytYUaUL2nya1ChQc4AgnOMMFrpBDASVUUDdvRufR6alHZ/q5jDO3bMS1GKudX36qfqB51KME2uWJhvIkAztbb/UibKhI5nuJcksYqPNoLMX7dmfp8xAM3br3gZ1hj8P6uXBH8gUu/j02AAAAAAH//wACAAEAAAAMAAAAFgAAAAIAAQADAA4AAQAEAAAAAgAAAAB42mNgYGBkAIKrS9Q5QPStO545MBoAQZcGgAAA) format('woff');
  167. font-weight: normal;
  168. font-style: normal;
  169. }
  170. .tui-icon {
  171. font-family: ticons;
  172. font-size: 24px;
  173. font-weight: normal;
  174. font-style: normal;
  175. line-height: 1;
  176. display: inline-block;
  177. text-decoration: none;
  178. -webkit-font-smoothing: antialiased;
  179. }
  180. .tui-icon-at:before {
  181. content: '\eb90';
  182. }
  183. .tui-icon-location:before {
  184. content: '\eb95';
  185. }
  186. .tui-icon-im_more:before {
  187. content: '\eb96';
  188. }
  189. .tui-icon-im_face:before {
  190. content: '\eb97';
  191. }
  192. .tui-icon-link:before {
  193. content: '\eb98';
  194. }
  195. .tui-icon-im_voice:before {
  196. content: '\eb99';
  197. }
  198. .tui-icon-photo:before {
  199. content: '\eb9a';
  200. }
  201. .tui-icon-redpacket:before {
  202. content: '\eb9b';
  203. }
  204. .tui-icon-im_keyboard:before {
  205. content: '\eb9c';
  206. }
  207. .tui-icon-principal:before {
  208. content: '\eb9d';
  209. }
  210. .tui-icon-video:before {
  211. content: '\eba2';
  212. }
  213. .tui-icon-delete_keybord:before {
  214. content: '\e7b8';
  215. }
  216. .tui-reply-tabbar {
  217. width: 100%;
  218. position: fixed;
  219. left: 0;
  220. bottom: 0;
  221. display: flex;
  222. flex-direction: column;
  223. box-sizing: border-box;
  224. z-index: 999;
  225. .tui-chat-tabbar {
  226. width: 100%;
  227. background-color: $uni-bg-color-grey;
  228. display: flex;
  229. align-items: flex-end;
  230. padding: 16rpx 24rpx;
  231. box-sizing: border-box;
  232. &::after {
  233. content: ' ';
  234. position: absolute;
  235. top: 0;
  236. right: 0;
  237. left: 0;
  238. border-top: 1rpx solid $uni-text-color-placeholder;
  239. -webkit-transform: scaleY(0.5);
  240. transform: scaleY(0.5);
  241. }
  242. .tui-chat-input {
  243. flex: 1;
  244. /* #ifndef MP-WEIXIN */
  245. min-height: 46rpx;
  246. padding: $uni-spacing-col-base 0;
  247. /* #endif */
  248. /* #ifdef MP-WEIXIN */
  249. min-height: 78rpx;
  250. /* #endif */
  251. background-color: $uni-bg-color;
  252. border-radius: 8rpx;
  253. margin: 0;
  254. }
  255. .tui-chat-voice_btn {
  256. flex: 1;
  257. height: 78rpx;
  258. border-radius: 8rpx;
  259. background-color: #fff;
  260. display: flex;
  261. align-items: center;
  262. justify-content: center;
  263. font-weight: bold;
  264. }
  265. .tui-icon-mr {
  266. margin-right: 28rpx;
  267. }
  268. .tui-icon-ml {
  269. margin-left: 28rpx;
  270. }
  271. .tui-icon {
  272. margin-bottom: 13rpx;
  273. }
  274. .tui-send-box {
  275. width: 80rpx;
  276. display: flex;
  277. align-items: center;
  278. justify-content: flex-end;
  279. }
  280. .tui-btn-send {
  281. flex-shrink: 0;
  282. padding: 22rpx 0;
  283. font-size: 30rpx;
  284. line-height: 30rpx;
  285. }
  286. }
  287. .tui-reply-more {
  288. width: 100%;
  289. position: relative;
  290. &::after {
  291. content: ' ';
  292. position: absolute;
  293. top: 0;
  294. right: 0;
  295. left: 0;
  296. border-top: 1rpx solid $uni-text-color-placeholder;
  297. -webkit-transform: scaleY(0.5);
  298. transform: scaleY(0.5);
  299. }
  300. .tui-face-box {
  301. width: 100%;
  302. position: relative;
  303. background-color: $uni-bg-color-hover;
  304. .tui-face-scroll {
  305. width: 100%;
  306. padding: $uni-spacing-row-lg 24rpx 80rpx;
  307. box-sizing: border-box;
  308. display: flex;
  309. flex-wrap: wrap;
  310. .tui-face-img_box {
  311. width: 14.2857%;
  312. height: 100rpx;
  313. display: flex;
  314. align-items: center;
  315. justify-content: center;
  316. .tui-face-img {
  317. width: 60rpx;
  318. height: 60rpx;
  319. }
  320. }
  321. }
  322. .tui-delete-face_box {
  323. position: absolute;
  324. background-color: $uni-bg-color-hover;
  325. width: 108rpx;
  326. height: 92rpx;
  327. right: 20rpx;
  328. bottom: 0;
  329. z-index: 10;
  330. .tui-delete-keybord {
  331. width: 108rpx;
  332. height: 68rpx;
  333. background-color: $uni-bg-color;
  334. display: flex;
  335. align-items: center;
  336. justify-content: center;
  337. border-radius: $uni-border-radius-lg;
  338. .tui-icon {
  339. font-size: 48rpx;
  340. }
  341. }
  342. }
  343. }
  344. .tui-more-box {
  345. width: 100%;
  346. padding: $uni-spacing-row-lg;
  347. box-sizing: border-box;
  348. position: relative;
  349. display: flex;
  350. align-items: flex-start;
  351. flex-wrap: wrap;
  352. background-color: $uni-bg-color-hover;
  353. .tui-more-item {
  354. width: 126rpx;
  355. display: flex;
  356. align-items: center;
  357. flex-direction: column;
  358. justify-content: center;
  359. margin-right: 40rpx;
  360. &:active {
  361. opacity: 0.6;
  362. }
  363. }
  364. .tui-more-icon {
  365. display: flex;
  366. align-items: center;
  367. justify-content: center;
  368. background-color: #ffffff;
  369. height: 126rpx;
  370. width: 126rpx;
  371. border-radius: 32rpx;
  372. .tui-icon {
  373. font-size: 60rpx;
  374. }
  375. }
  376. .tui-more-text {
  377. font-size: 24rpx;
  378. line-height: 24rpx;
  379. color: #7e7e7e;
  380. padding-top: 20rpx;
  381. padding-bottom: 20rpx;
  382. }
  383. }
  384. }
  385. .tui-inner-mask {
  386. position: absolute;
  387. width: 100%;
  388. height: 100%;
  389. left: 0;
  390. top: 0;
  391. background-color: rgba(248, 248, 248, 0.6);
  392. }
  393. }
  394. .tui-reply-mask {
  395. width: 100%;
  396. height: 100%;
  397. position: fixed;
  398. left: 0;
  399. top: 0;
  400. z-index: 990;
  401. background-color: $uni-bg-color-mask;
  402. visibility: hidden;
  403. transition: all 0.3s ease;
  404. opacity: 0;
  405. }
  406. .tui-box-show {
  407. visibility: visible !important;
  408. }
  409. .tui-mask-show {
  410. opacity: 1;
  411. }
  412. </style>