ShopDialog.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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="50rpx"
  8. background-color="transparent"
  9. @close="onClose"
  10. >
  11. <view class="shop-content">
  12. <!-- <view class="shop-tabs">
  13. <view
  14. v-for="(tab, index) in tabs"
  15. :key="index"
  16. class="tab-item"
  17. :class="{'active': currentTab === index}"
  18. @click="currentTab = index"
  19. >
  20. {{tab}}
  21. </view>
  22. </view> -->
  23. <view class="shop-header"></view>
  24. <view class="shop-name">{{shopName}}</view>
  25. <view class="shop-items">
  26. <view class="shop-item" v-for="(item, index) in currentItems" :key="index" @click="onItemClick(item)">
  27. <view class="item-card">
  28. <view class="new-tag" v-if="item.isNew">新品</view>
  29. <view class="item-left">
  30. <view class="item-grid">
  31. <image class="item-icon" :src="item.icon" mode="aspectFit"></image>
  32. <text class="owned-text">已有: {{item.owned}}</text>
  33. </view>
  34. </view>
  35. <view class="item-center">
  36. <text class="item-name">{{item.name}}</text>
  37. <view class="item-details">
  38. <text class="detail-text">{{item.detail}}</text>
  39. </view>
  40. </view>
  41. <view class="item-right">
  42. <view class="buy-btn">
  43. <view class="item-price">
  44. <image class="currency-icon" src="/static/island/UI/wd_icon_xingyuan.png" mode="aspectFit"></image>
  45. <text>{{item.price}}</text>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </custom-dialog>
  54. </template>
  55. <script>
  56. import CustomDialog from '../CustomDialog/CustomDialog.vue'
  57. export default {
  58. name: 'ShopDialog',
  59. components: {
  60. CustomDialog
  61. },
  62. props: {
  63. visible: {
  64. type: Boolean,
  65. default: false
  66. },
  67. shopName: {
  68. type: String,
  69. default: '商店'
  70. }
  71. },
  72. data() {
  73. return {
  74. dialogVisible: false,
  75. currentTab: 0,
  76. tabs: ['种子', '道具', '钻石'],
  77. items: {
  78. 0: [
  79. {
  80. icon: '/static/island/items/item_wood1.png',
  81. name: '草莓种子',
  82. detail: '收获期: 160时\n成长期: 60时\n产量: 10',
  83. price: 100,
  84. owned: 3,
  85. isNew: false
  86. },
  87. {
  88. icon: '/static/island/items/item_wood2.png',
  89. name: '草莓种子',
  90. detail: '收获期: 160时\n成长期: 60时\n产量: 10',
  91. price: 100,
  92. owned: 3,
  93. isNew: false
  94. },
  95. {
  96. icon: '/static/island/items/item_mine1.png',
  97. name: '草莓种子',
  98. detail: '收获期: 160时\n成长期: 60时\n产量: 10',
  99. price: 100,
  100. owned: 3,
  101. isNew: false
  102. },
  103. {
  104. icon: '/static/island/items/item_mine2.png',
  105. name: '铁矿石',
  106. detail: '收获期: 160时\n成长期: 60时\n产量: 10',
  107. price: 100,
  108. owned: 3,
  109. isNew: false
  110. },
  111. {
  112. icon: '/static/island/items/item_axe1.png',
  113. name: '斧头',
  114. detail: '收获期: 160时\n成长期: 60时\n产量: 10',
  115. price: 100,
  116. owned: 3,
  117. isNew: false
  118. }
  119. ],
  120. 1: [],
  121. 2: []
  122. }
  123. }
  124. },
  125. computed: {
  126. currentItems() {
  127. return this.items[this.currentTab]
  128. }
  129. },
  130. watch: {
  131. visible(val) {
  132. this.dialogVisible = val
  133. },
  134. dialogVisible(val) {
  135. this.$emit('update:visible', val)
  136. }
  137. },
  138. methods: {
  139. onClose() {
  140. this.dialogVisible = false
  141. },
  142. onItemClick(item) {
  143. this.$emit('buy', item)
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. @import './ShopDialog.scss';
  150. </style>