no message

This commit is contained in:
蔡玲
2024-09-14 17:55:41 +08:00
parent 9c4fb951c4
commit 7d591553cb
11 changed files with 27 additions and 35 deletions

View File

@@ -1,3 +1,4 @@
import Vue from 'vue'
import axios from 'axios' import axios from 'axios'
import store from '../vuex/store' import store from '../vuex/store'
import router from '@/router' import router from '@/router'
@@ -22,7 +23,6 @@ axios.interceptors.request.use(
return config return config
}, },
error => { error => {
this.$message.error('错误的传参')
return Promise.reject(error) return Promise.reject(error)
} }
) )
@@ -53,8 +53,11 @@ export const post = (sevmethod, params) => {
.then(response => { .then(response => {
resolve(response.data) resolve(response.data)
}, error => { }, error => {
this.$message.error(error.message) Vue.prototype.$message({
reject(error.message) message: error,
type: 'error'
})
reject(error)
}) })
.catch((error) => { .catch((error) => {
reject(error) reject(error)
@@ -68,8 +71,7 @@ export const get = (sevmethod, params) => {
.then(response => { .then(response => {
resolve(response.data) resolve(response.data)
}, error => { }, error => {
this.$message.error(error.message) reject(error)
reject(error.message)
}) })
.catch((error) => { .catch((error) => {
reject(error) reject(error)

BIN
src/images/agv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 KiB

After

Width:  |  Height:  |  Size: 317 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

View File

@@ -1,6 +1,6 @@
<template> <template>
<div class="canvas-wrap"> <div class="canvas-wrap" @click="rectClick">
<canvas id="carCanvas" width="645" height="686"></canvas> <canvas id="carCanvas" width="680" height="467"></canvas>
</div> </div>
</template> </template>
@@ -9,31 +9,36 @@ import Easing from '@config/Easing.js'
export default { export default {
data () { data () {
return { return {
keyPoints: [{x: 112, y: 183}, {x: 112, y: 425}, {x: 43, y: 427}, {x: 112, y: 425}] keyPoints: [{x: 105, y: 312}, {x: 105, y: 58}]
} }
}, },
mounted () { mounted () {
setTimeout(() => { setTimeout(() => {
this.handleCanvasCar() this.handleCanvasCar()
}, 3000) }, 1000)
}, },
methods: { methods: {
rectClick () {
var ev = window.event
console.log('x:' + ev.offsetX + 'y:' + ev.offsetY)
},
handleCanvasCar () { handleCanvasCar () {
const canvas = document.querySelector('#carCanvas') const canvas = document.querySelector('#carCanvas')
const ctx = canvas.getContext('2d') const ctx = canvas.getContext('2d')
let img = new Image() let img = new Image()
img.src = require('../images/che.png') img.src = require('../images/agv.png')
let nextX let nextX
let nextY let nextY
// 第一帧执行的时间 // 第一帧执行的时间
let startTime let startTime
// 期望动画持续的时间 // 期望动画持续的时间
const duration = 1000 const duration = 120
// 动画被切分成若干段,每一段所占总进度的比例 // 动画被切分成若干段,每一段所占总进度的比例
const partProportion = 1 / (this.keyPoints.length - 1) const partProportion = 1 / (this.keyPoints.length - 1)
// 缓存绘制第n段线段的n值,为了在进行下一段绘制前把这一段线段的末尾补齐 // 缓存绘制第n段线段的n值,为了在进行下一段绘制前把这一段线段的末尾补齐
// 动画帧绘制方法currentTime是requestAnimation执行回调方法step时会传入的一个执行时的时间(由performance.now()获得). // 动画帧绘制方法currentTime是requestAnimation执行回调方法step时会传入的一个执行时的时间(由performance.now()获得).
const step = (currentTime) => { const step = (currentTime) => {
console.log(currentTime)
// 第一帧绘制时记录下开始的时间 // 第一帧绘制时记录下开始的时间
!startTime && (startTime = currentTime) !startTime && (startTime = currentTime)
// 已经过去的时间(ms) // 已经过去的时间(ms)
@@ -49,16 +54,14 @@ export default {
// 绘制方法 // 绘制方法
const draw = () => { const draw = () => {
ctx.beginPath() ctx.beginPath()
ctx.clearRect(0, 0, 400, 500) ctx.clearRect(0, 0, 680, 467)
nextX = ~~(this.keyPoints[lineIndex - 1].x + ((this.keyPoints[lineIndex]).x - this.keyPoints[lineIndex - 1].x) * partProgress) nextX = ~~(this.keyPoints[lineIndex - 1].x + ((this.keyPoints[lineIndex]).x - this.keyPoints[lineIndex - 1].x) * partProgress)
nextY = ~~(this.keyPoints[lineIndex - 1].y + ((this.keyPoints[lineIndex]).y - this.keyPoints[lineIndex - 1].y) * partProgress) nextY = ~~(this.keyPoints[lineIndex - 1].y + ((this.keyPoints[lineIndex]).y - this.keyPoints[lineIndex - 1].y) * partProgress)
ctx.drawImage(img, nextX - 15, nextY - 50, 30, 50) ctx.drawImage(img, nextX - 10, nextY - 19, 20, 38)
} }
draw() draw()
if (progress < 1) { if (progress < 1) {
requestAnimationFrame(step) requestAnimationFrame(step)
} else {
console.log('动画执行完毕')
} }
} }
requestAnimationFrame(step) requestAnimationFrame(step)
@@ -71,16 +74,6 @@ export default {
.canvas-wrap .canvas-wrap
position relative position relative
width 100% width 100%
height 100% height 467px
background center / 100% auto url('~@/images/area_bg.png') no-repeat background center / 100% auto url('~@/images/area_bg.png') no-repeat
#lineCanvas
position absolute
left 0
top 0
z-index 10
#carCanvas
position absolute
left 0
top 0
z-index 11
</style> </style>

View File

@@ -125,7 +125,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="r-wrap" @click="rectClick"> <div class="zd-row flexcol jccenter r-wrap">
<t-canvas></t-canvas> <t-canvas></t-canvas>
</div> </div>
</div> </div>
@@ -174,10 +174,10 @@ export default {
} }
}, },
mounted () { mounted () {
this._queryAllPoints() // this._queryAllPoints()
this._queryMaterials() // this._queryMaterials()
this._queryAreas() // this._queryAreas()
this._queryTaskIds() // this._queryTaskIds()
}, },
methods: { methods: {
back () { back () {
@@ -295,10 +295,6 @@ export default {
} catch (e) { } catch (e) {
this.disabled5 = false this.disabled5 = false
} }
},
rectClick () {
var ev = window.event
console.log('x:' + ev.offsetX + 'y:' + ev.offsetY)
} }
} }
} }

View File

@@ -127,6 +127,7 @@
overflow auto overflow auto
.r-wrap .r-wrap
_wh(700px, 100%) _wh(700px, 100%)
padding 10px
background: center / 100% 100% url('~@/images/item_2_bg.png') no-repeat; background: center / 100% 100% url('~@/images/item_2_bg.png') no-repeat;
.item-wrap .item-wrap
width 100% width 100%