ShopDialog.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <custom-dialog
  3. :visible.sync="dialogVisible"
  4. title=""
  5. content-width="720rpx"
  6. closeImg="/static/island/UI/btn_close.png"
  7. closeImgTop="0rpx"
  8. @close="onClose"
  9. >
  10. <view class="shop-content">
  11. <view class="shop-tabs">
  12. <view
  13. v-for="(tab, index) in tabs"
  14. :key="index"
  15. class="tab-item"
  16. :class="{'active': currentTab === index}"
  17. @click="currentTab = index"
  18. >
  19. {{tab}}
  20. </view>
  21. </view>
  22. <view class="shop-items">
  23. <view class="shop-item" v-for="(item, index) in currentItems" :key="index" @click="onItemClick(item)">
  24. <view class="item-card">
  25. <view class="new-tag" v-if="item.isNew">新品</view>
  26. <view class="item-left">
  27. <image class="item-icon" :src="item.icon" mode="aspectFit"></image>
  28. <text class="owned-text">已持有: {{item.owned}}</text>
  29. </view>
  30. <view class="item-info">
  31. <text class="item-name">{{item.name}}</text>
  32. <view class="item-details">
  33. <text class="detail-text">收获期: {{item.harvestTime}}</text>
  34. <text class="detail-text">成长期: {{item.growthTime}}</text>
  35. <text class="detail-text">产量: {{item.yield}}</text>
  36. </view>
  37. <view class="item-bottom">
  38. <view class="item-price">
  39. <image class="currency-icon" src="/static/currency/coin.png" mode="aspectFit"></image>
  40. <text>{{item.price}}</text>
  41. </view>
  42. <button class="buy-btn">购买</button>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </custom-dialog>
  50. </template>
  51. <script>
  52. import CustomDialog from '../CustomDialog/CustomDialog.vue'
  53. import './ShopDialog.scss'
  54. export default {
  55. name: 'ShopDialog',
  56. components: {
  57. CustomDialog
  58. },
  59. props: {
  60. visible: {
  61. type: Boolean,
  62. default: false
  63. }
  64. },
  65. data() {
  66. return {
  67. dialogVisible: false,
  68. currentTab: 0,
  69. tabs: ['种子', '道具', '钻石'],
  70. items: {
  71. 0: [
  72. {
  73. icon: '/static/items/seed1.png',
  74. name: '草莓种子',
  75. harvestTime: '160时',
  76. growthTime: '60时',
  77. yield: '10',
  78. price: 100,
  79. owned: 3,
  80. isNew: true
  81. },
  82. {
  83. icon: '/static/items/seed1.png',
  84. name: '草莓种子',
  85. harvestTime: '160时',
  86. growthTime: '60时',
  87. yield: '10',
  88. price: 100,
  89. owned: 3,
  90. isNew: true
  91. },
  92. {
  93. icon: '/static/items/seed1.png',
  94. name: '草莓种子',
  95. harvestTime: '160时',
  96. growthTime: '60时',
  97. yield: '10',
  98. price: 100,
  99. owned: 3,
  100. isNew: true
  101. }
  102. ],
  103. 1: [],
  104. 2: []
  105. }
  106. }
  107. },
  108. computed: {
  109. currentItems() {
  110. return this.items[this.currentTab]
  111. }
  112. },
  113. watch: {
  114. visible(val) {
  115. this.dialogVisible = val
  116. },
  117. dialogVisible(val) {
  118. this.$emit('update:visible', val)
  119. }
  120. },
  121. methods: {
  122. onClose() {
  123. this.dialogVisible = false
  124. },
  125. onItemClick(item) {
  126. this.$emit('buy', item)
  127. }
  128. }
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. @import './ShopDialog.scss';
  133. </style>