Browse Source

fix: WiFi界面修改,还原线条变细

develop
song 4 years ago
parent
commit
6aa12e1d67
  1. 3
      CHANGELOG.md
  2. 2
      src/components/Wifi/Wifi.vue
  3. 176
      src/pagesProject/project/components/Evaluated/components/ProcessRestore - 副本.vue
  4. 3
      src/pagesProject/project/components/Evaluated/components/ProcessRestore.vue
  5. 13
      src/pagesYanyuan/wifi-binding/wifi-binding.vue

3
CHANGELOG.md

@ -1,4 +1,4 @@
# 0.1.0 (2022-01-19)
# 0.1.0 (2022-01-20)
### 🌟 新功能
范围|描述|commitId
@ -91,6 +91,7 @@
- | 试题接口 | [f8c137a](http://101.201.226.163:3000/binbin0314/yanyuan_js/commits/f8c137a)
- | 调整时间轴 | [82645be](http://101.201.226.163:3000/binbin0314/yanyuan_js/commits/82645be)
- | 距调整pc端 | [5069aa1](http://101.201.226.163:3000/binbin0314/yanyuan_js/commits/5069aa1)
- | 连接WiFi | [fb4cce5](http://101.201.226.163:3000/binbin0314/yanyuan_js/commits/fb4cce5)
- | 适配小程序 | [9e3c45d](http://101.201.226.163:3000/binbin0314/yanyuan_js/commits/9e3c45d)
- | 适配小程序;小程序登录 | [cefc0eb](http://101.201.226.163:3000/binbin0314/yanyuan_js/commits/cefc0eb)
- | 配置默认插件接口 | [f0c177d](http://101.201.226.163:3000/binbin0314/yanyuan_js/commits/f0c177d)

2
src/components/Wifi/Wifi.vue

@ -2,7 +2,7 @@
<view class="container">
<view class="page-body">
<view class="btn-area">
<u-button type="primary" @click="sendTCP">发送TCP</u-button>
<u-button type="primary" @click="sendTCP">确定</u-button>
</view>
</view>
</view>

176
src/pagesProject/project/components/Evaluated/components/ProcessRestore - 副本.vue

@ -1,176 +0,0 @@
<template>
<view class="canvas-box w-full">
<canvas style="width: 100%; height: 450px" canvas-id="firstCanvas"></canvas>
</view>
</template>
<script>
export default {
props: { trainResult: { type: Object, default: () => {} } },
data() {
return {
canvas: null,
context: null,
points: [],
timers: [],
width: '',
};
},
mounted() {
this.$nextTick(() => {
const query = uni.createSelectorQuery().in(this);
query
.selectAll('.canvas-box')
.boundingClientRect(data => {
if (data && data.length) {
this.width = data[0].width;
this.clearTimers();
this.initCanvas();
this.drawImage(this.width);
}
})
.exec();
});
},
methods: {
//
clearTimers() {
if (this.timers.length) {
this.timers.forEach(item => {
item && clearTimeout(item);
});
this.timers = [];
}
},
// canvas ctx
initCanvas() {
this.canvas = this.$refs['reduceCanvas'];
this.context = uni.createCanvasContext('firstCanvas', this);
},
//
drawImage(width) {
const { context } = this;
const { cardUrl, lines } = this.trainResult;
let that = this;
uni.downloadFile({
url: cardUrl,
success: function (res) {
context.drawImage(res.tempFilePath, 0, 0, width, 450);
context.draw(true);
//
lines.forEach(item => {
that.drawPath(item, width);
});
},
fail(error) {
console.error('图片加载失败:', error);
},
});
},
/**
* 绘制路径
* 图片坐标是155,194
*/
drawPath(str, width) {
const data = this.generatePathData(str);
const ctx = this.context;
this.timers.push(
setTimeout(() => {
if (!this.trainResult.lines || this.trainResult.lines.length === 0) {
return;
}
ctx.beginPath();
ctx.setLineWidth(10);
ctx.setStrokeStyle('#1890ff');
const x = (+data[0][0] * width) / 155;
const y = (+data[0][1] * 450) / 194;
ctx.moveTo(x, y);
if (data.length === 1) {
// 1
ctx.arc(x, y, 2, 0, Math.PI * 2, false);
ctx.fill();
}
}, +data[0][2]),
);
for (let i = 1, len = data.length; i < len; i++) {
if (!this.trainResult.lines || this.trainResult.lines.length === 0) return;
this.timers.push(
setTimeout(() => {
if (!this.trainResult.lines || this.trainResult.lines.length === 0) {
return;
}
if (i > 1) {
this.clearAndDraw(data, i, width);
} else {
const x = (+data[i][0] * width) / 155;
const y = (+data[i][1] * 450) / 194;
ctx.lineTo(x, y);
ctx.stroke();
ctx.draw(true);
}
ctx.closePath();
// }, +data[i][2]),
}, this.getIntervalTime(+data[i][2], +str.operateTime, +data[0][2])),
);
}
},
clearAndDraw(data, i, width) {
if (!data || data.length < 1 || i >= data.length) return;
const ctx = this.context;
const x = (+data[0][0] * width) / 155;
const y = (+data[0][1] * 450) / 194;
ctx.moveTo(x, y);
for (let j = 1; j < i + 1; j++) {
const x = (+data[j][0] * width) / 155;
const y = (+data[j][1] * 450) / 194;
ctx.lineTo(x, y);
if (j === i) {
ctx.stroke();
ctx.draw(true);
}
}
},
/**
* 计算间隔时间
* 第一条线的操作时间
* 每条线的第一个点的时间
* 时间 = 当前线条的操作时间 - 第一条线的操作时间+ 当前点的时间-同一条线的第一个点的时间
*/
getIntervalTime(pointTime, operateTime, firstPointTime) {
const { lines } = this.trainResult;
let time = 0;
time = operateTime - lines[0].operateTime + (pointTime - firstPointTime);
return time;
},
/**
* 生成绘制每段路径的数据
* @param {string} str 每条路径的数据"x,y,time;x,y,time"
* @return {array} result [[x,y,time]]
*/
generatePathData(str) {
if (!str || !str.line) return;
let result = [];
str.line.split(';').forEach(point => {
result.push(point.split(','));
});
return result;
},
},
};
</script>
<style scoped lang="scss"></style>

3
src/pagesProject/project/components/Evaluated/components/ProcessRestore.vue

@ -67,6 +67,7 @@ export default {
// points.forEach(item => {
// that.drawPath(item, width);
// });
console.log('points: ', points);
that.drawPath(points, width);
},
fail(error) {
@ -89,7 +90,7 @@ export default {
return;
}
ctx.beginPath();
ctx.setLineWidth(10);
ctx.setLineWidth(3);
ctx.setStrokeStyle('#1890ff');
const x = (+data[0][0] * width) / 155;
const y = (+data[0][1] * 450) / 194;

13
src/pagesYanyuan/wifi-binding/wifi-binding.vue

@ -10,18 +10,25 @@
</view>
<view class="bg-white w-full flex justify-between items-center py-2 px-3">
<text class="mr-3">WIFI密码</text>
<u-input v-model="password" placeholder="请输入" input-align="right" class="text-base" />
<u-input type="password" v-model="password" placeholder="请输入" input-align="right" class="text-base" />
</view>
<view class="flex w-full px-3 pt-10">
<view class="flex w-full px-3 pt-3">
<Wifi :name="name" :password="password" class="w-full" />
</view>
<view class="flex flex-col u-font-14 w-full px-3 pt-6 text-gray-400">
<text class="font-bold">联网说明:</text>
<text class="mt-2">1.长按点读笔进入配网模式</text>
<text class="mt-2">2.切换手机wifi,连接ccsens_pen</text>
<text class="mt-2">3.输入wifi名和密码点击配置</text>
<text class="mt-2">4.配网成功后点读笔有灯闪烁</text>
</view>
</view>
</template>
<script>
export default {
data() {
return { name: 'ccsens_pen', password: '' };
return { name: '', password: '', show: false };
},
};
</script>

Loading…
Cancel
Save