|
@@ -30,7 +30,11 @@
|
|
/>
|
|
/>
|
|
|
|
|
|
<!-- 上传图片部分 -->
|
|
<!-- 上传图片部分 -->
|
|
- <view class="flex upload-img-box">
|
|
|
|
|
|
+ <view
|
|
|
|
+ class="flex upload-img-box"
|
|
|
|
+ v-if="recorderStatus!=='doing'&&recorderStatus!=='pause'"
|
|
|
|
+ :style="[{'height':recorderStatus==='stop'&&'auto'},{'border-bottom':recorderStatus==='stop'?'1px solid #E6E6E6':''}]"
|
|
|
|
+ >
|
|
<view class="item" v-for="(item,index) in imgList" :key="item" @click="handlePreViewImg(item)">
|
|
<view class="item" v-for="(item,index) in imgList" :key="item" @click="handlePreViewImg(item)">
|
|
<image :src="item" mode="aspectFill"/>
|
|
<image :src="item" mode="aspectFill"/>
|
|
<view class="del-btn" @click.stop="handleDelImg(index)">
|
|
<view class="del-btn" @click.stop="handleDelImg(index)">
|
|
@@ -63,14 +67,14 @@
|
|
<image src="./static/del.png" mode="aspectFill" />
|
|
<image src="./static/del.png" mode="aspectFill" />
|
|
<text>删除</text>
|
|
<text>删除</text>
|
|
</view>
|
|
</view>
|
|
-
|
|
|
|
|
|
+ <view class="pre_publish_time" v-if="voiceId!=0">定时发布时间:{{pre_publish_time}}</view>
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
|
|
- <view class="empty-voice-box" v-if="recorderStatus==='start'">
|
|
|
|
|
|
+ <!-- <view class="empty-voice-box" v-if="recorderStatus==='start'">
|
|
<image src="./static/record.png" mode="aspectFill" />
|
|
<image src="./static/record.png" mode="aspectFill" />
|
|
<view>无录音(录音时长超过十分钟自动结束)</view>
|
|
<view>无录音(录音时长超过十分钟自动结束)</view>
|
|
- </view>
|
|
|
|
|
|
+ </view> -->
|
|
|
|
|
|
<view class="animat-box" v-if="recorderStatus==='doing'||recorderStatus==='pause'">
|
|
<view class="animat-box" v-if="recorderStatus==='doing'||recorderStatus==='pause'">
|
|
<view class="con-box">
|
|
<view class="con-box">
|
|
@@ -82,7 +86,7 @@
|
|
</view>
|
|
</view>
|
|
|
|
|
|
<view class="sound-record-wrap" v-if="recorderStatus!=='stop'">
|
|
<view class="sound-record-wrap" v-if="recorderStatus!=='stop'">
|
|
- <view class="top-text">点击开始录音</view>
|
|
|
|
|
|
+ <view class="top-text" v-show="recorderStatus=='start'">点击开始录音</view>
|
|
<image class="btn" :src="btnImg" mode="aspectFill" @click="handleClickBtn" />
|
|
<image class="btn" :src="btnImg" mode="aspectFill" @click="handleClickBtn" />
|
|
<view
|
|
<view
|
|
class="del-btn"
|
|
class="del-btn"
|
|
@@ -95,10 +99,11 @@
|
|
v-if="recorderStatus!=='start'"
|
|
v-if="recorderStatus!=='start'"
|
|
@click="handleEndRecorder"
|
|
@click="handleEndRecorder"
|
|
>完成</view>
|
|
>完成</view>
|
|
|
|
+ <view style="text-align:center;color:#999;margin-top:44rpx" v-if="recorderStatus==='start'">无录音(录音时长超过十分钟自动结束)</view>
|
|
</view>
|
|
</view>
|
|
|
|
|
|
<view class="publish-btn" v-if="recorderStatus==='stop'">
|
|
<view class="publish-btn" v-if="recorderStatus==='stop'">
|
|
- <text @click="showTimeAttention=true">定时发布</text>
|
|
|
|
|
|
+ <text @click="handlePublish('time')">定时发布</text>
|
|
<text @click="handlePublish">立即发布</text>
|
|
<text @click="handlePublish">立即发布</text>
|
|
</view>
|
|
</view>
|
|
|
|
|
|
@@ -145,7 +150,7 @@
|
|
/>
|
|
/>
|
|
</van-popup>
|
|
</van-popup>
|
|
|
|
|
|
- <van-dialog id="van-dialog" />
|
|
|
|
|
|
+ <!-- <van-dialog id="van-dialog" /> -->
|
|
<!-- 发布弹窗 -->
|
|
<!-- 发布弹窗 -->
|
|
<van-dialog
|
|
<van-dialog
|
|
use-slot
|
|
use-slot
|
|
@@ -153,8 +158,9 @@
|
|
confirm-button-text="发布且推送"
|
|
confirm-button-text="发布且推送"
|
|
cancel-button-text="仅发布"
|
|
cancel-button-text="仅发布"
|
|
show-cancel-button
|
|
show-cancel-button
|
|
- @confirm="handleConfirmPublish(false)"
|
|
|
|
- @cancel="handleConfirmPublish(true)"
|
|
|
|
|
|
+ @confirm="handleConfirmPublish(1)"
|
|
|
|
+ @cancel="handleConfirmPublish(0)"
|
|
|
|
+ @close="showPublish=false"
|
|
>
|
|
>
|
|
<view style="padding:40px 20px 20px;text-align:center;position: relative;">
|
|
<view style="padding:40px 20px 20px;text-align:center;position: relative;">
|
|
发布后将推送模板消息和客群,确认发布吗?
|
|
发布后将推送模板消息和客群,确认发布吗?
|
|
@@ -168,22 +174,24 @@
|
|
:show="showTimeAttention"
|
|
:show="showTimeAttention"
|
|
confirm-button-text="知道了"
|
|
confirm-button-text="知道了"
|
|
confirm-button-color="#E3B377"
|
|
confirm-button-color="#E3B377"
|
|
- @confirm="showTimeAttention=true"
|
|
|
|
|
|
+ @confirm="showTime=true"
|
|
|
|
+ @close="showTimeAttention=false"
|
|
>
|
|
>
|
|
<view style="padding:40px 20px 20px;text-align:center;position: relative;">
|
|
<view style="padding:40px 20px 20px;text-align:center;position: relative;">
|
|
设置定时发布后,会在设定的时间发布语音播报并推送模板消息
|
|
设置定时发布后,会在设定的时间发布语音播报并推送模板消息
|
|
- <van-icon name="cross" size="20" style="position: absolute;right:10px;top:10px" color="#666" @click="showTimeAttention=false"/>
|
|
|
|
|
|
+ <van-icon name="cross" size="20" style="position: absolute;right:10px;top:10px" color="#666" @click="showTime=true"/>
|
|
</view>
|
|
</view>
|
|
</van-dialog>
|
|
</van-dialog>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import {apiVoiceSectionList,apiVoiceSendMsg} from '@/api/voice'
|
|
|
|
|
|
+import {apiVoiceSectionList,apiVoiceSendMsg,apiVoiceAdd,apiVoiceEdit,apiVoicePublish,apiVoiceDetail} from '@/api/voice'
|
|
import {baseApiUrl} from '@/utils/config.js'
|
|
import {baseApiUrl} from '@/utils/config.js'
|
|
import CryptoJS from '@/utils/crypto.js'
|
|
import CryptoJS from '@/utils/crypto.js'
|
|
import uniAsync from "@/utils/uni-async.js"; // uni api async 化
|
|
import uniAsync from "@/utils/uni-async.js"; // uni api async 化
|
|
-import {uploadImg} from '@/utils/upload'
|
|
|
|
|
|
+import {uploadImg,commonUploadAudio} from '@/utils/upload'
|
|
|
|
+const moment=require('@/utils/moment-with-locales.min')
|
|
const recorderManager = wx.getRecorderManager();//录音实例
|
|
const recorderManager = wx.getRecorderManager();//录音实例
|
|
let innerAudioContext = uni.createInnerAudioContext();//播放音频实例
|
|
let innerAudioContext = uni.createInnerAudioContext();//播放音频实例
|
|
let TIMER=null//计时器
|
|
let TIMER=null//计时器
|
|
@@ -216,15 +224,18 @@ export default {
|
|
variety_id:'',
|
|
variety_id:'',
|
|
section_id:'',
|
|
section_id:'',
|
|
section_name:'',
|
|
section_name:'',
|
|
- img_url:''
|
|
|
|
|
|
+ img_url:'',//分享时的底图
|
|
},
|
|
},
|
|
|
|
+ voiceId:0,
|
|
|
|
+ voiceUrl:'',//编辑音频地址
|
|
|
|
+ pre_publish_time:'',
|
|
|
|
|
|
recorderStatus:'start',//当前录音状态 start开始 doing正在录音 stop停止录音 pause录音暂停
|
|
recorderStatus:'start',//当前录音状态 start开始 doing正在录音 stop停止录音 pause录音暂停
|
|
time:0,
|
|
time:0,
|
|
isReset:false,//是否点击了重置
|
|
isReset:false,//是否点击了重置
|
|
|
|
|
|
temAudio:{
|
|
temAudio:{
|
|
- url:'',//临时音频地址
|
|
|
|
|
|
+ url:'',//音频地址
|
|
duration:'',//时长
|
|
duration:'',//时长
|
|
size:'',//大小
|
|
size:'',//大小
|
|
curTime:0,//播放时当前播放的时间
|
|
curTime:0,//播放时当前播放的时间
|
|
@@ -242,18 +253,22 @@ export default {
|
|
showTime:false,
|
|
showTime:false,
|
|
showTimeAttention:false,
|
|
showTimeAttention:false,
|
|
selectTime:new Date().getTime(),
|
|
selectTime:new Date().getTime(),
|
|
- minDate:new Date().getTime()+60000,
|
|
|
|
|
|
+ minDate:new Date().getTime()+600000,
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- onLoad(){
|
|
|
|
|
|
+ onLoad(options){
|
|
// 调取用户授权使用麦克风
|
|
// 调取用户授权使用麦克风
|
|
uni.authorize({
|
|
uni.authorize({
|
|
scope: 'scope.record',
|
|
scope: 'scope.record',
|
|
success() {}
|
|
success() {}
|
|
})
|
|
})
|
|
this.listenVoice()
|
|
this.listenVoice()
|
|
-
|
|
|
|
this.getOptionsList()
|
|
this.getOptionsList()
|
|
|
|
+
|
|
|
|
+ if(options.voiceId){
|
|
|
|
+ this.voiceId=Number(options.voiceId)
|
|
|
|
+ this.getVoiceDetail()
|
|
|
|
+ }
|
|
},
|
|
},
|
|
onShow(){
|
|
onShow(){
|
|
innerAudioContext = uni.createInnerAudioContext()
|
|
innerAudioContext = uni.createInnerAudioContext()
|
|
@@ -265,8 +280,31 @@ export default {
|
|
},
|
|
},
|
|
onUnload(){
|
|
onUnload(){
|
|
innerAudioContext.destroy()
|
|
innerAudioContext.destroy()
|
|
|
|
+ clearInterval(TIMER)
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ //语音详情
|
|
|
|
+ async getVoiceDetail(){
|
|
|
|
+ uni.setNavigationBarTitle({ title: '编辑语音' })
|
|
|
|
+ const res=await apiVoiceDetail({broadcast_id:Number(this.voiceId)})
|
|
|
|
+ if(res.code===200){
|
|
|
|
+ this.form.title=res.data.BroadcastName
|
|
|
|
+ this.form.variety_name=res.data.VarietyName
|
|
|
|
+ this.form.variety_id=res.data.VarietyId
|
|
|
|
+ this.form.section_id=res.data.SectionId
|
|
|
|
+ this.form.section_name=res.data.SectionName
|
|
|
|
+ this.voiceUrl=res.data.VoiceUrl
|
|
|
|
+ this.temAudio.url=res.data.VoiceUrl
|
|
|
|
+ this.temAudio.duration=res.data.VoicePlaySeconds
|
|
|
|
+ this.temAudio.size=res.data.VoiceSize
|
|
|
|
+ this.activeId=res.data.SectionId
|
|
|
|
+ this.imgList=res.data.Imgs||[]
|
|
|
|
+ this.pre_publish_time=moment(res.data.PrePublishTime).format('YYYY-MM-DD HH:mm')
|
|
|
|
+ this.selectTime=moment(res.data.PrePublishTime).valueOf()
|
|
|
|
+ this.recorderStatus='stop'
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
//录音事件
|
|
//录音事件
|
|
listenVoice(){
|
|
listenVoice(){
|
|
recorderManager.onStart(()=>{
|
|
recorderManager.onStart(()=>{
|
|
@@ -465,7 +503,7 @@ export default {
|
|
},
|
|
},
|
|
|
|
|
|
// 发布
|
|
// 发布
|
|
- handlePublish(){
|
|
|
|
|
|
+ async handlePublish(type){
|
|
if(!this.form.title||!this.form.variety_id){
|
|
if(!this.form.title||!this.form.variety_id){
|
|
uni.showToast({
|
|
uni.showToast({
|
|
title:'请将内容填写完整',
|
|
title:'请将内容填写完整',
|
|
@@ -474,32 +512,37 @@ export default {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- this.showPublish=true
|
|
|
|
-
|
|
|
|
- // this.$dialog.confirm({
|
|
|
|
- // title:'',
|
|
|
|
- // message: '发布后将推送模板消息和客群,确认发布吗?',
|
|
|
|
- // confirmButtonText:'发布且推送',
|
|
|
|
- // cancelButtonText:'仅发布'
|
|
|
|
- // }).then(()=>{
|
|
|
|
- // //发布且推送
|
|
|
|
- // this.handleConfirmPublish(false)
|
|
|
|
- // }).catch(()=>{
|
|
|
|
- // //仅仅是发布
|
|
|
|
- // this.handleConfirmPublish(true)
|
|
|
|
- // })
|
|
|
|
|
|
+ if(type==='time'){//定时发布
|
|
|
|
+ this.showTimeAttention=true
|
|
|
|
+ }else{
|
|
|
|
+ this.showPublish=true
|
|
|
|
+ }
|
|
},
|
|
},
|
|
- //确认发布 onlyPublished:true仅发布
|
|
|
|
- handleConfirmPublish(onlyPublished){
|
|
|
|
- let formData={
|
|
|
|
|
|
+
|
|
|
|
+ //确认发布 publishType 发布类型: 0-仅发布 1-发布并推送 2-定时发布
|
|
|
|
+ async handleConfirmPublish(publishType){
|
|
|
|
+
|
|
|
|
+ //上传音频
|
|
|
|
+ if(this.temAudio.url!=this.voiceUrl){
|
|
|
|
+ const voiceRes=await commonUploadAudio(this.temAudio.url)
|
|
|
|
+ if(voiceRes.code===200){
|
|
|
|
+ this.temAudio.url=voiceRes.data.audio_url
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //新增、编辑语音
|
|
|
|
+ let params={
|
|
broadcast_name:this.form.title,
|
|
broadcast_name:this.form.title,
|
|
section_id:Number(this.form.section_id),
|
|
section_id:Number(this.form.section_id),
|
|
section_name:this.form.section_name,
|
|
section_name:this.form.section_name,
|
|
variety_id:Number(this.form.variety_id),
|
|
variety_id:Number(this.form.variety_id),
|
|
variety_name:this.form.variety_name,
|
|
variety_name:this.form.variety_name,
|
|
- img_url:this.form.img_url,
|
|
|
|
author_id:Number(this.$store.state.user.userInfo.user_id),
|
|
author_id:Number(this.$store.state.user.userInfo.user_id),
|
|
- author:this.$store.state.user.userInfo.real_name
|
|
|
|
|
|
+ author:this.$store.state.user.userInfo.real_name,
|
|
|
|
+ imgs:this.imgList.join(','),
|
|
|
|
+ voice_seconds:this.temAudio.duration.toString(),
|
|
|
|
+ voice_size:this.temAudio.size.toString(),
|
|
|
|
+ voice_url:this.temAudio.url
|
|
}
|
|
}
|
|
wx.showLoading({
|
|
wx.showLoading({
|
|
title: '发布中...',
|
|
title: '发布中...',
|
|
@@ -508,51 +551,60 @@ export default {
|
|
fail: () => {},
|
|
fail: () => {},
|
|
complete: () => {}
|
|
complete: () => {}
|
|
});
|
|
});
|
|
- uni.uploadFile({
|
|
|
|
- url: baseApiUrl + "/voice/broadcast/add",
|
|
|
|
- filePath: this.temAudio.url,
|
|
|
|
- name: 'file',
|
|
|
|
- header: {
|
|
|
|
- Authorization: this.$store.state.user.token,
|
|
|
|
- },
|
|
|
|
- formData: formData,
|
|
|
|
- success: (result) => {
|
|
|
|
- const { envVersion } = uni.getAccountInfoSync().miniProgram
|
|
|
|
- const res = envVersion === 'release' ? JSON.parse(CryptoJS.Des3Decrypt(result.data)) : JSON.parse(result.data);
|
|
|
|
- console.log(res);
|
|
|
|
- wx.hideLoading();
|
|
|
|
- if(res.code===200){
|
|
|
|
- if(onlyPublished){
|
|
|
|
- uni.showToast({
|
|
|
|
- title:'发布成功',
|
|
|
|
- icon:'success'
|
|
|
|
- })
|
|
|
|
- setTimeout(() => {
|
|
|
|
- uni.$emit('addVoiceSuccess')
|
|
|
|
- uni.navigateBack()
|
|
|
|
- }, 1000);
|
|
|
|
- }else{
|
|
|
|
- //需要推送
|
|
|
|
- this.handleSendMsg(res.data)
|
|
|
|
- }
|
|
|
|
- }else{
|
|
|
|
|
|
+ let addRes=null
|
|
|
|
+ if(this.voiceId!=0){//编辑语音
|
|
|
|
+ params.broadcast_id=this.voiceId
|
|
|
|
+ addRes=await apiVoiceEdit(params)
|
|
|
|
+ }else{
|
|
|
|
+ addRes=await apiVoiceAdd(params)
|
|
|
|
+ }
|
|
|
|
+ if(addRes.code===200){
|
|
|
|
+ let par={
|
|
|
|
+ broadcast_id:addRes.data.BroadcastId,
|
|
|
|
+ }
|
|
|
|
+ if(publishType===2){//定时发布
|
|
|
|
+ par.publish_type=2
|
|
|
|
+ par.pre_publish_time=moment(this.selectTime).format('YYYY-MM-DD HH:mm:ss')
|
|
|
|
+ }else{
|
|
|
|
+ par.publish_type=1
|
|
|
|
+ }
|
|
|
|
+ //发布语音
|
|
|
|
+ const publishRes=await apiVoicePublish(par)
|
|
|
|
+ wx.hideLoading();
|
|
|
|
+ if(publishRes.code===200){
|
|
|
|
+ if(publishType==0){//仅发布
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title:'发布成功',
|
|
|
|
+ icon:'success'
|
|
|
|
+ })
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ uni.$emit('addVoiceSuccess')
|
|
|
|
+ uni.navigateBack()
|
|
|
|
+ }, 1000);
|
|
|
|
+ }else if(publishType==1){//发布并推送
|
|
|
|
+ this.handleSendMsg(addRes.data.BroadcastId)
|
|
|
|
+ }else{////定时发布
|
|
uni.showToast({
|
|
uni.showToast({
|
|
- title:res.msg,
|
|
|
|
- icon:'none'
|
|
|
|
|
|
+ title:'定时发布成功',
|
|
|
|
+ icon:'success'
|
|
})
|
|
})
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ uni.navigateBack()
|
|
|
|
+ }, 1000);
|
|
}
|
|
}
|
|
- },
|
|
|
|
- fail: () => {
|
|
|
|
- console.log('发布失败');
|
|
|
|
|
|
+ }else{
|
|
uni.showToast({
|
|
uni.showToast({
|
|
- title:'发布失败,请稍后重试!',
|
|
|
|
|
|
+ title:publishRes.msg,
|
|
icon:'none'
|
|
icon:'none'
|
|
})
|
|
})
|
|
- },
|
|
|
|
- complete: () => {
|
|
|
|
- wx.hideLoading();
|
|
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ }else{
|
|
|
|
+ wx.hideLoading();
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title:addRes.msg,
|
|
|
|
+ icon:'none'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
},
|
|
},
|
|
|
|
|
|
//推送消息
|
|
//推送消息
|
|
@@ -600,7 +652,8 @@ export default {
|
|
handleConfirmTime(e){
|
|
handleConfirmTime(e){
|
|
this.selectTime=e.detail
|
|
this.selectTime=e.detail
|
|
this.showTime=false
|
|
this.showTime=false
|
|
- }
|
|
|
|
|
|
+ this.handleConfirmPublish(2)
|
|
|
|
+ },
|
|
|
|
|
|
},
|
|
},
|
|
}
|
|
}
|
|
@@ -754,6 +807,12 @@ page{
|
|
margin-right: 10rpx;
|
|
margin-right: 10rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ .pre_publish_time{
|
|
|
|
+ position: absolute;
|
|
|
|
+ bottom: -50rpx;
|
|
|
|
+ left: 0;
|
|
|
|
+ color: #999999;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
.publish-btn{
|
|
.publish-btn{
|
|
@@ -791,6 +850,8 @@ page{
|
|
.upload-img-box{
|
|
.upload-img-box{
|
|
padding: 34rpx 4rpx 34rpx 34rpx;
|
|
padding: 34rpx 4rpx 34rpx 34rpx;
|
|
flex-wrap: wrap;
|
|
flex-wrap: wrap;
|
|
|
|
+ height: 50vh;
|
|
|
|
+ align-content: flex-start;
|
|
.item{
|
|
.item{
|
|
width: 200rpx;
|
|
width: 200rpx;
|
|
height: 200rpx;
|
|
height: 200rpx;
|