金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
1.8 KiB

4 years ago
  1. <template>
  2. <view>
  3. <lf-nav title="等待用户支付" :showIcon="true" bgColor="#fff"></lf-nav>
  4. <view style="height: 50rpx;"></view>
  5. <lf-nocontent src="/static/images/empty.png" text="等待用户支付…"></lf-nocontent>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. data(){
  11. return {
  12. user_id: 0,
  13. amount: 0,
  14. timer: null,
  15. num: 5,
  16. count: 0,
  17. overtime: false
  18. }
  19. },
  20. onLoad(options){
  21. this.user_id = options.user_id;
  22. this.amount = options.amount;
  23. this.startTimer();
  24. },
  25. onUnload(){
  26. if(this.timer){
  27. clearInterval(this.timer);
  28. this.timer = null;
  29. }
  30. },
  31. methods: {
  32. startTimer(){
  33. if(this.timer){
  34. clearInterval(this.timer);
  35. this.timer = null;
  36. }
  37. this.count++;
  38. let max_date = 60 * 2; // 两分钟
  39. let current_date = this.count * 5; // 当前秒数
  40. if(current_date >= max_date){
  41. this.overtime = true;
  42. }
  43. this.checkOrderPay();
  44. this.timer = setInterval(() => {
  45. this.num--;
  46. if(this.num <= 0){
  47. clearInterval(this.timer);
  48. this.timer = null;
  49. this.num = 5;
  50. this.startTimer();
  51. }
  52. }, 1000);
  53. },
  54. checkOrderPay(){
  55. let token = this.$cookieStorage.get('store_token');
  56. this.$http.get({
  57. api: 'api/supplier/offline/check_order_pay',
  58. data: {
  59. user_id: this.user_id
  60. },
  61. header: {
  62. token: token
  63. }
  64. }).then(res => {
  65. if(this.$isRight(res.data.data)){
  66. let url = '/pages/business/payment/paystate';
  67. url += '?payState=1';
  68. url += '&amount='+ this.amount;
  69. this.$url(url, {type: 'redirect'});
  70. }else if(this.overtime){
  71. let url = '/pages/business/payment/paystate';
  72. url += '?payState=0';
  73. this.$url(url, {type: 'redirect'});
  74. }
  75. })
  76. }
  77. }
  78. }
  79. </script>
  80. <style lang="scss" scoped="scoped">
  81. </style>