index.js 1022 B

123456789101112131415161718192021222324252627282930313233343536
  1. // lionfish_comshop/components/payTimeCountDown/index.js
  2. Component({
  3. timer: null,
  4. properties: {
  5. maxPayTime: {
  6. type: Number
  7. },
  8. createTime: {
  9. type: String,
  10. observer: function (e) {
  11. var t = this, a = 60 * this.data.maxPayTime, i = void 0, r = void 0, n = void 0,
  12. formatTime = function () {
  13. var o = Date.parse(new Date())/1000;
  14. (n = parseInt(a - (o - e))) >= 0 && (i = parseInt(n / 60),
  15. r = parseFloat(n % 60),
  16. i = i >= 10 ? i : "0" + i,
  17. r = r >= 10 ? r : "0" + r),
  18. t.setData({
  19. showTimeCount: (i || "00") + ":" + (r || "00")
  20. });
  21. };
  22. formatTime(),
  23. this.timer = setInterval(function () {
  24. n <= 0 ? (t.timer && clearInterval(t.timer), t.triggerEvent("timeOut")) : formatTime();
  25. }, 1000);
  26. }
  27. }
  28. },
  29. data: {
  30. showTimeCount: ""
  31. },
  32. detached: function() {
  33. clearInterval(this.timer);
  34. },
  35. externalClasses: ["count-down"]
  36. })