ShopDialog.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. export default {
  54. name: 'ShopDialog',
  55. components: {
  56. CustomDialog
  57. },
  58. props: {
  59. visible: {
  60. type: Boolean,
  61. default: false
  62. }
  63. },
  64. data() {
  65. return {
  66. dialogVisible: false,
  67. currentTab: 0,
  68. tabs: ['种子', '道具', '钻石'],
  69. items: {
  70. 0: [
  71. {
  72. icon: '/static/items/seed1.png',
  73. name: '草莓种子',
  74. harvestTime: '160时',
  75. growthTime: '60时',
  76. yield: '10',
  77. price: 100,
  78. owned: 3,
  79. isNew: true
  80. },
  81. {
  82. icon: '/static/items/seed1.png',
  83. name: '草莓种子',
  84. harvestTime: '160时',
  85. growthTime: '60时',
  86. yield: '10',
  87. price: 100,
  88. owned: 3,
  89. isNew: true
  90. },
  91. {
  92. icon: '/static/items/seed1.png',
  93. name: '草莓种子',
  94. harvestTime: '160时',
  95. growthTime: '60时',
  96. yield: '10',
  97. price: 100,
  98. owned: 3,
  99. isNew: true
  100. }
  101. ],
  102. 1: [],
  103. 2: []
  104. }
  105. }
  106. },
  107. computed: {
  108. currentItems() {
  109. return this.items[this.currentTab]
  110. }
  111. },
  112. watch: {
  113. visible(val) {
  114. this.dialogVisible = val
  115. },
  116. dialogVisible(val) {
  117. this.$emit('update:visible', val)
  118. }
  119. },
  120. methods: {
  121. onClose() {
  122. this.dialogVisible = false
  123. },
  124. onItemClick(item) {
  125. this.$emit('buy', item)
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. @import './ShopDialog.scss';
  132. </style>