媒资管理
@@ -58,7 +58,7 @@ export default {
|
||||
},
|
||||
{
|
||||
title: '媒资管理',
|
||||
path: '/apps/AppResourcesManage/AppResourcesManage',
|
||||
path: '../AppResourcesManage/AppResourcesManage',
|
||||
text: '支持音频文件和录音内容添加',
|
||||
imgUrl: require('./img/bigHorn-icon44@2x.png'),
|
||||
bgClass: 'bg-F19661'
|
||||
|
||||
299
src/project/beta/AppResourcesManage/AppResourcesManage.vue
Normal file
@@ -0,0 +1,299 @@
|
||||
<template>
|
||||
<div class="AppResourcesManage">
|
||||
<AiTopFixed>
|
||||
<div class="currentLeft-top">
|
||||
<div class="left">
|
||||
<AiSelect @data="selectType" :list="typeList" v-model="type"></AiSelect>
|
||||
</div>
|
||||
<u-search v-model="keyword" :clearabled="true" placeholder="请输入素材名称/创建人员" :show-action="false" bg-color="#F5F5F5" search-icon-color="#ccc" color="#666" height="58" @search="getList" @clear="handerClear"></u-search>
|
||||
</div>
|
||||
</AiTopFixed>
|
||||
<div class="tab">
|
||||
<u-tabs :list="tab" :is-scroll="false" :current="currIndex" @change="change" height="96" :bar-style="barStyle"></u-tabs>
|
||||
</div>
|
||||
<div class="record" v-if="currIndex == 0">
|
||||
<div class="item" v-for="(item, index) in list" :key="index" @click="toDetail(item)">
|
||||
<img :src="`${$cdn}video/play-icon.png`" alt="" @click="choose(item)">
|
||||
<div class="info">
|
||||
<p>{{ item.name ? item.name.split('.')[0] : '-' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="record-text" v-else>
|
||||
<div class="item" v-for="(item, index) in list" :key="index" @click="toDetail(item)">
|
||||
<div>{{ item.name }}</div>
|
||||
<p>{{ item.content }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<AiEmpty v-if="!list.length"></AiEmpty>
|
||||
<img src="./img/add-icon.png" alt="" class="add-img" @click="add">
|
||||
<u-popup v-model="isShow" mode="bottom">
|
||||
<div class="audio">
|
||||
<AiVideo :src="url" autoplay></AiVideo>
|
||||
<!-- <audio :src="url" ref="audio" :controls="true" :name="autioName" style="display: block;"></audio> -->
|
||||
</div>
|
||||
</u-popup>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: "AppResourcesManage",
|
||||
appName: "媒资管理",
|
||||
data() {
|
||||
return {
|
||||
tab: [{name: '音频素材'}, {name: '文本素材'}],
|
||||
list: [],
|
||||
currIndex: 0,
|
||||
current: 1,
|
||||
isChoose: false,
|
||||
isMore: false,
|
||||
isShow: false,
|
||||
url: '',
|
||||
autioName: '',
|
||||
audio: null,
|
||||
barStyle: {width: '98px', bottom: '-3px', left: '-38px'},
|
||||
keyword: '',
|
||||
type: '0',
|
||||
typeList: [{label: '全部', value: '0'}, {label: '我创建的', value: '1'},]
|
||||
}
|
||||
},
|
||||
onLoad(query) {
|
||||
this.isChoose = !!query.isChoose
|
||||
this.getList()
|
||||
uni.$on('getList', () => {
|
||||
this.isMore = false
|
||||
this.list = []
|
||||
this.current = 1
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.getList()
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
onShow() {
|
||||
document.title = '媒资管理'
|
||||
},
|
||||
|
||||
methods: {
|
||||
selectType(selecteds) {
|
||||
this.type = selecteds?.[0]?.value
|
||||
this.getListInit()
|
||||
},
|
||||
change(index) {
|
||||
this.currIndex = index
|
||||
this.getListInit()
|
||||
},
|
||||
|
||||
add() {
|
||||
uni.navigateTo({
|
||||
url: `./addPlay?type=${this.currIndex === 0 ? 1 : 3}`
|
||||
})
|
||||
},
|
||||
|
||||
choose(item) {
|
||||
if (!this.isChoose) {
|
||||
console.log(item.url)
|
||||
this.url = item.url
|
||||
this.isShow = true
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
uni.$emit('choose', {
|
||||
mediaId: item.id,
|
||||
mediaName: item.name
|
||||
})
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
},
|
||||
|
||||
handerClear() {
|
||||
this.keyword = ''
|
||||
this.getListInit()
|
||||
},
|
||||
|
||||
getListInit() {
|
||||
this.isMore = false
|
||||
this.list = []
|
||||
this.current = 1
|
||||
this.getList()
|
||||
},
|
||||
|
||||
getList() {
|
||||
if (this.isMore) return
|
||||
|
||||
this.$http.post(`/app/appdlbresource/list`, null, {
|
||||
params: {
|
||||
...this.search,
|
||||
type: this.currIndex === 0 ? 1 : 3,
|
||||
current: this.current,
|
||||
size: 10
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.code == 0) {
|
||||
if (this.current > 1) {
|
||||
this.list = [...this.list, ...res.data.records]
|
||||
} else {
|
||||
this.list = res.data.records
|
||||
}
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.data.records.length < 10) {
|
||||
this.isMore = true
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
this.current = this.current + 1
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
}
|
||||
}).catch(() => {
|
||||
uni.hideLoading()
|
||||
})
|
||||
},
|
||||
toDetail(item) {
|
||||
uni.navigateTo({url: `./detail`})
|
||||
}
|
||||
},
|
||||
|
||||
onReachBottom() {
|
||||
this.getList()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.AppResourcesManage {
|
||||
padding-bottom: 128px;
|
||||
|
||||
.tab {
|
||||
border-bottom: 1px solid #ddd;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.audio {
|
||||
width: 100%;
|
||||
height: 400px;
|
||||
box-sizing: border-box;
|
||||
padding: 104px 0 46px;
|
||||
|
||||
audio {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.record {
|
||||
background-color: #fff;
|
||||
|
||||
.item {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding: 32px 30px;
|
||||
box-sizing: border-box;
|
||||
|
||||
img {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
margin-right: 14px;
|
||||
}
|
||||
|
||||
.info {
|
||||
width: calc(100% - 70px);
|
||||
line-height: 44px;
|
||||
font-size: 34px;
|
||||
font-family: PingFang-SC-Medium, PingFang-SC;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
|
||||
p {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.record-text {
|
||||
background-color: #fff;
|
||||
|
||||
.item {
|
||||
width: 100%;
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding: 32px 30px;
|
||||
box-sizing: border-box;
|
||||
font-size: 30px;
|
||||
|
||||
div {
|
||||
font-size: 30px;
|
||||
font-family: PingFangSC-Medium, PingFang SC;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
margin-bottom: 12px;
|
||||
|
||||
.color-0063E5 {
|
||||
color: #0063E5;
|
||||
}
|
||||
|
||||
.color-FF8100 {
|
||||
color: #FF8100;
|
||||
}
|
||||
|
||||
.color-FF4466 {
|
||||
color: #FF4466;
|
||||
}
|
||||
}
|
||||
|
||||
p {
|
||||
font-family: PingFangSC-Regular, PingFang SC;
|
||||
font-weight: 400;
|
||||
color: #666;
|
||||
line-height: 40px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
line-clamp: 2;
|
||||
word-break: break-all;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.add-img {
|
||||
width: 120px;
|
||||
position: fixed;
|
||||
bottom: 120px;
|
||||
right: 32px;
|
||||
}
|
||||
|
||||
.currentLeft-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.left {
|
||||
width: 200px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
img {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
}
|
||||
}
|
||||
}
|
||||
::v-deep .u-search {
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
204
src/project/beta/AppResourcesManage/addPlay.vue
Normal file
@@ -0,0 +1,204 @@
|
||||
<template>
|
||||
<div class="addPlay">
|
||||
<div v-if="type == '1'">
|
||||
<div class="content">
|
||||
<div class="item">
|
||||
<div class="label">音频文件</div>
|
||||
<div class="value" @click="toRecord">
|
||||
<span class="color-999" :style="{ color: file ? '#333' : '' }">{{ file ? '已选择' : '请选择' }}</span>
|
||||
<img src="./img/right-img.png" alt="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="radio-content">
|
||||
<div class="title">素材标题</div>
|
||||
<textarea rows="2" placeholder="请输入(30字以内)" v-model="name" style="width:100%;height:80px;"
|
||||
maxlength="30"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div class="radio-content mar-b16">
|
||||
<div class="title">素材标题</div>
|
||||
<textarea rows="2" placeholder="请输入(30字以内)" v-model="name" style="width:100%;height:80px;"
|
||||
maxlength="30"></textarea>
|
||||
</div>
|
||||
<div class="radio-content">
|
||||
<div class="title">文本内容</div>
|
||||
<textarea rows="8" placeholder="请输入文本内容(12000字以内)" v-model="content" style="width:100%;height:300px;"
|
||||
maxlength="12000"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn" @click="confirm">确认</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: "addPlay",
|
||||
data() {
|
||||
return {
|
||||
type: '1',
|
||||
file: null,
|
||||
name: '',
|
||||
content: ''
|
||||
}
|
||||
},
|
||||
|
||||
onLoad(query) {
|
||||
this.type = query.type
|
||||
uni.$on('record', e => {
|
||||
this.file = e
|
||||
})
|
||||
},
|
||||
onShow() {
|
||||
document.title = this.type == 1 ? '添加音频' : '添加文本'
|
||||
},
|
||||
|
||||
methods: {
|
||||
toRecord() {
|
||||
uni.navigateTo({
|
||||
url: `./recording`
|
||||
})
|
||||
},
|
||||
|
||||
dataURLtoFile(dataurl, filename) {
|
||||
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1]
|
||||
var bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n)
|
||||
|
||||
while (n--) {
|
||||
u8arr[n] = bstr.charCodeAt(n)
|
||||
}
|
||||
|
||||
return new File([u8arr], filename, {type: mime})
|
||||
},
|
||||
|
||||
confirm() {
|
||||
if (!this.file && this.type === '1') {
|
||||
return this.$u.toast('请选择音频文件')
|
||||
}
|
||||
|
||||
if (!this.name) {
|
||||
return this.$u.toast('请输入素材标题')
|
||||
}
|
||||
|
||||
if (!this.content && this.type === '3') {
|
||||
return this.$u.toast('请输入文本内容')
|
||||
}
|
||||
|
||||
uni.showLoading()
|
||||
let formData = {}
|
||||
formData = new FormData()
|
||||
if (this.type === '1') {
|
||||
formData.append('file', this.dataURLtoFile(this.file, this.name + '.mp3'))
|
||||
formData.append('type', this.type)
|
||||
formData.append('content', this.content)
|
||||
formData.append('name', this.name)
|
||||
} else {
|
||||
formData.append('type', this.type)
|
||||
formData.append('content', this.content)
|
||||
formData.append('name', this.name)
|
||||
}
|
||||
this.$http.post(`/app/appdlbresource/addResourceWithFile`, formData).then((res) => {
|
||||
uni.hideLoading()
|
||||
if (res.code === 0) {
|
||||
this.$u.toast('添加成功')
|
||||
uni.$emit('getList')
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}
|
||||
}).catch(err => {
|
||||
this.$u.toast('添加失败')
|
||||
uni.hideLoading()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.addPlay {
|
||||
padding-bottom: 128px;
|
||||
|
||||
.content {
|
||||
padding-left: 32px;
|
||||
background-color: #fff;
|
||||
|
||||
.item {
|
||||
width: 100%;
|
||||
padding: 34px 0;
|
||||
font-size: 32px;
|
||||
font-family: PingFangSC-Regular, PingFang SC;
|
||||
font-weight: 400;
|
||||
line-height: 44px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
display: flex;
|
||||
color: #333;
|
||||
justify-content: space-between;
|
||||
|
||||
.label {
|
||||
width: 198px;
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.value {
|
||||
font-size: 28px;
|
||||
width: calc(100% - 198px);
|
||||
padding-right: 32px;
|
||||
box-sizing: border-box;
|
||||
text-align: right;
|
||||
|
||||
img {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
vertical-align: middle;
|
||||
margin-left: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.color-999 {
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.radio-content {
|
||||
padding: 34px 32px 38px;
|
||||
background-color: #fff;
|
||||
|
||||
.title {
|
||||
font-size: 32px;
|
||||
font-family: PingFangSC-Regular, PingFang SC;
|
||||
font-weight: 400;
|
||||
color: #333;
|
||||
line-height: 44px;
|
||||
margin-bottom: 32px;
|
||||
|
||||
span {
|
||||
font-size: 24px;
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.mar-b16 {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 112px;
|
||||
line-height: 112px;
|
||||
text-align: center;
|
||||
background: #3975C6;
|
||||
font-size: 32px;
|
||||
font-family: PingFangSC-Medium, PingFang SC;
|
||||
font-weight: 500;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
96
src/project/beta/AppResourcesManage/detail.vue
Normal file
@@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<div class="detail">
|
||||
<div class="header">
|
||||
<img :src="`${$cdn}video/play-icon.png`" alt="">
|
||||
<div class="right">
|
||||
<h2>五一活动唱红歌.mp3</h2>
|
||||
<p>2022-06-09 09:43:45</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content"></div>
|
||||
<div class="footer-bottom"></div>
|
||||
<div class="footer">
|
||||
<div>删除素材</div>
|
||||
<div class="confirm">发布广播</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: "detail"
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.detail {
|
||||
padding-top: 8px;
|
||||
.header {
|
||||
margin: 0 0 32px 0;
|
||||
width: 100%;
|
||||
padding: 20px 30px 16px 30px;
|
||||
box-sizing: border-box;
|
||||
background: #FFF;
|
||||
box-shadow: inset 0px 0px 0px 0px #D8DDE6;
|
||||
display: flex;
|
||||
img {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
margin-right: 16px;
|
||||
}
|
||||
.right {
|
||||
width: calc(100% - 72px);
|
||||
font-family: PingFang-SC-Medium, PingFang-SC;
|
||||
h2{
|
||||
width: 100%;
|
||||
font-size: 34px;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
line-height: 48px;
|
||||
word-break: break-all;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
p{
|
||||
font-size: 26px;
|
||||
font-weight: 500;
|
||||
color: #999;
|
||||
line-height: 36px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.content{
|
||||
padding: 32px;
|
||||
font-size: 32px;
|
||||
font-family: PingFangSC-Regular, PingFang SC;
|
||||
color: #333;
|
||||
line-height: 44px;
|
||||
word-break: break-all;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.footer-bottom{
|
||||
height: 120px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 112px;
|
||||
line-height: 112px;
|
||||
display: flex;
|
||||
div{
|
||||
flex: 1;
|
||||
font-size: 36px;
|
||||
font-family: PingFangSC-Medium, PingFang SC;
|
||||
font-weight: 500;
|
||||
color: #F46;
|
||||
background-color: #fff;
|
||||
text-align: center;
|
||||
}
|
||||
.confirm{
|
||||
background: #3975C6;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
BIN
src/project/beta/AppResourcesManage/img/add-icon.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
src/project/beta/AppResourcesManage/img/body.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
src/project/beta/AppResourcesManage/img/circle-active.png
Normal file
|
After Width: | Height: | Size: 979 B |
BIN
src/project/beta/AppResourcesManage/img/circle-icon.png
Normal file
|
After Width: | Height: | Size: 795 B |
BIN
src/project/beta/AppResourcesManage/img/microphone.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
src/project/beta/AppResourcesManage/img/play-icon.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
src/project/beta/AppResourcesManage/img/right-icon.png
Normal file
|
After Width: | Height: | Size: 269 B |
BIN
src/project/beta/AppResourcesManage/img/right-img.png
Normal file
|
After Width: | Height: | Size: 269 B |
BIN
src/project/beta/AppResourcesManage/img/stop-img.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
src/project/beta/AppResourcesManage/img/top.png
Normal file
|
After Width: | Height: | Size: 531 B |
BIN
src/project/beta/AppResourcesManage/img/video-img.png
Normal file
|
After Width: | Height: | Size: 577 B |
541
src/project/beta/AppResourcesManage/recording.vue
Normal file
@@ -0,0 +1,541 @@
|
||||
<template>
|
||||
<div class="recording">
|
||||
<div class="recording-content" v-if="isRecording">
|
||||
<div class="header-top" :style="{width: progress + '%'}"></div>
|
||||
<div class="header-line" :style="{width: progress + '%'}">
|
||||
<span class="line1 animation"></span>
|
||||
<span class="line2 animation"></span>
|
||||
<span class="line3 animation"></span>
|
||||
<span class="line4 animation"></span>
|
||||
<span class="line5 animation"></span>
|
||||
<span class="line6 animation"></span>
|
||||
<span class="line7 animation"></span>
|
||||
<span class="line8 animation"></span>
|
||||
<span class="line9 animation"></span>
|
||||
<span class="line10 animation"></span>
|
||||
<span class="line11 animation"></span>
|
||||
<span class="line12 animation"></span>
|
||||
<span class="line13 animation"></span>
|
||||
<span class="line14 animation"></span>
|
||||
<span class="line15 animation"></span>
|
||||
<span class="line16 animation"></span>
|
||||
<span class="line17 animation"></span>
|
||||
<span class="line18 animation"></span>
|
||||
<span class="line19 animation"></span>
|
||||
<span class="line20 animation"></span>
|
||||
<span class="line1 animation"></span>
|
||||
<span class="line2 animation"></span>
|
||||
<span class="line3 animation"></span>
|
||||
<span class="line4 animation"></span>
|
||||
<span class="line5 animation"></span>
|
||||
<span class="line6 animation"></span>
|
||||
<span class="line7 animation"></span>
|
||||
<span class="line8 animation"></span>
|
||||
<span class="line9 animation"></span>
|
||||
<span class="line10 animation"></span>
|
||||
<span class="line11 animation"></span>
|
||||
<span class="line12 animation"></span>
|
||||
<span class="line13 animation"></span>
|
||||
<span class="line14 animation"></span>
|
||||
<span class="line15 animation"></span>
|
||||
<span class="line16 animation"></span>
|
||||
<span class="line17 animation"></span>
|
||||
<span class="line18 animation"></span>
|
||||
<span class="line19 animation"></span>
|
||||
<span class="line20 animation"></span>
|
||||
<span class="line1 animation"></span>
|
||||
<span class="line2 animation"></span>
|
||||
<span class="line3 animation"></span>
|
||||
<span class="line4 animation"></span>
|
||||
<span class="line5 animation"></span>
|
||||
<span class="line6 animation"></span>
|
||||
<span class="line7 animation"></span>
|
||||
<span class="line8 animation"></span>
|
||||
<span class="line9 animation"></span>
|
||||
<span class="line10 animation"></span>
|
||||
<span class="line10 animation"></span>
|
||||
<span class="line11 animation"></span>
|
||||
<span class="line12 animation"></span>
|
||||
<span class="line13 animation"></span>
|
||||
<span class="line14 animation"></span>
|
||||
<span class="line15 animation"></span>
|
||||
<span class="line16 animation"></span>
|
||||
<span class="line17 animation"></span>
|
||||
<span class="line18 animation"></span>
|
||||
<span class="line19 animation"></span>
|
||||
<span class="line20 animation"></span>
|
||||
</div>
|
||||
<div class="progress" :style="{left: progress + '%'}"></div>
|
||||
<p class="time">{{ time }}</p>
|
||||
</div>
|
||||
<div class="stop-content" v-else-if="!isRecording && isStop">
|
||||
<p class="time">{{ time }}</p>
|
||||
<div class="header-line">
|
||||
<span class="line1 animation"></span>
|
||||
<span class="line2 animation"></span>
|
||||
<span class="line3 animation"></span>
|
||||
<span class="line4 animation"></span>
|
||||
<span class="line5 animation"></span>
|
||||
<span class="line6 animation"></span>
|
||||
<span class="line7 animation"></span>
|
||||
<span class="line8 animation"></span>
|
||||
<span class="line9 animation"></span>
|
||||
<span class="line10 animation"></span>
|
||||
<span class="line11 animation"></span>
|
||||
<span class="line12 animation"></span>
|
||||
<span class="line13 animation"></span>
|
||||
<span class="line14 animation"></span>
|
||||
<span class="line15 animation"></span>
|
||||
<span class="line16 animation"></span>
|
||||
<span class="line17 animation"></span>
|
||||
<span class="line18 animation"></span>
|
||||
<span class="line19 animation"></span>
|
||||
<span class="line20 animation"></span>
|
||||
<span class="line1 animation"></span>
|
||||
<span class="line2 animation"></span>
|
||||
<span class="line3 animation"></span>
|
||||
<span class="line4 animation"></span>
|
||||
<span class="line5 animation"></span>
|
||||
<span class="line6 animation"></span>
|
||||
<span class="line7 animation"></span>
|
||||
<span class="line8 animation"></span>
|
||||
<span class="line9 animation"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content" v-else>
|
||||
<img src="./img/body.png" alt="">
|
||||
<p class="text">点击下方按钮开始录音</p>
|
||||
<p class="text">为了保证效果,请靠近手机讲话哦~</p>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<span v-if="isRecording || isStop" @click="restart">重新开始</span>
|
||||
<img v-if="isStop" :src="`${$cdn}video/${!isPlay ? 'play-icon' : 'stop-img'}.png`" @click="play">
|
||||
<img v-else :src="`${$cdn}video/${isRecording ? 'stop-img' : 'microphone'}.png`" @click="record">
|
||||
<!-- :src="isRecording ? stopImg : microphone" -->
|
||||
<span v-if="isStop" @click="save">保存</span>
|
||||
</div>
|
||||
<audio style="opacity: 0; visibility: hidden;" :src="audioSrc" @ended="onAudioEnd"></audio>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Recorder from 'recorder-core'
|
||||
import 'recorder-core/src/engine/mp3'
|
||||
import 'recorder-core/src/engine/mp3-engine'
|
||||
import microphone from './img/microphone.png'
|
||||
|
||||
export default {
|
||||
name: 'recording',
|
||||
data() {
|
||||
return {
|
||||
isRecording: false,
|
||||
progress: 0,
|
||||
microphone,
|
||||
isPlay: false,
|
||||
isStop: false,
|
||||
blobFile: null,
|
||||
time: '00:00:00',
|
||||
counterDownTime: 0,
|
||||
recorder: null,
|
||||
counterDownTimeout: null,
|
||||
timingTimeout: null,
|
||||
audioSrc: '',
|
||||
audio: null,
|
||||
duration: 0
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$nextTick(() => {
|
||||
this.audio = document.querySelector('audio')
|
||||
})
|
||||
},
|
||||
|
||||
onShow() {
|
||||
document.title = '音频录制'
|
||||
},
|
||||
|
||||
methods: {
|
||||
record() {
|
||||
if (!this.isRecording) {
|
||||
this.duration = 0
|
||||
this.recorder = Recorder({
|
||||
type: 'mp3',
|
||||
sampleRate: 16000,
|
||||
bitRate: 16,
|
||||
onProcess(buffers, powerLevel, bufferDuration, bufferSampleRate, newBufferIdx, asyncEnd) {
|
||||
//可利用extensions/waveview.js扩展实时绘制波形
|
||||
}
|
||||
})
|
||||
|
||||
this.recorder.open(() => {
|
||||
this.recorder.start()
|
||||
this.isRecording = true
|
||||
this.timing()
|
||||
})
|
||||
} else {
|
||||
this.stop()
|
||||
}
|
||||
},
|
||||
|
||||
blobToDataURI(blob) {
|
||||
return new Promise((resolve) => {
|
||||
var reader = new FileReader()
|
||||
reader.readAsDataURL(blob)
|
||||
reader.onload = function (e) {
|
||||
resolve(e.target.result)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
save() {
|
||||
if (!this.blobFile) {
|
||||
return this.$u.toast(`请录音`)
|
||||
}
|
||||
|
||||
this.blobToDataURI(this.blobFile).then(res => {
|
||||
uni.$emit('record', res)
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
onAudioEnd() {
|
||||
this.isPlay = false
|
||||
},
|
||||
|
||||
stop() {
|
||||
this.isRecording = false
|
||||
this.isStop = true
|
||||
clearTimeout(this.timingTimeout)
|
||||
this.recorder.stop((blob, duration) => {
|
||||
this.blobFile = blob
|
||||
|
||||
var durationObj = this.$dayjs.duration(this.counterDownTime * 1000)
|
||||
this.duration = this.counterDownTime
|
||||
var hours = durationObj.hours() > 9 ? durationObj.hours() : '0' + durationObj.hours()
|
||||
var min = durationObj.minutes() > 9 ? durationObj.minutes() : '0' + durationObj.minutes()
|
||||
var seconds = durationObj.seconds() > 9 ? durationObj.seconds() : '0' + durationObj.seconds()
|
||||
|
||||
this.time = hours + ':' + min + ':' + seconds
|
||||
console.log(blob, (window.URL || webkitURL).createObjectURL(blob), '时长:' + duration + 'ms')
|
||||
this.recorder.close()
|
||||
this.recorder = null
|
||||
}, msg => {
|
||||
console.log('录音失败:' + msg)
|
||||
this.recorder.close()
|
||||
this.recorder = null
|
||||
})
|
||||
},
|
||||
|
||||
play() {
|
||||
if (!this.isPlay) {
|
||||
this.playAudio()
|
||||
this.counterDown()
|
||||
} else {
|
||||
this.isPlay = false
|
||||
clearTimeout(this.counterDownTimeout)
|
||||
this.audio.pause()
|
||||
}
|
||||
},
|
||||
|
||||
playAudio() {
|
||||
this.isPlay = true
|
||||
if (!this.audioSrc) {
|
||||
this.audioSrc = (window.URL || webkitURL).createObjectURL(this.blobFile)
|
||||
}
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.audio.play()
|
||||
})
|
||||
},
|
||||
|
||||
recodeStop() {
|
||||
this.recorder.stop((blob, duration) => {
|
||||
this.restart()
|
||||
this.blobFile = blob
|
||||
console.log(blob, (window.URL || webkitURL).createObjectURL(blob), '时长:' + duration + 'ms')
|
||||
this.recorder.close()
|
||||
this.recorder = null
|
||||
}, msg => {
|
||||
console.log('录音失败:' + msg)
|
||||
this.recorder.close()
|
||||
this.recorder = null
|
||||
})
|
||||
},
|
||||
|
||||
restart() {
|
||||
this.time = '00:00:00'
|
||||
this.progress = 0
|
||||
this.blobFile = null
|
||||
this.isPlay = false
|
||||
this.isRecording = false
|
||||
clearTimeout(this.counterDownTimeout)
|
||||
clearTimeout(this.timingTimeout)
|
||||
this.counterDownTime = 0
|
||||
this.audioSrc = ''
|
||||
this.isStop = false
|
||||
},
|
||||
|
||||
counterDown() {
|
||||
if (this.counterDownTime === -1) {
|
||||
clearTimeout(this.counterDownTimeout)
|
||||
this.counterDownTime = this.duration
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
var durationObj = this.$dayjs.duration(this.counterDownTime * 1000)
|
||||
var hours = durationObj.hours() > 9 ? durationObj.hours() : '0' + durationObj.hours()
|
||||
var min = durationObj.minutes() > 9 ? durationObj.minutes() : '0' + durationObj.minutes()
|
||||
var seconds = durationObj.seconds() > 9 ? durationObj.seconds() : '0' + durationObj.seconds()
|
||||
|
||||
this.time = hours + ':' + min + ':' + seconds
|
||||
this.counterDownTime--
|
||||
this.counterDownTimeout = setTimeout(() => {
|
||||
this.counterDown()
|
||||
}, 1000)
|
||||
},
|
||||
|
||||
timing() {
|
||||
this.progress = ((this.counterDownTime / 120) * 100).toFixed(2) > 100 ? 101 : ((this.counterDownTime / 120) * 100).toFixed(2)
|
||||
var durationObj = this.$dayjs.duration(this.counterDownTime * 1000)
|
||||
var hours = durationObj.hours() > 9 ? durationObj.hours() : '0' + durationObj.hours()
|
||||
var min = durationObj.minutes() > 9 ? durationObj.minutes() : '0' + durationObj.minutes()
|
||||
var seconds = durationObj.seconds() > 9 ? durationObj.seconds() : '0' + durationObj.seconds()
|
||||
|
||||
this.time = hours + ':' + min + ':' + seconds
|
||||
this.counterDownTime++
|
||||
this.timingTimeout = setTimeout(() => {
|
||||
this.timing()
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
uni-page-body {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.recording {
|
||||
height: 100vh;
|
||||
overflow-y: hidden;
|
||||
|
||||
.content {
|
||||
padding-top: 310px;
|
||||
text-align: center;
|
||||
|
||||
img {
|
||||
width: 406px;
|
||||
height: 306px;
|
||||
margin-bottom: 48px;
|
||||
}
|
||||
|
||||
.text {
|
||||
font-size: 30px;
|
||||
color: #999;
|
||||
line-height: 42px;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 168px;
|
||||
background: #F6F8FC;
|
||||
padding: 20px 86px;
|
||||
box-sizing: border-box;
|
||||
|
||||
span {
|
||||
display: inline-block;
|
||||
width: 160px;
|
||||
height: 64px;
|
||||
background: #4E8EEE;
|
||||
border-radius: 32px;
|
||||
font-size: 30px;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
line-height: 64px;
|
||||
vertical-align: top;
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 128px;
|
||||
height: 128px;
|
||||
margin: 0 64px;
|
||||
}
|
||||
}
|
||||
|
||||
.recording-content {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.stop-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
height: calc(100% - 168px);
|
||||
|
||||
.header-line {
|
||||
width: 380px;
|
||||
}
|
||||
|
||||
.time {
|
||||
margin-top: 0;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
}
|
||||
|
||||
.header-top {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
left: 0;
|
||||
height: 6px;
|
||||
background: url(img/top.png) repeat-x;
|
||||
background-size: auto 6px;
|
||||
}
|
||||
|
||||
.time {
|
||||
width: 100%;
|
||||
margin-top: 208px;
|
||||
text-align: center;
|
||||
font-size: 96px;
|
||||
color: #000000;
|
||||
line-height: 134px;
|
||||
}
|
||||
|
||||
.progress {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
left: 0;
|
||||
width: 2px;
|
||||
height: 128px;
|
||||
background: #3477EE;
|
||||
}
|
||||
|
||||
.header-line {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
height: 128px;
|
||||
line-height: 128px;
|
||||
margin-top: 16px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.animation {
|
||||
animation: note 0.24s ease-in-out;
|
||||
animation-iteration-count: infinite;
|
||||
animation-direction: alternate;
|
||||
}
|
||||
|
||||
.header-line span {
|
||||
display: inline-block;
|
||||
width: 6px;
|
||||
height: 16px;
|
||||
margin: 0 6px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
background-color: #3476EE;
|
||||
}
|
||||
|
||||
.header-line span.line1 {
|
||||
animation-delay: -1s;
|
||||
}
|
||||
|
||||
.header-line span.line2 {
|
||||
animation-delay: -0.9s;
|
||||
}
|
||||
|
||||
.header-line span.line3 {
|
||||
animation-delay: -0.8s;
|
||||
}
|
||||
|
||||
.header-line span.line4 {
|
||||
animation-delay: -0.7s;
|
||||
}
|
||||
|
||||
.header-line span.line5 {
|
||||
animation-delay: -0.6s;
|
||||
}
|
||||
|
||||
.header-line span.line6 {
|
||||
animation-delay: -0.5s;
|
||||
}
|
||||
|
||||
.header-line span.line7 {
|
||||
animation-delay: -0.4s;
|
||||
}
|
||||
|
||||
.header-line span.line8 {
|
||||
animation-delay: -0.4s;
|
||||
}
|
||||
|
||||
.header-line span.line9 {
|
||||
animation-delay: -0.2s;
|
||||
}
|
||||
|
||||
.header-line span.line10 {
|
||||
animation-delay: -0.1s;
|
||||
}
|
||||
|
||||
.header-line span.line11 {
|
||||
animation-delay: -1s;
|
||||
}
|
||||
|
||||
.header-line span.line12 {
|
||||
animation-delay: -0.9s;
|
||||
}
|
||||
|
||||
.header-line span.line13 {
|
||||
animation-delay: -0.8s;
|
||||
}
|
||||
|
||||
.header-line span.line14 {
|
||||
animation-delay: -0.7s;
|
||||
}
|
||||
|
||||
.header-line span.line15 {
|
||||
animation-delay: -0.6s;
|
||||
}
|
||||
|
||||
.header-line span.line16 {
|
||||
animation-delay: -0.5s;
|
||||
}
|
||||
|
||||
.header-line span.line17 {
|
||||
animation-delay: -0.4s;
|
||||
}
|
||||
|
||||
.header-line span.line18 {
|
||||
animation-delay: -0.3s;
|
||||
}
|
||||
|
||||
.header-line span.line19 {
|
||||
animation-delay: -0.2s;
|
||||
}
|
||||
|
||||
.header-line span.line20 {
|
||||
animation-delay: -0.1s;
|
||||
}
|
||||
|
||||
@keyframes note {
|
||||
from {
|
||||
transform: scaleY(1);
|
||||
}
|
||||
to {
|
||||
transform: scaleY(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
95
src/project/beta/AppResourcesManage/talking.vue
Normal file
@@ -0,0 +1,95 @@
|
||||
<template>
|
||||
<div class="talking">
|
||||
<div class="header">
|
||||
<p>刘家河村委会、张家村…等<span>20</span>个设备</p>
|
||||
<img src="./img/right-img.png" alt="">
|
||||
</div>
|
||||
<div class="content">
|
||||
<!-- <p class="time">00:00:13</p> -->
|
||||
<img src="./img/body.png" alt="">
|
||||
<p class="text">请先选择设备</p>
|
||||
<p class="text">再点击下方按钮开始喊话~</p>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<img :src="`${$cdn}video/stop-img.png`" alt="">
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: "talking"
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
uni-page-body {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.talking {
|
||||
.header {
|
||||
width: 100%;
|
||||
height: 128px;
|
||||
background: #F6F8FC;
|
||||
padding: 42px 32px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
p {
|
||||
font-size: 32px;
|
||||
color: #333;
|
||||
line-height: 44px;
|
||||
|
||||
span {
|
||||
color: #1174FE;
|
||||
}
|
||||
}
|
||||
|
||||
img {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
margin-top: 224px;
|
||||
|
||||
.time {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 96px;
|
||||
color: #000000;
|
||||
line-height: 134px;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 406px;
|
||||
height: 306px;
|
||||
margin: 0 0 48px 172px;
|
||||
}
|
||||
|
||||
.text {
|
||||
font-size: 30px;
|
||||
color: #999;
|
||||
line-height: 42px;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.footer {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 168px;
|
||||
background: #F6F8FC;
|
||||
padding: 20px 310px;
|
||||
box-sizing: border-box;
|
||||
|
||||
img {
|
||||
width: 128px;
|
||||
height: 128px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||