feat: 添加扫码成功页面和实际库区选择功能
- 新增扫码成功页面,优化用户体验 - 添加实际库区选择组件和API接口 - 修改合并功能表单,增加实际库区选择 - 更新应用版本号和配置 - 优化首页跳转逻辑和错误处理
This commit is contained in:
@@ -137,17 +137,20 @@
|
||||
|
||||
uni.hideLoading();
|
||||
console.log('=== 扫码流程完成 ===');
|
||||
uni.showToast({
|
||||
title: '创建成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
uni.navigateTo({
|
||||
url: '/pages/scansuccess/scansuccess'
|
||||
})
|
||||
// uni.showToast({
|
||||
// title: '创建成功',
|
||||
// icon: 'success',
|
||||
// duration: 2000
|
||||
// });
|
||||
|
||||
// 延迟后返回或跳转
|
||||
setTimeout(() => {
|
||||
// 可以跳转到待操作列表或返回上一页
|
||||
uni.navigateBack();
|
||||
}, 2000);
|
||||
// // 延迟后返回或跳转
|
||||
// setTimeout(() => {
|
||||
// // 可以跳转到待操作列表或返回上一页
|
||||
// uni.navigateBack();
|
||||
// }, 2000);
|
||||
|
||||
} catch (err) {
|
||||
console.error('=== 扫码处理失败 ===');
|
||||
|
||||
@@ -1,93 +1,139 @@
|
||||
<template>
|
||||
<!-- <view class="production-page">
|
||||
|
||||
<klp-header @lineChange="setActive" class="line-header"></klp-header>
|
||||
|
||||
<view class="content-wrapper">
|
||||
<Acidity v-if="active == 0"/>
|
||||
<Paint v-else-if="active == 1"/>
|
||||
<Zinc1 v-else-if="active == 2"></Zinc1>
|
||||
<Zinc2 v-else-if="active == 3"></Zinc2>
|
||||
<Zinc3 v-else-if="active == 4"></Zinc3>
|
||||
</view>
|
||||
</view> -->
|
||||
<!-- 模板内容保持不变(注释部分可根据需求保留) -->
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// 根据不同的全责跳转到不同的页面
|
||||
// 如果是工人跳转到扫码页面
|
||||
// 如果是管理员跳转到产线
|
||||
export default {
|
||||
created() {
|
||||
data() {
|
||||
return {
|
||||
hasJumped: false // 防止重复跳转的标记
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
// 已跳转过则不再执行逻辑
|
||||
if (this.hasJumped) return;
|
||||
|
||||
// 显示加载状态,提升用户感知
|
||||
uni.showLoading({
|
||||
title: '验证身份中...',
|
||||
mask: true // 防止用户重复操作
|
||||
});
|
||||
|
||||
// 检查用户角色
|
||||
this.$store.dispatch('GetInfo').then(res => {
|
||||
const roles = res.data.roles;
|
||||
|
||||
if (roles.includes('admin')) {
|
||||
// 管理员角色,跳转到产线页面
|
||||
uni.switchTab({
|
||||
url: '/pages/line/line'
|
||||
});
|
||||
} else if (roles.includes('worker')) {
|
||||
// 工人角色,跳转到扫码页面
|
||||
uni.navigateTo({
|
||||
url: '/pages/easycode/easycode'
|
||||
});
|
||||
}
|
||||
// else {
|
||||
// // 其他角色,跳转到扫码页面
|
||||
// uni.navigateTo({
|
||||
// url: '/pages/easycode/easycode'
|
||||
this.$store.dispatch('GetInfo')
|
||||
.then(res => {
|
||||
uni.hideLoading(); // 关闭加载提示
|
||||
|
||||
console.log('获取身份信息内容', res.data, )
|
||||
// 验证返回数据格式
|
||||
if (!res || !res.data || !Array.isArray(res.data.roles)) {
|
||||
throw new Error('用户角色信息格式错误');
|
||||
}
|
||||
|
||||
console.log('用户角色信息', res.data.roles)
|
||||
|
||||
const roles = res.data.roles;
|
||||
|
||||
if (roles.includes('admin')) {
|
||||
// 管理员角色跳转
|
||||
uni.switchTab({
|
||||
url: '/pages/line/line',
|
||||
success: () => {
|
||||
this.hasJumped = true; // 标记已跳转
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('管理员页面跳转失败:', err);
|
||||
uni.showToast({
|
||||
title: '跳转产线页面失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (roles.includes('worker')) {
|
||||
// 工人角色跳转
|
||||
uni.navigateTo({
|
||||
url: '/pages/easycode/easycode',
|
||||
success: () => {
|
||||
this.hasJumped = true; // 标记已跳转
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('工人页面跳转失败:', err);
|
||||
uni.showToast({
|
||||
title: '跳转扫码页面失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 处理未定义角色(默认角色)
|
||||
uni.showToast({
|
||||
title: '检测到未知角色,将跳转至默认页面',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
|
||||
// 延迟跳转,确保提示被用户看到
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/easycode/easycode',
|
||||
success: () => {
|
||||
this.hasJumped = true;
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('默认角色页面跳转失败:', err);
|
||||
uni.showToast({
|
||||
title: '跳转默认页面失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 2000);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login'
|
||||
})
|
||||
// uni.hideLoading(); // 关闭加载提示
|
||||
// console.error('用户信息获取失败:', err);
|
||||
|
||||
// // 区分错误类型,给出更精准提示
|
||||
// const errorMsg = err.message || '网络异常,请检查网络后重试';
|
||||
// uni.showToast({
|
||||
// title: errorMsg,
|
||||
// icon: 'none',
|
||||
// duration: 3000
|
||||
// });
|
||||
// }
|
||||
})
|
||||
|
||||
|
||||
// // 提供重试入口
|
||||
// setTimeout(() => {
|
||||
// uni.showModal({
|
||||
// title: '加载失败',
|
||||
// content: '是否重新登录?',
|
||||
// success: (res) => {
|
||||
// if (res.confirm) {
|
||||
// uni.reLaunch({
|
||||
// url: '/pages/login'
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }, 3000);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// import Acidity from '@/components/lines/acidity.vue'
|
||||
// import Paint from '@/components/lines/paint.vue'
|
||||
// import Zinc1 from '@/components/lines/zinc1.vue'
|
||||
// import Zinc2 from '@/components/lines/zinc2.vue'
|
||||
// import Zinc3 from '@/components/lines/zinc3.vue'
|
||||
|
||||
// export default {
|
||||
// components: {
|
||||
// Acidity,
|
||||
// Paint,
|
||||
// Zinc1,
|
||||
// Zinc2,
|
||||
// Zinc3
|
||||
// },
|
||||
// data() {
|
||||
// return {
|
||||
// active: 0
|
||||
// }
|
||||
// },
|
||||
// methods: {
|
||||
// next() {
|
||||
// if (this.active >= 5) {
|
||||
// this.active = 0
|
||||
// } else {
|
||||
// this.active += 1
|
||||
// }
|
||||
// },
|
||||
// setActive({ index, line }) {
|
||||
// this.active = index;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
/* 主容器 - 简洁背景 */
|
||||
/* 样式保持不变 */
|
||||
.production-page {
|
||||
min-height: 100vh;
|
||||
background: #f6f6f6;
|
||||
}
|
||||
|
||||
/* 顶部装饰 */
|
||||
.page-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -124,8 +170,7 @@ export default {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
/* 内容容器 */
|
||||
.content-wrapper {
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
142
apps/hand-factory/pages/scansuccess/scansuccess.vue
Normal file
142
apps/hand-factory/pages/scansuccess/scansuccess.vue
Normal file
@@ -0,0 +1,142 @@
|
||||
<template>
|
||||
<view class="scan-success-page">
|
||||
<!-- 成功图标 -->
|
||||
<view class="success-icon">
|
||||
<view class="icon-circle">
|
||||
<view class="icon-check"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 成功提示文字 -->
|
||||
<view class="success-text">
|
||||
<text class="main-text">扫码成功</text>
|
||||
<text class="sub-text">信息已验证通过</text>
|
||||
</view>
|
||||
|
||||
<!-- 返回按钮 -->
|
||||
<button class="back-btn" @click="handleBack">
|
||||
返回
|
||||
</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
// 处理返回逻辑
|
||||
handleBack() {
|
||||
// 返回上一页,如果是从首页跳转可改为switchTab
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
fail: () => {
|
||||
// 若返回失败则改用switchTab跳转
|
||||
uni.switchTab({
|
||||
url: '/pages/code/code'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.scan-success-page {
|
||||
min-height: 100vh;
|
||||
background-color: #ffffff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 40rpx;
|
||||
}
|
||||
|
||||
// 成功图标样式
|
||||
.success-icon {
|
||||
margin-bottom: 60rpx;
|
||||
|
||||
.icon-circle {
|
||||
width: 180rpx;
|
||||
height: 180rpx;
|
||||
border-radius: 50%;
|
||||
background-color: #eaffea;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
animation: circleScale 0.5s ease-out;
|
||||
|
||||
.icon-check {
|
||||
width: 100rpx;
|
||||
height: 50rpx;
|
||||
border-left: 10rpx solid #00b42a;
|
||||
border-bottom: 10rpx solid #00b42a;
|
||||
transform: rotate(-45deg);
|
||||
animation: checkShow 0.3s ease-out 0.2s backwards;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 文字提示样式
|
||||
.success-text {
|
||||
text-align: center;
|
||||
margin-bottom: 100rpx;
|
||||
|
||||
.main-text {
|
||||
font-size: 36rpx;
|
||||
color: #333333;
|
||||
font-weight: 600;
|
||||
display: block;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.sub-text {
|
||||
font-size: 28rpx;
|
||||
color: #666666;
|
||||
}
|
||||
}
|
||||
|
||||
// 返回按钮样式
|
||||
.back-btn {
|
||||
width: 100%;
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
background-color: #007aff;
|
||||
color: #ffffff;
|
||||
font-size: 32rpx;
|
||||
border-radius: 45rpx;
|
||||
margin-top: 40rpx;
|
||||
box-shadow: 0 4rpx 10rpx rgba(0, 122, 255, 0.3);
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:active {
|
||||
background-color: #0066cc;
|
||||
transform: scale(0.98);
|
||||
}
|
||||
}
|
||||
|
||||
// 动画定义
|
||||
@keyframes circleScale {
|
||||
0% {
|
||||
transform: scale(0);
|
||||
opacity: 0;
|
||||
}
|
||||
70% {
|
||||
transform: scale(1.1);
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes checkShow {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: rotate(-45deg) scale(0.5);
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: rotate(-45deg) scale(1);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user