调整项目框架

This commit is contained in:
龙运模 2024-04-23 11:48:55 +08:00
parent 01ea333978
commit 2b8797a1ac
26 changed files with 962 additions and 352 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

123
App.vue
View File

@ -22,42 +22,45 @@
@import '@/uni_modules/uni-scss/index.scss';
/* #ifndef APP-NVUE */
@import '@/static/customicons.css';
@import 'uni.scss';
/* #endif */
//
page {
background-color: #060B26;
color: #fff;
background-color: $uni-bg-color-default !important;
color: $uni-text-color-inverse;
}
/* #endif */
.example-info {
font-size: 14px;
color: #333;
color: $uni-text-color;
padding: 10px;
}
.page_padding{padding: 14px;}
.page_content{padding: 0 12px 10px;}
//
.contentboxsty{border-radius: 8px;background: #1C2755;}
.contentboxsty{border-radius: 8px;background: $uni-bg-color-primary;}
//
.noborbot{border-bottom:none !important}
.t-icon{background-repeat: no-repeat;}
.icon22{width: 22px;height: 22px;}
//
.font12{font-size: $uni-font-size-sm;}
.font12{font-size: 12px;}
.font13{font-size: 13px;}
.font14{font-size: $uni-font-size-base;}
.font15{font-size: 15px!important;}
.font14{font-size: 14px;}
.font15{font-size: 15px;}
.font20{font-size: 20px;}
.font22{font-size: 22px;}
.font24{font-size: 24px;}
.font35{font-size: 35px;}
.font_bold{font-weight: bold;}
//
.text_color_black{color: #000;}
.theme_color{color: #009688 }//绿
.text_color_black{color: $uni-text-color-default;}
.theme_color{color: $uni-text-color-primary } //绿
//
.but_color{background: #009688 !important;}
// .text_{color: #00B68D;}
.but_color{background: $uni-color-primary !important;}
//
.flex_layout{display: flex;}
@ -72,17 +75,53 @@
//margin
.mar_top12{margin-top: 12px;}
.page_list{margin-bottom: 12px;padding:0 12px;}
//
.detail_list{margin-bottom: 12px;
.detail_list{
margin-bottom: 12px;
.list_top{
display: flex;
padding:12px;
font-size: 14px;
border-radius: 8px 8px 0px 0px;
background: linear-gradient(90deg, rgba(61, 84, 176, 0.70) 5.83%, rgba(58, 77, 158, 0.00) 73.76%);
.top_left{flex: 1;}
.top_left{flex: 1;display: flex;align-items: center; font-weight: bold;}
.top_right{display: flex;align-items: center;font-weight: bold;}
.top_right .arrow{margin-left: 5px;font-weight: normal;}
}
.list_content{padding:12px;}
.list_content{padding:12px;position: relative;}
.list_content .card_right{position: absolute;top: 12px;right: 12px;}
.card_right{
display: flex;
flex-direction: column;
.status{
padding: 3px 10px;
background: $uni-bg-color-success-dark;
color: $uni-text-color-success;
border-radius: 4px;
font-size: 12px;
}
.success{
background: $uni-bg-color-success-dark;
color: $uni-text-color-success;
}
.warning{
background: $uni-bg-color-warning-dark;
color: $uni-text-color-warning;
}
.error{
background: $uni-bg-color-error-dark;
color: $uni-text-color-danger;
}
}
}
.flexBox .detail_list:first-child{
margin-top: 2px;
}
//
.headerViewFixed{
background: $uni-bg-color-default;
}
//
.bottom_but{
@ -96,8 +135,60 @@
view{width: 50%;text-align: center;margin: 0 20px;border-radius: 19px;background: #DDD;line-height: 38px;height: 38px;margin-top: 6px;}
}
//
.page_bottom_button{width: 100%;position: fixed;bottom: 0px;background-color: #060B26;border-top: 1px solid #2E3249;height: 80px;
.page_bottom_button{
width: 100%;position: fixed;bottom: 0px;background-color: #060B26;border-top: 1px solid #2E3249;height: 80px;
.page_add{display: flex;justify-content: center;margin: 7px 20px;border-radius: 17.5px;background: #1C2755;line-height: 35px;}
}
.bot_padding{padding-bottom: 100px;}
.placeholderStyle{
color: $uni-text-color-placeholder;
font-size: 14px;
}
//
.progressBg{
position: absolute;
left: 2px;
top: 2px;
z-index: 20;
background: $uni-bg-color-primary;
width: 98px;
height: 98px;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
border-radius: 50%;
}
.progressBox{
background: $uni-bg-color-default-dark;
width: 90px;
height: 90px;
border-radius: 50%;
margin: 0 auto;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.circle-progress {
width: 102px;
height: 102px;
position: relative;
overflow: hidden;
background: $uni-bg-color-primary;
}
.circle-progress__bar {
position: absolute;
z-index: 10;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
height: 100%;
border-radius: 50%;
background-image: conic-gradient($uni-color-primary 0%, $uni-color-primary var(--progress), transparent 0);
}
</style>

View File

@ -4,7 +4,7 @@
<!-- 针对中间的导航栏 通过true来判断控制类名和样式 -->
<view class="tabbar-item" v-for="(item, index) in tabbarList" :class="[item.centerItem ? 'center-item' : '']" @click="changeItem(item)" :key="index">
<view class="item-top">
<image :src="currentItem == item.id ? item.selectIcon:item.icon"></image>
<image class="img" :src="currentItem == item.id ? item.selectIcon:item.icon"></image>
</view>
<!-- 通过三元判断控制类名 达到控制选中和未选中的样式 -->
<view class="item-bottom" :class="[currentItem == item.id ? 'item-active' : '']">
@ -38,9 +38,9 @@ export default {
},
{
id: 1,
path: '/pages/person/person',
// icon: '/static/logo.png',
// selectIcon: '/static/logo.png',
path: '',
icon: '/static/sweep.png',
selectIcon: '',
text: '扫一扫',
// class
centerItem: true
@ -61,9 +61,32 @@ export default {
},
methods: {
changeItem (item) {
if(item.centerItem){
this.scanQRCode();
return
}
uni.switchTab({
url: item.path
})
},
scanQRCode(){
uni.scanCode({
success: (res) => {
console.log('扫码结果:' + res.result);
uni.showModal({
title: '扫码结果',
content: res.result,
showCancel: false
});
},
fail: (err) => {
console.error('扫码失败:' + err);
uni.showToast({
title: '扫码失败',
icon: 'none'
});
}
});
}
}
};
@ -74,18 +97,32 @@ view {
margin: 0;
box-sizing: border-box;
}
.tabbar-container::before{
content: '';
position: absolute;
left: 10%;
top: 0;
z-index: 10;
height: 1px;
width: 80%;
background-image: linear-gradient(90deg, $uni-border-color-default, $uni-color-primary 50%, $uni-border-color-default);
background-size: 100% 1px;
background-repeat:no-repeat;
z-index: 1;
}
.tabbar-container {
position: fixed;
bottom: 0rpx;
left: 0rpx;
width: 100%;
height: 110rpx;
box-shadow: 0 0 5px #999;
display: flex;
align-items: center;
padding: 5rpx 0;
color: #999999;
background: #131E3B;
color: $uni-text-color-grey;
background: $uni-border-color-default;
box-shadow: 0 2px 4px $uni-border-shadow-color-default;
/* 针对tabbar的统一处理 */
.tabbar-item {
width: 33.33%;
@ -111,7 +148,7 @@ view {
}
//
.item-active {
color: #fff;
color: $uni-text-color-inverse;
}
}
@ -119,15 +156,26 @@ view {
.center-item {
display: block;
position: relative;
z-index: 20;
.item-top {
flex-shrink: 0;
width: 100rpx;
height: 100rpx;
position: absolute;
top: -50rpx;
top: -60rpx;
left: calc(50% - 50rpx);
border-radius: 50%;
box-shadow: 0 0 5px #999;
box-shadow: 0 2px 4px $uni-border-shadow-color-default;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
border: 2px solid $uni-text-color-inverse;
.img{
width: 100%;
height: 100%;
border-radius: 50%;
}
}
.item-bottom {
position: absolute;
@ -136,7 +184,7 @@ view {
.item-active {
position: absolute;
bottom: 5rpx;
color: #1fff;
color: $uni-text-color-inverse;
}
}
}

View File

@ -0,0 +1,70 @@
<template>
<view class="loadMore">
<!-- 无数据 -->
<view class="noData" v-if="noData">
<view class="imgView">
<image class="img" src="https://dm-auto.oss-cn-shanghai.aliyuncs.com/mes_wechat/noData.png" lazy-load="true"></image>
</view>
<view class="text font14">暂无数据...</view>
</view>
<view class="loadView" v-if="loading">
<view class="loadBox">
<text class="icon iconfont icon-loading"></text>
<text class="text font14">加载中...</text>
</view>
</view>
<view class="loadCompleted" v-if="loadEnd && !loading">
<view class="loadBox">
<text class="iconfont icon-meiyougengduo"></text>
<text class="text font14">没有更多数据了</text>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
props: {
noData:{
type:[Boolean],
default(){
return false
}
},
loading:{
type:[Boolean],
default(){
return false
}
},
loadEnd:{
type:[Boolean],
default(){
return false
}
}
},
computed: {
},
methods: {
}
}
</script>
<style scoped lang="scss">
.noData{
.text{
color: $uni-text-color-grey;
}
}
.loadBox{
color: $uni-color-primary;
}
</style>

View File

@ -1,19 +1,14 @@
<template>
<!-- style="height: 3.5rem; margin: 0 1em;" -->
<view>
<view class="line-total" :style="'width: ' + (val / total * 100) + '%'">
<text class="line-data">
{{val}}%
</text>
</view>
<view style="position: relative;bottom: 10px;">
<view style="position: relative;bottom: 13px;">
<view class="line-base"></view>
<view class="line-blue" :style="'width: ' + (val / total * 100) + '%'"></view>
</view>
<!-- <view class="line-val">
<text>{{title}}</text>
<text>{{total}}</text>
</view> -->
</view>
</template>
@ -48,7 +43,7 @@ export default {
}
</script>
<style scoped>
<style scoped lang="scss">
.line-total {
color: #67C23A;
text-align: right;
@ -61,12 +56,14 @@ export default {
}
.line-data{
color: #fff;
padding: 1px 3px;
color: $uni-text-color-inverse;
padding: 1px 5px;
border-radius: 9px;
border: 1px solid #FFF;
border: 1px solid $uni-text-color-inverse;
background: var(--color-warning, #67C23A);
width: 30px;
display: inline-block;
text-align: center;
font-size: 11px;
}
.line-base {

View File

@ -0,0 +1,40 @@
<template>
<view class="searchBox">
<view class="searchView">
<view class="searchInput">
<input class="input font14" confirm-type="search" placeholder-class="placeholderStyle placeholderClass iconfont icon-a-Vector6-copy" :placeholder="placeholder" />
<view class="filter">
<text class="iconfont icon-a-shaixuan2 font22"></text>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
props: {
placeholder:{
type:[String],
default:' 请输入关键字'
}
},
computed: {
},
methods: {
}
}
</script>
<style scoped lang="scss">
.searchBox .searchInput .input{
background: $uni-bg-color-primary;
}
</style>

17
main.js
View File

@ -1,12 +1,23 @@
import "./static/iconfont/iconfont.css"
import './static/css/app.css';
import "./static/iconfont/iconfont-weapp/iconfont-weapp-icon.css"
// 全局组件
import searchView from './components/searchView/index'
import loadMore from './components/loadMore/index'
import progressBar from './components/progressBar'
// #ifndef VUE3
import Vue from 'vue'
import App from './App'
import svg from './static/iconfont/svg.js'
Vue.component('search-view',searchView);
Vue.component('load-more',loadMore);
Vue.component('progress-bar',progressBar);
Vue.use(svg);
Vue.config.productionTip = false;
@ -26,6 +37,12 @@ import publicMethods from "./utils/public.js"
export function createApp() {
const app = createSSRApp(App)
// 全局注册组件
app.component('searchView', searchView);
app.component('loadMore', loadMore);
app.component('progressBar', progressBar);
app.config.globalProperties.$api = request;
app.config.globalProperties.$wf = publicMethods;
return {

View File

@ -1,5 +1,5 @@
{
"name" : "mes-mobile01",
"name" : "mes-mobile",
"appid" : "__UNI__41DB0F2",
"description" : "",
"versionName" : "1.0.0",
@ -52,9 +52,14 @@
/* */
"appid" : "wx38dc81b0eef130a3",
"setting" : {
"urlCheck" : false
"urlCheck" : false,
"postcss" : true,
"es6" : true,
"minified" : true
},
"usingComponents" : true
"usingComponents" : true,
"libVersion":"latest"
},
"vueVersion" : "3"
"vueVersion" : "3",
"locale" : "zh-Hans"
}

View File

@ -35,7 +35,6 @@
"path" : "pages/login/login",
"style" :
{
// "navigationBarTitleText" : "登录",
"enablePullDownRefresh" : false,
"navigationStyle": "custom"
}
@ -45,7 +44,10 @@
"style" :
{
"navigationBarTitleText" : "生产工单管理",
"enablePullDownRefresh" : false
"enablePullDownRefresh" : true,
"pullToRefresh":{
"color":"red"
}
}
},
{
@ -188,8 +190,16 @@
"navigationBarTextStyle": "white",
"navigationBarTitleText": "德木自动化系统",
"navigationBarBackgroundColor": "#060B26",
"backgroundColor":"#060B26",
"backgroundTextStyle":"light",
"app-plus": {
"background": "#efeff4"
"background": "#060B26"
},
"mp-weixin":{
"background":"#060B26",
"pullToRefresh":{
"color":"#060B26"
}
}
},
"condition" : { //

View File

@ -25,7 +25,7 @@
<view class="top">
2.89%
</view>
<view class="font22">
<view class="num font22">
1,567
</view>
</view>
@ -43,7 +43,7 @@
<view class="top">
2.89%
</view>
<view class="font22">
<view class="num font22">
1,567
</view>
</view>
@ -61,7 +61,7 @@
<view class="top">
2.89%
</view>
<view class="font22">
<view class="num font22">
1,567
</view>
</view>
@ -79,7 +79,7 @@
<view class="top">
2.89%
</view>
<view class="font22">
<view class="num font22">
1,567
</view>
</view>
@ -97,7 +97,7 @@
<view class="top">
2.89%
</view>
<view class="font22">
<view class="num font22">
1,567
</view>
</view>
@ -115,7 +115,7 @@
<view class="top">
2.89%
</view>
<view class="font22">
<view class="num font22">
1,567
</view>
</view>
@ -166,14 +166,6 @@
<view class="t-icon t-icon-shengchangongdan contenticon"></view>
<view class="contentname">生产工单</view>
</view>
<view class="content_module" @click="toSchedule()">
<view class="t-icon t-icon-gongdanjindu contenticon"></view>
<view class="contentname">工单进度</view>
</view>
<view class="content_module" @click="toMaterialYield()">
<view class="t-icon t-icon-gongdanchucaishuai contenticon"></view>
<view class="contentname">工单出材率</view>
</view>
<view class="content_module">
<view class="t-icon t-icon-shengchanbaobiao contenticon"></view>
<view class="contentname">生产报表</view>
@ -188,10 +180,18 @@
<view class="t-icon t-icon-paichengguanli contenticon"></view>
<view class="contentname">排程管理</view>
</view>
<view class="content_module">
<view class="content_module" @click="toSchedule()">
<view class="t-icon t-icon-gongdanjindu contenticon"></view>
<view class="contentname">工单进度</view>
</view>
<view class="content_module" @click="toMaterialYield()">
<view class="t-icon t-icon-gongdanchucaishuai contenticon"></view>
<view class="contentname">工单出材率</view>
</view>
<!-- <view class="content_module">
<view class="t-icon t-icon-paichengshichang contenticon"></view>
<view class="contentname">排程时长</view>
</view>
</view> -->
</view>
</view>
<view class="content_box">
@ -205,8 +205,8 @@
<view class="t-icon t-icon-shebeizhuangtai contenticon"></view>
<view class="contentname">设备状态</view>
</view>
<view class="content_module">
<view class="t-icon t-icon-shebeibaoxiu contenticon" @click="toDeviceRepair()"></view>
<view class="content_module" @click="toDeviceRepair()">
<view class="t-icon t-icon-shebeibaoxiu contenticon"></view>
<view class="contentname">设备报修</view>
</view>
</view>
@ -300,7 +300,7 @@
.name{flex:1;}
.accounticon{
margin-right: 5px;
color: #fff;
color: $uni-text-color-inverse;
font-size: 20px;
}
.notifyicon{font-size: 20px;padding-right: 20px;}
@ -312,33 +312,43 @@
.content_title{line-height: 25px;font-size: 16px;padding: 15px 0;}
.device_data{display: flex;flex-wrap: wrap;
.device_module{
width: calc(50% - 12px); /* 计算每个块的宽度(根据需要调整)*/
width: calc(50% - 6px); /* 计算每个块的宽度(根据需要调整)*/
// background-color: #ccc; /* */
background: $uni-bg-color-primary;
margin:6px;
background-color: #ccc; /* 设置背景色(根据需要调整)*/
padding: 10px;
background: #1C2755;
padding: 10px 14px;
border-radius: 8px;
display: flex;
.module_left{width: 60%;
.icon_background{width: 32px;height: 32px;background: #6576B7;border-radius: 8px; display: flex;align-items: center;justify-content: center;margin-bottom: 4px;}
.icon_background{width: 32px;height: 32px;background: $uni-bg-color-info;border-radius: 8px; display: flex;align-items: center;justify-content: center;margin-bottom: 4px;}
}
.module_right{width: 40%;
.top{float: right;font-size: 10px;padding: 2px 4px;background: rgba(103,194,58,0.3);border-radius: 4px;color: #67C23A;}
.top{
display: flex;flex-direction: column; font-size: 10px;padding: 2px 4px;background: rgba(103,194,58,0.3);border-radius: 4px;color: $uni-text-color-success;
}
.num{
margin-top: 6px;
}
}
}
.energy_data{padding: 12px; height: 64px; display: flex;align-items: center;background: #1C2755;border-radius: 8px;
.energy_icon{color: #009688;font-size: 24px;margin-right: 8px;}
.device_module:nth-child(even){
margin-right: 0;
}
.device_module:nth-child(odd){
margin-left: 0;
}
}
.energy_data{padding: 12px; height: 64px; display: flex;align-items: center;background: $uni-bg-color-primary;border-radius: 8px;
.energy_icon{color: $uni-text-color-primary;font-size: 24px;margin-right: 8px;}
.energy_image{flex: 1;text-align: center;
image{width: 86px;height: 32px;}
}
.energy_number{color: #FA3758;}
.energy_number{color: $uni-text-color-danger;}
}
.content_data{
// view{display: inline-block;width: 25%;}
padding: 10px 0;display: flex;position: relative;align-items: center;text-align: center;height: 98px;
padding: 10px 0;display: flex;position: relative;align-items: center;justify-content:flex-start;height: 98px;
.content_module{
width: 25%;margin: 10px 1%;height: 98px;display: flex;align-items: center;justify-content: center;flex-direction: column;background-color: #009688;border-radius: 8px;
width: calc(25% - 7px);margin: 10px 4px;height: 98px;display: flex;align-items: center;justify-content: center;flex-direction: column;background-color: $uni-color-primary;border-radius: 8px;
.contenticon{font-size: 24px;width: 32px;height: 32px;background-repeat: no-repeat;}
.contentname{padding-top: 2px;font-size: 12px;}
}

View File

@ -1,50 +1,49 @@
<template>
<!-- 工单出材率 -->
<view class="page_padding font13">
<view v-for="(item,index) in list" :key="index" class="detail_list contentboxsty">
<view v-for="(item,index) in list" :key="index" class="detail_list contentboxsty" @click="toDetail(498)">
<view class="list_top">
<view class="top_left">
工单号:{{item.name}}
工单号{{item.name}}
</view>
<view class="top_right">
工单详情 <text class="iconfont icon-gengduo"></text>
工单详情 <text class="arrow iconfont icon-gengduo"></text>
</view>
</view>
<view class="list_content font13">
<view class="list_centre">
<view class="list_row">
<view class="centre_left">
<text>加工规格</text>
<text>{{item.specs}}</text>
</view>
<view class="centre_right">
生产中
<text class="name">加工规格</text>
<text class="text">{{item.specs}}</text>
</view>
</view>
<view class="list_row">
<view class="centre_left">
<text>算法出材率</text>
<text>{{item.algorithm}}%</text>
<text class="name">算法出材率</text>
<text class="text">{{item.algorithm}}%</text>
</view>
</view>
</view>
<view class="list_below">
<view class="below_left">
<view class="">
出材率
</view>
<view class="percentage font24">
<view class="circle-progress">
<view class="progressBg">
<view class="progressBox">
<view class="percentage font22">
{{item.algorithm}}%
</view>
<view class="title font12">
出材率
</view>
<!-- <view class="below_left">
<view class="">
算法出材率
</view>
<view class="percentage font24">
{{item.reality}}%
</view>
</view> -->
<view class="circle-progress__bar" :style="'--progress:'+item.algorithm+'%'"></view>
</view>
</view>
</view>
<view class="card_right">
<view class="status">生产中</view>
</view>
</view>
</view>
@ -57,7 +56,7 @@
return {
list:[{
name:'SO202401111004',
algorithm:'81.5',
algorithm:'51.5',
reality:'81.4',
state:'生产中',
specs:'4*9*3.66',
@ -75,7 +74,7 @@
number:'12.66m³'
},{
name:'SO202401111004',
algorithm:'81.5',
algorithm:'61.5',
reality:'81.4',
state:'生产中',
specs:'4*9*3.66',
@ -95,27 +94,28 @@
}
},
methods: {
toDetail(id){
uni.navigateTo({
url:'/pages/production/productionDetail?id='+id
})
},
}
}
</script>
<style lang="scss">
<style scoped lang="scss">
.detail_list{
// .list_top{display: flex;padding: 12px 0;border-bottom: 1px solid #2D3A6F;margin-bottom: 8px;
// .top_left{flex: 1;}
// }
.list_centre{
.list_row{display: flex;padding-bottom: 12px;
.centre_left{flex: 1;display: flex;
text:first-child{width:80px;}
.centre_left{
flex: 1;
.name{width:80px;display: inline-block;font-weight: bold;}
}
.centre_right{background: rgba(230,162,60,0.2);border-radius: 4px 4px 4px 4px;height: 20px;padding: 0 6px;color: #E6A23C;}
}
}
.list_below{display: flex;text-align: center;padding: 20px 0;
view{flex: 1;}
.percentage{color: #00B68D;}
.below_left{flex: 1;display: flex;align-items: center;justify-content: center;}
.percentage{color: $uni-text-color-inverse;}
}
}
</style>

View File

@ -1,62 +1,77 @@
<template>
<!-- 工单进度管理 -->
<view class="page_padding">
<view class="detail_list contentboxsty font13">
<view class="page_padding columnFlex">
<view class="headerView" :class="headerFixed?'headerViewFixed':''">
<searchView placeholder=" 搜索工单" />
</view>
<view class="flexBox">
<view class="detail_list contentboxsty font13" v-for="(item,index) in list" :key="index">
<view @click="toDetail(497)">
<view class="list_top">
<view class="top_left">
工单号:
工单号{{item.sn}}
</view>
<view class="top_right">
工单详情
工单详情<text class="arrow iconfont icon-gengduo"></text>
</view>
</view>
<view class="list_content">
<view class="list_row">
<view class="row_left">
<view class="">开始时间</view>
<view class="">24-01-12 08:00</view>
</view>
<view class="row_right">
生产中
</view>
<text class="name">开始时间</text>
<text class="text">24-01-12 08:00</text>
</view>
<view class="list_row padd_top12">
<view class="">计划完成</view>
<view class="">24-01-12 08:00</view>
<text class="name">计划完成</text>
<text class="text">24-01-12 08:00</text>
</view>
<view class="padd_top12">
<progressBar :total="100" :val="20" title="" />
<progressBar :total="100" :val="item.num" title="" />
</view>
<view class="card_right">
<view class="status">生产中</view>
</view>
</view>
</view>
</view>
<!-- <annularProgressBar :progress_txt="20" :width="84" :height="69" title="出材率"/> -->
</view>
</view>
</template>
<script>
import progressBar from '/components/progressBar.vue'
import annularProgressBar from '/components/chocolate-progress-bar/chocolate-progress-bar.vue'
export default {
components: {
"progressBar":progressBar,
"annularProgressBar":annularProgressBar,
},
data() {
return {
list:[{name:''}]
list:[
{name:'',sn:"SO20240422000002",num:20},{name:'',sn:"SO20240422000002",num:70},{name:'',sn:"SO20240422000002",num:90},
{name:'',sn:"SO20240422000002",num:20},{name:'',sn:"SO20240422000002",num:70},{name:'',sn:"SO20240422000002",num:90}
]
}
},
methods: {
toDetail(id){
uni.navigateTo({
url:'/pages/production/productionDetail?id='+id
})
},
}
}
</script>
<style lang="scss">
<style scoped lang="scss">
.page_padding{
padding-top: 0;
}
.detail_list{
.list_content{
.list_row{display: flex;
.row_left{display: flex;}
.list_row{
.name{
width: 65px;
display: inline-block;
font-weight: bold;
}
}
}
}

View File

@ -3,10 +3,9 @@
<view class="iconfont icon-shouye" @click="toIndex()" style="height: 25px;position: absolute;top: 60px;width: 30px;"></view>
<view class="login_top">
<view class="login_logo">
<image src="https://dm-auto.oss-cn-shanghai.aliyuncs.com/mes_wechat/meslogo.png" class="logopng"></image>
<image src="https://dm-auto.oss-cn-shanghai.aliyuncs.com/mes_wechat/demu.png" class="demupng"></image>
<image src="https://dm-auto.oss-cn-shanghai.aliyuncs.com/mes_wechat/loginLogo.png" class="demupng"></image>
</view>
<view class="">
<view class="name">
自动化MES管理系统
</view>
</view>
@ -36,7 +35,7 @@
<view class="getCaptcha">{{codename}}</view>
</view>
</view>
<view class="" v-if="tab==1" style="color: #C4C4C4;font-size: 11px; padding-top: 14px;">
<view class="" v-if="tab==1" style="color: #C4C4C4;font-size: 12px;padding-top: 14px;">
记住密码
</view>
<view class="loginbut" @click="login()">
@ -80,13 +79,12 @@
this.$set(this,"tab",tab);
},
toIndex(){
uni.navigateBack({
delta: 2
uni.reLaunch({
url:'/pages/index/index'
});
},
login(){
this.$api.postFuncLoading('/user.login',{login_name:this.accountValue,password:this.passValue}).then(res=>{
console.log(res)
let obj = new Object();
obj.mes_user_name=res.data.user.name;
obj.mes_token=res.data.token;
@ -105,19 +103,21 @@
.login_page{
padding: 0 32px;
background: url('https://dm-auto.oss-cn-shanghai.aliyuncs.com/mes_wechat/background.png') no-repeat;
background-position: center center;
background-position: center;
background-size: cover;
height: 100vh;
}
.login_top{padding-top: 160px;padding-bottom: 32px;}
.login_top .name{letter-spacing: 1.2px;background: linear-gradient(to right, #fff, rgba(255,255,255,0.1));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.login_logo{display: flex;align-items: center;margin-bottom: 17px;}
.logopng{width: 53px;height: 44px;}
.demupng{width: 60px;height: 36px;}
.demupng{width: 117px;height: 43px;}
.login_centre{border-radius: 16px;background: #FFF;padding: 20px 24px 40px;}
.login_switch{display: flex;}
.login_name{flex: 1;text-align: center;
padding-bottom: 5px;
/* border-bottom: 1px solid #000; */
margin-bottom: 10px;
}
.login_name:focus {
@ -136,11 +136,11 @@
width: 30px;
border-bottom: 3px solid #009688;
}
.login_input{border-radius: 21.5px;background: #F3F5F9;margin-top: 12px;padding: 5px 15px;}
.login_input{border-radius: 21.5px;background: #F3F5F9;margin-top: 12px;padding: 9px 15px;font-size: 14px;}
.getCaptcha{border-radius: 21.5px;background: #009688;height: auto;color: white;display: flex;align-items: center;width: 40%;justify-content: center;}
.flex_layout{display: flex;margin-top: 12px;}
.login_code{margin-top: unset;width:60%;margin-right: 12px;}
.loginbut{background: #009688;text-align: center;margin-top: 60px;margin-bottom: 18px;padding: 9px;border-radius: 66rpx;}
.loginbut{background: #009688;text-align: center;margin-top: 40px;margin-bottom: 18px;padding: 9px;border-radius: 66rpx;}
.persontc{
border: none;
margin: 0;

View File

@ -2,11 +2,11 @@
<view class="person_page ">
<view class="person_top">
<view class="person_data">
<!-- <view class="person_logo"> -->
<view class="person_logo">
<!-- <button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar"> -->
<image class="person_logo" :src="avatarUrl"></image>
<image class="img" :src="avatarUrl"></image>
<!-- </button> -->
<!-- </view> -->
</view>
<view class="person_name">
<view class="name">
<text class="font15">肖银奎</text>
@ -76,6 +76,9 @@
<view class="t-icon t-icon-xitongshezhi-gerenzhongxin personicon"></view>
<view class="font13">系统设置</view>
</view>
<view class="login_out">
<view class="font13">退出登录</view>
</view>
</view>
<tab-bar :current-page="2"></tab-bar>
</view>
@ -83,7 +86,7 @@
<script>
import tabBar from "@/components/customTabBar/index";
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0';
const defaultAvatarUrl = 'https://dm-auto.oss-cn-shanghai.aliyuncs.com/mes_wechat/avatar.png';
export default {
components:{
tabBar
@ -137,7 +140,18 @@
.person_page{ padding: 14px;
.person_top{margin-bottom:33px ;
.person_data{display: flex;align-items: center;
.person_logo{border-radius: 50%;width: 54px;height: 54px;margin:0 6px 0 4px;}
.person_logo{
border-radius: 50%;width: 54px;height: 54px;margin:0 6px 0 4px;position: relative;
.img{
height: 100%;width: 100%;
}
}
.person_logo::before{
content: '';position: absolute;right: 2px;bottom: 1px;z-index: 10;border: 1px solid $uni-bg-color-default; background: $uni-bg-color-whith;width: 10px;height: 10px;border-radius: 50%;
}
.person_logo::after{
content: '';position: absolute;right: 4px;bottom: 3px;z-index: 20;background: $uni-bg-color-success;width: 8px;height: 8px;border-radius: 50%;
}
.person_name{
.name{display: flex;align-items: center;margin-bottom: 2px;
@ -148,19 +162,25 @@
}
}
.person_content{
.con_backlog{padding: 14px 10px 14px 15px;background: #1C2755;border-radius: 8px;margin-bottom: 12px;
.backlog_data{display: flex; flex-wrap: wrap;margin-top: 7px;
.backlog_module{width: 93px;height: 76px;display: flex;justify-content: center;flex-direction: column;align-items: center;border-radius: 8px;
background: #6576B7;margin: 5px 6px;}
padding-bottom: 100px;
.con_backlog{padding: 14px 10px;background: $uni-bg-color-primary;border-radius: 8px;margin-bottom: 12px;
.backlog_data{
display: flex;flex-wrap:wrap;margin-top:7px;
.backlog_module{
width: calc(33.33% - 12px);height: 76px;display: flex;justify-content: center;flex-direction: column;align-items: center;border-radius: 8px;
background: $uni-color-info;margin: 5px 6px;
box-sizing: border-box;
}
.backlogicon{width: 32px;height: 32px;}
.backlogname{
font-size: $uni-font-size-sm;
padding-top: 5px;}
padding-top: 5px;
}
}
}
.con_account{
border-radius: 8px;
background: #1C2755;
background: $uni-bg-color-primary;
display: flex;
height: 52px;
align-items: center;
@ -169,18 +189,31 @@
}
.personicon{width: 24px;height: 24px;margin-right: 15px;}
.con_data{border-radius: 8px;
background: #1C2755;
.con_data{
border-radius: 8px;
background: $uni-bg-color-primary;
padding: 0 14px;
margin-bottom: 12px;
.con_module{display: flex;height: 49px;align-items: center;border-bottom: 1px solid #2D3A6F;}
.con_module{display: flex;height: 49px;align-items: center;border-bottom: 1px solid $uni-border-color-primary;}
}
.con_set{border-radius: 8px;
background: #1C2755;
.con_set{
border-radius: 8px;
background: $uni-bg-color-primary;
display: flex;
height: 48px;
align-items: center;
padding: 0 14px;
margin-bottom: 12px;
}
.login_out{
border-radius: 8px;
background: $uni-bg-color-primary;
display: flex;
height: 48px;
align-items: center;
justify-content: center;
padding: 0 14px;
color: $uni-text-color-danger;
}
}
}

View File

@ -5,8 +5,8 @@
<view class="top_left">
工单号 <text class="padd_left12">{{form.order_sn}}</text>
</view>
<view class="top_right font13">
{{form.review_status_label}}
<view class="top_right font12">
{{form.active_status_label}}
</view>
</view>
<view class="list_content">
@ -21,7 +21,7 @@
</view>
<view class="content_row">
<text class="name">工单耗时</text>
<text class="data">10h</text>
<text class="data">{{form.processing_time}}</text>
</view>
<view class="content_row">
<text class="name">加工规格</text>
@ -29,11 +29,11 @@
</view>
<view class="content_row">
<text class="name">规格料</text>
<text class="data">13.01</text>
<text class="data">{{form.cube}}</text>
</view>
<view class="content_row">
<text class="name">生产负责</text>
<text class="data">张三</text>
<text class="data">{{form.creator_name}}</text>
</view>
<view class="content_row">
<text class="name">加工等级</text>
@ -49,7 +49,22 @@
</view>
</view>
<view class="content_right">
<progressBar :total="100" :val="form.progress_rate" title="" />
</view>
<view class="progressView">
<view class="circle-progress">
<view class="progressBg">
<view class="progressBox">
<view class="percentage font22">
{{form.yield_rate}}%
</view>
<view class="title font12">
出材率
</view>
</view>
</view>
<view class="circle-progress__bar" :style="'--progress:'+form.yield_rate+'%'"></view>
</view>
</view>
</view>
</view>
@ -64,16 +79,17 @@
}
},
onLoad(option){
console.log(option)
this.detailData(option.id)
},
onShow(){
// this.detailData()
},
onReady() {
},
methods: {
detailData(id){
this.$api.postFuncLoading('/order.info',{id:id}).then(res=>{
console.log(res.data)
this.form = res.data
})
},
@ -83,11 +99,18 @@
<style lang="scss">
.list_top{
.top_right{background: #243168;border-radius: 4px 4px 4px 4px;width: 46px;height: 20px;text-align: center;}
.top_right{background: #243168;border-radius: 4px;padding: 3px 10px; text-align: center;display: inline-block;}
}
.list_content{
.content_row{display: flex;padding:6px 0;
.name{width: 90px;}
.name{width: 90px;font-weight: bold;}
}
.content_right{padding: 6px 0;}
.progressView{
position: absolute;
top: 12px;
right:12px;
z-index: 20;
}
}
</style>

View File

@ -1,87 +1,162 @@
<template>
<!-- 生产工单 -->
<view class="page_padding">
<view class="page_padding columnFlex">
<view class="headerView" :class="headerFixed?'headerViewFixed':''">
<searchView placeholder=" 搜索工单" />
</view>
<view class="flexBox">
<!-- <scroll-view scroll-y="true" class="scrollView"> -->
<view v-for="(item,index) in list" :key="index" class="detail_list contentboxsty font13">
<view @click="toDetail(item.id)">
<view class="list_top">
<view class="top_left">
工单号:{{item.order_sn}}
工单号{{item.order_sn}}
</view>
<view class="top_right">
工单详情 <text class="iconfont icon-gengduo"></text>
工单详情 <text class="arrow iconfont icon-gengduo"></text>
</view>
</view>
<view class="list_content font13">
<view class="list_centre">
<view class="centre_left">
<view class="">
<view class="name font_bold">
算法出材率
</view>
<view class="percentage font24">
{{item.algorithm}}%
{{item.algorithm && item.algorithm!=''?item.algorithm+'':'0'}}%
</view>
</view>
<view class="centre_left">
<view class="">
<view class="name font_bold">
实际出材率
</view>
<view class="percentage font24">
{{item.reality}}%
{{item.reality && item.reality!=''?item.reality:'0'}}%
</view>
</view>
</view>
<view class="list_below">
<view class="row">
<view class="row_left">
<text>状态</text>
<text>{{item.review_status_label}}</text>
<text class="name">状态</text>
<text class="text status">{{item.active_status_label}}</text>
</view>
<view class="row_right">
<text>加工规格</text>
<text>{{item.order_spec}}</text>
<text class="name">加工规格</text>
<text class="text">{{item.order_spec}}</text>
</view>
</view>
<view class="row">
<view class="row_left">
<text>生产开始</text>
<text>{{item.plan_date}}</text>
<text class="name">生产开始</text>
<text class="text">{{item.plan_date}}</text>
</view>
<view class="row_right">
<text>工单耗时</text>
<text>{{item.timeConsuming}}</text>
<text class="name">工单耗时</text>
<text class="text">{{item.progress_rate}}</text>
</view>
</view>
<view class="row">
<view class="row_left">
<text>工单数量</text>
<text>{{item.order_number}}</text>
<text class="name">工单数量</text>
<text class="text">{{item.order_number}}</text>
</view>
</view>
</view>
</view>
</view>
</view>
<loadMore :noData="loadParams.noData" :loading="loadParams.loading" :loadEnd="loadParams.loadEnd" />
<!-- </scroll-view> -->
</view>
</view>
</template>
<script>
export default {
components:{
},
data() {
return {
list:[]
headerFixed:false,
list:[],
params:{
page:1,
pageSize:10,
},
loadParams:{
noData:false,
loading:false,
loadEnd:false
}
}
},
onShow(){
},
onReady() {
this.listData();
},
onPageScroll(e){
if(e.scrollTop>30){
this.headerFixed = true;
}else{
this.headerFixed = false;
}
},
//
onPullDownRefresh(){
this.params.page = 1;
this.listData(2);
},
//
onReachBottom(){
if(!(this.loadParams.loadEnd || this.loadParams.noData)){
this.loadParams.loading = true;
this.params.page ++;
this.listData();
}
},
methods: {
listData(){
this.$api.postFuncLoading('/order.list',{page: 1,pageSize: 15}).then(res=>{
this.list = res.data.rows
listData(type=1){
if(this.params.page == 1){
uni.showLoading({
title: '加载中',
mask: true
})
}
this.$api.request('/order.list',this.params).then(res=>{
console.log(res,566)
if(type ==2){
uni.stopPullDownRefresh();
}
setTimeout(function () {
uni.hideLoading();
}, 200);
this.loadParams.loading = false;
if(res.data.rows.length ==0 && this.params.page == 1){
this.loadParams.noData = true;
}
if(res.data.rows.length>0 && res.data.rows.length < this.params.pageSize){
this.loadParams.loadEnd = true;
}
if(this.params.page == 1){
this.list = res.data.rows;
}else{
this.list = this.list.concat(res.data.rows);
}
}).catch(err=>{
console.log('err',err)
setTimeout(function () {
uni.hideLoading();
}, 200);
})
},
//
toDetail(id){
console.log(id)
uni.navigateTo({
url:'/pages/production/productionDetail?id='+id
})
@ -90,16 +165,34 @@
}
</script>
<style lang="scss">
<style scoped lang="scss">
.page_padding{
padding-top: 0;
}
.detail_list{
.list_centre{display: flex;text-align: center;padding-bottom: 10px;
view{flex: 1;}
.percentage{color: #00B68D;}
.percentage{color: $uni-text-color-primary;margin: 10px 0 0 0;}
}
.list_below{padding-bottom: 12px;
.row{display: flex;padding-top: 10px;
.row_left{ white-space: nowrap;overflow: hidden;text-overflow: ellipsis;}
.row_left{
white-space: nowrap;overflow: hidden;text-overflow: ellipsis;
padding-right: 4px;
}
.row_right{
white-space: nowrap;overflow: hidden;text-overflow: ellipsis;
padding-left: 4px;
}
view{flex: 1;}
.row_left .name,.row_right .name{
display: inline-block;
width: 65px;
font-weight: bold;
}
.status{
color: $uni-text-color-warning;
}
}
}

BIN
static/.DS_Store vendored Normal file

Binary file not shown.

78
static/css/app.css Normal file
View File

@ -0,0 +1,78 @@
/* 检索部分 */
.columnFlex{
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
box-sizing: border-box;
}
.headerView{
padding: 10px 0;
flex-basis: 40px;
}
.searchBox .searchView{
position: relative;
}
.searchBox .searchInput{
display: flex;
flex-direction: row;
}
.searchBox .searchInput .input{
border-radius: 20px;
padding: 7px 13px 7px 13px;
flex: 1;
}
.searchBox .searchInput .filter{
flex-basis: 32px;
display: flex;
align-items: center;
justify-content: flex-end;
}
.headerViewFixed{
position: fixed;
left: 14px;
top: 0;
z-index: 100;
width: calc(100% - 28px);
}
.flexBox{
flex: 1;
}
.scrollView{
height: 100%;
}
/* 加载更多部分 */
.noData{
margin: 50% auto;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.noData .imgView .img{
width: 180px;
height: 138px;
}
.noData .text{
margin-top: 10px;
}
.loadBox{
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 20px;
}
.loadBox .text{
margin-left: 8px;
}
.loadBox .icon{
animation: spin 0.6s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}

BIN
static/iconfont/.DS_Store vendored Normal file

Binary file not shown.

BIN
static/iconfont/iconfont-weapp/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -1,8 +1,8 @@
@font-face {
font-family: "iconfont"; /* Project id 4403683 */
src: url('//at.alicdn.com/t/c/font_4403683_5b5i159cydc.woff2?t=1709604278213') format('woff2'),
url('//at.alicdn.com/t/c/font_4403683_5b5i159cydc.woff?t=1709604278213') format('woff'),
url('//at.alicdn.com/t/c/font_4403683_5b5i159cydc.ttf?t=1709604278213') format('truetype');
src: url('//at.alicdn.com/t/c/font_4403683_4mp9v07pqat.woff2?t=1713756401049') format('woff2'),
url('//at.alicdn.com/t/c/font_4403683_4mp9v07pqat.woff?t=1713756401049') format('woff'),
url('//at.alicdn.com/t/c/font_4403683_4mp9v07pqat.ttf?t=1713756401049') format('truetype');
}
.iconfont {
@ -13,6 +13,46 @@
-moz-osx-font-smoothing: grayscale;
}
.icon-meiyougengduo:before {
content: "\e638";
}
.icon-loading:before {
content: "\e891";
}
.icon-bianji1:before {
content: "\e601";
}
.icon-bangding1:before {
content: "\e602";
}
.icon-a-shaixuan2:before {
content: "\e636";
}
.icon-a-Vector6:before {
content: "\e637";
}
.icon-a-Vector6-copy:before {
content: "\e655";
}
.icon-saoyisao:before {
content: "\e600";
}
.icon-a-shengchanshijian1:before {
content: "\e63b";
}
.icon-weixuanzhong:before {
content: "\e635";
}
.icon-paizhao:before {
content: "\e633";
}

BIN
static/sweep.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -1,10 +1,56 @@
@import '@/uni_modules/uni-scss/variables.scss';
/* 行为基本色 */
$uni-color-primary: #009688;
$uni-color-success: #67C23A;
$uni-color-warning: #F5AC3F;
$uni-color-error: #F84545;
$uni-color-info: #6576B7;
/* 文字基本色 */
$uni-text-color-primary: #009688;
$uni-text-color-success: #67C23A;
$uni-text-color-info: #909398;
$uni-text-color-warning: #F5AC3F;
$uni-text-color-danger: #FA3758;
$uni-text-color: #333;
$uni-text-color-tip: #6E6E6E;
$uni-text-color-inverse: #fff;
$uni-text-color-grey: #999999;
$uni-text-color-placeholder: rgba(255,255,255,0.7);
$uni-text-color-default: #000000;
/* 文字尺寸 */
$uni-font-size-sm:24rpx;
$uni-font-size-base:28rpx;
$uni-font-size-lg:32rpx;
/* 背景色 */
$uni-bg-color-default:#060B26;
$uni-bg-color-primary:#1C2755;
$uni-bg-color-success:#67C23A;
$uni-bg-color-warning:#F5AC3F;
$uni-bg-color-error:#F84545;
$uni-bg-color-info:#6576B7;
$uni-bg-color-grey:#CCCCCC;
$uni-bg-color-whith:#FFFFFF;
$uni-bg-color-default-dark:rgba(0, 150, 136, 0.5);
$uni-bg-color-success-dark:rgba(103, 194, 58, 0.25);
$uni-bg-color-warning-dark:rgba(230, 162, 60, 0.25);
$uni-bg-color-error-dark:rgba(248, 69, 69, 0.25);
/* 边框的颜色 */
$uni-border-color-primary:#2D3A6F;
$uni-border-color-default:#131E3B;
/* 边框阴影 */
$uni-border-shadow-color-default:#999999;
$uni-border-shadow-color-white:#ffffff;
$uni-border-shadow-color-black:#000000;
/* 透明度 */
$uni-opacity-disabled: 0.3; // 组件禁用态的透明度

View File

@ -1,38 +1,39 @@
import config from './envConfig.js';
import wf from './public.js'
const request = (url = '', data = {}, header = { //这里这样封装是为了后续具体组件中使用时可以直接传参,需按此顺序传参而不需要写urlxxx等键值对传参
//具体的header和后端商同后再编写这里以常见的token为例
const request = (url = '', data = {}, header = {
'Authorization': 'Bearer '+uni.getStorageSync('mes_token') ? 'Bearer '+uni.getStorageSync('mes_token') : '',
}) => {
return new Promise((resolve, reject) => {
// console.log(config,800)
uni.request({
url: config.dev.VITE_BASE_API + url, //接口地址:前缀+方法中传入的地址
method: "POST", //请求方法
url: config.dev.VITE_BASE_API + url,
method: "POST",
dataType: "json",
data: data, //传递参数
header: header, //自定义头部,和后端商同后编写
data: data,
header: header,
success: (res) => {
// console.log('request.js文件的通用接口请求封装返回的结果数据',res);
//注因为这里对请求成功的没有统一设置抛错提示所以后续具体组件中使用接口请求的res除200实际以后端同事定好的为准成功外的其他code需要额外写抛错提示
if (res.data.code == 'xxx') { //自定请求失败的情况这里以常见的token失效或过期为例
uni.removeStorageSync('token');
if (res.data.code == 401){
setTimeout( ()=> {
uni.hideLoading();
}, 200);
console.log(res.data.code,455)
uni.showModal({
showCancel: false,
title: '温馨提示',
content: res.data.msg,
// header: {
// "Token": 'Bearer ' + uni.getStorageSync("mes_token")
// },
success: function(result) {
confirmColor:'#009688',
content: res.data.message,
success: (result)=> {
if (result.confirm) {
// uni.reLaunch({
// url: '/pages/login/index' //这里需用绝对路径才可
// });
uni.reLaunch({
url: '/pages/login/login'
});
wf.removeLoginData();
}
}
});
console.log(res.data.code,888)
}
if(res.header.Authorization){
uni.removeStorageSync('mes_token');
@ -43,10 +44,11 @@ const request = (url = '', data = {}, header = { //这里这样封装是为了
uni.setStorageSync("mes_token",obj.mes_token);
}
resolve(res.data) //成功
// 成功的回调
if(res.data.code == 200){
resolve(res.data)
}
},
// 这里的接口请求如果出现问题就输出接口请求失败的msg
//注因为这里对于请求失败的设置统一抛错提示了所以后续具体组件中使用接口请求的catch中不需要再写抛错提示
fail: (err) => {
uni.showToast({
title: "" + err.msg,
@ -57,8 +59,7 @@ const request = (url = '', data = {}, header = { //这里这样封装是为了
})
})
}
const postFuncLoading = (url = '', data = {}, header = { //这里这样封装是为了后续具体组件中使用时可以直接传参,需按此顺序传参而不需要写urlxxx等键值对传参
//具体的header和后端商同后再编写这里以常见的token为例
const postFuncLoading = (url = '', data = {}, header = {
'Authorization': 'Bearer '+uni.getStorageSync('mes_token') ? 'Bearer '+uni.getStorageSync('mes_token') : '',
}) => {
uni.showLoading({
@ -66,7 +67,6 @@ const request = (url = '', data = {}, header = { //这里这样封装是为了
mask: true
})
return new Promise((resolve, reject) => {
// console.log(config,800)
uni.request({
url: config.dev.VITE_BASE_API + url, //接口地址:前缀+方法中传入的地址
method: "POST", //请求方法
@ -74,25 +74,21 @@ const request = (url = '', data = {}, header = { //这里这样封装是为了
data: data, //传递参数
header: header, //自定义头部,和后端商同后编写
success: (res) => {
setTimeout(function () {
setTimeout( ()=> {
uni.hideLoading();
}, 200);
// console.log('request.js文件的通用接口请求封装返回的结果数据',res);
//注因为这里对请求成功的没有统一设置抛错提示所以后续具体组件中使用接口请求的res除200实际以后端同事定好的为准成功外的其他code需要额外写抛错提示
if (res.data.code == 'xxx') { //自定请求失败的情况这里以常见的token失效或过期为例
uni.removeStorageSync('token');
if (res.data.code == 401){
wf.removeLoginData();
uni.showModal({
showCancel: false,
title: '温馨提示',
content: res.data.msg,
// header: {
// "Token": 'Bearer ' + uni.getStorageSync("mes_token")
// },
success: function(result) {
confirmColor:'#009688',
content: res.data.message,
success: (result)=> {
if (result.confirm) {
// uni.reLaunch({
// url: '/pages/login/index' //这里需用绝对路径才可
// });
uni.reLaunch({
url: '/pages/login/login'
});
}
}
});
@ -105,11 +101,11 @@ const request = (url = '', data = {}, header = { //这里这样封装是为了
obj.mes_token = newStr;
uni.setStorageSync("mes_token",obj.mes_token);
}
resolve(res.data) //成功
// 成功的回调
if(res.data.code == 200){
resolve(res.data)
}
},
// 这里的接口请求如果出现问题就输出接口请求失败的msg
//注因为这里对于请求失败的设置统一抛错提示了所以后续具体组件中使用接口请求的catch中不需要再写抛错提示
fail: (err) => {
uni.showToast({
title: "" + err.msg,
@ -123,6 +119,5 @@ const request = (url = '', data = {}, header = { //这里这样封装是为了
export default {
request,
postFuncLoading
};

View File

@ -1,4 +1,3 @@
// 导出的环境请求地址
//本地环境
const dev = {
ENV: "dev",
@ -9,13 +8,7 @@ const pro = {
ENV: "pro",
VITE_BASE_API: "https://api.dev.dwoodauto.com",
};
// //测试环境
// const test = {
// ENV: "test",
// VITE_BASE_API: "https://api.dev.dwoodauto.com",
// };
export default {
dev,
// test,
pro,
};

View File

@ -4,6 +4,12 @@ const setLoginData=function(obj){
uni.setStorageSync("mes_token",obj.mes_token);
}
const removeLoginData=function(){
uni.removeStorageSync("demu_mes_user_name");
uni.removeStorageSync("mes_token");
}
export default {
setLoginData
setLoginData,
removeLoginData
};