bargain_code.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <view class="bargain-code-container">
  3. <tabs :active="active" @change="onChange" :isScroll="false">
  4. <tab v-for="(item, index) in bargain" :key="item.type" :name="item.name" >
  5. <bargain-list :ref="item.ref_name" :bargainType="item.type" v-if="item.isShow" />
  6. </tab>
  7. </tabs>
  8. </view>
  9. </template>
  10. <script>
  11. import {bargainType} from "@/utils/type"
  12. export default {
  13. data() {
  14. return {
  15. active: 0,
  16. bargainCodeType: bargainType.ALL,
  17. bargain: [{
  18. name: '全部',
  19. type: bargainType.ALL,
  20. ref_name: 'all',
  21. isShow: true
  22. }, {
  23. name: '砍价中',
  24. type: bargainType.BARGINNING,
  25. ref_name: 'barginning',
  26. isShow: false
  27. }, {
  28. name: "砍价成功",
  29. type: bargainType.SUCCESS,
  30. ref_name: 'success',
  31. isShow: false
  32. }, {
  33. name: '砍价失败',
  34. type: bargainType.FAIL,
  35. ref_name: 'fail',
  36. isShow: false
  37. }]
  38. }
  39. },
  40. onLoad(options) {
  41. },
  42. onReachBottom: function () {
  43. const {
  44. active, bargain
  45. } = this;
  46. let type = bargain[active].ref_name;
  47. let myComponent = this.$refs[type][0];
  48. if (myComponent.$getBargainActivityList) {
  49. myComponent.$getBargainActivityList();
  50. }
  51. },
  52. methods: {
  53. onChange(active) {
  54. const {bargain} = this;
  55. console.log(active)
  56. let type = bargain[active].ref_name
  57. let index = bargain.findIndex(item => {
  58. return item.ref_name == type;
  59. });
  60. if (index != -1) {
  61. this.bargain[index].isShow = true;
  62. this.active = index;
  63. }
  64. this.$nextTick(() => {
  65. console.log(this.$refs, "refs", type)
  66. console.log('this.$refs[all]', this.$refs['all'])
  67. if(this.$refs[type] && this.$refs[type][0].$getBargainActivityList) {
  68. this.$refs[type][0].$getBargainActivityList();
  69. }
  70. })
  71. }
  72. }
  73. }
  74. </script>