|
@@ -41,12 +41,20 @@
|
|
|
|
|
|
<!-- 选中工具的详情 -->
|
|
|
<view class="tool-details" v-if="selectedTool">
|
|
|
- <text class="tool-description">{{ selectedTool.description }}</text>
|
|
|
+ <text class="tool-description">{{ getToolDescription(selectedTool) }}</text>
|
|
|
<view class="materials-row">
|
|
|
<view class="materials">
|
|
|
- <view v-for="(cost, index) in selectedTool.costs" :key="index" class="material-item">
|
|
|
- <image :src="index === 0 ? '/static/island/items/item_wood1.png' : index === 1 ? '/static/island/items/item_mine1.png' : '/static/island/UI/wd_icon_xingyuan.png'" mode="aspectFit" class="material-icon"></image>
|
|
|
- <text class="material-count">{{ cost }}</text>
|
|
|
+ <view class="material-item">
|
|
|
+ <image src="/static/island/items/item_wood1.png" mode="aspectFit" class="material-icon"></image>
|
|
|
+ <text class="material-count">{{ selectedTool.price }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="material-item">
|
|
|
+ <image src="/static/island/items/item_mine1.png" mode="aspectFit" class="material-icon"></image>
|
|
|
+ <text class="material-count">{{ selectedTool.limit_time }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="material-item">
|
|
|
+ <image src="/static/island/UI/wd_icon_xingyuan.png" mode="aspectFit" class="material-icon"></image>
|
|
|
+ <text class="material-count">{{ selectedTool.num_out }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="craft-btn" @click="onCraft">打造</view>
|
|
@@ -74,32 +82,8 @@ export default {
|
|
|
startX: 0,
|
|
|
lastX: 0,
|
|
|
isDragging: false,
|
|
|
- tools: [
|
|
|
- {
|
|
|
- name: '捕虫网',
|
|
|
- image: '/static/island/items/item_bugnet1.png',
|
|
|
- description: '可以让你用来捕捉大虫',
|
|
|
- costs: [2000, 800, 920]
|
|
|
- },
|
|
|
- {
|
|
|
- name: '石镐',
|
|
|
- image: '/static/island/items/item_stonepickaxe1.png',
|
|
|
- description: '用来挖掘矿石',
|
|
|
- costs: [2000, 8000, 1300]
|
|
|
- },
|
|
|
- {
|
|
|
- name: '铲子',
|
|
|
- image: '/static/island/items/item_shovel1.png',
|
|
|
- description: '用来挖掘地面',
|
|
|
- costs: [3000, 7200, 2600]
|
|
|
- },
|
|
|
- {
|
|
|
- name: '斧子',
|
|
|
- image: '/static/island/items/item_axe1.png',
|
|
|
- description: '用来砍伐树木',
|
|
|
- costs: [5500, 10000, 5800]
|
|
|
- }
|
|
|
- ]
|
|
|
+ tools: [],
|
|
|
+ loading: false
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -107,6 +91,13 @@ export default {
|
|
|
return this.tools[this.selectedToolIndex]
|
|
|
}
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ visible(val) {
|
|
|
+ if (val) {
|
|
|
+ this.fetchCraftingData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
onClose() {
|
|
|
this.$emit('close')
|
|
@@ -117,7 +108,7 @@ export default {
|
|
|
onCraft() {
|
|
|
// TODO: 实现制造逻辑
|
|
|
uni.showToast({
|
|
|
- title: `正在制造${this.selectedTool.name}`,
|
|
|
+ title: `你的材料不足`,
|
|
|
icon: 'none'
|
|
|
})
|
|
|
},
|
|
@@ -160,6 +151,65 @@ export default {
|
|
|
});
|
|
|
this.isDragging = false;
|
|
|
e.preventDefault && e.preventDefault();
|
|
|
+ },
|
|
|
+ // 获取制造工具数据
|
|
|
+ async fetchCraftingData() {
|
|
|
+ if (this.loading) return
|
|
|
+ this.loading = true
|
|
|
+ try {
|
|
|
+ uni.request({
|
|
|
+ url: this.$apiHost + '/Game/get_crafting_list',
|
|
|
+ method: 'GET',
|
|
|
+ data: {
|
|
|
+ uuid: getApp().globalData.uuid
|
|
|
+ },
|
|
|
+ header: {
|
|
|
+ 'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
+ 'sign': getApp().globalData.headerSign,
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ console.log("制造工具数据:", res.data)
|
|
|
+ if (res.data && res.data.code === 0) {
|
|
|
+ this.tools = res.data.list || []
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: res.data?.msg || '获取制造工具数据失败',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ console.error('获取制造工具数据异常', err)
|
|
|
+ uni.showToast({
|
|
|
+ title: '网络异常,请重试',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取制造工具数据异常', error)
|
|
|
+ uni.showToast({
|
|
|
+ title: '网络异常,请重试',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 获取工具描述
|
|
|
+ getToolDescription(tool) {
|
|
|
+ if (!tool) return ''
|
|
|
+
|
|
|
+ const descriptions = {
|
|
|
+ 1: '可以让你用来捕捉大虫',
|
|
|
+ 2: '用来挖掘矿石',
|
|
|
+ 3: '用来挖掘地面',
|
|
|
+ 4: '用来砍伐树木'
|
|
|
+ }
|
|
|
+
|
|
|
+ return descriptions[tool.id] || '工具描述'
|
|
|
}
|
|
|
}
|
|
|
}
|