ShopDialog.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. {
  122. icon: '/static/island/items/item_wood1.png',
  123. name: '杂木材',
  124. detail: '普通木材,用来造普通的东西',
  125. price: 100,
  126. owned: 3,
  127. isNew: false
  128. },
  129. {
  130. icon: '/static/island/items/item_wood2.png',
  131. name: '松木材',
  132. detail: '松树木材,比一般木材硬一点,可以用来造强度更好的东西',
  133. price: 100,
  134. owned: 3,
  135. isNew: false
  136. },
  137. {
  138. icon: '/static/island/items/item_mine1.png',
  139. name: '石材',
  140. detail: '匀称规整的石头,适合用来造房子和石器',
  141. price: 100,
  142. owned: 3,
  143. isNew: false
  144. },
  145. {
  146. icon: '/static/island/items/item_mine2.png',
  147. name: '铁矿石',
  148. detail: '铁矿石,可以练出铁锭',
  149. price: 100,
  150. owned: 3,
  151. isNew: false
  152. },
  153. {
  154. icon: '/static/island/items/item_blueprint1.png',
  155. name: '斧头图纸',
  156. detail: '制造斧头的图纸,购买学习后可以制作斧头',
  157. price: 100,
  158. owned: 3,
  159. isNew: false
  160. }
  161. ],
  162. 2: []
  163. }
  164. }
  165. },
  166. computed: {
  167. currentItems() {
  168. return this.items[this.currentTab]
  169. }
  170. },
  171. watch: {
  172. visible(val) {
  173. this.dialogVisible = val
  174. },
  175. dialogVisible(val) {
  176. this.$emit('update:visible', val)
  177. },
  178. shopName: {
  179. immediate: true,
  180. handler(val) {
  181. if (val === '材料商店') {
  182. this.currentTab = 1
  183. } else {
  184. this.currentTab = 0
  185. }
  186. }
  187. }
  188. },
  189. methods: {
  190. onClose() {
  191. this.dialogVisible = false
  192. },
  193. onItemClick(item) {
  194. this.$emit('buy', item)
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="scss" scoped>
  200. @import './ShopDialog.scss';
  201. </style>