소스 검색

任务和背包

ck@123911.net 2 달 전
부모
커밋
0a53656977
5개의 변경된 파일94개의 추가작업 그리고 44개의 파일을 삭제
  1. 84 41
      components/dialogs/BackpackDialog.vue
  2. 3 0
      manifest.json
  3. 5 1
      pages/isLand/TaskDialog.vue
  4. 1 1
      pages/isLand/homeLand.vue
  5. 1 1
      pages/isLand/mainLand.vue

+ 84 - 41
components/dialogs/BackpackDialog.vue

@@ -63,43 +63,8 @@ export default {
     return {
       dialogVisible: false,
       selectedIndex: -1,
-      items: [
-        { 
-          icon: '/static/island/items/item_wood1.png', 
-          count: 999,
-          name: '木材',
-          description: '这是一个木材,可以用来制作各种物品',
-          price: 100
-        },
-        { 
-          icon: '/static/island/items/item_wood2.png', 
-          count: 999,
-          name: '高级木材',
-          description: '这是一个高级木材,可以用来制作高级物品',
-          price: 200
-        },
-        { 
-          icon: '/static/island/items/item_mine1.png', 
-          count: 999,
-          name: '矿石',
-          description: '这是一个矿石,可以用来制作金属物品',
-          price: 150
-        },
-        { 
-          icon: '/static/island/items/item_mine2.png', 
-          count: 999,
-          name: '高级矿石',
-          description: '这是一个高级矿石,可以用来制作高级金属物品',
-          price: 300
-        },
-        { 
-          icon: '/static/island/items/item_axe1.png', 
-          count: 999,
-          name: '斧头',
-          description: '这是一个斧头,可以用来砍伐树木',
-          price: 500
-        }
-      ]
+      items: [],
+      loading: false
     }
   },
   computed: {
@@ -113,8 +78,7 @@ export default {
     visible(val) {
       this.dialogVisible = val
       if(val) {
-        // 默认选中第一个有道具的格子
-        this.selectedIndex = this.items.length > 0 ? 0 : -1
+        this.fetchBagList()
       }
     },
     dialogVisible(val) {
@@ -122,6 +86,51 @@ export default {
     }
   },
   methods: {
+    fetchBagList() {
+      this.loading = true
+      uni.request({
+        url: this.$apiHost + '/Game/get_bag_list',
+        method: 'GET',
+        data: {
+          uuid: getApp().globalData.uuid,
+        },
+          header: {
+            'Content-Type': 'application/x-www-form-urlencoded',
+            'sign': getApp().globalData.headerSign,
+          },
+        success: (res) => {
+          if (res.data.code === 0) {
+            this.items = res.data.data.bagList.map(item => ({
+              id: item.id,
+              tid: item.tid,
+              type: item.type,
+              count: item.num,
+              name: item.name,
+              icon: item.image,
+              description: `这是一个${item.name},数量:${item.num}`,
+              price: item.price // 这里可以根据实际需求设置价格
+            }))
+            // 默认选中第一个有道具的格子
+            this.selectedIndex = this.items.length > 0 ? 0 : -1
+          } else {
+            uni.showToast({
+              title: res.data.msg || '获取背包数据失败',
+              icon: 'none'
+            })
+          }
+        },
+        fail: (err) => {
+          console.error('获取背包数据失败:', err)
+          uni.showToast({
+            title: '获取背包数据失败',
+            icon: 'none'
+          })
+        },
+        complete: () => {
+          this.loading = false
+        }
+      })
+    },
     onClose() {
       this.dialogVisible = false
     },
@@ -144,8 +153,42 @@ export default {
         cancelText: '取消',
         success: (res) => {
           if(res.confirm) {
-            // TODO: 处理出售逻辑
-            this.$emit('sell', item)
+            uni.request({
+              url: this.$apiHost + '/Game/sell_bag_item',
+              method: 'POST',
+              data: {
+                uuid: getApp().globalData.uuid,
+                bag_id: item.id
+              },
+              header: {
+                'Content-Type': 'application/x-www-form-urlencoded',
+                'sign': getApp().globalData.headerSign,
+              },
+              success: (res) => {
+                if (res.data.code === 0) {
+                  uni.showToast({
+                    title: '出售成功',
+                    icon: 'success'
+                  })
+                  // 刷新背包列表
+                  this.fetchBagList()
+                  // 通知父组件更新铃钱
+                  this.$emit('money-change', res.data.data.money)
+                } else {
+                  uni.showToast({
+                    title: res.data.msg || '出售失败',
+                    icon: 'none'
+                  })
+                }
+              },
+              fail: (err) => {
+                console.error('出售失败:', err)
+                uni.showToast({
+                  title: '出售失败',
+                  icon: 'none'
+                })
+              }
+            })
           }
         }
       })

+ 3 - 0
manifest.json

@@ -83,6 +83,9 @@
                         "__platform__" : [ "android" ],
                         "appid" : "wxfed977c88f539599",
                         "UniversalLinks" : ""
+                    },
+                    "alipay" : {
+                        "__platform__" : [ "ios", "android" ]
                     }
                 },
                 "speech" : {},

+ 5 - 1
pages/isLand/TaskDialog.vue

@@ -55,6 +55,10 @@ export default {
     visible: {
       type: Boolean,
       default: false
+    },
+    type: {
+      type: String,
+      default: 'main'
     }
   },
   data() {
@@ -85,7 +89,7 @@ export default {
           method: 'GET',
           data: {
             uuid: getApp().globalData.uuid,
-            type: 'main'
+            type: this.type
           },
           header: {
             'Content-Type': 'application/x-www-form-urlencoded',

+ 1 - 1
pages/isLand/homeLand.vue

@@ -55,7 +55,7 @@
     <backpack-dialog :visible.sync="inventoryVisible" @close="onInventoryClose"></backpack-dialog>
     <character-dialog :visible.sync="characterVisible" @close="onCharacterClose"></character-dialog>
     <shop-dialog :visible.sync="shopVisible" @close="onShopClose" @buy="onShopBuy"></shop-dialog>
-    <task-dialog class="task-dialog" :visible.sync="taskVisible" @close="onTaskClose"></task-dialog>
+    <task-dialog class="task-dialog" :visible.sync="taskVisible" @close="onTaskClose" type="main"></task-dialog>
     
     <!-- 引导对话组件 -->
     <talk-guide 

+ 1 - 1
pages/isLand/mainLand.vue

@@ -99,7 +99,7 @@
     <character-dialog :visible.sync="characterVisible" @close="onCharacterClose"></character-dialog>
     <shop-dialog :visible.sync="shopVisible" :shopName="currentShopName" @close="onShopClose" @buy="onShopBuy"></shop-dialog>
     <hua-tian :visible.sync="huaTianVisible" @close="onHuaTianClose" ref="huaTian"></hua-tian>
-    <task-dialog :visible.sync="taskDialogVisible" @close="onTaskDialogClose"></task-dialog>
+    <task-dialog :visible.sync="taskDialogVisible" @close="onTaskDialogClose" type="huatian"></task-dialog>
 
     <!-- 引导管理器 -->
     <guide-manager ref="guideManager"></guide-manager>