jiuyiUniapp/jiuyi2/pages/index/durainActivation.vue

126 lines
2.5 KiB
Vue
Raw Normal View History

2024-12-18 15:46:27 +08:00
<script setup>
import {
onMounted,
ref,
reactive,
computed,
getCurrentInstance,
watch,
defineExpose,
} from 'vue';
import {
useStore,
} from 'vuex'
import {
onLoad
} from '@dcloudio/uni-app'
2025-01-05 15:43:14 +08:00
// 工具库
import util from '@/common/js/util';
//
import api from '@/api/index.js';
2024-12-18 15:46:27 +08:00
const treeData = ref([])
const store = useStore()
const userinfo = computed(() => {
let result = store.state.userinfo
return result
})
onLoad(() => {
2025-01-02 01:01:23 +08:00
// 获取榴莲果树
2024-12-18 15:46:27 +08:00
buyDurianList()
})
// 我的榴莲果树
function buyDurianList() {
2025-01-05 15:43:14 +08:00
api.durian.buyDurianList({}).then(rs => {
2025-01-02 01:01:23 +08:00
if (rs.code == 200) {
2025-01-05 15:43:14 +08:00
treeData.value = rs.data.dataList.map(item => {
item.formatHash = formatStr(item.treeHash)
return item
})
2025-01-02 01:01:23 +08:00
return
2024-12-18 15:46:27 +08:00
}
2025-01-02 01:01:23 +08:00
util.alert({
content: rs.msg,
showCancel: false
})
2024-12-18 15:46:27 +08:00
})
}
2025-01-05 15:43:14 +08:00
/**
* 处理字符串
* @param {Object} str
*/
function formatStr(str) {
// 如果字符串长度小于等于6直接返回原字符串
if (str.length <= 6) return str
return str.slice(0, 3) + '***' + str.slice(-3); // 拼接结果
}
/**
* 跳转详情
* @param {Object} item
*/
function handleDetail(item) {
uni.navigateTo({
url: util.setUrl('/pages/index/durianLog', {
id: item.durianTreeId,
})
})
}
/**
* 复制
* @param {Object} ev 需要复制的码
*/
function handleCopy(ev) {
util.copyText(ev)
}
2024-12-18 15:46:27 +08:00
</script>
<template>
<view class="appbw">
<!-- -->
<view class="list mlr40">
2025-01-05 15:43:14 +08:00
<view class="item rows mtb25 br15" v-for="(item,index) in treeData" :key="index"
@click="handleDetail(item)">
<image class="wh180 fs0" src="/static/tree.png" mode="aspectFit" />
<view class="col f1 ml30 mtb30 c333 f26">
<view class="txt mtb10">每日可释放{{item.release}}</view>
<view class="txt mtb10">剩余可释放{{item.remainFruitCount}}</view>
<view class="txt mtb10">当前级别{{item.treeName}}</view>
<view class="txt mtb10" @click.stop="util.copyText(item.treeHash)">
<text>哈希值 {{item.formatHash}}</text>
<image class="wh20 ml10" src="/static/copy.png" mode="aspectFit" />
</view>
2024-12-18 15:46:27 +08:00
</view>
</view>
</view>
<!-- 填充 -->
<view class="fill" style="height: 60rpx;"></view>
</view>
</template>
<style lang="scss">
//
.list {
.item {
background-color: #F4F4F4;
}
.item+.item:nth-child(3n+1) {
background-color: #F4CAFF;
}
.item+.item:nth-child(3n+2) {
background-color: #E4FBFF;
}
.item+.item:nth-child(3n+3) {
background-color: #CACDFF;
}
}
</style>