You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
250 lines
6.2 KiB
250 lines
6.2 KiB
|
8 months ago
|
<template>
|
||
|
|
<div class="body">
|
||
|
|
<span class="grid" v-for="(v, idx) in grid">
|
||
|
|
<div class="equip" v-if="v" @contextmenu.prevent.stop="emit('openEquipMenu', idx, $event)"
|
||
|
8 months ago
|
@touchstart="mobile.onTouchStart($event, [v, idx])" @touchmove="mobile.onTouchMove"
|
||
|
|
@touchend="mobile.onTouchEnd" @dblclick="commit('close_equip_tip'); dispatch('useEquip', idx);"
|
||
|
8 months ago
|
@mouseover="commit('show_equip_tip', { equip: v, compare: true, e: $event })"
|
||
|
7 months ago
|
@mouseleave="commit('close_equip_tip')" @click="clickGrid($event, v)">
|
||
|
8 months ago
|
<EquipIcon :equip="v" />
|
||
|
|
<div class="equip-lock" v-if="v.locked">
|
||
|
|
<img :src="lock_icon">
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</span>
|
||
|
|
</div>
|
||
|
|
<div class="footer">
|
||
|
|
<span class="capacity" :class="{ 'height': itemNum / grid.length > 0.8 }">
|
||
|
|
{{ itemNum }}/{{ grid.length }}
|
||
|
|
</span>
|
||
|
7 months ago
|
<button class="button addGrid" @click="addGrid">+</button>
|
||
|
8 months ago
|
<button class="button" @click="neaten">{{ t('neaten') }}</button>
|
||
|
|
<button class="button" @click="sellAll">{{ t('sellAll') }}</button>
|
||
|
|
<AutoSell />
|
||
|
|
</div>
|
||
|
|
|
||
|
7 months ago
|
<Confirm ref="confirm" width="8rem" :tip="replace(t('addGrid.1'), [needCoins, addNum])" :confirm="t('addGrid.2')"
|
||
|
|
:cancel="t('addGrid.3')" @confirm="confirmAddGrid" />
|
||
|
|
|
||
|
8 months ago
|
</template>
|
||
|
|
|
||
|
|
<script lang="ts" setup>
|
||
|
|
import { useStore } from "vuex";
|
||
|
|
import { computed, onMounted, ref } from "vue";
|
||
|
|
import { useI18n } from "vue3-i18n";
|
||
|
7 months ago
|
import { EquipIcon, Confirm } from "@/components";
|
||
|
8 months ago
|
import { lock_icon, backpack_num } from "@/config";
|
||
|
|
import AutoSell from "./auto-sell.vue";
|
||
|
7 months ago
|
import { userMobile, replace } from "@/tool";
|
||
|
8 months ago
|
|
||
|
|
const { t } = useI18n();
|
||
|
|
const { state, commit, dispatch } = useStore();
|
||
|
|
const grid = computed(() => {
|
||
|
|
return state.grid;
|
||
|
|
});
|
||
|
7 months ago
|
const emit = defineEmits(['openEquipMenu']);
|
||
|
|
const confirm = ref();
|
||
|
|
const userCoins = computed(() => {
|
||
|
|
return state.playerAttribute.coins;
|
||
|
|
})
|
||
|
|
const needCoins = 2000000;
|
||
|
|
const addNum = 8;
|
||
|
7 months ago
|
const maxNum = 320;
|
||
|
8 months ago
|
|
||
|
|
const itemNum = computed(() => {
|
||
|
|
let i = 0;
|
||
|
|
state.grid.forEach((item) => {
|
||
|
|
if (item) {
|
||
|
|
i++;
|
||
|
|
}
|
||
|
|
})
|
||
|
|
return i;
|
||
|
|
});
|
||
|
|
|
||
|
|
const neaten = () => {
|
||
|
7 months ago
|
grid.value.sort((a, b) => {
|
||
|
|
if (!a && !b) return 0;
|
||
|
|
else if (!a) return 1;
|
||
|
|
else if (!b) return -1;
|
||
|
|
let tmp = b.type.localeCompare(a.type, 'en');
|
||
|
|
if (tmp != 0) return tmp;
|
||
|
|
tmp = b.base.name.localeCompare(a.base.name, 'en');
|
||
|
|
if (tmp != 0) return tmp;
|
||
|
|
return b.lv - a.lv;
|
||
|
|
});
|
||
|
8 months ago
|
}
|
||
|
|
const sellAll = () => {
|
||
|
|
state.grid.forEach((item, index) => {
|
||
|
|
if (item && !item.locked) {
|
||
|
|
dispatch('sell_equip', index)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
8 months ago
|
const mobile = userMobile();
|
||
|
|
mobile.onLongTouch = (e, data) => {
|
||
|
|
e.touches[0].preventDefault = () => { };
|
||
|
|
emit('openEquipMenu', data[1], e.touches[0]);
|
||
|
|
}
|
||
|
|
mobile.onClick = (e, data) => {
|
||
|
|
commit('show_equip_tip', { equip: data[0], compare: true, e: e.touches[0] })
|
||
|
|
}
|
||
|
8 months ago
|
|
||
|
7 months ago
|
const addGrid = (e) => {
|
||
|
|
if (grid.value.length >= maxNum) {
|
||
|
|
commit("set_sys_info", { msg: replace(t('addGrid.4'), [maxNum]), type: "warning", });
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
confirm.value.open(0, e)
|
||
|
|
}
|
||
|
|
const confirmAddGrid = () => {
|
||
|
|
if (userCoins.value < needCoins) {
|
||
|
|
commit("set_sys_info", { msg: t('stNoCoins'), type: "warning", });
|
||
|
|
return
|
||
|
|
}
|
||
|
|
commit("add_player_coins", -1 * needCoins);
|
||
|
|
for (let i = 0; i < addNum; i++) {
|
||
|
|
grid.value.push(null);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
7 months ago
|
const clickGrid = (e, equip) => {
|
||
|
|
if (e.altKey && equip) {
|
||
|
|
equip.locked = !equip.locked;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
8 months ago
|
onMounted(() => { });
|
||
|
|
</script>
|
||
|
|
<style lang="scss" scoped>
|
||
|
|
.body {
|
||
|
|
width: 30rem;
|
||
|
|
height: 14rem;
|
||
|
|
margin-top: 1rem;
|
||
|
|
justify-items: flex-start;
|
||
|
|
align-items: flex-start;
|
||
|
|
flex-wrap: wrap;
|
||
|
|
display: flex;
|
||
|
7 months ago
|
padding-left: 0.8rem;
|
||
|
|
overflow: auto;
|
||
|
8 months ago
|
}
|
||
|
|
|
||
|
|
.grid {
|
||
|
|
width: 3.5rem;
|
||
|
|
height: 3.5rem;
|
||
|
|
border: 1px solid #ccc;
|
||
|
|
margin-left: -1px;
|
||
|
7 months ago
|
// margin-top: -1px;
|
||
|
8 months ago
|
box-shadow: inset 0 0 6px 6px rgba($color: #000000, $alpha: 0.5);
|
||
|
|
|
||
|
|
.equip {
|
||
|
|
display: flex;
|
||
|
|
width: 100%;
|
||
|
|
cursor: pointer;
|
||
|
|
position: relative;
|
||
|
8 months ago
|
-webkit-touch-callout: none;
|
||
|
|
/*系统默认菜单被禁用*/
|
||
|
|
-webkit-user-select: none;
|
||
|
|
/*webkit浏览器*/
|
||
|
|
-khtml-user-select: none;
|
||
|
|
/*早起浏览器*/
|
||
|
|
-moz-user-select: none;
|
||
|
|
/*火狐浏览器*/
|
||
|
|
-ms-user-select: none;
|
||
|
|
/*IE浏览器*/
|
||
|
|
user-select: none;
|
||
|
|
/*用户是否能够选中文本*/
|
||
|
8 months ago
|
}
|
||
|
|
|
||
|
|
.equip-lock {
|
||
|
|
position: absolute;
|
||
|
|
top: -0.2rem;
|
||
|
|
right: -1.1rem;
|
||
|
|
border-left: 1.7rem solid transparent;
|
||
|
|
border-right: 1.7rem solid transparent;
|
||
|
|
border-bottom: 1.7rem solid rgba(255, 0, 0, 0.658);
|
||
|
|
transform: rotate(45deg);
|
||
|
|
|
||
|
|
img {
|
||
|
|
width: 1rem;
|
||
|
|
height: 1rem;
|
||
|
|
transform: rotate(-45deg) translate(-50%, -0%);
|
||
|
|
position: absolute;
|
||
|
|
top: 50%;
|
||
|
|
left: 50%;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
.footer {
|
||
|
|
height: 4rem;
|
||
|
|
width: 100%;
|
||
|
|
|
||
|
|
.capacity {
|
||
|
|
font-size: 1.5rem;
|
||
|
|
line-height: 4rem;
|
||
|
|
float: left;
|
||
|
|
color: white;
|
||
|
|
}
|
||
|
|
|
||
|
|
.height {
|
||
|
|
color: red;
|
||
|
|
}
|
||
|
|
|
||
|
7 months ago
|
|
||
|
8 months ago
|
.button {
|
||
|
|
float: right;
|
||
|
|
margin-top: 0.9rem;
|
||
|
|
}
|
||
|
7 months ago
|
|
||
|
|
.addGrid {
|
||
|
|
padding: 0 0.8rem;
|
||
|
|
float: left;
|
||
|
|
}
|
||
|
8 months ago
|
}
|
||
|
8 months ago
|
|
||
|
|
@media only screen and (max-width: 768px) {
|
||
|
|
.body {
|
||
|
|
width: 22rem;
|
||
|
|
height: 10rem;
|
||
|
|
}
|
||
|
|
|
||
|
|
.grid {
|
||
|
|
width: 2.5rem;
|
||
|
|
height: 2.5rem;
|
||
|
|
|
||
|
|
|
||
|
|
.equip-lock {
|
||
|
|
top: -0.2rem;
|
||
|
|
right: -0.7rem;
|
||
|
|
border-left: 1.2rem solid transparent;
|
||
|
|
border-right: 1.2rem solid transparent;
|
||
|
|
border-bottom: 1.2rem solid rgba(255, 0, 0, 0.658);
|
||
|
|
|
||
|
|
img {
|
||
|
|
width: 0.7rem;
|
||
|
|
height: 0.7rem;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
.footer {
|
||
|
|
height: 3rem;
|
||
|
|
|
||
|
|
.capacity {
|
||
|
|
font-size: 1.2rem;
|
||
|
|
line-height: 3rem;
|
||
|
|
}
|
||
|
|
|
||
|
|
.button {
|
||
|
|
margin-top: 0.5rem;
|
||
|
|
}
|
||
|
7 months ago
|
|
||
|
|
.addGrid {
|
||
|
|
padding: 0 0.4rem;
|
||
|
|
float: left;
|
||
|
|
}
|
||
|
8 months ago
|
}
|
||
|
|
|
||
|
|
}
|
||
|
8 months ago
|
</style>
|