progress.js 555 B

12345678910111213141516171819202122232425262728293031
  1. function _next(){
  2. var that = this;
  3. if(this.data.progress >= 100){
  4. this.setData({
  5. disabled: false
  6. });
  7. return true;
  8. }
  9. this.setData({
  10. progress: ++this.data.progress
  11. });
  12. setTimeout(function(){
  13. _next.call(that);
  14. }, 20);
  15. }
  16. Page({
  17. data: {
  18. progress: 0,
  19. disabled: false
  20. },
  21. upload: function(){
  22. if(this.data.disabled) return;
  23. this.setData({
  24. progress: 0,
  25. disabled: true
  26. });
  27. _next.call(this);
  28. }
  29. });