Commit 58d4243e by 匡雅琴

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

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