bargain_record.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view class="bargain-code-container">
  3. <tabs :active="active" @change="onChange">
  4. <tab v-for="(item, index) in bargain" :key="item.type" :title="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. export default {
  12. data() {
  13. return {
  14. active: 0,
  15. bargainCodeType: bargainType.ALL,
  16. bargain: [{
  17. name: '全部',
  18. type: bargainType.ALL,
  19. ref_name: 'all',
  20. isShow: true
  21. }, {
  22. name: '砍价中',
  23. type: bargainType.BARGINNING,
  24. ref_name: 'barginning',
  25. isShow: false
  26. }, {
  27. name: "砍价成功",
  28. type: bargainType.SUCCESS,
  29. ref_name: 'success',
  30. isShow: false
  31. }, {
  32. name: '砍价失败',
  33. type: bargainType.FAIL,
  34. ref_name: 'fail',
  35. isShow: false
  36. }]
  37. }
  38. },
  39. onLoad(options) {
  40. },
  41. onReachBottom: function () {
  42. const {
  43. active, bargain
  44. } = this;
  45. let type = bargain[active].ref_name;
  46. let myComponent = this.$refs[type][0];
  47. if (myComponent.$getBargainActivityList) {
  48. myComponent.$getBargainActivityList();
  49. }
  50. },
  51. methods: {
  52. onChange(active) {
  53. const {bargain} = this;
  54. console.log(active)
  55. let type = bargain[active].ref_name
  56. let index = bargain.findIndex(item => {
  57. return item.ref_name == type;
  58. });
  59. if (index != -1) {
  60. this.bargain[index].isShow = true;
  61. console.log(this.bargain)
  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>