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')
},
};
Vue轮询
关注
打赏