|
@@ -3,6 +3,16 @@ export default {
|
|
|
name: "lemonMessageVoice",
|
|
|
inheritAttrs: false,
|
|
|
inject: ["IMUI"],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ context: null,
|
|
|
+ duration: 100,
|
|
|
+ status: false,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+
|
|
|
+ },
|
|
|
render() {
|
|
|
return (
|
|
|
<lemon-message-basic
|
|
@@ -10,21 +20,148 @@ export default {
|
|
|
props={{ ...this.$attrs }}
|
|
|
scopedSlots={{
|
|
|
content: props => {
|
|
|
- return <span>{props.content} 🔈</span>;
|
|
|
+ console.log("qxj props:"+JSON.stringify(props));
|
|
|
+ return this.renderHtml(props);
|
|
|
}
|
|
|
}}
|
|
|
/>
|
|
|
);
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ renderHtml(data){
|
|
|
+
|
|
|
+ return <audio block="true" showDuration='false' duration={data.duration} controls src={data.content} ></audio>;
|
|
|
+ // return <span>{props.content} 🔈</span>;
|
|
|
+ },
|
|
|
+
|
|
|
+ renderNew(data){
|
|
|
+ //this.context.src = data.url;
|
|
|
+ return <view class='flex audio active' style='width:520rpx, background:#5ba5ef' click='play(1)' >
|
|
|
+ <view class='mr-3' >
|
|
|
+ <view class='wifi-symbol status'>
|
|
|
+ <view class="wifi-circle first"></view>
|
|
|
+ <view class="wifi-circle second"></view>
|
|
|
+ <view class="wifi-circle third"></view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class='ml-3'>{data.duration ? data.duration + 's' : ''}</view>
|
|
|
+ </view>
|
|
|
+ },
|
|
|
+ play(id) { //点击播放
|
|
|
+ console.log("qxj play:"+id);
|
|
|
+ if(this.status) {
|
|
|
+ this.context.pause();
|
|
|
+ this.status = !this.status;
|
|
|
+ }else {
|
|
|
+ uni.$emit('stop',id)
|
|
|
+ this.context.play()
|
|
|
+ this.status = !this.status;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onEnded() { //播放结束
|
|
|
+ this.context.onEnded(()=> {
|
|
|
+ this.status = false;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getWith(s){
|
|
|
+ if(s){
|
|
|
+ const w = s *10 + 150
|
|
|
+ return w > 520?'520rpx' :(s *10 + 150)+'rpx'
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
+
|
|
|
<style lang="stylus">
|
|
|
+
|
|
|
.lemon-message.lemon-message-voice
|
|
|
user-select none
|
|
|
.lemon-message__content
|
|
|
- border 2px solid #000
|
|
|
+ border 0px solid #000
|
|
|
font-size 12px
|
|
|
cursor pointer
|
|
|
&::before
|
|
|
display none
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ .audio
|
|
|
+ background #68d7bb
|
|
|
+ height 58rpx
|
|
|
+ border-radius 50rpx
|
|
|
+ width 200rpx
|
|
|
+ align-items center
|
|
|
+
|
|
|
+
|
|
|
+ .flex
|
|
|
+ display flex
|
|
|
+ flex-direction row
|
|
|
+ justify-content space-between
|
|
|
+
|
|
|
+ .flex-1
|
|
|
+ flex 1
|
|
|
+
|
|
|
+ .ml-3
|
|
|
+ margin-right 30rpx
|
|
|
+ color #fff
|
|
|
+
|
|
|
+ .mr-3
|
|
|
+ margin-left 30rpx
|
|
|
+
|
|
|
+ .wifi-symbol
|
|
|
+ width 50rpx
|
|
|
+ height 50rpx
|
|
|
+ box-sizing border-box
|
|
|
+ overflow hidden
|
|
|
+ transform rotate(135deg) translate3d(0, 0, 0)
|
|
|
+ -webkit-transform rotate(135deg) translate3d(0, 0, 0)
|
|
|
+ backface-visibility hidden
|
|
|
+ -webkit-backface-visibility hidden
|
|
|
+
|
|
|
+ .wifi-circle
|
|
|
+ border 5rpx solid #fff
|
|
|
+ border-radius 50%
|
|
|
+ position absolute
|
|
|
+
|
|
|
+ .first
|
|
|
+ width 5rpx
|
|
|
+ height 5rpx
|
|
|
+ background #fff
|
|
|
+ top 45rpx
|
|
|
+ left 45rpx
|
|
|
+
|
|
|
+ .second
|
|
|
+ width 25rpx
|
|
|
+ height 25rpx
|
|
|
+ top 35rpx
|
|
|
+ left 35rpx
|
|
|
+
|
|
|
+ .third
|
|
|
+ width 40rpx
|
|
|
+ height 40rpx
|
|
|
+ top 25rpx
|
|
|
+ left 25rpx
|
|
|
+
|
|
|
+ .active
|
|
|
+ .second
|
|
|
+ animation fadeInOut 1s infinite 0.2s
|
|
|
+ -webkit-animation fadeInOut 1s infinite 0.2s
|
|
|
+
|
|
|
+
|
|
|
+ .third
|
|
|
+ animation fadeInOut 1s infinite 0.4s
|
|
|
+ -webkit-animation fadeInOut 1s infinite 0.4s
|
|
|
+
|
|
|
+
|
|
|
+ @keyframes fadeInOut
|
|
|
+ 0%
|
|
|
+ opacity 0
|
|
|
+
|
|
|
+ 100%
|
|
|
+ opacity 1
|
|
|
+
|
|
|
+
|
|
|
</style>
|