| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- // components/mine/index.js
- import { bootCoin } from "../../api/mine"
- import { getNotifications } from "../../api/api"
- import { formatTime } from "../../utils/util"
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- },
- /**
- * 组件的初始数据
- */
- data: {
- symbol: "BTC",
- icon: "/images/one.png",
- btnTxt: "开始挖矿",
- history: [{
- "symbol": "doge",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021/05/10 15:50:03",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": 0,
- },{
- "symbol": "doge",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021/05/10 17:12:42",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": -1,
- }],
- totals: 9999.9999,
- progress: 99.999,
- timer: null,
- coinTimer: null
- },
- /**
- * 组件的方法列表
- */
- methods: {
- tabIn: function() {
- this.getNotification();
- this.starTimer();
- console.log(formatTime(new Date(1620633003000)));
- this.setData({history: []});
- },
- tabOut: function() {
- clearInterval(this.data.timer);
- clearTimeout(this.data.coinTimer);
- },
- getNotification: function() {
- var that = this;
- getNotifications().then(res=>{
- console.log(res);
- that.setData({
- });
- }, err=>{
- console.log(err);
- that.setData({
- totals: 0,
- progress: 0
- });
- });
- that.data.coinTimer = setTimeout(()=>{
- that.getNotification();
- }, 30000);
- },
- starTimer: function() {
- var that = this;
- that.data.timer = setInterval(function(){
- var current = parseFloat(that.data.progress);
- that.setData({
- progress: (current + parseFloat(Math.random() * 0.001)).toFixed(4)
- });
- }, 1000);
- },
- drawClick: function() {
- let that = this;
- that.setData({
- btnTxt: "挖矿中"
- });
- },
- goRule: function() {
- wx.navigateTo({
- url: '/pages/mine_rule/index',
- })
- },
- dateTime: function(time) {
- console.log(time);
- return formatTime(new Date(parseInt(time)));
- }
- }
- })
|