Commit 58d4243e by 匡雅琴

调整marketing包中上传文件文件名多个点问题

1 parent 436082f0
......@@ -147,17 +147,15 @@ export default {
}
},
mounted() {
this.eventBus.$emit('update', this.previewList)
// this.updateList(this.previewList)
// obj.init('video')
},
methods: {
handleImgChange(e, targetItem) {
var reader = new FileReader()
var file = e.srcElement.files[0]
// 默认1MB
const limitSize = targetItem.limitSize || 1
const isLt = file.size / 1024 / 1024 < limitSize
......@@ -170,12 +168,10 @@ export default {
var image = new Image()
image.src = e.target.result
image.onload = () => {
const imgFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
const base64 = file.name.split('.')[file.name.split('.').length - 1] + '@' + imgFile.split(',')[1]
this.$apis.common.pictureUpload({ file: base64 }).then(res => {
if (res) {
this.previewList.push({
attType: ATT_TYPE.IMAGE,
attContent: res
......@@ -198,10 +194,9 @@ export default {
reader.readAsDataURL(file)
reader.onload = e => {
const imgFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
const base64 = file.name.split('.')[file.name.split('.').length - 1] + '@' + imgFile.split(',')[1]
this.$apis.common.pictureUpload({ file: base64 }).then(res => {
if (res) {
this.previewList.push({
attType: ATT_TYPE.VEDIO,
attContent: res
......@@ -213,7 +208,7 @@ export default {
handleImg(e) {
var reader = new FileReader()
var file = e.srcElement.files[0]
// 默认1MB
const limitSize = 10
const isLt = file.size / 1024 / 1024 < limitSize
......@@ -227,11 +222,10 @@ export default {
image.src = e.target.result
image.onload = () => {
const imgFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
const base64 = file.name.split('.')[file.name.split('.').length - 1] + '@' + imgFile.split(',')[1]
this.$set(this.appletForm, 'picUrl', 'dfasdfasfa')
this.$apis.common.pictureUpload({ file: base64 }).then(res => {
if (res) {
this.$set(this.appletForm, 'picUrl', res)
}
})
......@@ -239,7 +233,6 @@ export default {
}
},
switchDailog(funName) {
if (funName == 'link') {
this.dialogTitle = '添加网页消息'
} else if (funName == 'applet') {
......@@ -253,7 +246,6 @@ export default {
case '添加网页消息':
this.$refs.linkForm.validate(valid => {
if (valid) {
this.previewList.push({
attType: ATT_TYPE.URL,
attContent: this.linkForm
......@@ -264,16 +256,13 @@ export default {
// this.linkForm = {}
// this.$refs.linkForm.clearValidate()
} else {
return false
}
})
break
case '添加小程序':
this.$refs.appletForm.validate(valid => {
if (valid) {
this.previewList.push({
attType: ATT_TYPE.MINIPROGRAM,
attContent: this.appletForm
......@@ -283,25 +272,21 @@ export default {
// this.appletForm = {}
// this.$refs.appletForm.clearValidate()
} else {
return false
}
})
break
default:
}
},
close(index) {
// this.previewList
this.previewList.splice(index, 1)
this.eventBus.$emit('update', this.previewList)
},
textInput(val) {
const hasText = this.previewList.some(item => item.attType == 1)
if (hasText) {
this.$set(this.previewList, 0, {
attContent: val,
......@@ -313,7 +298,6 @@ export default {
attType: ATT_TYPE.TEXT
})
}
},
closeDialog() {
if (this.dialogVisible) {
......@@ -342,7 +326,7 @@ export default {
<style lang="scss" scoped>
.welcome-box {
display: inline-block !important;
display: inline-block !important;
// padding-top: 20px;
// margin-left: 87px;
}
......
......@@ -449,7 +449,7 @@ export default {
reader.readAsDataURL(file)
reader.onload = e => {
const imgFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
const base64 = file.name.split('.')[file.name.split('.').length - 1] + '@' + imgFile.split(',')[1]
this.$apis.common.pictureUpload({ file: base64 }).then(res => {
if (res) {
// console.log(res)
......
......@@ -43,7 +43,7 @@ export default {
this.$emit('focus')
}
// 上传图片
this.editor.config.customUploadImg = function (resultFiles, insertImgFn) {
this.editor.config.customUploadImg = function(resultFiles, insertImgFn) {
var file = resultFiles[0]
var reader = new FileReader()
// 默认1MB
......@@ -56,7 +56,7 @@ export default {
reader.readAsDataURL(file)
reader.onload = e => {
const imgFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
const base64 = file.name.split('.')[file.name.split('.').length - 1] + '@' + imgFile.split(',')[1]
_this.$apis.common.pictureUpload({ file: base64 }).then(res => {
if (res) {
// console.log(res)
......@@ -69,7 +69,7 @@ export default {
}
}
// 上传视频
this.editor.config.customUploadVideo = function (resultFiles, insertVideoFn) {
this.editor.config.customUploadVideo = function(resultFiles, insertVideoFn) {
var file = resultFiles[0]
var reader = new FileReader()
// 默认1MB
......@@ -82,7 +82,7 @@ export default {
reader.readAsDataURL(file)
reader.onload = e => {
const videoFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + videoFile.split(',')[1]
const base64 = file.name.split('.')[file.name.split('.').length - 1] + '@' + videoFile.split(',')[1]
_this.$apis.common.pictureUpload({ file: base64 }).then(res => {
if (res) {
// console.log(res)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!