toolsPopup.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <su-popup
  3. :show="showTools"
  4. @close="handleClose"
  5. >
  6. <view class="ss-modal-box ss-flex-col">
  7. <slot></slot>
  8. <view class="content ss-flex ss-flex-1">
  9. <template v-if="toolsMode === 'emoji'">
  10. <swiper
  11. class="emoji-swiper"
  12. :indicator-dots="true"
  13. circular
  14. indicator-active-color="#7063D2"
  15. indicator-color="rgba(235, 231, 255, 1)"
  16. :autoplay="false"
  17. :interval="3000"
  18. :duration="1000"
  19. >
  20. <swiper-item v-for="emoji in emojiPage" :key="emoji">
  21. <view class="ss-flex ss-flex-wrap">
  22. <image
  23. v-for="item in emoji" :key="item"
  24. class="emoji-img"
  25. :src="sheep.$url.cdn(`/static/img/chat/emoji/${item.file}`)"
  26. @tap="onEmoji(item)"
  27. >
  28. </image>
  29. </view>
  30. </swiper-item>
  31. </swiper>
  32. </template>
  33. <template v-else>
  34. <view class="image">
  35. <s-uploader
  36. file-mediatype="image"
  37. :imageStyles="{ width: 50, height: 50, border: false }"
  38. @select="imageSelect({ type: 'image', data: $event })"
  39. >
  40. <image
  41. class="icon"
  42. :src="sheep.$url.static('/static/img/shop/chat/image.png')"
  43. mode="aspectFill"
  44. ></image>
  45. </s-uploader>
  46. <view>图片</view>
  47. </view>
  48. <view class="goods" @tap="onShowSelect('goods')">
  49. <image
  50. class="icon"
  51. :src="sheep.$url.static('/static/img/shop/chat/goods.png')"
  52. mode="aspectFill"
  53. ></image>
  54. <view>商品</view>
  55. </view>
  56. <view class="order" @tap="onShowSelect('order')">
  57. <image
  58. class="icon"
  59. :src="sheep.$url.static('/static/img/shop/chat/order.png')"
  60. mode="aspectFill"
  61. ></image>
  62. <view>订单</view>
  63. </view>
  64. </template>
  65. </view>
  66. </view>
  67. </su-popup>
  68. </template>
  69. <script setup>
  70. /**
  71. * 聊天工具
  72. */
  73. import { emojiPage } from '@/pages/chat/util/emoji';
  74. import sheep from '@/sheep';
  75. const props = defineProps({
  76. // 工具模式
  77. toolsMode: {
  78. type: String,
  79. default: '',
  80. },
  81. // 控制工具菜单弹出
  82. showTools: {
  83. type: Boolean,
  84. default: () => false,
  85. },
  86. });
  87. const emits = defineEmits(['onEmoji', 'imageSelect', 'onShowSelect', 'close']);
  88. // 关闭弹出工具菜单
  89. function handleClose() {
  90. emits('close');
  91. }
  92. // 选择表情
  93. function onEmoji(emoji) {
  94. emits('onEmoji', emoji);
  95. }
  96. // 选择图片
  97. function imageSelect(val) {
  98. emits('imageSelect', val);
  99. }
  100. // 选择商品或订单
  101. function onShowSelect(mode) {
  102. emits('onShowSelect', mode);
  103. }
  104. </script>
  105. <style scoped lang="scss">
  106. .content {
  107. width: 100%;
  108. align-content: space-around;
  109. border-top: 1px solid #dfdfdf;
  110. padding: 20rpx 0 0;
  111. .emoji-swiper {
  112. width: 100%;
  113. height: 280rpx;
  114. padding: 0 20rpx;
  115. .emoji-img {
  116. width: 50rpx;
  117. height: 50rpx;
  118. display: inline-block;
  119. margin: 10rpx;
  120. }
  121. }
  122. .image,
  123. .goods,
  124. .order {
  125. width: 33.3%;
  126. height: 280rpx;
  127. text-align: center;
  128. font-size: 24rpx;
  129. color: #333;
  130. display: flex;
  131. flex-direction: column;
  132. align-items: center;
  133. justify-content: center;
  134. .icon {
  135. width: 50rpx;
  136. height: 50rpx;
  137. margin-bottom: 21rpx;
  138. }
  139. }
  140. :deep() {
  141. .uni-file-picker__container {
  142. justify-content: center;
  143. }
  144. .file-picker__box {
  145. display: none;
  146. &:last-of-type {
  147. display: flex;
  148. }
  149. }
  150. }
  151. }
  152. </style>