jiuyiUniapp/jiuyi2/pages/index/wallet/wallet.vue

292 lines
6.6 KiB
Vue
Raw Normal View History

2024-12-18 15:46:27 +08:00
<script setup>
/**
* 我的钱包
*/
import {
onMounted,
computed,
reactive,
ref,
getCurrentInstance,
} from 'vue'
import {
onLoad,
onReady,
onReachBottom,
onPullDownRefresh
} from '@dcloudio/uni-app'
import {
useStore,
} from 'vuex'
// api
import api from "@/api/index.js"
// 工具库
import util from '@/common/js/util.js'
// 代理
const {
proxy
} = getCurrentInstance()
const store = useStore()
2025-02-09 21:32:55 +08:00
// 待入帐列表
const releasedList = ref([])
2025-01-23 21:29:16 +08:00
// 积分变动记录
2024-12-18 15:46:27 +08:00
const scrollLog = reactive({
data: [],
pageNum: 1,
pageSize: 30,
total: 0,
})
2025-01-23 21:29:16 +08:00
// 收益明细列表
const getLog = reactive({
data: [],
pageNum: 1,
pageSize: 30,
total: 0,
})
// 收益类型列表
const getTypeList = reactive([{
type: 0,
name: '待结算',
}, {
type: 1,
name: '待入账',
}, {
type: 2,
name: '已入账',
}])
// 收益类型列表索引
const getTypeListIndex = ref(0)
// 待释放列表
const releasedLst = ref([])
2024-12-18 15:46:27 +08:00
// 用户信息
const userinfo = computed(() => {
let result = store.state.userinfo || {}
return result
})
2025-01-02 01:01:23 +08:00
// 我的钱包
const wallet = computed(() => {
let result = store.state.purse || {}
return result
})
2024-12-18 15:46:27 +08:00
onLoad(() => {
// 获取待释放
getReleased()
2025-01-23 21:29:16 +08:00
// 获取收益列表
getGetList()
2024-12-18 15:46:27 +08:00
// 获取钱包
2025-01-02 01:01:23 +08:00
util.getPurse()
2024-12-18 15:46:27 +08:00
})
2025-01-23 21:29:16 +08:00
// 重载收益列表
function refreshMoreGetList() {
getLog.pageNum = 1
// 获取收益列表
getGetList()
}
// 获取更多收益列表
function getMoreGetList() {
if (getLog.total <= getLog.data.length) return
getLog.pageNum++
// 获取收益列表
getGetList()
}
// 获取收益列表
function getGetList() {
api.mine.getGetList({
query: {
pageSize: getLog.pageSize,
pageNum: getLog.pageNum,
},
data: {
status: getTypeList[getTypeListIndex.value].type,
},
}).then(rs => {
if (rs.code == 200) {
if (getLog.pageNum === 1) getLog.data.length = 0
//
getLog.data.push(...rs.rows)
//
getLog.total = rs.total
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
}
2024-12-18 15:46:27 +08:00
// 获取待释放
function getReleased() {
api.mine.releasedList({}).then(rs => {
if (rs.code == 200) {
releasedList.value = rs.data
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
}
2025-01-23 21:29:16 +08:00
/**
* 收益类型下标
* @param {Object} index
*/
function handleGetTypeIndex(index) {
if (getTypeListIndex.value === index) return
getTypeListIndex.value = index
getLog.data.length = 0
// 重载收益列表
refreshMoreGetList()
}
2024-12-27 15:03:48 +08:00
/**
* 跳转
* @param {Object} url 路径
*/
function link(url) {
2024-12-18 15:46:27 +08:00
uni.navigateTo({
2024-12-27 15:03:48 +08:00
url: url
2024-12-18 15:46:27 +08:00
});
}
</script>
<template>
<view class="app plr60">
<!-- 我的钱包 -->
2025-01-01 00:04:32 +08:00
<view class="board mt60 ptb25 plr30 c111 f28 br25">
2024-12-18 15:46:27 +08:00
<view class="">总资产(余额)</view>
<view class="balance rows">
<view class="price dib mtb10 ptb10 plr15 c333 f48 bfff br15">
<text>{{wallet.balance || 0}}</text>
</view>
<view class="">
2025-01-01 00:04:32 +08:00
<navigator url="/pages/index/wallet/topUp" hover-class="none">
<view class="btn sm bar black plr20">充值</view>
</navigator>
<navigator url="/pages/index/wallet/get" hover-class="none">
<view class="btn sm bar black mt20 plr20">提现</view>
</navigator>
2024-12-18 15:46:27 +08:00
</view>
</view>
<view class="mtb10">可用积分 {{wallet.score || 0}}</view>
</view>
<view class="rows mtb30 ptb20 plr30 cfff f34 b000 br10" @click="$refs.released.open()">
2024-12-31 14:46:56 +08:00
<text>待入账列表</text>
2024-12-18 15:46:27 +08:00
<uni-icons type="right" color="" />
</view>
2024-12-27 15:03:48 +08:00
<view class="rows mtb30 ptb20 plr30 cfff f34 b000 br10" @click="link('/pages/index/wallet/bill')">
2024-12-18 15:46:27 +08:00
<text>我的账单</text>
<uni-icons type="right" color="" />
</view>
2025-01-23 21:29:16 +08:00
<view class="rows mtb30 ptb20 plr30 cfff f34 b000 br10">
<text>商家明细</text>
2024-12-27 15:03:48 +08:00
<uni-icons type="right" color="" />
2024-12-18 15:46:27 +08:00
</view>
2025-01-23 21:29:16 +08:00
<view class="rows mtb30 ptb20 plr30 cfff f34 b000 br10" @click="$refs.get.open()">
2025-01-02 01:01:23 +08:00
<text>我的收益</text>
<uni-icons type="right" color="" />
</view>
2024-12-18 15:46:27 +08:00
<!-- 待释放 -->
<uni-popup ref="released" type="center">
2025-01-23 21:29:16 +08:00
<view class="releasedAlt alertContainer oh popMid bfff br20">
2024-12-18 15:46:27 +08:00
<view class="header rows ptb20 plr20 c333 f34 b">
2025-01-02 01:01:23 +08:00
<view class="title">待入账列表</view>
2024-12-18 15:46:27 +08:00
<uni-icons type="closeempty" @click="$refs.released.close()" />
</view>
<view class="main mtb20 plr30">
<scroll-view scroll-y="true" class="scroll">
<view class="list c333 f30" v-for="(item,index) in releasedList" :key="index">
<view class="item mtb30">
<text>待释放{{item.mount}}</text>
<text v-if="item.type === 0">积分</text>
<text v-else-if="item.type === 1">榴莲果</text>
<text v-else-if="item.type === 2">积分</text>
</view>
</view>
2025-02-09 21:32:55 +08:00
<view class="nomore" v-if="releasedList[0]">暂无更多~</view>
<view class="nomore" v-if="!releasedList[0]">暂无内容~</view>
2024-12-18 15:46:27 +08:00
</scroll-view>
</view>
</view>
</uni-popup>
2025-01-23 21:29:16 +08:00
<!-- 收益 -->
<uni-popup ref="get" type="center">
<view class="getAlt alertContainer oh popMid bfff br20">
<view class="header rows ptb20 plr20 c333 f34 b">
<view class="title">我的收益</view>
<uni-icons type="closeempty" @click="$refs.get.close()" />
</view>
<view class="tab">
<view class="item fmid fdc ptb10" :class="{'active':index === getTypeListIndex}"
v-for="(item,index) in getTypeList" :key="index" @click="handleGetTypeIndex(index)">
<view>{{item.name}}</view>
</view>
</view>
<view class="main mtb20 plr30">
<scroll-view scroll-y="true" class="scroll" @scrolltolower="getMoreGetList">
<view class="list c333 f30">
<view class="item mtb30 f32" v-for="(item,index) in getLog.data" :key="index">
<view>{{item.typeName}}{{item.amount}}</view>
<view class="time mt10 c999 f28 ">{{item.createTime}}</view>
</view>
</view>
<view class="nomore" v-if="!getLog.data[0]">暂无内容~</view>
<view class="nomore" v-else-if="getLog.data.length === getLog.total">暂无更多~</view>
</scroll-view>
</view>
</view>
</uni-popup>
2024-12-18 15:46:27 +08:00
</view>
</template>
<style lang="scss" scoped>
// 板子
.board {
2025-01-01 00:04:32 +08:00
background-image: linear-gradient(130deg, rgb(233, 170, 80) 0%, rgb(249, 217, 89) 50%, rgb(233, 170, 80) 100%);
2024-12-18 15:46:27 +08:00
}
// 待释放弹窗
2025-01-23 21:29:16 +08:00
.alertContainer {
2024-12-18 15:46:27 +08:00
.header {
border-bottom: 2rpx solid #ddd;
}
2025-01-23 21:29:16 +08:00
// tab
.tab {
display: flex;
2024-12-18 15:46:27 +08:00
2025-01-23 21:29:16 +08:00
// 单项
.item {
flex: 1;
color: #999;
2024-12-18 15:46:27 +08:00
2025-01-23 21:29:16 +08:00
&.active {
font-weight: 600;
color: #333;
}
2024-12-18 15:46:27 +08:00
}
}
2025-01-23 21:29:16 +08:00
.scroll {
height: 50vh;
}
2024-12-18 15:46:27 +08:00
}
</style>