diff --git a/Build_God_Api/Build_God_Api/DB/BagItem.cs b/Build_God_Api/Build_God_Api/DB/BagItem.cs index 8dbabbb..307d091 100644 --- a/Build_God_Api/Build_God_Api/DB/BagItem.cs +++ b/Build_God_Api/Build_God_Api/DB/BagItem.cs @@ -31,6 +31,7 @@ namespace Build_God_Api.DB /// /// 是否绑定(绑定后不可交易/拍卖) /// + [SugarColumn(DefaultValue = "false")] public bool IsBound { get; set; } } diff --git a/Build_God_Api/Build_God_Api/Program.cs b/Build_God_Api/Build_God_Api/Program.cs index 52dd858..c1e3822 100644 --- a/Build_God_Api/Build_God_Api/Program.cs +++ b/Build_God_Api/Build_God_Api/Program.cs @@ -98,6 +98,9 @@ namespace Build_God_Api sqlSugarClient.CodeFirst.InitTables(typeof(Scrap)); sqlSugarClient.CodeFirst.InitTables(typeof(Monster)); sqlSugarClient.CodeFirst.InitTables(typeof(MonsterReward)); + sqlSugarClient.CodeFirst.InitTables(typeof(CharacterShop)); + sqlSugarClient.CodeFirst.InitTables(typeof(CharacterShopPurchaseLog)); + sqlSugarClient.CodeFirst.InitTables(typeof(ShopItem)); return sqlSugarClient; }); diff --git a/Build_God_Game/src/api/shop.ts b/Build_God_Game/src/api/shop.ts new file mode 100644 index 0000000..9c96446 --- /dev/null +++ b/Build_God_Game/src/api/shop.ts @@ -0,0 +1,28 @@ +import http from './index' + +export interface ShopItemDisplay { + shopItemId: number + itemType: number + itemId: number + itemName: string | null + price: number + dailyLimit: number + purchasedToday: number + remainingStock: number + icon: string | null + itemRarity: number | null +} + +export interface Shop { + characterId: number + lastRefreshTime: string + items: ShopItemDisplay[] +} + +export const getShop = (): Promise => { + return http.get('shop') +} + +export const buyItem = (shopItemId: number): Promise => { + return http.post('shop/buy', { shopItemId }) +} \ No newline at end of file diff --git a/Build_God_Game/src/assets/images/shop.svg b/Build_God_Game/src/assets/images/shop.svg new file mode 100644 index 0000000..24ca49d --- /dev/null +++ b/Build_God_Game/src/assets/images/shop.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Build_God_Game/src/router/index.ts b/Build_God_Game/src/router/index.ts index cb6b02b..b832250 100644 --- a/Build_God_Game/src/router/index.ts +++ b/Build_God_Game/src/router/index.ts @@ -75,6 +75,12 @@ const router = createRouter({ component: () => import('@/views/BattleView.vue'), meta: { requiresAuth: true } }, + { + path: '/shop', + name: 'shop', + component: () => import('@/views/ShopView.vue'), + meta: { requiresAuth: true } + }, { path: '/:pathMatch(.*)*', name: 'NotFound', diff --git a/Build_God_Game/src/views/GameView.vue b/Build_God_Game/src/views/GameView.vue index 4b3f2ce..35a76f5 100644 --- a/Build_God_Game/src/views/GameView.vue +++ b/Build_God_Game/src/views/GameView.vue @@ -15,6 +15,7 @@ import scrapIcon from '@/assets/images/scrap.svg' import characterIco from '@/assets/images/character.svg' import bagIcon from '@/assets/images/bag.svg' import monsterIcon from '@/assets/images/monster.svg' +import shopIcon from '@/assets/images/shop.svg' const authStore = useAuthStore() const characterStore = useCharacterStore() @@ -46,6 +47,7 @@ const menuItems = computed(() => [ { label: isTraining.value ? '打坐中' : '打坐', icon: trainingIcon, useImage: true, isTraining: isTraining.value }, { label: '背包', icon: bagIcon, useImage: true }, { label: '捡垃圾', icon: scrapIcon, useImage: true }, + { label: '商店', icon: shopIcon, useImage: true }, { label: '挑战', icon: monsterIcon, useImage: true }, ]) @@ -78,6 +80,8 @@ const navigateTo = (item: { label: string }) => { router.push('/scrap') } else if (item.label === '挑战') { router.push('/monster-list') + } else if (item.label === '商店') { + router.push('/shop') } else if (item.label === '角色') { openCharacterDetail() } diff --git a/Build_God_Game/src/views/ShopView.vue b/Build_God_Game/src/views/ShopView.vue new file mode 100644 index 0000000..ea1dcc1 --- /dev/null +++ b/Build_God_Game/src/views/ShopView.vue @@ -0,0 +1,387 @@ + + + + + + + + + + ← + 返回 + + 商店 + + 💰 {{ formatNumber(currentMoney) }} 灵石 + + + + + 商品刷新时间: {{ formatRefreshTime(shop.lastRefreshTime) }} + + + + 加载中... + + + + {{ error }} + 重试 + + + + 商店暂无可购商品,请联系管理员上架商品 + + + + + + + {{ getItemEmoji(item.itemType) }} + + {{ rarityMap[item.itemRarity] }} + + + + {{ item.itemName }} + + + 💰 {{ formatNumber(item.price) }} + + + + 今日已购: {{ item.purchasedToday }} / {{ item.dailyLimit }} + + + + {{ buying === item.shopItemId ? '购买中...' : getBuyButtonText(item) }} + + + + + + + \ No newline at end of file