1
huangxiaoqiang
2025-05-26 41702c7ce4c88ad70f52d83d153dd4c596ff69d5
ÏîÄ¿´úÂë/LGPDA/pages/index/index.vue
@@ -1,7 +1,17 @@
<template>
   <!-- <u-card :title="title" > -->
   <!-- <u-card :title="你好"> -->
   <view class="" slot="body">
      <!-- <view v-for="(item,index) in tree" :key="item.id"> -->
      <template>
         <view style="display: flex;height:50px;">
            <button
               :style="{borderRadius: '50%',width: '35px',height: '35px',margin: '5px',backgroundColor: online ? 'green' : 'red'}"></button>
            <div style="margin:10px;">{{online?'在线':'离线'}}</div>
            <u-switch v-model="value" @change="asyncChange" style="margin-left: 180px;margin-top: 10px;"></u-switch>
            <text style="margin-left: 10px;margin-top: 15px;">{{ value ? '自动模式' : '手动模式' }}</text>
         </view>
      </template>
      <u-grid :col="3">
         <u-grid-item @tap="clickCoupon(item.url)" v-for="(item) in tree" :key="item.id">
            <u-icon name="coupon" :size="50"></u-icon>
@@ -25,7 +35,10 @@
            // title: '操作功能'
            datas: [],
            tree: [],
            version: ""
            version: "",
            online: false,
            value: false,
            isChanging: false
         }
      },
      onShow() {
@@ -43,8 +56,22 @@
      },
      onLoad() {
         this.getCurrentTree();
         this.Socketonline();
         this.GetAutoStatus();
      },
      beforeDestroy() {
         if (this.intervalId) {
            clearInterval(this.intervalId);
         }
      },
      mounted() {
         this.Socketonline();
         this.GetAutoStatus();
         setInterval(() => {
            this.Socketonline();
            this.GetAutoStatus();
         }, 5000);
         var print = uni.getStorageSync('printFloor');
         if (print) {
            config.printFloor = print;;
@@ -55,11 +82,59 @@
            config.outboundFloor = outbound;
         }
      },
      methods: {
         asyncChange(e) {
            if (this.isChanging) return;
            this.isChanging = true;
            // å…ˆæ˜¾ç¤ºloading状态
            this.$refs.uToast.show({
               title: '正在切换模式...',
               type: 'loading',
               duration: 1000
            });
            // var param = {
            //    MainData: {
            //       "auto": e ? 'true' : 'false' // ç›´æŽ¥ä½¿ç”¨ä¼ å…¥çš„e值
            //    },
            // }
            // console.log(param);
            this.$u.post('/api/PDA/AutoStatus?auto='+( e ? 'true' : 'false'), {}).then(result => {
               console.log(result);
               if (result) {
                  this.value = e; // åªæœ‰åœ¨è¯·æ±‚成功后才更新实际值
                  this.switchValue = e; // åŒæ­¥switch的状态
                  this.$refs.uToast.show({
                     title: '模式切换成功',
                     type: 'success',
                     duration: 1000
                  });
               } else {
                  this.switchValue = !e; // è¯·æ±‚失败则恢复switch状态
                  this.$refs.uToast.show({
                     title: '模式切换失败',
                     type: 'error',
                     duration: 1000
                  });
               }
            }).catch(error => {
               this.switchValue = !e; // è¯·æ±‚失败则恢复switch状态
               this.$refs.uToast.show({
                  title: '请求出错',
                  type: 'error',
                  duration: 1000
               });
            }).finally(() => {
               this.isChanging = false;
            });
         },
         AndroidCheckUpdate: function() {
            var _this = this;
            uni.request({
               url: 'http://10.1.211.101:9004/api/PDA/GetPDAVersion?version=' + this.version,
               url: 'http://192.168.30.250:5000/api/PDA/GetPDAVersion?version=' + this.version,
               method: 'GET',
               data: {},
               success: res => {
@@ -72,7 +147,7 @@
                        icon: "none"
                     });
                     var dtask = plus.downloader.createDownload(
                        "http://10.1.211.101:9004/api/PDA/DownLoadApp", {},
                        "http://192.168.30.250:5000/api/PDA/DownLoadApp", {},
                        function(d, status) {
                           // ä¸‹è½½å®Œæˆ 
                           if (status == 200) {
@@ -102,10 +177,34 @@
            });
         },
         getCurrentTree() {
            this.$u.post('/api/Sys_Menu/getTreeMenu', {}).then(result => {
            this.$u.post('/api/Menu/getTreeMenu', {}).then(result => {
               this.tree = result;
            })
         },
         GetAutoStatus() {
            this.$u.post('/api/PDA/GetAutoStatus', {}).then(result => {
               if (result == false) {
                  this.value = false;
               } else {
                  this.value = true;
               }
            }).catch(error => {
               this.value = false;
            });
         },
         Socketonline() {
            this.$u.post('/api/PDA/Socketonline', {}).then(result => {
               if (result.data != null && result.data == false) {
                  console.log(result);
                  this.online = false;
               } else {
                  this.online = true;
               }
               // = result;
            }).catch(error => {
               this.online = false;
            });
         },
         getTree(id, data, isRootId) {
            this.datas.forEach((x) => {
               if (x.pid == id) {