Commit a9a7ddaf by 前端

fixed

1 parent ed0df259
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
</template> </template>
<script> <script>
const openUrl = function (url) { const openUrl = function(url) {
const link = document.createElement('a') const link = document.createElement('a')
link.href = url link.href = url
link.target = '_blank' link.target = '_blank'
...@@ -126,7 +126,10 @@ export default { ...@@ -126,7 +126,10 @@ export default {
} }
}, },
props: { props: {
activityList: Array activityList: {
type: Array,
default: []
}
}, },
computed: { computed: {
selectType() { selectType() {
...@@ -152,7 +155,9 @@ export default { ...@@ -152,7 +155,9 @@ export default {
this.dialogVisible = false this.dialogVisible = false
const marketingId = this.selectItem.id ? this.selectItem.id : this.selectItem.equityClassId const marketingId = this.selectItem.id ? this.selectItem.id : this.selectItem.equityClassId
const marketingName = this.selectType == 'card' ? this.selectItem.equityName : this.selectType == 'package' ? this.selectItem.packageName : this.selectType == 'activity' || this.selectType == 'crowdfunding' ? this.selectItem.activityName : this.selectType == 'coupon' ? this.selectItem.couponName : this.selectItem.equityName const marketingName = this.selectType == 'card' ? this.selectItem.equityName : this.selectType == 'package' ? this.selectItem.packageName : this.selectType == 'activity' || this.selectType == 'crowdfunding' ? this.selectItem.activityName : this.selectType == 'coupon' ? this.selectItem.couponName : this.selectItem.equityName
const marketingContent = { ...this.selectItem, selectType: this.selectType } const { equityName, packageName, couponName, activityName, effectivedDay, effectiveType, endTime, startTime, residueAmount, packagePrice, freeDay } = this.selectItem
const otherContent = { equityName, packageName, couponName, activityName, effectivedDay, effectiveType, endTime, startTime, residueAmount, packagePrice, freeDay }
const marketingContent = { ...otherContent, selectType: this.selectType }
const params = {} const params = {}
if (this.selectType == 'crowdfunding') { if (this.selectType == 'crowdfunding') {
params.url = this.selectItem.url params.url = this.selectItem.url
......
...@@ -122,6 +122,24 @@ ...@@ -122,6 +122,24 @@
<img src="../../../assets/welcomeWord/icon-applet.png" alt /> <img src="../../../assets/welcomeWord/icon-applet.png" alt />
<span :title="itm.attContent.title">{{ itm.attContent.title }}</span> <span :title="itm.attContent.title">{{ itm.attContent.title }}</span>
</template> </template>
<template v-else-if="itm.attType == ATT_TYPE.URL">
<div class="welcome-activity-panel">
<div class="welcome-activity-box">
<div class="welcome-activity-icon">
<img :src="itm.attContent.picurl" v-if="itm.attContent.picurl" alt="" />
<img src="../../../assets/welcomeWord/coupon.png" v-else />
</div>
<div class="delete-solid">
<i class="el-icon-delete-solid" @click="close(index)"></i>
</div>
<div class="welcome-activity-desc">
<div class="model-item-title">{{ itm.attContent.title }}</div>
<div class="model-item-content">{{ itm.attContent.desc }}</div>
</div>
</div>
</div>
</template>
<template v-else-if="itm.attType == ATT_TYPE.FILE"> <template v-else-if="itm.attType == ATT_TYPE.FILE">
<div class="welcome-activity-panel"> <div class="welcome-activity-panel">
<div class="welcome-activity-box"> <div class="welcome-activity-box">
...@@ -168,6 +186,7 @@ ...@@ -168,6 +186,7 @@
<activity-model ref="activity" @selectActivity="selectActivity" :activityList="activityList"></activity-model> <activity-model ref="activity" @selectActivity="selectActivity" :activityList="activityList"></activity-model>
<message-model ref="message" @selectItem="selectMessage" :messageList="messageList"></message-model> <message-model ref="message" @selectItem="selectMessage" :messageList="messageList"></message-model>
<material-model ref="material" :materialList="materialList" @handleMaterialConfirm="handleMaterialConfirm"></material-model> <material-model ref="material" :materialList="materialList" @handleMaterialConfirm="handleMaterialConfirm"></material-model>
<link-model @selectLink="selectLink" ref="linkForm" :postLinkList="postLinkList"></link-model>
</div> </div>
</template> </template>
<script> <script>
...@@ -182,11 +201,12 @@ const ATT_TYPE = { ...@@ -182,11 +201,12 @@ const ATT_TYPE = {
ACTIVITY: 7, ACTIVITY: 7,
MATERIAL: 10 MATERIAL: 10
} }
const wordType = ['expression', 'img', 'video', 'nickname', 'activity', 'material', 'message', 'link', 'code'] const wordType = ['expression', 'img', 'video', 'nickname', 'activity', 'material', 'message', 'link', 'code', 'postLink']
import emoji from '../../../utils/emo' import emoji from '../../../utils/emo'
import ActivityModel from './activityModel' import ActivityModel from './activityModel'
import MessageModel from './messageModel' import MessageModel from './messageModel'
import materialModel from './materialModel' import materialModel from './materialModel'
import linkModel from './linkModel'
import Emotion from './emotionWords' import Emotion from './emotionWords'
import wTextarea from './tag-textarea' import wTextarea from './tag-textarea'
import vuedraggable from 'vuedraggable' import vuedraggable from 'vuedraggable'
...@@ -199,22 +219,27 @@ export default { ...@@ -199,22 +219,27 @@ export default {
wTextarea, wTextarea,
MessageModel, MessageModel,
materialModel, materialModel,
vuedraggable vuedraggable,
linkModel
}, },
props: { props: {
btnList: Array, btnList: {
type: Array,
default: []
},
form: String, form: String,
boxHeight: { boxHeight: {
type: Number, type: Number,
default: 400 default: 400
}, },
ATT_TYPE: { ATT_TYPE: {
type: Array, type: Object,
default: ATT_TYPE default: ATT_TYPE
} }
}, },
data() { data() {
return { return {
selectLinkConent: {},
textNum: 0, textNum: 0,
maxNum: 600, maxNum: 600,
myArr: [{ name: 888 }, { name: 888 }], myArr: [{ name: 888 }, { name: 888 }],
...@@ -235,7 +260,6 @@ export default { ...@@ -235,7 +260,6 @@ export default {
}, },
mounted() { mounted() {
document.addEventListener('click', e => { document.addEventListener('click', e => {
console.log(e.target.className)
if (e.target.className != 'emotion-item') { if (e.target.className != 'emotion-item') {
this.emotionStatus = false this.emotionStatus = false
} }
...@@ -243,7 +267,7 @@ export default { ...@@ -243,7 +267,7 @@ export default {
}, },
computed: { computed: {
activityList() { activityList() {
return this.btnList.find(item => item.type == 'activity') ? this.btnList.find(item => item.type == 'activity').funParams : {} return this.btnList.find(item => item.type == 'activity') ? this.btnList.find(item => item.type == 'activity').funParams : []
}, },
messageList() { messageList() {
return this.btnList.find(item => item.type == 'message') || {} return this.btnList.find(item => item.type == 'message') || {}
...@@ -263,6 +287,9 @@ export default { ...@@ -263,6 +287,9 @@ export default {
linkList() { linkList() {
return this.btnList.find(item => item.type == 'link') || {} return this.btnList.find(item => item.type == 'link') || {}
}, },
postLinkList() {
return this.btnList.find(item => item.type == 'postLink') || {}
},
materialItem() { materialItem() {
let attContent let attContent
this.previewList.forEach(item => { this.previewList.forEach(item => {
...@@ -450,18 +477,35 @@ export default { ...@@ -450,18 +477,35 @@ export default {
this.$refs.material.init() this.$refs.material.init()
} else if (name == 'link') { } else if (name == 'link') {
this.$refs.textContent.addCardLink(this.linkList) this.$refs.textContent.addCardLink(this.linkList)
} else if (name == 'postLink') {
this.$refs.linkForm.init()
} }
}, },
close(index) { close(index) {
this.previewList.splice(index, 1) this.previewList.splice(index, 1)
}, },
textInput(val) { conversion(val, status = 'emo') {
val = val let retult = val.replace(/&nbsp;/g, '')
.replace(/&nbsp;/g, '') if (status == 'emo' || status == 'es') {
retult = retult.replace(/\[([\u4E00-\u9FA5]{1,4}|OK|NO|666)\]/g, '')
}
if (status == 'special' || status == 'es') {
retult = retult
.replace(/&amp;/g, '&') .replace(/&amp;/g, '&')
.replace(/&lt;/g, '<') .replace(/&lt;/g, '<')
.replace(/&gt;/g, '>') .replace(/&gt;/g, '>')
this.textNum = val.replace(/(\n|\s)/g, '').length }
return retult
},
reduction(val) {
return val
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
},
textInput(val) {
val = val.replace(/&nbsp;/g, '')
this.textNum = this.conversion(val, 'es').replace(/(\n|\s)/g, '').length
if (this.textNum > this.maxNum) { if (this.textNum > this.maxNum) {
this.textNum = this.maxNum this.textNum = this.maxNum
this.updateList(this.previewList, 1) this.updateList(this.previewList, 1)
...@@ -470,12 +514,12 @@ export default { ...@@ -470,12 +514,12 @@ export default {
const hasText = this.previewList.some(item => item.attType == this.ATT_TYPE.TEXT) const hasText = this.previewList.some(item => item.attType == this.ATT_TYPE.TEXT)
if (hasText) { if (hasText) {
this.$set(this.previewList, 0, { this.$set(this.previewList, 0, {
attContent: val, attContent: this.conversion(val, 'special'),
attType: this.ATT_TYPE.TEXT attType: this.ATT_TYPE.TEXT
}) })
} else { } else {
this.previewList.unshift({ this.previewList.unshift({
attContent: val, attContent: this.conversion(val, 'special'),
attType: this.ATT_TYPE.TEXT attType: this.ATT_TYPE.TEXT
}) })
} }
...@@ -537,31 +581,26 @@ export default { ...@@ -537,31 +581,26 @@ export default {
html = html.replace('\n', '').replace(/<br\/>/g, '') html = html.replace('\n', '').replace(/<br\/>/g, '')
} }
html = html html = html
.replace(/&amp;/g, '&') // .replace(/&lt;/g, '<')
.replace(/&lt;/g, '<') // .replace(/&gt;/g, '>')
.replace(/&gt;/g, '>') // .replace(/&amp;/g, '&')
let textLen = this.previewList[idx].attContent + html let textLen = this.reduction(this.previewList[idx].attContent) + html
if (textLen.replace(/(\n|\s)/g, '').length > this.maxNum) { if (this.conversion(textLen, 'es').replace(/(\n|\s|&nbsp;)/g, '').length > this.maxNum) {
textLen = this.previewList[idx].attContent textLen = this.previewList[idx].attContent
} else { } else {
this.textNum = textLen.replace(/(\n|\s)/g, '').length this.textNum = this.conversion(textLen, 'es').replace(/(\n|\s|&nbsp;)/g, '').length
} }
this.$set(this.previewList, 0, { this.$set(this.previewList, 0, {
attContent: textLen, attContent: textLen,
attType: this.ATT_TYPE.TEXT attType: this.ATT_TYPE.TEXT
}) })
} else { } else {
html = html html = html.replace('\n', '').replace(/<br\/>/g, '')
.replace('\n', '')
.replace(/<br\/>/g, '')
.replace(/&amp;/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
let textLen = html let textLen = html
if (textLen.replace(/(\n|\s)/g, '').length > this.maxNum) { if (this.conversion(textLen, 'es').replace(/(\n|\s|&nbsp;)/g, '').length > this.maxNum) {
textLen = '' textLen = ''
} else { } else {
this.textNum = textLen.replace(/(\n|\s)/g, '').length this.textNum = this.conversion(textLen, 'es').replace(/(\n|\s|&nbsp;)/g, '').length
} }
this.previewList.unshift({ this.previewList.unshift({
attContent: textLen, attContent: textLen,
...@@ -570,6 +609,9 @@ export default { ...@@ -570,6 +609,9 @@ export default {
} }
this.updateList(this.previewList, 1) this.updateList(this.previewList, 1)
}, },
selectLink(val) {
this.previewAddValue(val, 'URL')
},
selectMessage(val) { selectMessage(val) {
const content = val.content const content = val.content
this.updateText(content) this.updateText(content)
...@@ -593,15 +635,15 @@ export default { ...@@ -593,15 +635,15 @@ export default {
if (obj) { if (obj) {
let attContent let attContent
if (status) { if (status) {
attContent = obj.attContent.replace(/(@昵称|#兑换码)/g, '<wise id="1" contenteditable="false">$1</wise>') attContent = obj.attContent.replace(/\[(@昵称|#兑换码)\]/g, '<wise id="1" contenteditable="false">$1</wise>')
} else { } else {
this.textNum = obj.attContent this.textNum = obj.attContent
.replace(/(\n|\s)/g, '') .replace(/(\n|\s)/g, '')
.replace(/\[(@昵称|#兑换码)\]/g, '$1') .replace(/\[(@昵称|#兑换码)\]/g, '$1')
.replace(/\[[\u4E00-\u9FA56]{1,4}]/g, '').length .replace(/\[([\u4E00-\u9FA5]{1,4}|OK|NO|666)\]/g, '').length
attContent = obj.attContent.replace(/\[(@昵称|#兑换码)\]/g, '<wise id="1" contenteditable="false">$1</wise>') attContent = this.reduction(obj.attContent).replace(/\[(@昵称|#兑换码)\]/g, '<wise id="1" contenteditable="false">$1</wise>')
} }
let htm = attContent.replace(/\[[\u4E00-\u9FA56]{1,4}]/gi, function(res) { let htm = attContent.replace(/\[([\u4E00-\u9FA5]{1,4}|OK|NO|666)]/gi, function(res) {
let word = res.replace(/\[|\]/gi, '') let word = res.replace(/\[|\]/gi, '')
const list = emoji.flat(Infinity) const list = emoji.flat(Infinity)
let index = parseInt(list.indexOf(word)) + 1 let index = parseInt(list.indexOf(word)) + 1
...@@ -618,6 +660,11 @@ export default { ...@@ -618,6 +660,11 @@ export default {
setTimeout(() => { setTimeout(() => {
document.querySelector('.w-textarea_input').innerHTML = htm document.querySelector('.w-textarea_input').innerHTML = htm
}, 100) }, 100)
this.previewList.forEach(item => {
if (item.attType == this.ATT_TYPE.TEXT) {
item.attContent = this.conversion(item.attContent, 'special')
}
})
} else { } else {
this.textValue = '' this.textValue = ''
} }
...@@ -625,7 +672,6 @@ export default { ...@@ -625,7 +672,6 @@ export default {
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.welcome-box { .welcome-box {
} }
...@@ -769,12 +815,20 @@ export default { ...@@ -769,12 +815,20 @@ export default {
font-weight: 600; font-weight: 600;
color: #333333; color: #333333;
line-height: 20px; line-height: 20px;
max-width: 150px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
} }
.model-item-content { .model-item-content {
font-size: 12px; font-size: 12px;
font-weight: 400; font-weight: 400;
color: #999999; color: #999999;
line-height: 17px; line-height: 17px;
max-width: 150px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
span { span {
color: #5850ff; color: #5850ff;
} }
...@@ -864,7 +918,6 @@ export default { ...@@ -864,7 +918,6 @@ export default {
padding-right: 10px; padding-right: 10px;
} }
} }
.date-picker { .date-picker {
margin-top: 10px; margin-top: 10px;
font-size: 14px; font-size: 14px;
...@@ -882,7 +935,6 @@ export default { ...@@ -882,7 +935,6 @@ export default {
color: #f56c6c; color: #f56c6c;
margin-right: 4 px; margin-right: 4 px;
} }
.form-tips { .form-tips {
font-size: 12px; font-size: 12px;
color: #999; color: #999;
......
<template>
<div class="square-main">
<GLDialog title="链接配置" :hasFooter="true" :visible.sync="dialogVisible">
<el-form :model="linkForm" :rules="linkRules" ref="linkForm" label-width="100px" class="gl-form-min">
<el-form-item label="活动标题:" size="small" prop="title">
<el-input v-model="linkForm.title" maxlength="128"></el-input>
</el-form-item>
<el-form-item label="活动链接:" size="small" prop="url">
<el-input v-model="linkForm.url" maxlength="128"></el-input>
</el-form-item>
<el-form-item label="活动海报:" size="small">
<div class="el-form-content">
<div class="upload-panel " v-if="linkForm.picurl" :style="`background-image: url('${linkForm.picurl}')`">
<div class="upload-view">
<i class="el-icon-view" @click="handleEnlarge(linkForm.picurl)"></i>
<i class="el-icon-delete" @click="linkForm.picurl = ''"></i>
</div>
</div>
<div class="upload-panel" v-else>
<i class="el-icon-plus upload-icon"></i>
<div class="upload-text">上传</div>
<input type="file" style="opacity: 0" ref="avatar" accept="image/png, image/jpeg, image/jpg" @change="uploadImg" />
</div>
</div>
</el-form-item>
<el-form-item label="备注:" size="small">
<el-input type="textarea" class="link-text" :rows="2" maxlength="512" placeholder="请输入内容" v-model="linkForm.desc"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="dialogVisible = false">取 消</el-button>
<el-button size="small" type="primary" @click="handleCreate">保存</el-button>
</span>
</GLDialog>
<el-dialog class="image-dialog" :visible.sync="dialogVisibleImg" width="50%">
<img :src="dialogSrc" width="100%" />
</el-dialog>
</div>
</template>
<script>
export default {
name: 'linkModel',
data() {
return {
dialogVisible: false,
linkForm: {},
dialogVisibleImg: false,
dialogSrc: '',
linkRules: {
title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
url: [{ required: true, message: '请输入活动链接', trigger: 'blur' }]
}
}
},
props: {
postLinkList: {
type: Object,
default: {}
}
},
methods: {
init() {
this.dialogVisible = true
this.linkForm = {
picurl: ''
}
},
handleEnlarge(src) {
this.dialogVisibleImg = true
this.dialogSrc = src
},
handleCreate() {
this.$refs.linkForm.validate(valid => {
if (valid) {
this.dialogVisible = false
this.$emit('selectLink', this.linkForm)
}
})
},
uploadImg(e) {
const file = e.srcElement.files[0]
const reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = event => {
const imgFile = event.target.result
const arrBase64 = imgFile.split(',')
const splitStr = file.name.split('.')
const fileUrl = splitStr[splitStr.length - 1] + '@' + arrBase64[1]
this.postLinkList.uploadApi({ file: fileUrl }).then(res => {
if (res) {
this.linkForm.picurl = res
}
this.$refs.avatar.value = ''
})
}
}
}
}
</script>
<style lang="scss" scoped>
.upload-panel {
cursor: pointer;
width: 104px;
height: 104px;
background: rgba(0, 0, 0, 0.04);
background-size: 100% 100%;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 4px;
text-align: center;
position: relative;
.upload-view {
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
background: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
transition: opacity 0.3s;
&:hover {
opacity: 1;
}
i {
color: rgba(255, 255, 255, 0.8);
font-size: 16px;
&:first-child {
margin-right: 5px;
}
}
}
input {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
cursor: pointer;
}
.upload-icon {
font-size: 20px;
margin-top: 25px;
color: rgba(0, 0, 0, 0.45);
}
.upload-text {
font-size: 14px;
height: 20px;
line-height: 20px;
color: #666666;
}
}
.link-text {
/deep/ .el-textarea__inner {
background-color: #fff;
width: 432px;
}
}
</style>
...@@ -208,15 +208,20 @@ export default { ...@@ -208,15 +208,20 @@ export default {
// 插入链接 // 插入链接
if (this.isInsert) { if (this.isInsert) {
this.savedRange.insertNode(node) this.savedRange.insertNode(node)
this.savedRange.insertNode(document.createElement('span'))
} else { } else {
document.querySelector('.w-textarea_input').appendChild(node) document.querySelector('.w-textarea_input').appendChild(node)
}
if (navigator.userAgent.indexOf('Chrome') != -1) {
this.savedRange.insertNode(document.createElement('span')) this.savedRange.insertNode(document.createElement('span'))
} }
this.isInsert = false this.isInsert = false
// 更新双向绑定数据 // 更新双向绑定数据
let target = this.$refs.wTextareaContent let target = this.$refs.wTextareaContent
if (navigator.userAgent.indexOf('Firefox') > 0 || navigator.userAgent.indexOf('QQBrowser') > 0) {
this.updateData(target.innerHTML + '&nbsp;')
} else {
this.updateData(target.innerHTML) this.updateData(target.innerHTML)
}
let htm = target.innerHTML let htm = target.innerHTML
this.subText(htm) this.subText(htm)
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!