金诚优选前端代码
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.

91 lines
2.2 KiB

4 years ago
4 years ago
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 class="lf-row-center" style="margin-top: -100rpx;">
  7. <countdown-time minute="2" second="0" :showDay="false" :showHour="false" color="#FF9D9D" splitorColor="#FF9D9D"></countdown-time>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. import countdownTime from '@/components/uni-countdown/uni-countdown.vue';
  13. export default {
  14. components: {
  15. countdownTime
  16. },
  17. data(){
  18. return {
  19. user_id: 0,
  20. amount: 0,
  21. timer: null,
  22. num: 5,
  23. count: 0,
  24. overtime: false
  25. }
  26. },
  27. onLoad(options){
  28. this.user_id = options.user_id;
  29. this.amount = options.amount;
  30. this.startTimer();
  31. },
  32. onUnload(){
  33. if(this.timer){
  34. clearInterval(this.timer);
  35. this.timer = null;
  36. }
  37. },
  38. methods: {
  39. startTimer(){
  40. if(this.timer){
  41. clearInterval(this.timer);
  42. this.timer = null;
  43. }
  44. this.count++;
  45. let max_date = 60 * 2; // 两分钟
  46. let current_date = this.count * 5; // 当前秒数
  47. if(current_date >= max_date){
  48. this.overtime = true;
  49. }
  50. this.checkOrderPay();
  51. this.timer = setInterval(() => {
  52. this.num--;
  53. if(this.num <= 0){
  54. clearInterval(this.timer);
  55. this.timer = null;
  56. this.num = 5;
  57. this.startTimer();
  58. }
  59. }, 1000);
  60. },
  61. checkOrderPay(){
  62. let token = this.$cookieStorage.get('store_token');
  63. this.$http.get({
  64. api: 'api/supplier/offline/check_order_pay',
  65. data: {
  66. user_id: this.user_id
  67. },
  68. header: {
  69. token: token
  70. }
  71. }).then(res => {
  72. if(this.$isRight(res.data.data) && res.data.data.status == 2){
  73. let url = '/pages/business/payment/paystate';
  74. url += '?payState=1';
  75. url += '&amount='+ this.amount;
  76. this.$url(url, {type: 'redirect'});
  77. }else if(this.overtime || (res.data.data && res.data.data.status == 3)){
  78. let url = '/pages/business/payment/paystate';
  79. url += '?payState=0';
  80. this.$url(url, {type: 'redirect'});
  81. }
  82. })
  83. }
  84. }
  85. }
  86. </script>
  87. <style lang="scss" scoped="scoped">
  88. </style>