This commit is contained in:
Putoo
2026-05-28 19:06:40 +08:00
parent 0d5443ef36
commit 69ae1e3174
39 changed files with 1742 additions and 31 deletions

View File

@@ -1,3 +1,115 @@
<template>
</template>
<div class="content">
商城<br>
金元:{{ gold }}<br>
金贝:{{ cowry }}<br>
</div>
<div class="content">
<Acheak @click="Change('0')" :on-value="type" on-cheak="0">金贝</Acheak> |
<Acheak @click="Change('1')" :on-value="type" on-cheak="1">金元</Acheak>
</div>
<div class="content">
<div class="common">名称|价格</div>
<div class="item" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
<Abar :href='"/prop/equ?id=" + item.parameter' v-if="item.type == 'Equ'">
{{ item.name }}({{ GameTool.GetCurrencyNameAll(item.price, item.payType) }})</Abar>
<Abar :href='"/prop/goods?id=" + item.parameter' v-else>
{{ item.name }}({{ GameTool.GetCurrencyNameAll(item.price, item.payType) }})</Abar>
[<Abutton @click="ShopView(item)">购买</Abutton>]
</div>
</div>
<div class="content">
<Pagination :currentPage="currentPage" :limit="10" :total="total" @pageChange="handlePageChange" />
</div>
<!-- 购买 -->
<GamePopup v-model:show="showBuy" title="【购买】">
<!-- 自定义内容 -->
<div class="common">
物品名称{{ showGoods.name }}<br>
购买价格{{ GameTool.GetCurrencyNameAll(showGoods.price, showGoods.payType) }}<br>
</div>
<div class="common" style="text-align: center;">
购买数量<input type="number" class="search-ipt" v-model="count"><br>
<button class="ipt-btn" name="serch" @click="ShopOk" style="margin-top: 15px;">确认</button>
</div>
</GamePopup>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
})
const type = ref('0');
const gold = ref(0);
const cowry = ref(0);
const currentPage = ref<number>(1);
const total = ref<number>(0);
const data = ref<Array<any>>([]);
const showBuy = ref(false);
const showGoods = ref<any>({});
const count = ref(1);
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async (): Promise<void> => {
let result = await MallService.GetMall(type.value, currentPage.value);
if (result.code == 0) {
data.value = result.data.data;
total.value = result.data.total;
gold.value = result.data.gold;
cowry.value = result.data.cowry;
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
const Change = async (_type: string): Promise<void> => {
currentPage.value = 1;
type.value = _type;
await BindData();
}
/**翻页 */
const handlePageChange = async (page: number): Promise<void> => {
currentPage.value = page;
await BindData();
};
//购买
const ShopView = (info: any) => {
showGoods.value = info;
showBuy.value = true;
count.value = 1;
}
const ShopOk = async (): Promise<void> => {
if (count.value < 1 || count.value > 99) {
MessageExtend.ShowToast("每次购买数量在1~99哦.");
return;
}
MessageExtend.LoadingToast("购买中...");
let result = await MallService.Buy(showGoods.value.mallId, count.value);
MessageExtend.LoadingClose();
if (result.code == 0) {
showBuy.value = false;
MessageExtend.Notify(`成功购买${showGoods.value.name}×${count.value}`, "success");
await BindData();
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
</script>