zhugf
2023-03-23 d5eef829f2daf8bf021c9524e2c93312091ba58f
细节优化

1.登录无token导致多次跳转问题
2.登录失败无提示问题
3.首页查询数据为空问题
4.定时器无法停止问题
已修改5个文件
55 ■■■■■ 文件已修改
common/request/fly.js 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.js 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/login/login.vue 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/tabBar/general.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/tabBar/monitor.vue 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/request/fly.js
@@ -23,8 +23,6 @@
        
        if(userinfo)
        config.headers["X-Tenant-Id"] = userinfo.loginTenantId;
    }else{
        jumpToLogin();
    }
    console.log('========================================== ')
    console.log('==    请求数据:' + JSON.stringify(config))
@@ -52,8 +50,19 @@
        console.info(err)
        uni.hideLoading()
        //登录超时,重新登录
        if (err.response.status == 401) {
        if (err.response && err.response.status == 401) {
            uni.showToast({
                title:  "登录状态已失效,重新登录!",
                icon: 'none',
                mask: true,
                 complete: function (res) {
                     setTimeout(()=>{
            jumpToLogin();
                     },1000)
                      },
            });
        }
        //发生网络错误后会走到这里
        //return Promise.resolve("ssss")
main.js
@@ -20,6 +20,9 @@
    // 全局挂载后使用
Vue.prototype.$lget = lget
//全局监控定时器(在页面使用局部定时器会出现无法关闭问题)
Vue.prototype.$monitorTimer = null
Vue.config.productionTip = false
App.mpType = 'app'
pages/login/login.vue
@@ -95,9 +95,13 @@
                        uni.switchTab({
                            url: '/pages/tabBar/general'
                        })
                    }else {
                        uni.showToast({
                            title:  res.message,
                            icon: 'none',
                            mask: true
                        });
                    }
                }).catch((err) => {
pages/tabBar/general.vue
@@ -382,7 +382,7 @@
            getOrderList(date1,date2) {
                let params = {
                    "orderTime_begin":date1 + " 00:00:00",
                    "orderTime_end":date2 + " 00:00:00",
                    "orderTime_end":date2 + " 23:59:59",
                }
                this.$api.getOrderList(params).then((res) => {
                    if (res.success) {
pages/tabBar/monitor.vue
@@ -66,10 +66,9 @@
                <view class="scoreBox">
                    <text class="text-green text-xl text-bold">{{$lget(model,'target')}}%<text
                            class="text-gray text-sm">/目标</text> </text>
                    <text class="text-gray text-xl text-bold">{{$lget(model,'initial')}}%<text
                            class="text-gray text-sm">/初始</text> </text>
                    <text class="text-gray text-sm">目标: <text class="text-green text-xl text-bold">{{$lget(model,'target')}}% </text> </text>
                    <text class="text-gray text-sm">初始: <text class="text-gray text-xl text-bold">{{$lget(model,'initial')}}% </text></text>
                    <!-- <view class="text-yellow text-xs flex justify-around">
                        <uni-text class="text-yellow cuIcon-favorfill"></uni-text>
                        <uni-text class="text-yellow cuIcon-favorfill"></uni-text>
@@ -200,8 +199,8 @@
                    <view class="h-td">干燥时间</view>
                </view>
                <view class="h-tr h-tr-2">
                    <view class="h-td">{{$lget(model,'envTemp')}}℃</view>
                    <view class="h-td">{{$lget(model,'envHum')}}%</view>
                    <view class="h-td">{{$lget(model,'envTemp')  == "" ? "--" :  $lget(model,'envTemp')}}℃</view>
                    <view class="h-td">{{$lget(model,'envHum') == "" ? "--" :$lget(model,'envHum') }}%</view>
                    <view class="h-td">{{$lget(model,'windTemp')}}℃</view>
                    <view class="h-td">{{$lget(model,'delay')}}ms</view>
                    <view class="h-td">{{$lget(model,'et')}}min</view>
@@ -330,7 +329,7 @@
            </view>
        </view>
        <view class="chartsMain">
            <qiun-data-charts type="area" :opts="opts" :canvas2d="true" :ontouch="true" :chartData="chartData" />
            <qiun-data-charts type="area" :opts="opts" :animation="false" :canvas2d="true" :ontouch="true" :chartData="chartData" />
        </view>
@@ -378,7 +377,6 @@
                    }
                },
                notice: "2023-03-1812:00:001号机台低温报警",
                timer: null,
                model: {},
                queryParam: {
                    machineid: "GM001",
@@ -398,10 +396,10 @@
        onShow() {
            console.info("监控页面显示")
            this.getRealData()
            if (!this.timer) {
                this.timer = setInterval(() => {
            if (!this.$monitorTimer) {
                this.$monitorTimer = setInterval(() => {
                    console.info("定时器工作")
                    console.info(this.timer)
                    console.info(this.$monitorTimer)
                    this.getRealData()
                }, 1000 * 12)
@@ -413,13 +411,14 @@
        },
        onHide() {
            clearInterval(this.timer)
            clearInterval(this.$monitorTimer)
            this.$monitorTimer = null
            console.info("监控页面隐藏")
            console.info("定时器停止")
            console.info(this.timer)
            console.info(this.$monitorTimer)
        },
        onUnload() {
            clearInterval(this.timer)
        },
        mounted() {