Commit 1fcb1399 by xinla

修改海报问题

1 parent e4ec0185
...@@ -4,7 +4,7 @@ const serviceCategory = window.CONFIG.services.wecom + '/poster' ...@@ -4,7 +4,7 @@ const serviceCategory = window.CONFIG.services.wecom + '/poster'
/** /**
* 查询海报列表 * 查询海报列表
* @param {*} params * @param {*} params
*/ */
export function getList(params) { export function getList(params) {
return request({ url: service + '/list', params }) return request({ url: service + '/list', params })
...@@ -16,7 +16,7 @@ export function getList(params) { ...@@ -16,7 +16,7 @@ export function getList(params) {
*/ */
export function updatePoster(data) { export function updatePoster(data) {
console.log('poster change:', JSON.stringify(data)) console.log('poster change:', JSON.stringify(data))
return request({ url: serviceCategory + '/update', method: 'put', data }) return request({ url: serviceCategory + '/update', method: 'put', data })
} }
/** /**
...@@ -24,7 +24,6 @@ export function updatePoster(data) { ...@@ -24,7 +24,6 @@ export function updatePoster(data) {
* @param {*} data * @param {*} data
*/ */
export function addPoster(data) { export function addPoster(data) {
console.log('poster add:', JSON.stringify(data))
return request({ url: serviceCategory + '/insert', method: 'post', data }) return request({ url: serviceCategory + '/insert', method: 'post', data })
} }
......
...@@ -4,8 +4,6 @@ import MaPage from '@/views/material/components/MaPage' ...@@ -4,8 +4,6 @@ import MaPage from '@/views/material/components/MaPage'
import SelectMaterial from '@/components/SelectMaterial' import SelectMaterial from '@/components/SelectMaterial'
import { fabric } from 'fabric' import { fabric } from 'fabric'
import qrCodeImage from '@/assets/poster/img/qrCodeImage.png'
export default { export default {
name: 'Poster', name: 'Poster',
components: { components: {
...@@ -22,18 +20,7 @@ export default { ...@@ -22,18 +20,7 @@ export default {
edit: false // 编辑弹出显示隐藏 edit: false // 编辑弹出显示隐藏
}, },
rangeErrorMsg: '', rangeErrorMsg: '',
form: { form: {},
title: '', // 海报名称
categoryId: '', // 所属分类
type: '1', // 海报类型
// content: '', // 内容
// count: '', // 虚拟次数
// sort: '', // 海报排序
// jump: [], // 跳转页面
delFlag: 0, // 是否启用
backgroundImgPath: '', // 图片url
mediaId: '' // 图片id
},
rules: { rules: {
title: { title: {
required: true, required: true,
...@@ -94,7 +81,14 @@ export default { ...@@ -94,7 +81,14 @@ export default {
this.posterSubassemblyList = data.posterSubassemblyList || [] this.posterSubassemblyList = data.posterSubassemblyList || []
} else { } else {
// 新增,清除编辑的数据 // 新增,清除编辑的数据
this.form = {} this.form = {
title: '', // 海报名称
categoryId: '', // 所属分类
type: '1', // 海报类型
delFlag: 0, // 是否启用
backgroundImgPath: '', // 图片url
mediaId: '' // 图片id
}
this.posterSubassemblyList = [] this.posterSubassemblyList = []
} }
this.dialog.edit = true this.dialog.edit = true
...@@ -264,6 +258,7 @@ export default { ...@@ -264,6 +258,7 @@ export default {
}, },
addObj(type, obj) { addObj(type, obj) {
let options = { let options = {
fill: '#333333',
left: 100, left: 100,
top: 100, top: 100,
borderDashArray: [3, 3], borderDashArray: [3, 3],
...@@ -281,10 +276,10 @@ export default { ...@@ -281,10 +276,10 @@ export default {
case 'image': case 'image':
case 'qrcode': case 'qrcode':
new fabric.Image.fromURL(type == 'image' ? obj : qrCodeImage, (img) => { new fabric.Image.fromURL(type == 'image' ? obj : 'http://demo.linkwechat.cn/lib/qrCode.png', (img) => {
img.set(options) img.set(options)
img.scale(this.canvas.width / img.width / 2) // img.scale(this.canvas.width / img.width / 2)
// img.scaleToWidth(200) img.scaleToWidth(200)
this.canvas.add(img).setActiveObject(img) this.canvas.add(img).setActiveObject(img)
}) })
break break
...@@ -342,8 +337,10 @@ export default { ...@@ -342,8 +337,10 @@ export default {
let vo = null let vo = null
let i = 0 let i = 0
let len = list.length let len = list.length
console.log(form.posterJSON)
while (i < len) { while (i < len) {
vo = list[i] vo = list[i]
debugger
let isText = vo.type == 'i-text' let isText = vo.type == 'i-text'
...@@ -359,8 +356,8 @@ export default { ...@@ -359,8 +356,8 @@ export default {
fontTextAlign: align, // 1 2 3 left center right fontTextAlign: align, // 1 2 3 left center right
left: parseInt(vo.left), // - (isText ? 0 : vo.width >> 1), // 显示偏移了 left: parseInt(vo.left), // - (isText ? 0 : vo.width >> 1), // 显示偏移了
top: parseInt(vo.top), // - (isText ? 0 : vo.height >> 1), top: parseInt(vo.top), // - (isText ? 0 : vo.height >> 1),
width: parseInt(vo.width + (isText ? vo.fontSize / 2 : 0)), width: parseInt(vo.width * vo.scaleX + (isText ? vo.fontSize / 2 : 0)),
height: parseInt(vo.height), height: parseInt(vo.height * vo.scaleY),
imgPath: vo.src || '', imgPath: vo.src || '',
posterId: null, posterId: null,
type: vo.customType, // 1 固定文本 2 固定图片 3 二维码图片 type: vo.customType, // 1 固定文本 2 固定图片 3 二维码图片
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!