This commit is contained in:
Putoo
2026-06-27 16:32:11 +08:00
parent aefd94ccd6
commit 438027de21
9 changed files with 144 additions and 19 deletions

View File

@@ -3,11 +3,11 @@
*/
export class MessageExtend {
// 消息通知
static Notify(message: any, type?: 'primary' | 'success' | 'danger' | 'warning') {
static Notify(message: any, type?: 'primary' | 'success' | 'danger' | 'warning', time?: number) {
showNotify({
type: type,
message: message,
duration: 1500,
duration: time || 1500,
});
}

View File

@@ -20,8 +20,8 @@
<div class="common" v-if="data.code == 'Drug'">
<Abutton @click="ShowDrugBar">添加药品栏</Abutton>
</div>
<div class="common" v-if="useState==1">
<Abutton>使用物品</Abutton>
<div class="common" v-if="useState == 1">
<Abutton @click="showUseNumView = true">使用物品</Abutton>
</div>
</div>
@@ -39,6 +39,17 @@
<button class="ipt-btn" name="serch" @click="AddDrugBar" style="margin-top: 15px;">确认</button>
</div>
</GamePopup>
<GamePopup v-model:show="showUseNumView" title="使用物品">
<!-- 自定义内容 -->
<div class="common">
物品名称{{ data.goodsName }}<br>
物品数量{{ count }}<br>
</div>
<div class="common" style="text-align: center;">
使用数量<input type="number" class="search-ipt" v-model="useCount"><br>
<button class="ipt-btn" name="serch" @click="UseGoods" style="margin-top: 15px;">确认</button>
</div>
</GamePopup>
</template>
<script setup lang="ts">
@@ -49,6 +60,7 @@ definePageMeta({
const data = ref<any>({});
const count = ref(0);
const useState = ref(0);
const useCount = ref(1);
let goodsId = PageExtend.QueryString("id");
onMounted(async () => {
try {
@@ -99,4 +111,20 @@ const AddDrugBar = async () => {
}
}
const showUseNumView = ref(false);
const UseGoods = async () => {
MessageExtend.LoadingToast("使用中...");
let result = await GoodsService.UseGoods(Number(goodsId),useCount.value);
MessageExtend.LoadingClose();
if (result.code == 0) {
showUseNumView.value = false;
await BindData();
MessageExtend.Notify(result.msg, "success",5000);
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
}
</script>

View File

@@ -1,15 +1,16 @@
<template>
<div class="content">
我的物品.<Abutton @click="Refresh">刷新</Abutton> <br>
金元:{{ bagInfo.gold }}<br />
金贝:{{ bagInfo.cowry }} <br />
负重:{{ bagInfo.onWeight }}/{{ bagInfo.maxWeight }} <br />
金元{{ bagInfo.gold }}<br />
金贝{{ bagInfo.cowry }} <br />
负重{{ bagInfo.onWeight }}/{{ bagInfo.maxWeight }}&nbsp;<span v-if="bagInfo.onWeight > bagInfo.maxWeight"
style="color: red;font-weight: bold;">!</span><br />
{{ GameTool.FormatCopper(bagInfo.copper) }}<br />
<Abar href="/">交易记录</Abar><br>
<Abar href="/">赠送记录</Abar>
</div>
<div class="content">
<div class="common">
<div class="common" style="">
<Acheak @click="ChangeBag('0')" :on-value="type" on-cheak="0">装备</Acheak>|
<Acheak @click="ChangeBag('1')" :on-value="type" on-cheak="1">药品</Acheak>|

View File

@@ -7,4 +7,12 @@ export class GoodsService {
static async GetGoodsInfo(goodsId: number) {
return await ApiService.Request("get", "/Goods/GetGoodsInfo", { goodsId });
}
/**
* 使用物品
* GET /Goods/UseGoods
*/
static async UseGoods(goodsId: number, count: number) {
return await ApiService.Request("get", "/Goods/UseGoods", { goodsId, count });
}
}