| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- // components/mine/index.js
- import { bootCoin } from "../../api/mine"
- import { getNotifications } from "../../api/api"
- import { formatTime } from "../../utils/util"
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- },
- /**
- * 组件的初始数据
- */
- data: {
- btnTxt: "启动",
- history: [{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.034,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": 0,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": -1,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 1,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": 0,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": -1,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": 0,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": -1,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": 0,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": -1,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": 0,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": -1,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": 0,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": -1,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": 0,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": -1,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": 0,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": -1,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": 0,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021-05-10",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": -1,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021/05/10 15:50",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": 0,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021/05/10 17:12",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": -1,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021/05/10 15:50",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": 0,
- },{
- "symbol": "DOGE",
- "icon": "/images/one.png",
- "amount": 12.00034,
- "ts": "2021/05/10 17:12",
- "from": "abcde034345dd",
- "to": "aabde2343df34",
- "out": -1,
- }],
- symbol: "DOGE",
- icon: "/images/one.png",
- totals: 9999.9999,
- progress: 99.999, // 0 表示已停止
-
- 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);
- },
- onClickStart: 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)));
- }
- }
- })
|