Commit aec43fdf by 李伟康

提交代码

1 parent d3b2e7f8
...@@ -45,4 +45,15 @@ export default { ...@@ -45,4 +45,15 @@ export default {
data data
}) })
}, },
/** 订单详情 */
getOrderList (activityId) {
let data = {
activityId,
method: 'scrm.api.shopmall.weapp.crowdFunding.order.list'
}
return window.$HTTP({
url,
data
})
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -8,6 +8,30 @@ ...@@ -8,6 +8,30 @@
} }
} }
@keyframes move-btn {
10%,
90% {
transform: translate3d(-1px, 0, 0);
}
20%,
80% {
transform: translate3d(2px, 0, 0);
}
30%,
50%,
70% {
transform: translate3d(-4px, 0, 0);
}
40%,
60% {
transform: translate3d(4px, 0, 0);
}
}
.layout { .layout {
padding-bottom: 100px; padding-bottom: 100px;
...@@ -25,23 +49,25 @@ ...@@ -25,23 +49,25 @@
.page-btn { .page-btn {
position: fixed; position: fixed;
right: 0; right: 10px;
top: 450px; top: 426px;
z-index: 3; z-index: 3;
background: #FFFFFF;
width: 74px;
box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.1000);
border-radius: 4px 0px 0px 4px;
border: 1px solid #EFEFEF;
.page-item { .page-item {
height: 30px; width: 42px;
font-size: 9px; height: 42px;
font-weight: 500; background: #FFFFFF;
color: #666666; box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.1000);
padding: 0 8px; border: 1px solid #EFEFEF;
.sprite-icon{ color: #2C2C2C;
margin-right: 2px; font-size: 10px;
} margin-bottom: 10px;
border-radius: 100%;
flex-direction: column;
justify-content: center;
}
.order-move {
animation: move-btn 1.5s infinite cubic-bezier(.36, .07, .19, .97) both;
} }
} }
...@@ -76,19 +102,20 @@ ...@@ -76,19 +102,20 @@
position: absolute; position: absolute;
top: 40px; top: 40px;
right: 20px; right: 20px;
border: 1px solid #fff;
border-radius: 100%;
box-sizing: border-box;
width: 34px;
height: 34px;
.icon-music { .icon-music {
animation: move 3s infinite ease-in-out; animation: move 3s infinite ease-in-out;
border: 1px solid #fff;
border-radius: 100%;
} }
} }
}
.video { .musicOff {
position: fixed; border: none;
top: -10000px; }
left: -10000px;
} }
.video-box { .video-box {
......
...@@ -79,4 +79,13 @@ video{ ...@@ -79,4 +79,13 @@ video{
background-color: rgba($color: #000000, $alpha: .1); background-color: rgba($color: #000000, $alpha: .1);
display: block; display: block;
} }
}
#audio {
position: fixed;
top: -10000px;
left: -10000px;
width: 10px;
height: 10px;
} }
\ No newline at end of file \ No newline at end of file

108 KB | W: | H:

113 KB | W: | H:

src/assets/images/order-bg.png
src/assets/images/order-bg.png
src/assets/images/order-bg.png
src/assets/images/order-bg.png
  • 2-up
  • Swipe
  • Onion skin

115 KB | W: | H:

114 KB | W: | H:

src/assets/images/sprite.png
src/assets/images/sprite.png
src/assets/images/sprite.png
src/assets/images/sprite.png
  • 2-up
  • Swipe
  • Onion skin

2.01 KB | W: | H:

1.63 KB | W: | H:

src/assets/spritesmith/kf.png
src/assets/spritesmith/kf.png
src/assets/spritesmith/kf.png
src/assets/spritesmith/kf.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -17,8 +17,8 @@ const pages = { ...@@ -17,8 +17,8 @@ const pages = {
}, },
}, },
{ {
name:'agreement', name: 'agreement',
meta:{ meta: {
// keepAlive: true, // keepAlive: true,
backgroundColor: '#FFF', backgroundColor: '#FFF',
noAuth: true, noAuth: true,
...@@ -26,20 +26,28 @@ const pages = { ...@@ -26,20 +26,28 @@ const pages = {
} }
}, },
{ {
name:'carBrands', name: 'carBrands',
meta:{ meta: {
keepAlive: true, keepAlive: true,
backgroundColor: '#FFF', backgroundColor: '#FFF',
title: '品牌' title: '品牌'
} }
}, },
{ {
name:'carSeries', name: 'carSeries',
meta:{ meta: {
keepAlive: true, keepAlive: true,
backgroundColor: '#F7F8FA', backgroundColor: '#F7F8FA',
title: '选择车系' title: '选择车系'
} }
},
{
name: 'orderList',
meta: {
keepAlive: true,
backgroundColor: '#FFF',
title: '订单'
}
} }
] ]
} }
......
export function Audio (url, callBack) { export function Audio (url, callBack) {
this.IsIOS = false // this.IsIOS = false
// this.IsIOS = window.$IsIOS this.IsIOS = window.$IsIOS
this.audioContext = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)() this.audioContext = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)()
this.sourceNode = null this.sourceNode = null
this.buffer = null this.buffer = null
this.isPlayingBGM = false this.isPlayingBGM = false
if (this.IsIOS) {
this.audioContext = document.createElement('audio')
let _this = this
this.audioContext.addEventListener('canplay', function () {
console.log('durationchange_______IOS播放——————————————')
_this.audioContext.play()
})
this.audioContext.src = url
this.audioContext.loop = true
}
this.toggleBGM = function (off) { this.toggleBGM = function (off) {
if (typeof this.sourceNode == 'object' && !this.IsIOS) { if (typeof this.sourceNode == 'object' && !this.IsIOS) {
if (this.isPlayingBGM || off) { if (this.isPlayingBGM || off) {
...@@ -23,7 +13,6 @@ export function Audio (url, callBack) { ...@@ -23,7 +13,6 @@ export function Audio (url, callBack) {
console.log('暂停——————————————', this.sourceNode) console.log('暂停——————————————', this.sourceNode)
} else this._playSourceNode() } else this._playSourceNode()
} else { } else {
console.log(this.audioContext.paused)
if (this.audioContext.paused && !off) this.audioContext.play() if (this.audioContext.paused && !off) this.audioContext.play()
else this.audioContext.pause() else this.audioContext.pause()
} }
...@@ -51,10 +40,10 @@ export function Audio (url, callBack) { ...@@ -51,10 +40,10 @@ export function Audio (url, callBack) {
} }
let loadAndAutoPlay = (audioUrl) => { let loadAndAutoPlay = (audioUrl) => {
// alert(window.$IsIOS) // alert(window.$IsIOS)
let _this = this
if (!this.IsIOS) { if (!this.IsIOS) {
const audioContext = this.audioContext const audioContext = this.audioContext
const xhr = new XMLHttpRequest() const xhr = new XMLHttpRequest()
let _this = this
xhr.open('GET', `${audioUrl}?v=${Date.now()}`, true) xhr.open('GET', `${audioUrl}?v=${Date.now()}`, true)
xhr.responseType = 'arraybuffer' xhr.responseType = 'arraybuffer'
xhr.onreadystatechange = () => { xhr.onreadystatechange = () => {
...@@ -78,7 +67,13 @@ export function Audio (url, callBack) { ...@@ -78,7 +67,13 @@ export function Audio (url, callBack) {
} }
xhr.send() xhr.send()
} else { } else {
callBack() this.audioContext = document.getElementById('audio')
this.audioContext.src = url
this.audioContext.onloadedmetadata = ()=>{
console.log('——————————————————IOS播放————————————————onloadedmetadata')
this.audioContext.play()
callBack()
}
} }
} }
loadAndAutoPlay(url) loadAndAutoPlay(url)
......
...@@ -55,8 +55,8 @@ class Draw { ...@@ -55,8 +55,8 @@ class Draw {
toRpx (val) { toRpx (val) {
return this[_pixelRatio_] * val return this[_pixelRatio_] * val
} }
getTextWidth (text) { getTextWidth (text, fontSize = 12) {
return this[_ctx_].measureText(text).width return this[_ctx_].measureText(text).width * fontSize / 12
} }
drawText (textParams) { drawText (textParams) {
let { let {
...@@ -76,7 +76,7 @@ class Draw { ...@@ -76,7 +76,7 @@ class Draw {
x, x,
y, y,
} = textParams } = textParams
let text_width = this.getTextWidth(text), let text_width = this.getTextWidth(text, 12),
font = this[_ctx_].font.split('px')[1] font = this[_ctx_].font.split('px')[1]
textAlign = textAlign || 'left' textAlign = textAlign || 'left'
textBaseline = textBaseline || 'normal' textBaseline = textBaseline || 'normal'
...@@ -103,11 +103,16 @@ class Draw { ...@@ -103,11 +103,16 @@ class Draw {
x, x,
}) })
const drawOneLineText = () => { const drawOneLineText = () => {
let newText = text let textArr = text.split('')
let maxLength = -1 let newText = ''
if (textWidth && text.length * fontSize + fontX > textWidth) maxLength = parseInt((width - textWidth - fontX) / fontSize) - 1 try {
if (text.length * fontSize + fontX > width && !maxWidth) maxLength = parseInt((width - fontX) / fontSize) - 1 textArr.map(e =>{
newText = maxLength !== -1 ? `${text.substring(0, maxLength)}...` : text newText += e
if (this.getTextWidth(newText) > width - fontX - this.getTextWidth('…') - fontSize) throw newText
})
} catch (error) {
newText = `${error}…`
}
this[_ctx_].fillText(newText, x, y, maxWidth) this[_ctx_].fillText(newText, x, y, maxWidth)
if (checkTextDecoration(textDecoration)) { if (checkTextDecoration(textDecoration)) {
this.drawDecoration({ this.drawDecoration({
...@@ -129,7 +134,6 @@ class Draw { ...@@ -129,7 +134,6 @@ class Draw {
currentText = '', currentText = '',
viewWidth = width - fontX viewWidth = width - fontX
if (text_width > viewWidth) { if (text_width > viewWidth) {
textArr.map(e => { textArr.map(e => {
currentText += e currentText += e
if (this.getTextWidth(currentText) >= viewWidth && textRowArr.length < lineNum - 1) { if (this.getTextWidth(currentText) >= viewWidth && textRowArr.length < lineNum - 1) {
...@@ -144,10 +148,10 @@ class Draw { ...@@ -144,10 +148,10 @@ class Draw {
let lastText = '', lastArr = e.split('') let lastText = '', lastArr = e.split('')
lastArr.map(i => { lastArr.map(i => {
lastText += i lastText += i
if (this.getTextWidth(lastText) > width - fontX - this.getTextWidth('...') - fontSize) throw lastText if (this.getTextWidth(lastText) > width - fontX - this.getTextWidth('…') - fontSize) throw lastText
}) })
} catch (error) { } catch (error) {
e = `${error}...` e = `${error}…`
} }
} }
let textHeight = y + index * (lineHeight || fontSize) let textHeight = y + index * (lineHeight || fontSize)
......
...@@ -244,10 +244,6 @@ const isMobileDevice = () => {//判断当前设备是否为移动端 ...@@ -244,10 +244,6 @@ const isMobileDevice = () => {//判断当前设备是否为移动端
return t1 || t2 return t1 || t2
} }
/**页面跳转 */
const jump = name => {
console.log(this)
}
/**秒数转天时分秒*/ /**秒数转天时分秒*/
const date_format = num => { const date_format = num => {
const addZero = i => i < 10 ? `0${i}` : `${i}` const addZero = i => i < 10 ? `0${i}` : `${i}`
...@@ -302,8 +298,7 @@ const utils = { ...@@ -302,8 +298,7 @@ const utils = {
throttle, throttle,
decimal, decimal,
dialog, dialog,
toTop, toTop
jump
} }
Object.keys(utils).map(key => { Object.keys(utils).map(key => {
......
<template>
<canvas
:id="canvasId"
class="create"
></canvas>
</template>
<script type='text/ecmascript-6'>
import Draw from '@/utils/draw'
export default {
name: 'createOrderImg',
props: {
canvasId: {
type: String,
default: 'canvas'
},
orderInfo: {
type: Object,
default: () => { }
},
},
watch: {
orderInfo (n) {
if (n) this.drawOrderImg()
}
},
data () {
return {
ctx: null,
}
},
mounted () {
},
methods: {
drawOrderImg (callBack) {
let {
userName,
userPhone,
plateNo,
vehicleBrandName,
vehicleSubBrandName,
vehicleSeriesName,
vehicleShapeName,
goodsName,
createdDate,
payPrice,
orderStatus
} = this.orderInfo
this.ctx = document.getElementById(this.canvasId)
let valueX = 95,
labelX = 17,
valueEndX = 320 - 7,
fontSize = 14,
textBaseline = 'top',
canvasWidth = 337,
canvasHeight = 422,
carText = '',
labelList = ['姓名:', '手机:'],
spacing = 0,
textYList = []
const draw = new Draw(this, {
width: canvasWidth,
height: canvasHeight
})
let valueList = [
userName,
userPhone,
]
if (plateNo) {
labelList.push('车牌号:')
valueList.push(plateNo)
}
if (vehicleBrandName) {
carText = `${vehicleBrandName || ''} ${vehicleSubBrandName || ''} ${vehicleSeriesName || ''} ${vehicleShapeName || ''}`
labelList.push('品牌车型:')
valueList.push(carText)
}
labelList = [...labelList, '商品名称:', '支付时间:', '支付定金']
valueList = [...valueList, goodsName, new Date(createdDate).format('yyyy年M月d日 hh:mm:ss'), `${payPrice}元`]
labelList.map((e, index) => {
if (e == '商品名称:' && draw.getTextWidth(carText, fontSize) + valueX > valueEndX) spacing = 24
if (index == labelList.length - 1) textYList.push(352)
else textYList.push(index * 32 + 109 + spacing)
})
draw.drawImages({
url: require(`@/assets/images/order-bg${orderStatus == 8 ? '-2' : ''}.png`),
x: 0,
y: 0,
width: 337,
height: 422,
}, () => {
labelList && labelList.length > 0 && (labelList.map((e, index) => {
let y = textYList[index] + 7
let label = {
text: e,
x: labelX,
y,
color: '#999',
fontSize,
textBaseline
}
let value = {
text: valueList[index],
x: valueX,
y,
color: '#282829',
fontSize,
textBaseline,
width: valueEndX
}
if (e === '品牌车型:') {
value.lineNum = 2
value.lineHeight = 24
}
if (e === '商品名称:') value.color = '#FC5B32'
if (e === '支付定金') {
label.color = '#282829'
value.color = orderStatus == 8 ? '#3162E6' : '#F13C3D'
value.fontWeight = '600'
value.fontSize = 18
value.y = textYList[index] + 5
}
draw.drawText(label)
draw.drawText(value)
}))
draw.drawLine({
startX: labelX,
startY: 335,
endX: 320,
endY: 335,
width: 1,
color: '#F1F1F1'
})
let url = this.ctx.toDataURL('image/png')
this.$emit('success', url)
if (callBack) callBack(url)
})
}
}
}
</script>
<style scoped lang='scss'>
.create {
position: fixed;
top: -1000%;
left: -1000%;
}
</style>
\ No newline at end of file \ No newline at end of file
...@@ -2,9 +2,11 @@ import MoveGroup from './MoveGroup.vue' ...@@ -2,9 +2,11 @@ import MoveGroup from './MoveGroup.vue'
import CountDown from './CountDown.vue' import CountDown from './CountDown.vue'
import Action from './Action.vue' import Action from './Action.vue'
import KfModal from './KfModal.vue' import KfModal from './KfModal.vue'
import createOrderImg from './createOrderImg.vue'
export { export {
MoveGroup, MoveGroup,
CountDown, CountDown,
Action, Action,
KfModal, KfModal,
createOrderImg
} }
\ No newline at end of file \ No newline at end of file
...@@ -7,36 +7,33 @@ ...@@ -7,36 +7,33 @@
> >
<div class="sprite-icon icon-top"></div> <div class="sprite-icon icon-top"></div>
</div> </div>
<template v-if="detail.customerServiceName <div class="page-btn">
<template v-if="detail.customerServiceName
|| detail.customerServicePhone || detail.customerServicePhone
|| detail.customerServiceQrImg || detail.customerServiceQrImg
|| detail.customerServerUrl"> || detail.customerServerUrl">
<div class="page-btn"> <div
<template v-if="detail.customerServiceName class="page-item flex"
|| detail.customerServicePhone @click="clickKF"
|| detail.customerServiceQrImg @touchstart="touchstart"
|| detail.customerServerUrl"> @touchend="touchend"
<div class="page-item flex"> >
<div <div class="sprite-icon icon-kf"></div>
class="sprite-icon icon-kf" 客服
@click="clickKF" </div>
@touchstart="touchstart" </template>
@touchend="touchend" <!-- <template v-if="showOrderBtn">
></div> <div
在线客服 class="page-item flex order-move"
</div> @click="to('crowdfunding.orderList')"
</template> @touchstart="touchstart"
<!-- <div class="page-item flex"> @touchend="touchend"
<div >
class="sprite-icon icon-kf" <div class="sprite-icon icon-order"></div>
@click="clickKF" 订单
@touchstart="touchstart" </div>
@touchend="touchend" </template> -->
></div> </div>
我的订单
</div> -->
</div>
</template>
<div class="big-img"> <div class="big-img">
<img :src="detail.activityBigImg" /> <img :src="detail.activityBigImg" />
<template v-if="detail.activityStatus != 1"> <template v-if="detail.activityStatus != 1">
...@@ -50,10 +47,15 @@ ...@@ -50,10 +47,15 @@
</template> </template>
<template v-if="audioFlag"> <template v-if="audioFlag">
<div <div
class="music" :class="['music',{musicOff}]"
@click="audioAutoPlay" @click="audioAutoPlay"
> >
<div :class="['sprite-icon', musicOff ? 'icon-music-off' : 'icon-music']"></div> <template v-if="musicOff">
<div class="sprite-icon icon-music-off"></div>
</template>
<template v-else>
<div class="sprite-icon icon-music"></div>
</template>
</div> </div>
</template> </template>
<template v-if="detail.activityStatus != 1"> <template v-if="detail.activityStatus != 1">
...@@ -222,6 +224,18 @@ ...@@ -222,6 +224,18 @@
v-model="showKf" v-model="showKf"
:detail="detail" :detail="detail"
/> />
<video
id="audio"
style="object-fit:contain;"
controls
webkit-playsinline="true"
playsinline="true"
x5-video-player-type="h5-page"
preload="auto"
autoplay
loop
>
</video>
</div> </div>
</template> </template>
...@@ -245,7 +259,8 @@ export default { ...@@ -245,7 +259,8 @@ export default {
showKf: false, showKf: false,
viewFlag: false, viewFlag: false,
audioFlag: false, audioFlag: false,
carInfoKey: Date.now() carInfoKey: Date.now(),
showOrderBtn: false
} }
}, },
beforeRouteEnter (to, from, next) { beforeRouteEnter (to, from, next) {
...@@ -316,6 +331,7 @@ export default { ...@@ -316,6 +331,7 @@ export default {
document.title = data.activityName document.title = data.activityName
this.setLocalStorage('wx_scrm_page_title', data.activityName) this.setLocalStorage('wx_scrm_page_title', data.activityName)
this.getActivityGroup() this.getActivityGroup()
this.getOrderList()
let [redirectUrl] = window.location.href.split('?') let [redirectUrl] = window.location.href.split('?')
if (data.activityVideos && data.activityVideos.length) { if (data.activityVideos && data.activityVideos.length) {
/**安卓退出全屏 */ /**安卓退出全屏 */
...@@ -407,6 +423,11 @@ export default { ...@@ -407,6 +423,11 @@ export default {
this.updata = Date.now() this.updata = Date.now()
}) })
}, },
getOrderList () {
shopmallApi.getOrderList(this.id).then(data => {
if (data && data.length) this.showOrderBtn = true
})
},
audioAutoPlay (off = false) { audioAutoPlay (off = false) {
if (off === true) { if (off === true) {
this.musicOff = true this.musicOff = true
......
<template>
<div class="layout">
<div class="title">左右滑动查看核销凭证</div>
<div
class="img-box"
:key="updata"
ref="imgBox"
@touchend="scroll"
@touchstart="scrollstart"
>
<div
:class="['move flex',`test-${tabIndex}`]"
id="img-move"
>
<template v-for="(i,index) in orderList">
<div
:key="index"
class="img-item"
>
<create-order-img
:orderInfo="i"
:canvasId="`order-${index}`"
:ref="`order-${index}`"
/>
<van-image
:src="imgList[index]"
class="img"
>
<template v-slot:loading>
<van-loading
type="spinner"
size="20"
/>
</template>
</van-image>
</div>
</template>
</div>
</div>
<div class="tips text-center">长按保存图片</div>
</div>
</template>
<script type='text/ecmascript-6'>
import { shopmallApi } from '@/api'
import { createOrderImg } from './components/index'
import { util } from '@/utils'
let _this = null
export default {
components: { createOrderImg },
name: 'orderList',
data () {
return {
orderList: [],
imgList: [],
updata: Date.now(),
tabIndex: 0
}
},
activated () {
_this = this
this.getOrderList()
},
methods: {
scrollstart(){
this.tabIndex = null
},
scroll: util.debounce(e => {
let box = document.getElementsByClassName('img-box')[0],
moveBox = document.getElementById('img-move')
let { imgList } = _this
let spacing = imgList.length > 1 ? (imgList.length - 1) * 10 : 0
let width = document.getElementsByClassName('img-item')[0].offsetWidth
let index = (box.scrollLeft / width).toFixed()
let target = index == 0 ? 0 : width * index + spacing
// moveBox.style.width = width * imgList.length + 32 + (spacing * imgList.length)
console.log(index)
_this.tabIndex = index
}),
getOrderList () {
let { id } = this.getLocalStorage('wx_scrm_link_params')
shopmallApi.getOrderList(id).then(data => {
console.log(data)
data && data.length && data.map(e => {
e.createdDate = new Date(this.iosTimeFormat(e.payDate))
})
this.orderList = data || []
this.$nextTick(() => {
this.orderList.map((e, index) => {
this.$refs[`order-${index}`][0].drawOrderImg(url => {
this.imgList[index] = url
this.updata = Date.now()
})
})
})
})
}
}
}
</script>
<style scoped lang='scss'>
.layout {
user-select: none;
.title {
font-size: 12px;
color: #999999;
padding: 16px 0 8px 20px;
}
.img-box {
position: relative;
overflow-x: scroll;
width: 100%;
height: 422px;
&::-webkit-scrollbar {
display: none;
}
.img-item {
margin-left: 10px;
&:first-of-type {
margin-left: 19px;
}
&:last-of-type {
border-right: 16px solid #fff;
}
}
.img {
width: 337px;
height: 422px;
object-fit: contain;
}
.move {
position: absolute;
left: 0;
top: 0;
flex-wrap: nowrap;
width: 1103px;
height: 100%;
touch-action: pan-x;
-webkit-overflow-scrolling: touch;
transition: all 0.5s;
}
.test-0 {
transform: translateX(0);
}
.test-1 {
transform: translateX(-366px);
}
.test-2 {
transform: translateX(-703px);
}
}
.tips {
width: 219px;
height: 28px;
background: #f6f6f6;
border-radius: 4px;
font-size: 14px;
color: #656566;
margin: 14px auto 0;
}
}
</style>
\ No newline at end of file \ No newline at end of file
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
<div class="sprite-icon icon-success"></div>恭喜您已参团成功! <div class="sprite-icon icon-success"></div>恭喜您已参团成功!
</div> </div>
<div class="info">到店凭当前图片核销订单并支付尾款</div> <div class="info">到店凭当前图片核销订单并支付尾款</div>
<canvas id="canvas"></canvas>
<van-image <van-image
:src="img" :src="img"
class="img" class="img"
...@@ -17,124 +16,49 @@ ...@@ -17,124 +16,49 @@
</template> </template>
</van-image> </van-image>
<div class="tips text-center">长按保存图片</div> <div class="tips text-center">长按保存图片</div>
<create-order-img
@success="img = $event"
:orderInfo="orderInfo"
/>
</div> </div>
</template> </template>
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import Draw from '@/utils/draw' import { createOrderImg } from './components/index'
export default { export default {
name: '', components: { createOrderImg },
name: 'success',
data () { data () {
return { return {
ctx: null, img: null,
img: null orderInfo: null
} }
}, },
activated () { activated () {
let { orderInfo } = this.getParams() let { orderInfo } = this.getParams()
if (orderInfo) this.setLocalStorage('wx_scrm_pay_info', orderInfo) if (orderInfo) this.setLocalStorage('wx_scrm_pay_info', orderInfo)
else orderInfo = this.getLocalStorage('wx_scrm_pay_info') else orderInfo = this.getLocalStorage('wx_scrm_pay_info')
this.drawOrderImg(orderInfo) let {
// if (!orderInfo || !Object.keys(orderInfo).length) { activityJoin,
// this.$router.back() payPrice,
// return orderGoods: [orderGoods]
// } } = orderInfo
this.orderInfo = {
userName: activityJoin.userName,
userPhone: activityJoin.userPhone,
plateNo: activityJoin.plateNo,
vehicleBrandName: activityJoin.vehicleBrandName,
vehicleSubBrandName: activityJoin.vehicleSubBrandName,
vehicleSeriesName: activityJoin.vehicleSeriesName,
vehicleShapeName: activityJoin.vehicleShapeName,
goodsName: orderGoods.goodsName,
createdDate: activityJoin.createdDate,
payPrice,
orderStatus: 1
}
}, },
methods: { methods: {
drawOrderImg (orderInfo) {
this.ctx = document.getElementById('canvas')
let {
activityJoin,
payPrice,
orderGoods: [orderGoods]
} = orderInfo,
valueX = 98,
labelX = 20,
valueWidth = 303,
fontSize = 14,
textBaseline = 'top',
canvasWidth = 343,
canvasHeight = 422,
carText = '',
labelList = ['姓名:', '手机:'],
spacing = 0,
textYList = []
const draw = new Draw(this, {
width: canvasWidth,
height: canvasHeight
})
console.log(activityJoin)
let valueList = [
activityJoin.userName,
activityJoin.userPhone,
]
if (activityJoin.plateNo) {
labelList.push('车牌号:')
valueList.push(activityJoin.plateNo)
}
if (activityJoin.vehicleBrandName) {
carText = `${activityJoin.vehicleBrandName || ''} ${activityJoin.vehicleSubBrandName || ''} ${activityJoin.vehicleSeriesName || ''} ${activityJoin.vehicleShapeName || ''}`
labelList.push('品牌车型:')
valueList.push(carText)
}
labelList = [...labelList, '商品名称:', '支付时间:', '支付定金']
valueList = [...valueList, orderGoods.goodsName, new Date(activityJoin.createdDate).format('yyyy年M月d日 hh:mm:ss'), `${payPrice}元`]
labelList.map((e, index) => {
if (e == '商品名称:' && draw.getTextWidth(carText) + valueX > valueWidth) spacing = 24
if (index == labelList.length - 1) textYList.push(352)
else textYList.push(index * 32 + 109 + spacing)
})
draw.drawImages({
url: require('@/assets/images/order-bg.png'),
x: 0,
y: 0,
width: 343,
height: 422,
}, () => {
labelList && labelList.length > 0 && (labelList.map((e, index) => {
let y = textYList[index] + 7
let label = {
text: e,
x: labelX,
y,
color: '#999',
fontSize,
textBaseline
}
let value = {
text: valueList[index],
x: valueX,
y,
color: '#282829',
fontSize,
textBaseline,
width: valueWidth
}
if (e === '品牌车型:') {
value.lineNum = 2
value.lineHeight = 24
}
if (e === '支付定金') {
label.color = '#282829'
value.color = '#3162E6'
value.fontWeight = '600'
value.fontSize = 18
value.y = textYList[index] + 5
}
draw.drawText(label)
draw.drawText(value)
}))
draw.drawLine({
startX: 20,
startY: 335,
endX: 323,
endY: 335,
width: 1,
color: '#F1F1F1'
})
this.img = this.ctx.toDataURL('image/png')
})
}
} }
} }
</script> </script>
...@@ -158,13 +82,8 @@ export default { ...@@ -158,13 +82,8 @@ export default {
margin-bottom: 16px; margin-bottom: 16px;
text-align: center; text-align: center;
} }
#canvas {
position: fixed;
top: -1000%;
left: -1000%;
}
.img { .img {
width: 343px; width: 337px;
height: 422px; height: 422px;
object-fit: contain; object-fit: contain;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!