Commit 8b161c01 by 李伟康

提交代码

1 parent 9b93a247
...@@ -60,9 +60,12 @@ const actions = { ...@@ -60,9 +60,12 @@ const actions = {
util.setSessionId(data.sessionId) util.setSessionId(data.sessionId)
dispatch('registerHttp', data.sessionId) dispatch('registerHttp', data.sessionId)
state.showWindow = true state.showWindow = true
let pageQuery = decodeURIComponent(window.location.href.split('/split/')[1]) let query = window.location.href.split('/split/')[1]
let pageQuery = query ? decodeURIComponent(query) : ''
pageQuery = pageQuery.replace(/\|/g, '&') pageQuery = pageQuery.replace(/\|/g, '&')
window.location.replace(`${redirectUrl}#/${route}?${pageQuery}`) let url = `${redirectUrl}#/${route}`
if (pageQuery) url += `?${pageQuery}`
window.location.replace(url)
} else { } else {
Notify(message) Notify(message)
} }
...@@ -121,9 +124,12 @@ const actions = { ...@@ -121,9 +124,12 @@ const actions = {
util.setSessionId(sessionId) util.setSessionId(sessionId)
dispatch('registerHttp', sessionId) dispatch('registerHttp', sessionId)
state.showWindow = true state.showWindow = true
let pageQuery = decodeURIComponent(window.location.href.split('/split/')[1]) let query = window.location.href.split('/split/')[1]
let pageQuery = query ? decodeURIComponent(query) : ''
pageQuery = pageQuery.replace(/\|/g, '&') pageQuery = pageQuery.replace(/\|/g, '&')
window.location.replace(`${redirectUrl}#/${route}?${pageQuery}`) let url = `${redirectUrl}#/${route}`
if (pageQuery) url += `?${pageQuery}`
window.location.replace(url)
} else { } else {
Notify(message) Notify(message)
} }
......
...@@ -14,7 +14,7 @@ class Draw { ...@@ -14,7 +14,7 @@ class Draw {
_this_.ctx.width = width _this_.ctx.width = width
_this_.ctx.height = height _this_.ctx.height = height
this[_ctx_].clearRect(0, 0, width, height) this[_ctx_].clearRect(0, 0, width, height)
this[_ctx_].fillStyle = canvasObject.backgroundColor || 'transparent' || '#fff' this[_ctx_].fillStyle = canvasObject.backgroundColor || 'rgba(255, 255, 255, 0)' || '#fff'
this[_ctx_].fillRect(0, 0, width, height) this[_ctx_].fillRect(0, 0, width, height)
this[_ctx_].save() this[_ctx_].save()
} }
...@@ -76,7 +76,8 @@ class Draw { ...@@ -76,7 +76,8 @@ class Draw {
x, x,
y, y,
} = textParams } = textParams
let text_width = this.getTextWidth(text) let text_width = this.getTextWidth(text),
font = this[_ctx_].font.split('px')[1]
textAlign = textAlign || 'left' textAlign = textAlign || 'left'
textBaseline = textBaseline || 'normal' textBaseline = textBaseline || 'normal'
opacity = typeof opacity === 'number' ? opacity : 1 opacity = typeof opacity === 'number' ? opacity : 1
...@@ -89,7 +90,7 @@ class Draw { ...@@ -89,7 +90,7 @@ class Draw {
y = this.toRpx(y) y = this.toRpx(y)
this[_ctx_].beginPath() this[_ctx_].beginPath()
this[_ctx_].globalAlpha = opacity this[_ctx_].globalAlpha = opacity
this[_ctx_].font = `${fontSize}px sans-serif` this[_ctx_].font = `${fontWeight || 400} ${fontSize}px${font}`
this[_ctx_].fillStyle = color || '#000' this[_ctx_].fillStyle = color || '#000'
this[_ctx_].strokeStyle = color || '#000' this[_ctx_].strokeStyle = color || '#000'
this[_ctx_].textBaseline = textBaseline this[_ctx_].textBaseline = textBaseline
...@@ -108,7 +109,6 @@ class Draw { ...@@ -108,7 +109,6 @@ class Draw {
if (text.length * fontSize + fontX > width && !maxWidth) maxLength = parseInt((width - fontX) / fontSize) - 1 if (text.length * fontSize + fontX > width && !maxWidth) maxLength = parseInt((width - fontX) / fontSize) - 1
newText = maxLength !== -1 ? `${text.substring(0, maxLength)}...` : text newText = maxLength !== -1 ? `${text.substring(0, maxLength)}...` : text
this[_ctx_].fillText(newText, x, y, maxWidth) this[_ctx_].fillText(newText, x, y, maxWidth)
if (checkFontWeight(fontWeight)) this[_ctx_].strokeText(newText, x, y, maxWidth)
if (checkTextDecoration(textDecoration)) { if (checkTextDecoration(textDecoration)) {
this.drawDecoration({ this.drawDecoration({
textDecoration, textDecoration,
...@@ -152,7 +152,6 @@ class Draw { ...@@ -152,7 +152,6 @@ class Draw {
} }
let textHeight = y + index * (lineHeight || fontSize) let textHeight = y + index * (lineHeight || fontSize)
this[_ctx_].fillText(e, x, textHeight, maxWidth) this[_ctx_].fillText(e, x, textHeight, maxWidth)
if (checkFontWeight(fontWeight)) this[_ctx_].strokeText(e, x, textHeight, maxWidth)
if (checkTextDecoration(textDecoration)) { if (checkTextDecoration(textDecoration)) {
this.drawDecoration({ this.drawDecoration({
'y': textHeight, 'y': textHeight,
...@@ -291,9 +290,6 @@ class Draw { ...@@ -291,9 +290,6 @@ class Draw {
this[_ctx_].lineTo(lineX + this.getTextWidth(newText), lineY) this[_ctx_].lineTo(lineX + this.getTextWidth(newText), lineY)
} }
} }
const checkFontWeight = (fontWeight = '0') => {
return (fontWeight && (typeof fontWeight === 'string' || typeof fontWeight === 'number') && (fontWeight == 'bold' || fontWeight >= 700))
}
const checkTextDecoration = textDecoration => { const checkTextDecoration = textDecoration => {
return (textDecoration && (textDecoration === 'underline' || textDecoration === 'overline' || textDecoration === 'line-through')) return (textDecoration && (textDecoration === 'underline' || textDecoration === 'overline' || textDecoration === 'line-through'))
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
/> />
</template> </template>
</van-image> </van-image>
<div class="tips text-center">长按保存图片</div>
</div> </div>
</template> </template>
...@@ -37,18 +38,16 @@ export default { ...@@ -37,18 +38,16 @@ export default {
methods: { methods: {
drawOrderImg () { drawOrderImg () {
let labelList = ['姓名:', '手机:', '车牌号:', '品牌车型:', '商品名称:', '支付时间:', '支付定金'] let labelList = ['姓名:', '手机:', '车牌号:', '品牌车型:', '商品名称:', '支付时间:', '支付定金']
let valueList = ['恒河猴', let valueList = ['恒河猴',
'18888888888', '18888888888',
'粤B12345', '粤B12345',
// '阿尔法・罗密欧阿尔法・罗密欧166 2004款 2.0T Spark 苟利国家生死岂因祸福避趋之', '奥迪奥迪Q5L Sportback2022款 40 TFSI RS套件燃速型',
'奥迪 奥迪A6L 2022款 55 TFSI quattro 尊享动感型',
'氛围灯', '2022年8月3日 17:43:48', '199元'] '氛围灯', '2022年8月3日 17:43:48', '199元']
let textYList = [109, 141, 173, 205, 261, 293, 352] let textYList = [109, 141, 173, 205, 261, 293, 352]
this.ctx = document.getElementById('canvas') this.ctx = document.getElementById('canvas')
const draw = new Draw(this, { const draw = new Draw(this, {
width: 343, width: 343,
height: 422, height: 422,
pixelRatio: 1
}) })
draw.drawImages({ draw.drawImages({
...@@ -82,12 +81,13 @@ export default { ...@@ -82,12 +81,13 @@ export default {
if (e === '品牌车型:') { if (e === '品牌车型:') {
value.lineNum = 2 value.lineNum = 2
value.lineHeight = 24 value.lineHeight = 24
value.lineTextLength = 20
} }
if (e === '支付定金') { if (e === '支付定金') {
label.color = '#282829' label.color = '#282829'
value.color = '#3162E6' value.color = '#3162E6'
value.fontWeight = '600' value.fontWeight = '600'
value.fontSize = 18
value.y = textYList[index] + 5
} }
draw.drawText(label) draw.drawText(label)
draw.drawText(value) draw.drawText(value)
...@@ -113,6 +113,7 @@ export default { ...@@ -113,6 +113,7 @@ export default {
flex-direction: column; flex-direction: column;
font-size: 14px; font-size: 14px;
color: #656566; color: #656566;
user-select: none;
.title { .title {
font-size: 18px; font-size: 18px;
font-weight: 500; font-weight: 500;
...@@ -136,5 +137,14 @@ export default { ...@@ -136,5 +137,14 @@ export default {
height: 422px; height: 422px;
object-fit: contain; object-fit: contain;
} }
.tips {
width: 219px;
height: 28px;
background: #f6f6f6;
border-radius: 4px;
font-size: 14px;
color: #656566;
margin: 14px auto 0;
}
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!