recommend.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <u-popup v-model="show" mode="bottom" closeable border-radius="14" safe-area-inset-bottom :duration="100">
  3. <!-- 内容列表 -->
  4. <view class="content-wrapper">
  5. <tabs :current="active" @change="changeTabs" height="100" :is-scroll="false" width="400rpx" :showBar="false" :async="isAsync">
  6. <tab name="宝贝">
  7. <goods @change="handleGoods" v-model="goodsData" :i="0" :index="active"></goods>
  8. </tab>
  9. <tab name="店铺">
  10. <shop @change="handleShop" v-model="shopData" :i="1" :index="active"></shop>
  11. </tab>
  12. </tabs>
  13. </view>
  14. <!-- 底部 -->
  15. <view class="recommend-footer flex">
  16. <button class="white br60 bg-primary btn" @click="confirm">确认</button>
  17. </view>
  18. </u-popup>
  19. </template>
  20. <script>
  21. import Goods from "./goods.vue"
  22. import Shop from "./shop.vue"
  23. export default {
  24. name: "recommend",
  25. components: {
  26. Goods,
  27. Shop
  28. },
  29. props: {
  30. value: {
  31. type: Boolean
  32. },
  33. goods: {
  34. type: [Object, Array]
  35. },
  36. shop: {
  37. type: [Object, Array]
  38. }
  39. },
  40. data() {
  41. return {
  42. list: [{
  43. name: '宝贝'
  44. }, {
  45. name: '店铺'
  46. }],
  47. active: 0,
  48. goodsData: [],
  49. shopData: [],
  50. isAsync: true // 是否异步
  51. }
  52. },
  53. computed: {
  54. // 弹窗Popup显示状态
  55. show: {
  56. get: function() {
  57. return this.value
  58. },
  59. set: function(value) {
  60. this.$emit('input', value)
  61. }
  62. }
  63. },
  64. watch: {
  65. goods(val) {
  66. this.active = 0;
  67. this.goodsData = val;
  68. console.log(this.goodsData)
  69. },
  70. shop(val) {
  71. this.active = 1;
  72. this.shopData = val
  73. }
  74. },
  75. methods: {
  76. changeTabs(event) {
  77. if(this.goodsData.length!=0 || this.shopData.length!=0) return this.$toast({title: '不能同时选择宝贝/店铺'})
  78. this.isAsync = false
  79. this.active = event
  80. this.isAsync = true
  81. },
  82. handleGoods(event) {
  83. this.goodsData = event;
  84. },
  85. handleShop(event) {
  86. this.shopData = event;
  87. },
  88. confirm() {
  89. if( this.active == 0 ) {
  90. this.$emit('change', {
  91. type: 0,
  92. data: this.goodsData
  93. })
  94. } else {
  95. this.$emit('change', {
  96. type: 1,
  97. data: this.shopData
  98. })
  99. }
  100. this.$emit('input', false)
  101. }
  102. }
  103. }
  104. </script>
  105. <style lang="scss">
  106. .bb {
  107. border-bottom: 1px solid $-color-body;
  108. }
  109. .content-wrapper {
  110. height: 900rpx;
  111. }
  112. .recommend-footer {
  113. width: 100%;
  114. height: 100rpx;
  115. padding: 0 30rpx;
  116. box-shadow: 0 -4rpx 10rpx rgba(#000000, .1);
  117. .btn {
  118. width: 100%;
  119. height: 82rpx;
  120. font-size: 32rpx;
  121. line-height: 82rpx;
  122. }
  123. }
  124. </style>