|
@@ -1,604 +0,0 @@
|
|
|
-// import { Toast } from "mint-ui";
|
|
|
- import {adverMaterielServer} from '@/services'
|
|
|
- var qiniu = require('qiniu-js');
|
|
|
-export default {
|
|
|
- data() {
|
|
|
- return {
|
|
|
- callback: null,
|
|
|
- // cropperFlag:true,
|
|
|
- isDisable: false,
|
|
|
- }
|
|
|
- },
|
|
|
- methods: {
|
|
|
- // preview 预览图片
|
|
|
- preview(type) {
|
|
|
- var test = window.open('about:blank')
|
|
|
- test.document.body.innerHTML = '图片生成中..'
|
|
|
- if (type === 'blob') {
|
|
|
- this.$refs.cropper.getCropBlob((data) => {
|
|
|
- test.location.href = window.URL.createObjectURL(data)
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.$refs.cropper.getCropData((data) => {
|
|
|
- test.location.href = data
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- uploadImgFunc(e, option, form, callback) {
|
|
|
- // this.currentOption
|
|
|
- // 对象合并
|
|
|
- Object.assign(this.currentOption, option);
|
|
|
- this.currentOption.form = form;
|
|
|
- this.callback = callback;
|
|
|
- // this.currentOption.Item = obj;
|
|
|
- //上传图片
|
|
|
- var file = e.target.files[0];
|
|
|
- const isLt2M = file.size / 1024 / 1024 < this.limit;
|
|
|
-
|
|
|
- if (!/\.(gif|jpg|jpeg|png|bmp|GIF|JPG|PNG)$/.test(e.target.value)) {
|
|
|
- this.$message.warning('图片类型必须是.gif,jpeg,jpg,png,bmp中的一种');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- if (!isLt2M) {
|
|
|
- // this.$message.error('上传图片大小不能超过 ' + this.limit + 'MB!');
|
|
|
- this.$message.warning('上传图片大小不能超过 ' + this.limit + 'MB!');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- this.currentOption.fileName = file.name;
|
|
|
- var reader = new FileReader()
|
|
|
- reader.onload = (e) => {
|
|
|
- let data
|
|
|
- if (typeof e.target.result === 'object') {
|
|
|
- // 把Array Buffer转化为blob 如果是base64不需要
|
|
|
- data = window.URL.createObjectURL(new Blob([e.target.result]))
|
|
|
- } else {
|
|
|
- data = e.target.result
|
|
|
- }
|
|
|
- this.currentOption.img = data;
|
|
|
- this.showCropper = true;
|
|
|
- setTimeout(()=>{
|
|
|
- cropperFlag = true; //重置状态,使得可以重新上传
|
|
|
- },1000)
|
|
|
- }
|
|
|
- // 转化为base64
|
|
|
- // reader.readAsDataURL(file)
|
|
|
- // 转化为blob
|
|
|
- reader.readAsArrayBuffer(file)
|
|
|
- },
|
|
|
- uploadImgObj(e, option, form, obj, flag) {
|
|
|
- // this.currentOption
|
|
|
- // 对象合并
|
|
|
- if (e.target.dataset.common == 1) {
|
|
|
- this.commonFlag = true;
|
|
|
- }
|
|
|
- console.log("1%%%$$^*&*", this.currentOption, option)
|
|
|
- Object.assign(this.currentOption, option);
|
|
|
- this.currentOption.form = form;
|
|
|
- this.currentOption.Item = obj;
|
|
|
- console.log("2%%%$$^*&*", this.currentOption, option)
|
|
|
- //上传图片
|
|
|
- var file = e.target.files[0];
|
|
|
- const fileSize = file.size / 1024 / 1024;
|
|
|
- if (this.gifLimit && fileSize > this.gifLimit && !file.type.includes('mp4')) {
|
|
|
- this.$message.warning('上传gif图片大小不能超过 ' + this.gifLimit + 'MB!');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- const isLt2M = file.size / 1024 / 1024 < this.limit;
|
|
|
- if(obj == 'uploadSwipVideo'){
|
|
|
- if (!/\.(MP4|mp4)$/.test(e.target.value)) {
|
|
|
- this.$message.warning('文件片类型必须是MP4');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- }
|
|
|
- else if (obj == 'includeVideo') { //可以上传视频
|
|
|
- if (!/\.(gif|jpg|jpeg|png|bmp|GIF|JPG|PNG|MP4|mp4)$/.test(e.target.value)) {
|
|
|
- this.$message.warning('文件片类型必须是.gif,jpeg,jpg,png,bmp,MP4中的一种');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- if (!/\.(gif|jpg|jpeg|png|bmp|GIF|JPG|PNG)$/.test(e.target.value)) {
|
|
|
- this.$message.warning('图片类型必须是.gif,jpeg,jpg,png,bmp中的一种');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- }
|
|
|
- if (!isLt2M && !file.type.includes('gif') && !file.type.includes('mp4')) {
|
|
|
- // this.$message.error('上传图片大小不能超过 ' + this.limit + 'MB!');
|
|
|
- this.$message.warning('上传图片大小不能超过 ' + this.limit + 'MB!');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- if (fileSize > 1000 && file.type.includes('mp4')) {
|
|
|
- // this.$message.error('上传图片大小不能超过 ' + this.limit + 'MB!');
|
|
|
- this.$message.warning('上传视频大小不能超过 ' + 10 + 'MB!');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- if ((file.type === 'image/gif' || obj == 'includeVideo' || obj == 'isOriginal' || this.operateKey ==
|
|
|
- 'videoCoverUrl' || flag == 'isOriginUpload') && this.uploadMaterielFile && typeof this.uploadMaterielFile ==
|
|
|
- "function") {
|
|
|
- console.log('gif图,进入非剪裁')
|
|
|
- var item = {};
|
|
|
- item.file = file;
|
|
|
- this.uploadMaterielFile(item, form, file.type.includes('mp4') ? 'video' : 'gif'); //正常上传图片
|
|
|
- setTimeout(()=>{
|
|
|
- cropperFlag = true; //重置状态,使得可以重新上传
|
|
|
- },1000)
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- console.log('进入非剪裁')
|
|
|
- var item = {};
|
|
|
- item.file = file;
|
|
|
- this.uploadMaterielFile(item, form, file.type.includes('mp4') ? 'video' : 'gif'); //正常上传图片
|
|
|
- setTimeout(()=>{
|
|
|
- cropperFlag = true; //重置状态,使得可以重新上传
|
|
|
- },1000)
|
|
|
- return false;
|
|
|
- }
|
|
|
- // console.log('进入剪裁')
|
|
|
- // this.currentOption.fileName = file.name;
|
|
|
- // var reader = new FileReader()
|
|
|
- // reader.onload = (e) => {
|
|
|
- // let data
|
|
|
- // if (typeof e.target.result === 'object') {
|
|
|
- // // 把Array Buffer转化为blob 如果是base64不需要
|
|
|
- // data = window.URL.createObjectURL(new Blob([e.target.result]))
|
|
|
- // } else {
|
|
|
- // data = e.target.result
|
|
|
- // }
|
|
|
- // this.currentOption.img = data;
|
|
|
- // this.showCropper = true;
|
|
|
- // }
|
|
|
- // reader.readAsArrayBuffer(file)
|
|
|
- },
|
|
|
- uploadImg(e, option, form, staticLimit, gifLimit, obj) {
|
|
|
-
|
|
|
- var file = e.target.files[0];
|
|
|
- if (form === 'tdForm' && e.target.value.includes('gif')) {
|
|
|
- this.$message.warning('图片类型不能为gif格式');
|
|
|
- return false
|
|
|
- }
|
|
|
- if (form === 'tdForm' && file.size / 1024 / 1024 > 2) {
|
|
|
- this.$message.warning('图片大小不能超过2M!');
|
|
|
- return false
|
|
|
- }
|
|
|
- console.log("***uploadImg***");
|
|
|
- var _limit = staticLimit ? staticLimit : this.limit;
|
|
|
- var _giflimit = gifLimit ? gifLimit : 5; //Gif 图片的限制是5MB,产品确认的
|
|
|
- const isLt2M = file.size / 1024 / 1024 < _limit;
|
|
|
- const isLtGIF = file.size / 1024 / 1024 < _giflimit;
|
|
|
- if (!/\.(gif|jpg|jpeg|png|bmp|GIF|JPG|PNG|pdf)$/.test(e.target.value)) {
|
|
|
- this.$message.warning('图片类型必须是.gif,jpeg,jpg,png,bmp中的一种');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- if (file.type === 'image/gif') {
|
|
|
- if (!isLtGIF) {
|
|
|
- this.$message.warning('上传图片大小不能超过' + _giflimit + 'MB!');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- } else if (!isLt2M) {
|
|
|
- this.$message.warning('上传图片大小不能超过 ' + _limit + 'MB!');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- Object.assign(this.currentOption, option);
|
|
|
-
|
|
|
- // 如果是gif图片则调用正常上传不启用裁剪过程
|
|
|
- if ((file.type === 'image/gif' || obj == 'isOriginal') && this.uploadMaterielFile && typeof this.uploadMaterielFile == "function") {
|
|
|
- var item = {};
|
|
|
- item.file = file;
|
|
|
- this.uploadMaterielFile(item, form); //正常上传图片
|
|
|
- setTimeout(()=>{
|
|
|
- cropperFlag = true; //重置状态,使得可以重新上传
|
|
|
- },1000)
|
|
|
- return false;
|
|
|
- }
|
|
|
- // Object.assign(this.currentOption, option);
|
|
|
- this.currentOption.form = form;
|
|
|
- this.currentOption.fileName = file.name;
|
|
|
- var reader = new FileReader()
|
|
|
- reader.onload = (e) => {
|
|
|
- let data
|
|
|
- if (typeof e.target.result === 'object') {
|
|
|
- // 把Array Buffer转化为blob 如果是base64不需要
|
|
|
- data = window.URL.createObjectURL(new Blob([e.target.result]))
|
|
|
- } else {
|
|
|
- data = e.target.result
|
|
|
- }
|
|
|
- this.currentOption.img = data;
|
|
|
- this.showCropper = true;
|
|
|
- setTimeout(()=>{
|
|
|
- cropperFlag = true; //重置状态,使得可以重新上传
|
|
|
- },1000)
|
|
|
- }
|
|
|
- // 转化为base64
|
|
|
- // reader.readAsDataURL(file)
|
|
|
- // 转化为blob
|
|
|
- reader.readAsArrayBuffer(file)
|
|
|
- },
|
|
|
- uploadImgXMB(e, option, form, limit, obj) {
|
|
|
- console.log("***uploadImg***");
|
|
|
- var file = e.target.files[0];
|
|
|
- var _limit = limit || 2;
|
|
|
- const isLt2M = file.size / 1024 / 1024 < _limit;
|
|
|
- const isLtGIF = file.size / 1024 / 1024 < _limit; //Gif 图片的限制是5MB,产品确认的
|
|
|
- if (!/\.(gif|jpg|jpeg|png|bmp|GIF|JPG|PNG)$/.test(e.target.value)) {
|
|
|
- this.$message.warning('图片类型必须是.gif,jpeg,jpg,png,bmp中的一种');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- if (file.type === 'image/gif') {
|
|
|
- if (!isLtGIF) {
|
|
|
- this.$message.warning('上传图片大小不能超过' + _limit + 'MB!');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- } else if (!isLt2M) {
|
|
|
- this.$message.warning('上传图片大小不能超过 ' + _limit + 'MB!');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- Object.assign(this.currentOption, option);
|
|
|
- // 如果是gif图片则调用正常上传不启用裁剪过程
|
|
|
- if ((file.type === 'image/gif' || obj == 'isOriginal') && this.uploadMaterielFile && typeof this.uploadMaterielFile == "function") {
|
|
|
- var item = {};
|
|
|
- item.file = file;
|
|
|
- this.uploadMaterielFile(item, form); //正常上传图片
|
|
|
- setTimeout(()=>{
|
|
|
- cropperFlag = true; //重置状态,使得可以重新上传
|
|
|
- },1000)
|
|
|
- return false;
|
|
|
- }
|
|
|
- // Object.assign(this.currentOption, option);
|
|
|
- this.currentOption.form = form;
|
|
|
- this.currentOption.fileName = file.name;
|
|
|
- var reader = new FileReader()
|
|
|
- reader.onload = (e) => {
|
|
|
- let data
|
|
|
- if (typeof e.target.result === 'object') {
|
|
|
- // 把Array Buffer转化为blob 如果是base64不需要
|
|
|
- data = window.URL.createObjectURL(new Blob([e.target.result]))
|
|
|
- } else {
|
|
|
- data = e.target.result
|
|
|
- }
|
|
|
- this.currentOption.img = data;
|
|
|
- this.showCropper = true;
|
|
|
- setTimeout(()=>{
|
|
|
- cropperFlag = true; //重置状态,使得可以重新上传
|
|
|
- },1000)
|
|
|
- }
|
|
|
- // 转化为base64
|
|
|
- // reader.readAsDataURL(file)
|
|
|
- // 转化为blob
|
|
|
- reader.readAsArrayBuffer(file)
|
|
|
- },
|
|
|
- // 上传原图:obj 是 包含图片的对象,property 是obj 对象里面图片地址对应的属性key
|
|
|
- async uploadObjImageFile(e, form, obj, property) {
|
|
|
- var self = this;
|
|
|
- var file = e.target.files[0];
|
|
|
- const isLt2M = file.size / 1024 / 1024 < this.limit;
|
|
|
- const isLtVideo = file.size / 1024 / 1024 < this.videolimit; //视频 的限制是5MB
|
|
|
- const isLtGIF = file.size / 1024 / 1024 < this.gifLimit; //Gif 图片的限制是5MB,产品确认的
|
|
|
- if (!/\.(gif|jpg|jpeg|png|GIF|JPG|PNG|mp4)$/.test(e.target.value)) {
|
|
|
- this.$message.warning('类型必须是.gif,jpeg,jpg,png,mp4中的一种');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- if (file.type === 'video/mp4') {
|
|
|
- if (!isLtVideo) {
|
|
|
- this.$message.warning('上传文件大小不能超过' + this.videolimit + 'MB!');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- }
|
|
|
- else{
|
|
|
- if (file.type === 'image/gif') {
|
|
|
- if (!isLtGIF) {
|
|
|
- this.$message.warning('上传图片大小不能超过' + this.gifLimit + 'MB!');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- } else if (!isLt2M) {
|
|
|
- this.$message.warning('上传图片大小不能超过 ' + this.limit + 'MB!');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false
|
|
|
- }
|
|
|
- }
|
|
|
- if (file.name.length > 100) {
|
|
|
- this.$message.warning('文件名过长,请不要超过100个字符');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false;
|
|
|
- }
|
|
|
- self.$store.state.loading = true;
|
|
|
-
|
|
|
- var formData = new FormData();
|
|
|
- formData.append("file", file);
|
|
|
- let res = await requestConfig('aliyunOpenapiUploadOss', formData, false);
|
|
|
- if (res.success) {
|
|
|
- var imgUrl = res.single || ''
|
|
|
- obj[property] = imgUrl;
|
|
|
- }
|
|
|
- self.$store.state.loading = false;
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- },
|
|
|
- cropperUpload(type, callback) {
|
|
|
- var file = "";
|
|
|
- var self = this;
|
|
|
- this.isDisable = true;
|
|
|
- console.log("cropperFlag1:", cropperFlag);
|
|
|
- if (cropperFlag == false) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- cropperFlag = false;
|
|
|
- console.log("cropperFlag2:", cropperFlag);
|
|
|
- // if(this.cropperFlag == true){
|
|
|
- // return this.$message.warning("请等待上传完毕,不要重复点击");
|
|
|
- // }
|
|
|
- // this.cropperFlag = true;
|
|
|
- try {
|
|
|
- if (type === 'blob') {
|
|
|
- self.$refs.cropper.getCropBlob((data) => {
|
|
|
- file = window.URL.createObjectURL(data)
|
|
|
- // console.log("***uploadProjectFile***", type, file)
|
|
|
- if (!self.callback) {
|
|
|
- self.callback = callback;
|
|
|
- }
|
|
|
-
|
|
|
- typeof self.callback == "function" && self.callback(file); // 执行回调函数
|
|
|
- // cropperFlag = true;
|
|
|
- self.isDisable = false;
|
|
|
- })
|
|
|
- } else {
|
|
|
- self.$refs.cropper.getCropData((data) => {
|
|
|
- file = data
|
|
|
- // console.log("***uploadProjectFile***", type, file)
|
|
|
- // this.uploadProjectFile(file)
|
|
|
- if (!self.callback) {
|
|
|
- self.callback = callback;
|
|
|
- }
|
|
|
-
|
|
|
- typeof self.callback == "function" && self.callback(file); // 执行回调函数
|
|
|
- // cropperFlag = true;
|
|
|
- self.isDisable = false;
|
|
|
- })
|
|
|
- }
|
|
|
- } catch (e) {
|
|
|
- this.$message.error(e.message);
|
|
|
- cropperFlag = true;
|
|
|
- }
|
|
|
- },
|
|
|
- // 关闭弹层
|
|
|
- cropoerCancel(option, callback) {
|
|
|
- var videoForm = document.getElementById(option.form); //获取表单对象
|
|
|
- videoForm.reset(); // 重置表单
|
|
|
- this.showCropper = false;
|
|
|
- option.img = "";
|
|
|
- callback && typeof callback == "function" && callback();
|
|
|
- },
|
|
|
- rotateLeft() {
|
|
|
- this.$refs.cropper.rotateLeft()
|
|
|
- },
|
|
|
- rotateRight() {
|
|
|
- this.$refs.cropper.rotateRight()
|
|
|
- },
|
|
|
- next(res) {},
|
|
|
- // 上传七牛云发生错误
|
|
|
- error(res) {
|
|
|
- this.$message.error('上传失败' + res.message);
|
|
|
- },
|
|
|
- async uploadMaterielFile(item, form, type) {
|
|
|
- if (item.file.name.length > 100) {
|
|
|
- this.$message.warning('文件名过长,请不要超过100个字符');
|
|
|
- var videoForm = document.getElementById(form); //获取表单对象
|
|
|
- videoForm && videoForm.reset(); // 重置表单
|
|
|
- return false;
|
|
|
- }
|
|
|
- var self = this;
|
|
|
- console.log(item);
|
|
|
-
|
|
|
- var formData = new FormData();
|
|
|
- formData.append("file", item.file);
|
|
|
- let imgUrl = ''
|
|
|
- let res = await requestConfig('aliyunOpenapiUploadOss', formData, false);
|
|
|
- if (res.success) {
|
|
|
- imgUrl = res.single || ''
|
|
|
- if (self.currentOption.Item === 'iconItem') {
|
|
|
- self.area.areaTitleObj.iconStyle['background-image'] = 'url(' + imgUrl + ')'
|
|
|
- } else if (self.currentOption.Item === 'uploadSwipImg') {//轮播组件的图片
|
|
|
- self.area.imagesList[self.moduleCurrentEditIndex].imageUrl = imgUrl
|
|
|
- } else if (self.currentOption.Item === 'uploadSwipVideo') {//轮播组件的视频
|
|
|
- self.area.imagesList[self.moduleCurrentEditIndex].videoUrl = imgUrl
|
|
|
- } else if (self.currentOption.Item === 'uploadSwipImg4') {
|
|
|
- self.area.moduleLeftList[self.moduleCurrentEditIndex].moduleStyle.imageUrl = imgUrl
|
|
|
- } else if (self.currentOption.Item === 'uploadDoubleRightImg') {
|
|
|
- self.area.moduleRightList[self.moduleCurrentEditIndex].moduleStyle.imageUrl = imgUrl
|
|
|
- } else if (self.currentOption.Item === 'uploadMsgIconImg') {//统一标题icon图片
|
|
|
- self.area.unifyTitleObj.iconStyle['background-image'] = 'url(' + imgUrl + ')'
|
|
|
- } else if (self.currentOption.Item === 'uploadProjectIconImg') { //项目位置
|
|
|
- self.area.projectSet.iconStyle['background-image'] = 'url(' + imgUrl + ')'
|
|
|
- } else if(self.currentOption.Item==='uploadTitleIconImg'){
|
|
|
- self.area.areaTitleObj.iconStyle['background-image'] = 'url('+imgUrl+')'
|
|
|
- } else if (self.currentOption.Item === 'moduleTitleObjIconItem') {
|
|
|
- self.moduleView.titleObj.iconStyle['background-image'] = 'url(' + imgUrl + ')'
|
|
|
- } else if (self.currentOption.Item === 'moduleTitleObjunIconItem') {
|
|
|
- self.moduleView.titleObj.iconStyle['unbackground-image'] = 'url(' + imgUrl + ')'
|
|
|
- } else if (self.currentOption.Item === 'moduleIconItem') {
|
|
|
- self.moduleView.iconStyle['background-image'] = 'url(' + imgUrl + ')'
|
|
|
- } else if (self.currentOption.Item === 'moduleunIconItem') {
|
|
|
- self.moduleView.iconStyle['unbackground-image'] = 'url(' + imgUrl + ')'
|
|
|
- } else if (self.currentOption.Item === 'afterImageUrl') {
|
|
|
- self.moduleView.moduleStyle.afterImageUrl = imgUrl;
|
|
|
- } else if (self.currentOption.Item === 'overImageUrl') {
|
|
|
- self.moduleView.moduleStyle.overImageUrl = imgUrl;
|
|
|
- } else if (self.currentOption.Item === 'areaIconImageUrl') {//关闭icon配置
|
|
|
- self.area.iconStyle['background-image'] = 'url('+imgUrl+')'
|
|
|
- } else if(self.currentOption.Item==='areaImageUrl'){//区域背景图
|
|
|
- self.area.areaStyle['background-image'] = 'url('+imgUrl+')'
|
|
|
- } else if (self.currentOption.Item === 'includeVideo') {
|
|
|
- if (type == 'video') {
|
|
|
- self.moduleView.moduleStyle.videoUrl = imgUrl
|
|
|
- } else {
|
|
|
- self.moduleView.moduleStyle.imageUrl = imgUrl
|
|
|
- }
|
|
|
- } else {
|
|
|
- console.log(self.moduleView.moduleStyle)
|
|
|
- self.moduleView.moduleStyle.imageUrl = imgUrl
|
|
|
- }
|
|
|
- self.$message.success('上传成功');
|
|
|
- }
|
|
|
- if (this.area.diyArea) {
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$store.state.loading = true;
|
|
|
- setTimeout(() => {
|
|
|
- let img = document.createElement("img");
|
|
|
- img.src = imgUrl;
|
|
|
- img.onload = () => {
|
|
|
- console.log("图片加载完成----", self.uploadImgs, "当前索引---", self.moduleCurrentEditIndex);
|
|
|
- if (self.uploadImgs.includes(self.moduleCurrentEditIndex)) {//当前图片已经上传
|
|
|
- self.usedIMGWidth -= self.getNum(self.area.moduleList[self.moduleCurrentEditIndex].moduleStyle.width);
|
|
|
- self.uploadImgs.splice(self.uploadImgs.indexOf(self.moduleCurrentEditIndex), 1);
|
|
|
- }
|
|
|
- let imageCount = self.uploadImgs.length;
|
|
|
- console.log("图片加载完成", imageCount);
|
|
|
- if (imageCount < self.area.moduleList.length) {
|
|
|
- if (self.area.moduleList.length === 1) {
|
|
|
- if (img.width <= 50) {
|
|
|
- this.area.moduleList[0].moduleStyle.width = 50 + 'px';
|
|
|
- this.area.moduleList[0].moduleStyle.height = (parseInt(img.height * 50 / img.width)) + 'px'
|
|
|
- this.area.areaStyle.height = (parseInt(img.height * 50 / img.width)) + 'px';
|
|
|
- } else if (img.width > 50 && img.width <= 750) {
|
|
|
- this.area.moduleList[0].moduleStyle.width = parseInt(img.width) + 'px';
|
|
|
- this.area.moduleList[0].moduleStyle.height = parseInt(img.height) + 'px';
|
|
|
- this.area.areaStyle.height = parseInt(img.height) + 'px';
|
|
|
- } else {
|
|
|
- this.area.moduleList[0].moduleStyle.width = 750 + 'px';
|
|
|
- this.area.moduleList[0].moduleStyle.height = parseInt(img.height * 750 / img.width) + 'px';
|
|
|
- this.area.areaStyle.height = parseInt(img.height * 750 / img.width) + 'px';
|
|
|
- }
|
|
|
- } else {
|
|
|
- let currentMaxWidth = 750 - self.usedIMGWidth - (self.area.moduleList.length - imageCount - 1) * 50;
|
|
|
- console.log("上传图片的参数-22", "当前剩余宽度: " + currentMaxWidth + " 宽度: " + img.width, " 高度: " + img.height, " 索引: " + this.moduleCurrentEditIndex);
|
|
|
- if (img.width >= currentMaxWidth) {
|
|
|
- self.area.moduleList[self.moduleCurrentEditIndex].moduleStyle.width = currentMaxWidth + 'px';
|
|
|
- self.usedIMGWidth += currentMaxWidth;
|
|
|
- self.area.moduleList[self.moduleCurrentEditIndex].moduleStyle.height = (parseInt(img.height * currentMaxWidth / img.width)) + 'px';
|
|
|
- } else {
|
|
|
- if (img.width <= 50) {
|
|
|
- self.area.moduleList[self.moduleCurrentEditIndex].moduleStyle.width = 50 + 'px';
|
|
|
- self.usedIMGWidth += 50;
|
|
|
- console.log("宽度不够最大的,小于50,-一个", self.area.moduleList[self.moduleCurrentEditIndex].moduleStyle);
|
|
|
- self.area.moduleList[self.moduleCurrentEditIndex].moduleStyle.height = (parseInt(img.height * 50 / img.width)) + 'px';
|
|
|
- } else {
|
|
|
- self.area.moduleList[self.moduleCurrentEditIndex].moduleStyle.width = parseInt(img.width) + 'px';
|
|
|
- self.usedIMGWidth += parseInt(img.width);
|
|
|
- console.log("宽度不够最大的,大于50,-", self.area.moduleList[self.moduleCurrentEditIndex].moduleStyle);
|
|
|
- self.area.moduleList[self.moduleCurrentEditIndex].moduleStyle.height = parseInt(img.height) + 'px';
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- self.area.areaStyle.height = "auto";
|
|
|
- }
|
|
|
- }
|
|
|
- this.$store.state.loading = false;
|
|
|
- if (!self.uploadImgs.includes(self.moduleCurrentEditIndex)) { //已上传中没有
|
|
|
- self.uploadImgs.push(self.moduleCurrentEditIndex); //存储已经上传的图片位置
|
|
|
- }
|
|
|
- self.area.uploadImgPositions = self.uploadImgs;
|
|
|
- self.area.usedIMGWidth = self.usedIMGWidth;
|
|
|
-
|
|
|
- }
|
|
|
- }, 1000)
|
|
|
- })
|
|
|
- }
|
|
|
- var videoForm = document.getElementById(this.currentOption.form); //获取表单对象
|
|
|
- videoForm && videoForm.reset();// 重置表单
|
|
|
- },
|
|
|
- async uploadFile(file) {
|
|
|
- let data = {
|
|
|
- "base64Str": file,
|
|
|
- };
|
|
|
- let result = await adverMaterielServer.uploadBase64(data);
|
|
|
- console.log(result, 'gggggg')
|
|
|
- if (result && result.data.success) {
|
|
|
- if (this.currentOption.Item === 'iconItem') {
|
|
|
- this.area.areaTitleObj.iconStyle['background-image'] = 'url(' + result.data.single.filePath + ')'
|
|
|
- } else if (this.currentOption.Item === 'uploadSwipImg') {
|
|
|
- this.area.imagesList[this.moduleCurrentEditIndex].imageUrl = result.data.single.filePath
|
|
|
- } else if (this.currentOption.Item === 'uploadSwipImg4') {
|
|
|
- this.area.moduleLeftList[this.moduleCurrentEditIndex].moduleStyle.imageUrl = result.data.single.filePath
|
|
|
- } else if (this.currentOption.Item === 'uploadDoubleRightImg') {
|
|
|
- this.area.moduleRightList[this.moduleCurrentEditIndex].moduleStyle.imageUrl = result.data.single.filePath
|
|
|
- } else if (this.currentOption.Item === 'uploadMsgIconImg') {//统一标题icon图片
|
|
|
- this.area.unifyTitleObj.iconStyle['background-image'] = 'url(' + result.data.single.filePath + ')'
|
|
|
- } else if (this.currentOption.Item === 'uploadProjectIconImg') {
|
|
|
- this.area.projectSet.iconStyle['background-image'] = 'url(' + result.data.single.filePath + ')'
|
|
|
- } else if (this.currentOption.Item === 'uploadTitleIconImg') {
|
|
|
- this.area.areaTitleObj.iconStyle['background-image'] = 'url(' + result.data.single.filePath + ')'
|
|
|
- } else if (this.currentOption.Item === 'moduleTitleObjIconItem') {
|
|
|
- this.moduleView.titleObj.iconStyle['background-image'] = 'url(' + result.data.single.filePath + ')'
|
|
|
- } else if (this.currentOption.Item === 'moduleTitleObjunIconItem') {
|
|
|
- this.moduleView.titleObj.iconStyle['unbackground-image'] = 'url(' + result.data.single.filePath + ')'
|
|
|
- } else if (this.currentOption.Item === 'moduleIconItem') {
|
|
|
- this.moduleView.iconStyle['background-image'] = 'url(' + result.data.single.filePath + ')'
|
|
|
- } else if (this.currentOption.Item === 'moduleunIconItem') {
|
|
|
- this.moduleView.iconStyle['unbackground-image'] = 'url(' + result.data.single.filePath + ')'
|
|
|
- } else if (this.currentOption.Item === 'uploadModuleImage1Form') {
|
|
|
- this.moduleView.imageStyle.imageUrl = result.data.single.filePath
|
|
|
- } else if (this.currentOption.Item === 'afterImageUrl') {
|
|
|
- this.moduleView.moduleStyle.afterImageUrl = result.data.single.filePath
|
|
|
- } else if (this.currentOption.Item === 'overImageUrl') {
|
|
|
- this.moduleView.moduleStyle.overImageUrl = result.data.single.filePath
|
|
|
- } else {
|
|
|
- console.log(this.moduleView)
|
|
|
- this.moduleView.moduleStyle.imageUrl = result.data.single.filePath
|
|
|
- }
|
|
|
- if (this.area.diyArea) {
|
|
|
- let img = document.createElement("img");
|
|
|
- img.src = result.data.single.filePath;
|
|
|
- img.onload = () => {
|
|
|
- this.area.areaStyle.height = (parseInt(img.height * 750 / img.width)) + 'px'
|
|
|
- this.area.moduleList[0].moduleStyle.height = (parseInt(img.height * 750 / img.width)) + 'px'
|
|
|
- }
|
|
|
- }
|
|
|
- this.showCropper = false;
|
|
|
- var videoForm = document.getElementById(this.currentOption.form); //获取表单对象
|
|
|
- videoForm && videoForm.reset();// 重置表单
|
|
|
- } else {
|
|
|
- this.$message.error('图片上传失败');
|
|
|
- this.showCropper = false;
|
|
|
- this.currentOption.img = "";
|
|
|
- var videoForm = document.getElementById(this.currentOption.form); //获取表单对象
|
|
|
- videoForm && videoForm.reset();// 重置表单
|
|
|
- }
|
|
|
- cropperFlag = true; //重置状态,使得可以重新上传
|
|
|
- },
|
|
|
- }
|
|
|
-}
|