您当前的位置: 首页 > 

苗先生的PHP记录

暂无认证

  • 1浏览

    0关注

    190博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Vue轮询

苗先生的PHP记录 发布时间:2020-10-15 17:13:41 ,浏览量:1


  import axios from 'axios';
  export default {
    data() {
      return {
        activeName: 'first',
        uid : this.$session.get('uid') || '',
        Authorization : this.$session.get('Authorizations') || '',  //token
        haslist : [],  //持有列表
        historylist : [], //历史列表
      };
    },
    created () {
      const that = this;
      if (this.uid == '' || this.Authorization == ''){
        layer.confirm('请登录', {
          btn : ['确定'] ,//按钮
          cancel:function(index, layero){
            that.$router.push('/login');
          }
        }, function() {
          that.$router.push('/login');
        });
      }


        //持有记录
        // axios.post('/api/time/my_trade', {
        //   status : 1,
        //   page : 1 ,
        //   limit : 1,
        // } ,{
        //   headers: {
        //     'Authorization' : this.Authorization
        //   }
        // }).then(res => {
        //   this.haslist = res.data.message.data;
        // })


      //历史记录
      axios.post('/api/time/my_trade', {
        page : 1 ,
        limit : 1,
        status : 3,
      } ,{
        headers: {
          'Authorization' : this.Authorization
        }
      }).then(res => {
        this.historylist = res.data.message.data;
      })
    },
    methods: {
      handleClick(tab, event) {
        console.log(tab, event);
      },
      getList() {
        axios.post('/api/time/my_trade', {
          status : 1,
          page : 1 ,
          limit : 1,
        } ,{
          headers: {
            'Authorization' : this.Authorization
          }
        }).then(res => {
          this.haslist = res.data.message.data;
        })
      }
    },
    filters : {
      number (value) {
        // 截取当前数据到小数点后两位
        let realVal = parseFloat(value).toFixed(2)
        return realVal
      }
    },
    mounted() {
      this.getList();
      this.timer = window.setInterval(() => {
        setTimeout(() => {
          this.getList()
        },0)
      },3000)
    },
    destroyed(){
      clearInterval(this.timer)
    },
    // ===========更改页面背景色==========
    beforeCreate() { //在页面创建之前设置body的背景色
      document.querySelector('body').setAttribute('style', 'background:#F5F5F5')
    },
    beforeDestroy() { //在页面销毁之前移除body的属性,目的是设置的颜色只对当前页面有效 document.querySelector('body').removeAttribute('style') },
      document.querySelector('body').removeAttribute('style')
    },
  };

关注
打赏
1665468453
查看更多评论
立即登录/注册

微信扫码登录

0.0878s