Commit 199af93c by chenwq

音乐上传

1 parent f634a69e
......@@ -33,6 +33,17 @@ const uploadImgApi = params => {
})
}
const uploadMusicApi = params => {
params.method = 'scrm.api.carlife.common.uploadMusic'
return http({
url: 'rop-scrm-carlife/router',
method: 'POST',
data: params,
sign: true,
noSignAttr: ['file']
})
}
const uploadVideoApi = params => {
params.method = `${defaultPath}common.uploadVideo`
return http({
......@@ -128,4 +139,4 @@ const getStaffFollowerListApi = params => {
})
}
export default { getMerchantGoodsListApi, getGoodsListApi, uploadImgApi, uploadVideoApi, getMerchantList, getSimpleMerchantList, getZoneListApi, getClassifyListApi, pictureUpload, querylabeltree, getCrowdTreeListApi, getStaffFollowerListApi }
export default { getMerchantGoodsListApi, getGoodsListApi, uploadImgApi, uploadMusicApi, uploadVideoApi, getMerchantList, getSimpleMerchantList, getZoneListApi, getClassifyListApi, pictureUpload, querylabeltree, getCrowdTreeListApi, getStaffFollowerListApi }
......@@ -78,10 +78,16 @@
<glsx-combi-form class="edit-form-container" ref="serviceEditFormRef" :isEdit="true" :isBlock="false" :formRef="editChildRef" :formObj="editForm" :formData="serviceEditFormData" :formRules="editRule"></glsx-combi-form>
</div>
</template>
<template slot="activityMusic">
<el-upload class="upload-demo" action="" accept="audio/mp3, audio/m4a" :http-request="handleMusicUpload" :on-change="handleMusicChange" :on-remove="handleRemove" :before-remove="beforeRemove" :limit="1" :on-exceed="handleExceed" :file-list="fileList">
<template slot="activityMusic" slot-scope="scope">
<el-upload v-show="!editForm[scope.scope.name]" class="upload-demo" action="" accept="audio/mp3, audio/m4a" :show-file-list="false" :http-request="handleMusicUpload" :on-change="e => handleMusicChange(e, scope.scope)" :limit="1" :on-exceed="handleExceed">
<el-button class="el-icon-plus" size="small" type="default">背景音乐</el-button>
</el-upload>
<div v-if="editForm[scope.scope.name]" class="flex">
<audio controls>
<source :src="editForm[scope.scope.name]" type="audio/mpeg" />
</audio>
<el-button class="describe-delete" icon="el-icon-delete" type="text" @click="handleMusicDelete(scope.scope)"></el-button>
</div>
</template>
<template slot="fictitious">
<div class="fictitious" id="fictitious">
......@@ -469,7 +475,8 @@ export default {
label: '音乐文件',
name: 'activityMusic',
tips: '活动页背景音乐',
// addHtml: 'activityMusic'
limitSize: 2,
addHtml: 'activityMusic'
},
{
label: '预估销量',
......@@ -729,12 +736,39 @@ export default {
},
// 音乐
handleMusicUpload() {
console.log('???')
handleMusicUpload() { },
musicUpload(e, targetItem) {
var reader = new FileReader()
var file = e.raw
// 默认1MB
const limitSize = targetItem.limitSize
const isLt = file.size / 1024 / 1024 < limitSize
const isType = ['audio/mp3', 'audio/m4a']
if (!isType) {
this.$message.error('上传文件不是jpg、jpeg或png的格式!')
return true
}
if (!isLt) {
this.$message.error('上传的文件大小不能超过' + limitSize + 'MB!')
return true
}
reader.readAsDataURL(file)
reader.onload = e => {
const imgFile = e.target.result
const base64 = file.name.split('.')[file.name.split('.').length - 1] + '@' + imgFile.split(',')[1]
this.$apis.common.uploadMusicApi({ file: base64 }).then(res => {
this.$set(this.editForm, targetItem.name, res)
})
}
},
handleMusicChange(file, targetItem) {
this.musicUpload(file, targetItem)
},
handleMusicChange(file) {
console.log(file)
handleMusicDelete(targetItem) {
this.$set(this.editForm, targetItem.name, '')
},
// 表单设置
......@@ -758,7 +792,6 @@ export default {
getInfo() {
this.$apis.seckillActivity.getActivityDetailApi({ id: this.routeInfo.id }).then(res => {
var info = res
console.log(res)
this.editForm = this.$common.utils.deepClone(res)
this.activityInfo = info
this.editForm.activityTime = [info.startTime, info.endTime]
......@@ -790,7 +823,6 @@ export default {
if (!this.formDescribeList.length) {
this.formDescribeList = [{ value: '' }]
}
console.log(this.editForm)
this.$nextTick(() => {
this.editStatus = false
})
......@@ -868,7 +900,6 @@ export default {
addOrUpdate() {
var params = this.getCouponInfoParams()
// console.log(params)
this.$apis.seckillActivity.addOrUpdateActivityApi(params).then(res => {
this.$message({
......@@ -882,7 +913,6 @@ export default {
},
handleConfirm() {
// console.log(this.editForm)
this.validateRules()
var flag = true
if (this.nameToValSpecsList && this.nameToValSpecsList.length > 0) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!