group-code.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <view class="flex-common-css">
  3. <Nav title=" " leftIconColor="#333" titleColor="#333" bgckgroundBox='transparent'></Nav>
  4. <scroll-view :scroll-y="true" class="scroll-view-css p-24 box-border-box" @scrolltolower="scrolltolower">
  5. <view class="text-align-center fs-34 fc-3 fw-600 mb-20">
  6. {{codeData.goods_name || ''}}
  7. </view>
  8. <view class="fs-26 fc-9 mb-20 text-align-center">
  9. 有效期:{{codeData.end_time || ''}}
  10. </view>
  11. <view class="bgc-f b-rad-20 p-24 box-border-box">
  12. <view class="fs-30 fc-3 fw-500 mb-20">
  13. 券码 <span class="fs-26 fc-9" v-if="codeData.code">({{codeData.code.length || ''}}张)</span>
  14. </view>
  15. <view class="align-items-center flex-wrap-wrap">
  16. <view class="" v-for="(item,index) in codeData.code" :key="index">
  17. <view class="fs-26 fw-600 mr-20" v-show="index<=2">
  18. {{item.code}}
  19. </view>
  20. </view>
  21. </view>
  22. <view class="fs-28">
  23. ...
  24. </view>
  25. <view class="flex-direction align-items-center flex-justify-center">
  26. <canvasCode ref="canvasCodeRef" class="mb-20"></canvasCode>
  27. <view class="but bgc-41ABF5 b-rad-200 fs-30 fc-f text-align-center" @click="groupOrderCode()">
  28. 刷新券码
  29. </view>
  30. </view>
  31. </view>
  32. </scroll-view>
  33. </view>
  34. </template>
  35. <script>
  36. import canvasCode from '../components/canvas-code/code.vue'
  37. import {
  38. groupOrderCode
  39. } from "@/api/groupOrder.js"
  40. import tools from "@/service/tools";
  41. export default {
  42. components: {
  43. canvasCode
  44. },
  45. data() {
  46. return {
  47. order_id: 0,
  48. codeData: {
  49. code: []
  50. },
  51. time: ''
  52. };
  53. },
  54. onLoad(data) {
  55. if (data) {
  56. this.order_id = data.order_id
  57. this.groupOrderCode()
  58. this.time = setInterval(() => {
  59. this.groupOrderCode()
  60. }, 5000)
  61. }
  62. },
  63. onUnload() {
  64. clearInterval(this.time)
  65. },
  66. mounted() {},
  67. methods: {
  68. scrolltolower() {
  69. console.log('触底');
  70. },
  71. groupOrderCode() {
  72. groupOrderCode({
  73. order_id: this.order_id
  74. }).then((res) => {
  75. if (res.code === 1) {
  76. if (res.data.code.length === 0) {
  77. tools.error('暂无可用券')
  78. setTimeout(() => {
  79. tools.leftClick()
  80. }, 1000)
  81. }
  82. if (this.codeData.code.length != 0) {
  83. if (this.codeData.code.length == res.data.code.length) {
  84. return
  85. }
  86. }
  87. this.codeData = res.data
  88. this.$refs.canvasCodeRef.getCode(this.codeData.code[0].code)
  89. } else {
  90. tools.leftClick()
  91. }
  92. })
  93. }
  94. },
  95. }
  96. </script>
  97. <style lang="scss" scoped>
  98. .but {
  99. width: 100%;
  100. padding: 15rpx 0;
  101. box-sizing: border-box;
  102. }
  103. </style>