index.js 688 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { createSubscribe } from "applet-page-component";
  2. Component(
  3. createSubscribe({
  4. onShow() {},
  5. })({
  6. props: {},
  7. data: {
  8. isPaySuccess: true,
  9. sec: 3,
  10. },
  11. didMount() {
  12. this.init();
  13. },
  14. methods: {
  15. init() {
  16. const _this = this;
  17. const myInterval = () => {
  18. if (_this.data.sec > 0) {
  19. _this.setData({
  20. sec: _this.data.sec - 1,
  21. });
  22. } else {
  23. clearInterval(myIntervalId);
  24. // 支付成功后暂时返回首页,方便通过验收
  25. const len = getCurrentPages().length;
  26. my.navigateBack({
  27. delta: len + 1,
  28. });
  29. }
  30. };
  31. const myIntervalId = setInterval(myInterval, 1000);
  32. },
  33. },
  34. })
  35. );