m-recorder.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="m-recorder" v-show="isShow">
  3. <view class="icon_ m-recorder-gif">
  4. <image class="img" :src="require('@/static/image/sound.gif')" mode="heightFix" v-if="recordTime < 50"></image>
  5. <view class="color_4a" v-else>{{ 60 - recordTime }}"后将停止录音</view>
  6. </view>
  7. <view class="m-recorder-str2" :class="{ m_recorder_str2: isCancel }">
  8. <view class="icon_ size_white m-recorder-text" v-if="isCancel">
  9. 松手
  10. <view style="width: 10rpx"></view>
  11. 取消
  12. </view>
  13. <view class="icon_ size_white m-recorder-text" v-else>
  14. 上划
  15. <view style="width: 10rpx"></view>
  16. 取消
  17. </view>
  18. </view>
  19. <view class="m-recorder-str">
  20. <view class="m-recorder-str-icon">
  21. <image
  22. class="img"
  23. src="data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+PHBhdGggZD0iTTY3NC44MDYgNzcuMTI2YTQ2LjAwOCA0Ni4wMDggMCAwIDAtNjYuMTc2IDAgNDYuMDA4IDQ2LjAwOCAwIDAgMCAwIDYzLjAyNSA1MjAuNTg4IDUyMC41ODggMCAwIDEgMCA3MzUuNTA0IDQ3LjI2OSA0Ny4yNjkgMCAwIDAgMCA2Ni44MDcgNDcuMjY5IDQ3LjI2OSAwIDAgMCA2Ni44MDcgMCA2MTQuNDk2IDYxNC40OTYgMCAwIDAtLjYzLTg2NS4zMzZ6IiBmaWxsPSIjNTE1MTUxIi8+PHBhdGggZD0iTTQ2Ny40NTMgMjQyLjg4MmE0Ny4yNjkgNDcuMjY5IDAgMCAwLTYzLjAyNSAwIDQ2LjYzOSA0Ni42MzkgMCAwIDAgMCA2My4wMjYgMjk5LjM3IDI5OS4zNyAwIDAgMSAwIDQyMi4yNjggNDcuMjY5IDQ3LjI2OSAwIDAgMCAwIDYzLjAyNiA0Ni42MzkgNDYuNjM5IDAgMCAwIDYzLjAyNSAwIDM5My45MDggMzkzLjkwOCAwIDAgMCAwLTU0OC4zMnptLTI3Ny4zMSAyMTQuOTE2YTc4LjE1MSA3OC4xNTEgMCAwIDAgMCAxMTAuOTI1IDc4Ljc4MiA3OC43ODIgMCAxIDAgMC0xMTAuOTI1eiIgZmlsbD0iIzUxNTE1MSIvPjwvc3ZnPg=="
  24. mode="aspectFill"
  25. ></image>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. let recordTimeInterval = null;
  32. export default {
  33. props: {
  34. value: {
  35. type: Boolean,
  36. default: false
  37. },
  38. isCancel: {
  39. type: Boolean,
  40. default: false
  41. }
  42. },
  43. data() {
  44. return {
  45. recordTime: 1,
  46. isShow: false,
  47. emojiList: []
  48. };
  49. },
  50. watch: {
  51. value: {
  52. handler: function (newV) {
  53. this.isShow = newV;
  54. this.recordTime = 1;
  55. if (newV) {
  56. recordTimeInterval = setInterval(() => {
  57. this.recordTime++;
  58. if (this.recordTime === 60) {
  59. this.touchend();
  60. }
  61. }, 1000);
  62. } else {
  63. clearInterval(recordTimeInterval);
  64. }
  65. this.$nextTick(() => {
  66. let view = uni.createSelectorQuery().select('.m-recorder-str');
  67. view.boundingClientRect((data) => {
  68. this.$emit('recorderTop', data);
  69. }).exec();
  70. // setTimeout(() => {
  71. // const query = uni.createSelectorQuery().in(this);
  72. // query
  73. // .select('.m-recorder-str')
  74. // .boundingClientRect((data) => {
  75. // console.log('得到布局位置信息' + JSON.stringify(data));
  76. // console.log('节点离页面顶部的距离为' + data.top);
  77. // })
  78. // .exec();
  79. // }, 1000);
  80. });
  81. },
  82. immediate: true
  83. }
  84. },
  85. methods: {
  86. touchend() {
  87. this.$emit('touchend');
  88. }
  89. }
  90. };
  91. </script>
  92. <style lang="scss" scoped>
  93. .m-recorder {
  94. position: fixed;
  95. z-index: 9999;
  96. top: 0;
  97. left: 0;
  98. bottom: 0;
  99. right: 0;
  100. overflow: hidden;
  101. background-color: rgba(0, 0, 0, 0.75);
  102. .m-recorder-gif {
  103. position: absolute;
  104. top: 50vh;
  105. left: calc(50% - 160rpx);
  106. z-index: 99;
  107. width: 340rpx;
  108. height: 170rpx;
  109. box-sizing: border-box;
  110. padding: 16rpx;
  111. border-radius: 30rpx;
  112. background-color: #95ec6a;
  113. .img {
  114. width: 100%;
  115. height: 100%;
  116. }
  117. }
  118. .m-recorder-gif::after {
  119. position: absolute;
  120. z-index: -1;
  121. content: '';
  122. bottom: -10rpx;
  123. left: calc(50% - 18rpx);
  124. width: 36rpx;
  125. height: 36rpx;
  126. border-radius: 2px;
  127. transform: rotate(45deg);
  128. background-color: #95ec6a;
  129. }
  130. .m-recorder-str {
  131. box-sizing: border-box;
  132. position: absolute;
  133. top: calc(100vh - 300rpx);
  134. left: calc(50% - 150vw);
  135. width: 300vw;
  136. height: 300vw;
  137. border: 12rpx solid #cccccc;
  138. border-radius: 50%;
  139. background-image: radial-gradient(#fff, #dddddd, #797979);
  140. .m-recorder-str-icon {
  141. position: absolute;
  142. top: 100rpx;
  143. left: calc(50% - 25rpx);
  144. width: 60rpx;
  145. height: 60rpx;
  146. }
  147. }
  148. .m-recorder-str2 {
  149. box-sizing: border-box;
  150. position: absolute;
  151. top: calc(100vh - 400rpx);
  152. left: calc(50% - 150vw);
  153. width: 300vw;
  154. height: 300vw;
  155. opacity: 0.7;
  156. background-color: rgba(240, 240, 240, 0.3);
  157. border-radius: 50%;
  158. transition: all 0.2s;
  159. .m-recorder-text {
  160. width: 200rpx;
  161. position: absolute;
  162. top: 30rpx;
  163. left: calc(50% - 100rpx);
  164. }
  165. }
  166. .m_recorder_str2 {
  167. background-color: #fa5251;
  168. box-shadow: #fa5251 0px 0px 50px;
  169. }
  170. }
  171. </style>