index.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. // components/mine/index.js
  2. import { bootCoin } from "../../api/mine"
  3. import { getNotifications } from "../../api/api"
  4. import { formatTime } from "../../utils/util"
  5. Component({
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {
  10. },
  11. /**
  12. * 组件的初始数据
  13. */
  14. data: {
  15. btnTxt: "启动",
  16. history: [{
  17. "symbol": "DOGE",
  18. "icon": "/images/one.png",
  19. "amount": 12.034,
  20. "ts": "2021-05-10",
  21. "from": "abcde034345dd",
  22. "to": "aabde2343df34",
  23. "out": 0,
  24. },{
  25. "symbol": "DOGE",
  26. "icon": "/images/one.png",
  27. "amount": 12,
  28. "ts": "2021-05-10",
  29. "from": "abcde034345dd",
  30. "to": "aabde2343df34",
  31. "out": -1,
  32. },{
  33. "symbol": "DOGE",
  34. "icon": "/images/one.png",
  35. "amount": 1,
  36. "ts": "2021-05-10",
  37. "from": "abcde034345dd",
  38. "to": "aabde2343df34",
  39. "out": 0,
  40. },{
  41. "symbol": "DOGE",
  42. "icon": "/images/one.png",
  43. "amount": 12.00034,
  44. "ts": "2021-05-10",
  45. "from": "abcde034345dd",
  46. "to": "aabde2343df34",
  47. "out": -1,
  48. },{
  49. "symbol": "DOGE",
  50. "icon": "/images/one.png",
  51. "amount": 12.00034,
  52. "ts": "2021-05-10",
  53. "from": "abcde034345dd",
  54. "to": "aabde2343df34",
  55. "out": 0,
  56. },{
  57. "symbol": "DOGE",
  58. "icon": "/images/one.png",
  59. "amount": 12.00034,
  60. "ts": "2021-05-10",
  61. "from": "abcde034345dd",
  62. "to": "aabde2343df34",
  63. "out": -1,
  64. },{
  65. "symbol": "DOGE",
  66. "icon": "/images/one.png",
  67. "amount": 12.00034,
  68. "ts": "2021-05-10",
  69. "from": "abcde034345dd",
  70. "to": "aabde2343df34",
  71. "out": 0,
  72. },{
  73. "symbol": "DOGE",
  74. "icon": "/images/one.png",
  75. "amount": 12.00034,
  76. "ts": "2021-05-10",
  77. "from": "abcde034345dd",
  78. "to": "aabde2343df34",
  79. "out": -1,
  80. },{
  81. "symbol": "DOGE",
  82. "icon": "/images/one.png",
  83. "amount": 12.00034,
  84. "ts": "2021-05-10",
  85. "from": "abcde034345dd",
  86. "to": "aabde2343df34",
  87. "out": 0,
  88. },{
  89. "symbol": "DOGE",
  90. "icon": "/images/one.png",
  91. "amount": 12.00034,
  92. "ts": "2021-05-10",
  93. "from": "abcde034345dd",
  94. "to": "aabde2343df34",
  95. "out": -1,
  96. },{
  97. "symbol": "DOGE",
  98. "icon": "/images/one.png",
  99. "amount": 12.00034,
  100. "ts": "2021-05-10",
  101. "from": "abcde034345dd",
  102. "to": "aabde2343df34",
  103. "out": 0,
  104. },{
  105. "symbol": "DOGE",
  106. "icon": "/images/one.png",
  107. "amount": 12.00034,
  108. "ts": "2021-05-10",
  109. "from": "abcde034345dd",
  110. "to": "aabde2343df34",
  111. "out": -1,
  112. },{
  113. "symbol": "DOGE",
  114. "icon": "/images/one.png",
  115. "amount": 12.00034,
  116. "ts": "2021-05-10",
  117. "from": "abcde034345dd",
  118. "to": "aabde2343df34",
  119. "out": 0,
  120. },{
  121. "symbol": "DOGE",
  122. "icon": "/images/one.png",
  123. "amount": 12.00034,
  124. "ts": "2021-05-10",
  125. "from": "abcde034345dd",
  126. "to": "aabde2343df34",
  127. "out": -1,
  128. },{
  129. "symbol": "DOGE",
  130. "icon": "/images/one.png",
  131. "amount": 12.00034,
  132. "ts": "2021-05-10",
  133. "from": "abcde034345dd",
  134. "to": "aabde2343df34",
  135. "out": 0,
  136. },{
  137. "symbol": "DOGE",
  138. "icon": "/images/one.png",
  139. "amount": 12.00034,
  140. "ts": "2021-05-10",
  141. "from": "abcde034345dd",
  142. "to": "aabde2343df34",
  143. "out": -1,
  144. },{
  145. "symbol": "DOGE",
  146. "icon": "/images/one.png",
  147. "amount": 12.00034,
  148. "ts": "2021-05-10",
  149. "from": "abcde034345dd",
  150. "to": "aabde2343df34",
  151. "out": 0,
  152. },{
  153. "symbol": "DOGE",
  154. "icon": "/images/one.png",
  155. "amount": 12.00034,
  156. "ts": "2021-05-10",
  157. "from": "abcde034345dd",
  158. "to": "aabde2343df34",
  159. "out": -1,
  160. },{
  161. "symbol": "DOGE",
  162. "icon": "/images/one.png",
  163. "amount": 12.00034,
  164. "ts": "2021/05/10 15:50",
  165. "from": "abcde034345dd",
  166. "to": "aabde2343df34",
  167. "out": 0,
  168. },{
  169. "symbol": "DOGE",
  170. "icon": "/images/one.png",
  171. "amount": 12.00034,
  172. "ts": "2021/05/10 17:12",
  173. "from": "abcde034345dd",
  174. "to": "aabde2343df34",
  175. "out": -1,
  176. },{
  177. "symbol": "DOGE",
  178. "icon": "/images/one.png",
  179. "amount": 12.00034,
  180. "ts": "2021/05/10 15:50",
  181. "from": "abcde034345dd",
  182. "to": "aabde2343df34",
  183. "out": 0,
  184. },{
  185. "symbol": "DOGE",
  186. "icon": "/images/one.png",
  187. "amount": 12.00034,
  188. "ts": "2021/05/10 17:12",
  189. "from": "abcde034345dd",
  190. "to": "aabde2343df34",
  191. "out": -1,
  192. }],
  193. symbol: "DOGE",
  194. icon: "/images/one.png",
  195. totals: 9999.9999,
  196. progress: 99.999, // 0 表示已停止
  197. timer: null,
  198. coinTimer: null
  199. },
  200. /**
  201. * 组件的方法列表
  202. */
  203. methods: {
  204. tabIn: function() {
  205. this.getNotification();
  206. this.starTimer();
  207. console.log(formatTime(new Date(1620633003000)));
  208. this.setData({history: []});
  209. },
  210. tabOut: function() {
  211. clearInterval(this.data.timer);
  212. clearTimeout(this.data.coinTimer);
  213. },
  214. getNotification: function() {
  215. var that = this;
  216. getNotifications().then(res=>{
  217. console.log(res);
  218. that.setData({
  219. });
  220. }, err=>{
  221. console.log(err);
  222. that.setData({
  223. totals: 0,
  224. progress: 0
  225. });
  226. });
  227. that.data.coinTimer = setTimeout(()=>{
  228. that.getNotification();
  229. }, 30000);
  230. },
  231. starTimer: function() {
  232. var that = this;
  233. that.data.timer = setInterval(function(){
  234. var current = parseFloat(that.data.progress);
  235. that.setData({
  236. progress: (current + parseFloat(Math.random() * 0.001)).toFixed(4)
  237. });
  238. }, 1000);
  239. },
  240. onClickStart: function() {
  241. let that = this;
  242. that.setData({
  243. btnTxt: "挖矿中"
  244. });
  245. },
  246. goRule: function() {
  247. wx.navigateTo({
  248. url: '/pages/mine_rule/index',
  249. })
  250. },
  251. dateTime: function(time) {
  252. console.log(time);
  253. return formatTime(new Date(parseInt(time)));
  254. }
  255. }
  256. })