Files
mht.js/pages/cottonCandy/SugarMaking.vue
2025-10-22 07:50:31 +08:00

157 lines
4.2 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="text" >
<text class="text" >开始做糖请耐心等待.....\n</text>
<text> {{this.tetil}}{{this.StepNumber}}\n</text>
<!-- <button type="primary" size="mini">点击开始做糖</button> -->
<image :src="gifUrl" class="img-gif"></image>
</view>
</template>
<script>
const innerAudioContext = uni.createInnerAudioContext();
import process from '@/utils/process.js';
import { vShow } from "vue";
export default {
data() {
return {
gifUrl :"../../static/image/tang.gif",
StepNumber:0,
tetil: '正在做糖,当前第',
timer:null,
timer1:null,
}
},
created() {
this.ReadData();
this.MakeSugar();
this.timer = setInterval(() => {
this.$forceUpdate(); //使用强制刷新
}, 100);
},
onShow() {
process.bushu = 0;
},
onHide() {
console.log('onHide');
clearInterval(this.timer);
this.timer = null;
clearInterval(this.timer1);
this.timer1 = null;
},
methods: {
//做糖提示逻辑:
MakeSugar(){
//把当前模式都改成自动模式
if(process.glbFFBB_Byte06.AutomaticAndManual === 0x0) //手动模式按下
{
process.glbFFBB_Byte06.AutomaticAndManual = 0x00
}
else if(process.glbFFBB_Byte06.AutomaticAndManual === 0x1){ //自动模式按下
process.glbFFBB_Byte06.AutomaticAndManual = 0x00
}
else{ }
//启动做糖命令
process.glbFFBB_Byte06.StartAndStop = 0x01 //启动按下
//加个定时器2s后启动松开
this.timer1 = setInterval(() => {
process.glbFFBB_Byte06.StartAndStop = 0x00 //启动松开
}, 2*1000);
this.ReadData();
// //显示当前位置
// this.StepNumber= process.recData1.recCurrentSteps //当前位置步数
// //判断如果步数为51步就让客户取糖
// if(this.StepNumber === 255){
// //播放取糖提示音,并 弹窗提示取糖 在5s后关闭窗口
// this.bofang(); // 播放提示音
// this.tetil = '做糖已完成,第'
// uni.showToast({
// title: '做糖完成,请取糖',
// icon:'none',
// //显示持续时间为 5秒
// duration: 10000
// })
// }
// else if( this.StepNumber === 51){
// //关闭播放提示音
// innerAudioContext.stop();
// //关闭定时器
// if(this.timer) {
// clearTimeout(this.timer);
// this.timer = null;
// }
// //并跳转到选择样式界面
// uni.reLaunch({
// url:'/pages/productlist/productlist'
// })
// }
// //步数为其他就什么都不做
// else{ }
},
//读取数据,并更新显示
ReadData(){
//显示当前位置
this.StepNumber= process.recData1.recCurrentSteps //当前位置步数
this.$forceUpdate(); //使用强制刷新
//棉花糖机反应慢就判断 是不是255步
if(255 != this.StepNumber)
{
//当不是255步时表示机器开始做糖如果步数为51步就让客户取糖
if( 50 === this.StepNumber){
//播放取糖提示音,并 弹窗提示取糖 在5s后关闭窗口
this.bofang(); // 播放提示音
this.tetil = '做糖已完成,第'
uni.showToast({
title: '做糖完成,请取糖',
icon:'none',
//显示持续时间为 5秒
duration: 8000
})
}
else if( 255 === this.StepNumber) { //如果是255步就表示客户已经取完糖
//关闭播放提示音
innerAudioContext.stop();
//关闭定时器
if(this.timer) {
clearTimeout(this.timer);
this.timer = null;
}
//并跳转到选择样式界面
uni.reLaunch({
url:'/pages/productlist/productlist'
})
}
//步数为其他就什么都不做
else{ }
}
else{ }
},
bofang(){
innerAudioContext.src = '/static/mp3/kanong.mp3';
innerAudioContext.play()
}
}
}
</script>
<style>
.img-gif{
margin-top: 20rpx;
margin-left: 50rpx;
}
.text{
font-size: 50rpx;
text-align: center;
align-items: center;
}
.button{
height: 60rpx;
width: 240rpx;
text-align: center;
align-items: center;
border-radius: 10px;
}
</style>