Commit 6d4f1127 by liuchuanming

Merge branch 'dev_poster' of https://gitee.com/LinkWeChat/link-wechat into dev_poster

2 parents c7076b16 461c925e
...@@ -60,12 +60,6 @@ export default { ...@@ -60,12 +60,6 @@ export default {
},500) },500)
}); });
} }
this.editorInstance.loadImageFromURL('https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2980445260,41238050&fm=26&gp=0.jpg', 'imagePoster').then(async result => {
console.log('old : ' + result.oldWidth + ', ' + result.oldHeight);
console.log('new : ' + result.newWidth + ', ' + result.newHeight);
// await this.addImage('https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2980445260,41238050&fm=26&gp=0.jpg')
// await this.addText('aloha');
});
// hack UI // hack UI
this.editorInstance.events.addText = [] this.editorInstance.events.addText = []
...@@ -85,6 +79,14 @@ export default { ...@@ -85,6 +79,14 @@ export default {
this.editorInstance = null; this.editorInstance = null;
}, },
methods: { methods: {
getBackgroundUrl(bacUrl) {
this.editorInstance.loadImageFromURL(bacUrl, 'imagePoster').then(async result => {
console.log('old : ' + result.oldWidth + ', ' + result.oldHeight);
console.log('new : ' + result.newWidth + ', ' + result.newHeight);
// await this.addImage('https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2980445260,41238050&fm=26&gp=0.jpg')
// await this.addText('aloha');
});
},
initBtn () { initBtn () {
this.activeObjectId = null; this.activeObjectId = null;
......
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
removePoster, removePoster,
} from '@/api/material/poster.js' } from '@/api/material/poster.js'
import MaPage from '@/views/material/components/MaPage' import MaPage from '@/views/material/components/MaPage'
import SelectMaterial from '@/components/SelectMaterial'
// Load Style Code // Load Style Code
import "tui-image-editor/dist/tui-image-editor.css"; import "tui-image-editor/dist/tui-image-editor.css";
import "tui-color-picker/dist/tui-color-picker.css"; import "tui-color-picker/dist/tui-color-picker.css";
...@@ -26,12 +26,14 @@ export default { ...@@ -26,12 +26,14 @@ export default {
name: 'Poster', name: 'Poster',
components: { components: {
MaPage, MaPage,
SelectMaterial,
"tui-image-editor": PosterPage "tui-image-editor": PosterPage
}, },
data () { data () {
return { return {
imgList: {}, imgList: {},
imgData: [], imgData: [],
dialogVisibleSelectMaterial: false,
dialog: { dialog: {
preview: false, // 预览弹出显示隐藏 preview: false, // 预览弹出显示隐藏
edit: false // 编辑弹出显示隐藏 edit: false // 编辑弹出显示隐藏
...@@ -39,6 +41,8 @@ export default { ...@@ -39,6 +41,8 @@ export default {
posterEdit: { posterEdit: {
step: 0 step: 0
}, },
materialSelected: '', // 图片url
rangeErrorMsg: '',
posterForm: { posterForm: {
title: '', // 海报名称 title: '', // 海报名称
categoryId: '', // 所属分类 categoryId: '', // 所属分类
...@@ -47,7 +51,8 @@ export default { ...@@ -47,7 +51,8 @@ export default {
// count: '', // 虚拟次数 // count: '', // 虚拟次数
// sort: '', // 海报排序 // sort: '', // 海报排序
// jump: [], // 跳转页面 // jump: [], // 跳转页面
delFlag: 0 // 是否启用 delFlag: 0, // 是否启用
mediaId: '', // 图片id
}, },
rules: { rules: {
title: { title: {
...@@ -171,8 +176,9 @@ export default { ...@@ -171,8 +176,9 @@ export default {
title: data.title, title: data.title,
categoryId: data.categoryId, categoryId: data.categoryId,
type: data.type, type: data.type,
delFlag: data.delFlag delFlag: data.delFlag,
} }
this.materialSelected = data.backgroundImgPath
this.posterEdit.step = 0 this.posterEdit.step = 0
this.dialog.edit = true this.dialog.edit = true
} catch (error) { } catch (error) {
...@@ -265,9 +271,16 @@ export default { ...@@ -265,9 +271,16 @@ export default {
imageEditor.stopDrawingMode(); imageEditor.stopDrawingMode();
}, },
toNextStep () { toNextStep () {
if (this.materialSelected === '') {
this.rangeErrorMsg = '请选择背景图片'
return
} else {
this.rangeErrorMsg = ''
}
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (valid) { if (valid) {
this.posterEdit.step = 1 this.posterEdit.step = 1
this.$refs.tuiImageEditor.getBackgroundUrl(this.materialSelected)
} else { } else {
return false; return false;
} }
...@@ -367,6 +380,16 @@ export default { ...@@ -367,6 +380,16 @@ export default {
this.imgData.push(data) this.imgData.push(data)
// console.log(this.imgData) // console.log(this.imgData)
}, },
// 选择素材确认按钮
submitSelectMaterial(text, image, file) {
this.posterForm.mediaId = image.id
this.materialSelected = image.materialUrl
this.dialogVisibleSelectMaterial = false
},
removeMaterial() {
this.posterForm.mediaId = ''
this.materialSelected = ''
},
// //
async save() { async save() {
let list =[]; let list =[];
...@@ -439,13 +462,15 @@ export default { ...@@ -439,13 +462,15 @@ export default {
if (posterForm.id) { if (posterForm.id) {
// 编辑海报 // 编辑海报
res = await updatePoster(Object.assign({}, { res = await updatePoster(Object.assign({}, {
backgroundImgPath: 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2980445260,41238050&fm=26&gp=0.jpg', // backgroundImgPath: 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2980445260,41238050&fm=26&gp=0.jpg',
posterSubassemblyList: [] backgroundImgPath: this.materialSelected,
posterSubassemblyList: posterSubList
}, this.posterForm)) }, this.posterForm))
} else { } else {
// 新建海报 // 新建海报
res = await addPoster(Object.assign({}, { res = await addPoster(Object.assign({}, {
backgroundImgPath: 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2980445260,41238050&fm=26&gp=0.jpg', // backgroundImgPath: 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2980445260,41238050&fm=26&gp=0.jpg',
backgroundImgPath: this.materialSelected,
posterSubassemblyList: posterSubList posterSubassemblyList: posterSubList
}, this.posterForm)) }, this.posterForm))
} }
...@@ -460,6 +485,7 @@ export default { ...@@ -460,6 +485,7 @@ export default {
</script> </script>
<template> <template>
<div>
<MaPage <MaPage
ref="page" ref="page"
type="5" type="5"
...@@ -592,6 +618,22 @@ export default { ...@@ -592,6 +618,22 @@ export default {
<el-radio :label="0">否</el-radio> <el-radio :label="0">否</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="背景图片" :required="true" :error="rangeErrorMsg">
<div v-if="materialSelected !== ''">
<el-image
style="width: 100px; height: 100px; cursor: pointer;border-radius: 6px;"
:src="materialSelected"
fit="fit"
>
</el-image>
<i class="el-icon-error" @click="removeMaterial"></i>
</div>
<el-button
icon="el-icon-plus"
size="mini"
@click="dialogVisibleSelectMaterial = true"
>添加图片</el-button>
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="success" @click="toNextStep" <el-button type="success" @click="toNextStep"
>前往设计海报</el-button >前往设计海报</el-button
...@@ -604,7 +646,7 @@ export default { ...@@ -604,7 +646,7 @@ export default {
<tui-image-editor <tui-image-editor
ref="tuiImageEditor" ref="tuiImageEditor"
:include-ui="useDefaultUI" :include-ui="useDefaultUI"
:options="options" :options="options"
@getImageData="getImgData" @getImageData="getImgData"
></tui-image-editor> ></tui-image-editor>
</div> </div>
...@@ -648,6 +690,15 @@ export default { ...@@ -648,6 +690,15 @@ export default {
</div> </div>
</el-dialog> </el-dialog>
</MaPage> </MaPage>
<!-- 选择素材弹窗 -->
<SelectMaterial
:visible.sync="dialogVisibleSelectMaterial"
type="1"
:showArr="[1]"
@success="submitSelectMaterial"
>
</SelectMaterial>
</div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!