feat(提现)
This commit is contained in:
parent
4f1a9a3440
commit
69aa02da78
14
pages.json
14
pages.json
|
@ -101,6 +101,20 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"root": "pages/user",
|
||||||
|
"pages": [
|
||||||
|
{
|
||||||
|
"path": "wallet/money",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "余额"
|
||||||
|
},
|
||||||
|
"meta": {
|
||||||
|
"auth": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tabBar": {
|
"tabBar": {
|
||||||
|
|
|
@ -6,32 +6,15 @@
|
||||||
</view>
|
</view>
|
||||||
<uni-forms ref="smsLoginRef" v-model="state.model" :rules="state.rules" validateTrigger="bind">
|
<uni-forms ref="smsLoginRef" v-model="state.model" :rules="state.rules" validateTrigger="bind">
|
||||||
<uni-forms-item name="mobile">
|
<uni-forms-item name="mobile">
|
||||||
<uni-easyinput
|
<uni-easyinput :styles="state.inputStyle" trim="all" placeholder="请输入手机号" v-model="state.model.mobile"
|
||||||
:styles="state.inputStyle"
|
:inputBorder="false" type="number" />
|
||||||
trim="all"
|
|
||||||
placeholder="请输入手机号"
|
|
||||||
v-model="state.model.mobile"
|
|
||||||
:inputBorder="false"
|
|
||||||
type="number"
|
|
||||||
/>
|
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
<uni-forms-item name="code">
|
<uni-forms-item name="code">
|
||||||
<uni-easyinput
|
<uni-easyinput :styles="state.inputStyle" trim="all" placeholder="验证码" v-model="state.model.code"
|
||||||
:styles="state.inputStyle"
|
:inputBorder="false" type="number" maxlength="4">
|
||||||
trim="all"
|
|
||||||
placeholder="验证码"
|
|
||||||
v-model="state.model.code"
|
|
||||||
:inputBorder="false"
|
|
||||||
type="number"
|
|
||||||
maxlength="4"
|
|
||||||
>
|
|
||||||
<template #right>
|
<template #right>
|
||||||
<button
|
<button :disabled="state.isMobileEnd" :class="{ 'code-btn-end': state.isMobileEnd }"
|
||||||
:disabled="state.isMobileEnd"
|
class="ss-reset-button code-btn code-btn-start" @tap="getSmsCode('smsLogin', state.model.mobile)">
|
||||||
:class="{ 'code-btn-end': state.isMobileEnd }"
|
|
||||||
class="ss-reset-button code-btn code-btn-start"
|
|
||||||
@tap="getSmsCode('smsLogin', state.model.mobile)"
|
|
||||||
>
|
|
||||||
{{ getSmsTimer('smsLogin') }}
|
{{ getSmsTimer('smsLogin') }}
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
@ -41,12 +24,8 @@
|
||||||
<button class="ss-reset-button login-btn-start" @tap="smsLoginSubmit">登录</button>
|
<button class="ss-reset-button login-btn-start" @tap="smsLoginSubmit">登录</button>
|
||||||
<view class="agreement-box ss-flex ss-row-center" :class="{ shake: state.isShaking }">
|
<view class="agreement-box ss-flex ss-row-center" :class="{ shake: state.isShaking }">
|
||||||
<label class="radio ss-flex" @tap="onChange">
|
<label class="radio ss-flex" @tap="onChange">
|
||||||
<radio
|
<radio :checked="state.agreeStatus" color="var(--ui-BG-Main)" style="transform: scale(0.8)"
|
||||||
:checked="state.agreeStatus"
|
@tap.stop="onChange" />
|
||||||
color="var(--ui-BG-Main)"
|
|
||||||
style="transform: scale(0.8)"
|
|
||||||
@tap.stop="onChange"
|
|
||||||
/>
|
|
||||||
<view class="agreement-text ss-flex ss-m-l-8">
|
<view class="agreement-text ss-flex ss-m-l-8">
|
||||||
我已阅读并遵守
|
我已阅读并遵守
|
||||||
<view class="tcp-text" @tap.stop="onProtocol('商家入驻协议')"> 《商家入驻协议》 </view>
|
<view class="tcp-text" @tap.stop="onProtocol('商家入驻协议')"> 《商家入驻协议》 </view>
|
||||||
|
@ -88,6 +67,10 @@ function onChange() {
|
||||||
state.value.agreeStatus = !state.value.agreeStatus
|
state.value.agreeStatus = !state.value.agreeStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onProtocol() {
|
||||||
|
peach.$router.go('/pages/public/richtext?title=商家入驻协议')
|
||||||
|
}
|
||||||
|
|
||||||
async function smsLoginSubmit() {
|
async function smsLoginSubmit() {
|
||||||
const validate = await smsLoginRef.value.validate().catch((err) => {
|
const validate = await smsLoginRef.value.validate().catch((err) => {
|
||||||
console.log('err', err)
|
console.log('err', err)
|
||||||
|
|
|
@ -1,43 +1,24 @@
|
||||||
<!-- 我的钱包 -->
|
|
||||||
<template>
|
<template>
|
||||||
<pb-layout navbar="inner" class="wallet-wrap" title="钱包" :bgStyle="bgStyle">
|
<pb-layout navbar="inner" class="wallet-wrap" color="#fff" title="余额" :bgStyle="bgStyle">
|
||||||
<!-- 钱包卡片 -->
|
<view class="header-box ss-row-center ss-col-center">
|
||||||
<view class="header-box ss-flex ss-row-center ss-col-center">
|
<view class="card-box ui-BG-Main ui-Shadow-Main ss-flex ss-row-between ss-col-center">
|
||||||
<view class="card-box ui-BG-Main ui-Shadow-Main">
|
<view class="ss-flex ss-flex-col ss-row-between ss-col-top ss-gap-40">
|
||||||
<view class="card-head ss-flex ss-col-center">
|
<view class="card-head ss-flex ss-col-center">
|
||||||
<view class="card-title ss-m-r-10">钱包余额(元)</view>
|
<view class="card-title ss-m-r-10">账户余额(元)</view>
|
||||||
<view
|
<view @tap="state.showMoney = !state.showMoney" class="ss-eye-icon"
|
||||||
@tap="state.showMoney = !state.showMoney"
|
:class="state.showMoney ? 'cicon-eye' : 'cicon-eye-off'" />
|
||||||
class="ss-eye-icon"
|
|
||||||
:class="state.showMoney ? 'cicon-eye' : 'cicon-eye-off'"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="ss-flex ss-row-between ss-col-center ss-m-t-64">
|
|
||||||
<view class="money-num">{{ state.showMoney ? fen2yuan(userWallet.balance) : '*****' }}</view>
|
<view class="money-num">{{ state.showMoney ? fen2yuan(userWallet.balance) : '*****' }}</view>
|
||||||
<button class="ss-reset-button topup-btn" @tap="peach.$router.go('/pages/pay/recharge')">
|
|
||||||
充值
|
|
||||||
</button>
|
|
||||||
</view>
|
</view>
|
||||||
|
<button class="ss-reset-button topup-btn" @tap="peach.$router.go('/pages/pay/recharge')">
|
||||||
|
提现
|
||||||
|
</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<su-sticky>
|
|
||||||
<!-- 统计 -->
|
<p-empty v-if="state.pagination.total === 0" :marginTop="40" text="暂无数据" icon="/static/data-empty.png" />
|
||||||
<view class="filter-box ss-p-x-30 ss-flex ss-col-center ss-row-between">
|
|
||||||
<uni-datetime-picker v-model="state.data" type="daterange" @change="onChangeTime" :end="state.today">
|
|
||||||
<button class="ss-reset-button date-btn">
|
|
||||||
<text>{{ dateFilterText }}</text>
|
|
||||||
<text class="cicon-drop-down ss-seldate-icon"></text>
|
|
||||||
</button>
|
|
||||||
</uni-datetime-picker>
|
|
||||||
<view class="total-box">
|
|
||||||
<view class="ss-m-b-10">总收入¥{{ fen2yuan(state.summary.totalIncome) }}</view>
|
|
||||||
<view>总支出¥{{ fen2yuan(state.summary.totalExpense) }}</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<su-tabs :list="tabMaps" @change="onChange" :scrollable="false" :current="state.currentTab"></su-tabs>
|
|
||||||
</su-sticky>
|
|
||||||
<s-empty v-if="state.pagination.total === 0" text="暂无数据" icon="/static/data-empty.png" />
|
|
||||||
|
|
||||||
<!-- 钱包记录 -->
|
<!-- 钱包记录 -->
|
||||||
<view v-if="state.pagination.total > 0">
|
<view v-if="state.pagination.total > 0">
|
||||||
|
@ -58,13 +39,9 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<uni-load-more
|
<uni-load-more v-if="state.pagination.total > 0" :status="state.loadStatus" :content-text="{
|
||||||
v-if="state.pagination.total > 0"
|
|
||||||
:status="state.loadStatus"
|
|
||||||
:content-text="{
|
|
||||||
contentdown: '上拉加载更多',
|
contentdown: '上拉加载更多',
|
||||||
}"
|
}" />
|
||||||
/>
|
|
||||||
</pb-layout>
|
</pb-layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -76,7 +53,7 @@ import dayjs from 'dayjs'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import PayWalletApi from '@/peach/api/pay/wallet'
|
import PayWalletApi from '@/peach/api/pay/wallet'
|
||||||
import { fen2yuan } from '@/peach/hooks/useGoods'
|
import { fen2yuan } from '@/peach/hooks/useGoods'
|
||||||
import { resetPagination } from '@/peach/util'
|
import { resetPagination } from '@/peach/utils'
|
||||||
|
|
||||||
const bgStyle = {
|
const bgStyle = {
|
||||||
backgroundImage: '/static/bg-page.png',
|
backgroundImage: '/static/bg-page.png',
|
||||||
|
@ -85,109 +62,45 @@ const bgStyle = {
|
||||||
description: '',
|
description: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
const headerBg = peach.$url.css('/static/img/shop/user/wallet_card_bg.png')
|
// const headerBg = peach.$url.css('/static/img/shop/user/wallet_card_bg.png')
|
||||||
|
|
||||||
// 数据
|
// 数据
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
showMoney: false,
|
showMoney: false,
|
||||||
date: [], // 筛选的时间段
|
|
||||||
currentTab: 0,
|
|
||||||
pagination: {
|
pagination: {
|
||||||
list: [],
|
list: [],
|
||||||
total: 0,
|
total: 0,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 8,
|
pageSize: 8,
|
||||||
},
|
},
|
||||||
summary: {
|
|
||||||
totalIncome: 0,
|
|
||||||
totalExpense: 0,
|
|
||||||
},
|
|
||||||
loadStatus: '',
|
loadStatus: '',
|
||||||
today: '',
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const tabMaps = [
|
|
||||||
{
|
|
||||||
name: '全部',
|
|
||||||
value: '',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '收入',
|
|
||||||
value: '1',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '支出',
|
|
||||||
value: '2',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
const userWallet = computed(() => peach.$store('user').userWallet)
|
const userWallet = computed(() => peach.$store('user').userWallet)
|
||||||
|
|
||||||
// 格式化时间段
|
|
||||||
const dateFilterText = computed(() => {
|
|
||||||
if (state.date[0] === state.date[1]) {
|
|
||||||
return state.date[0]
|
|
||||||
} else {
|
|
||||||
return state.date.join('~')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// 获得钱包记录分页
|
// 获得钱包记录分页
|
||||||
async function getLogList() {
|
async function getLogList() {
|
||||||
state.loadStatus = 'loading'
|
state.loadStatus = 'loading'
|
||||||
const { data, code } = await PayWalletApi.getWalletTransactionPage({
|
// const { data, code } = await PayWalletApi.getWalletTransactionPage({
|
||||||
pageNo: state.pagination.pageNo,
|
// pageNo: state.pagination.pageNo,
|
||||||
pageSize: state.pagination.pageSize,
|
// pageSize: state.pagination.pageSize,
|
||||||
type: tabMaps[state.currentTab].value,
|
|
||||||
'createTime[0]': state.date[0] + ' 00:00:00',
|
// })
|
||||||
'createTime[1]': state.date[1] + ' 23:59:59',
|
|
||||||
})
|
// state.pagination.list = _.concat(state.pagination.list, data.list)
|
||||||
if (code !== 0) {
|
// state.pagination.total = data.total
|
||||||
return
|
// state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore'
|
||||||
}
|
|
||||||
state.pagination.list = _.concat(state.pagination.list, data.list)
|
|
||||||
state.pagination.total = data.total
|
|
||||||
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获得钱包统计
|
|
||||||
async function getSummary() {
|
|
||||||
const { data, code } = await PayWalletApi.getWalletTransactionSummary({
|
|
||||||
createTime: [state.date[0] + ' 00:00:00', state.date[1] + ' 23:59:59'],
|
|
||||||
})
|
|
||||||
if (code !== 0) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
state.summary = data
|
|
||||||
}
|
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
state.today = dayjs().format('YYYY-MM-DD')
|
|
||||||
state.date = [state.today, state.today]
|
|
||||||
getLogList()
|
getLogList()
|
||||||
getSummary()
|
|
||||||
// 刷新钱包的缓存
|
// 刷新钱包的缓存
|
||||||
peach.$store('user').getWallet()
|
// peach.$store('user').getWallet()
|
||||||
})
|
})
|
||||||
|
|
||||||
// 处理 tab 切换
|
|
||||||
function onChange(e) {
|
|
||||||
state.currentTab = e.index
|
|
||||||
// 重新加载列表
|
|
||||||
resetPagination(state.pagination)
|
|
||||||
getLogList()
|
|
||||||
getSummary()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理时间筛选
|
|
||||||
function onChangeTime(e) {
|
|
||||||
state.date[0] = e[0]
|
|
||||||
state.date[1] = e[e.length - 1]
|
|
||||||
// 重新加载列表
|
|
||||||
resetPagination(state.pagination)
|
|
||||||
getLogList()
|
|
||||||
getSummary()
|
|
||||||
}
|
|
||||||
|
|
||||||
onReachBottom(() => {
|
onReachBottom(() => {
|
||||||
if (state.loadStatus === 'noMore') {
|
if (state.loadStatus === 'noMore') {
|
||||||
|
@ -199,15 +112,11 @@ onReachBottom(() => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
// 钱包
|
|
||||||
.header-box {
|
.header-box {
|
||||||
background-color: $white;
|
|
||||||
padding: 30rpx;
|
|
||||||
|
|
||||||
.card-box {
|
.card-box {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 300rpx;
|
min-height: 250rpx;
|
||||||
padding: 40rpx;
|
padding: 0 40rpx;
|
||||||
background-size: 100% 100%;
|
background-size: 100% 100%;
|
||||||
border-radius: 30rpx;
|
border-radius: 30rpx;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@ -215,19 +124,6 @@ onReachBottom(() => {
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
&::after {
|
|
||||||
content: '';
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
z-index: 2;
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
background: v-bind(headerBg) no-repeat;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-head {
|
.card-head {
|
||||||
color: $white;
|
color: $white;
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
|
@ -253,7 +149,7 @@ onReachBottom(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
.topup-btn {
|
.topup-btn {
|
||||||
width: 120rpx;
|
width: 150rpx;
|
||||||
height: 60rpx;
|
height: 60rpx;
|
||||||
line-height: 60rpx;
|
line-height: 60rpx;
|
||||||
border-radius: 30px;
|
border-radius: 30px;
|
||||||
|
@ -293,11 +189,6 @@ onReachBottom(() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tabs-box {
|
|
||||||
background: $white;
|
|
||||||
border-bottom: 2rpx solid #eeeeee;
|
|
||||||
}
|
|
||||||
|
|
||||||
// tab
|
// tab
|
||||||
.wallet-tab-card {
|
.wallet-tab-card {
|
||||||
.tab-item {
|
.tab-item {
|
||||||
|
@ -358,6 +249,7 @@ onReachBottom(() => {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-family: OPPOSANS;
|
font-family: OPPOSANS;
|
||||||
|
|
||||||
.add {
|
.add {
|
||||||
color: var(--ui-BG-Main);
|
color: var(--ui-BG-Main);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import request from "@/peach/request";
|
||||||
|
|
||||||
|
const PayWalletApi = {
|
||||||
|
getWalletTransactionPage: () => {},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PayWalletApi;
|
|
@ -1,6 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="ss-flex-col ss-col-center ss-row-center empty-box" :style="[{ paddingTop: paddingTop + 'rpx' }]">
|
<view class="ss-flex-col ss-col-center ss-row-center empty-box"
|
||||||
<view class=""><image class="empty-icon" :src="icon" mode="widthFix"></image></view>
|
:style="[{ paddingTop: paddingTop + 'rpx', backgroundColor: bgColor, marginTop: marginTop + 'rpx' }]">
|
||||||
|
<view class="">
|
||||||
|
<image class="empty-icon" :src="icon" mode="widthFix"></image>
|
||||||
|
</view>
|
||||||
<view class="empty-text ss-m-t-28 ss-m-b-40">
|
<view class="empty-text ss-m-t-28 ss-m-b-40">
|
||||||
<text v-if="text !== ''">{{ text }}</text>
|
<text v-if="text !== ''">{{ text }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
@ -49,6 +52,14 @@ const props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: 'var(--ui-BG-Main)',
|
default: 'var(--ui-BG-Main)',
|
||||||
},
|
},
|
||||||
|
bgColor: {
|
||||||
|
type: String,
|
||||||
|
default: '#ffffff',
|
||||||
|
},
|
||||||
|
marginTop: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emits = defineEmits(['clickAction'])
|
const emits = defineEmits(['clickAction'])
|
||||||
|
@ -65,6 +76,7 @@ function clickAction() {
|
||||||
.empty-box {
|
.empty-box {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-icon {
|
.empty-icon {
|
||||||
width: 240rpx;
|
width: 240rpx;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
import { ref } from 'vue'
|
import { ref } from "vue";
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from "pinia";
|
||||||
import $share from '@/peach/platform/share'
|
import $share from "@/peach/platform/share";
|
||||||
import $router from '@/peach/router'
|
import $router from "@/peach/router";
|
||||||
import UserUtil from '@/peach/api/member/user'
|
import UserUtil from "@/peach/api/member/user";
|
||||||
import { isEmpty, cloneDeep, clone } from 'lodash'
|
import { isEmpty, cloneDeep, clone } from "lodash";
|
||||||
|
|
||||||
// 默认用户信息
|
// 默认用户信息
|
||||||
const defaultUserInfo = {
|
const defaultUserInfo = {
|
||||||
avatar: '', // 头像
|
avatar: "", // 头像
|
||||||
nickname: '', // 昵称
|
nickname: "", // 昵称
|
||||||
mobile: '', // 手机号
|
mobile: "", // 手机号
|
||||||
point: 0, // 积分
|
point: 0, // 积分
|
||||||
particulars: null,
|
particulars: null,
|
||||||
}
|
};
|
||||||
|
|
||||||
// 默认钱包信息
|
// 默认钱包信息
|
||||||
const defaultWallet = {
|
const defaultWallet = {
|
||||||
balance: 0, // 余额
|
balance: 0, // 余额
|
||||||
totalExpense: 0, // 总消费
|
totalExpense: 0, // 总消费
|
||||||
totalRecharge: 0, // 总充值
|
totalRecharge: 0, // 总充值
|
||||||
}
|
};
|
||||||
|
|
||||||
// 默认订单信息
|
// 默认订单信息
|
||||||
const defaultNumData = {
|
const defaultNumData = {
|
||||||
|
@ -32,93 +32,94 @@ const defaultNumData = {
|
||||||
uncommentedCount: 0,
|
uncommentedCount: 0,
|
||||||
afterSaleCount: 0,
|
afterSaleCount: 0,
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
const useUserStore = defineStore(
|
const useUserStore = defineStore(
|
||||||
'user',
|
"user",
|
||||||
() => {
|
() => {
|
||||||
const userInfo = ref(cloneDeep(defaultUserInfo))
|
const userInfo = ref(cloneDeep(defaultUserInfo));
|
||||||
const userWallet = ref(clone(defaultWallet))
|
const userWallet = ref(clone(defaultWallet));
|
||||||
const userNumData = ref(cloneDeep(defaultNumData))
|
const userNumData = ref(cloneDeep(defaultNumData));
|
||||||
const isLogin = ref(!!uni.getStorageSync('token'))
|
const isLogin = ref(!!uni.getStorageSync("token"));
|
||||||
const lastUpdateTime = ref(0)
|
const lastUpdateTime = ref(0);
|
||||||
const lastRoutePage = ref(null)
|
const lastRoutePage = ref(null);
|
||||||
|
|
||||||
async function getUserInfo() {
|
async function getUserInfo() {
|
||||||
let res = await UserUtil.getUserInfo()
|
let res = await UserUtil.getUserInfo();
|
||||||
userInfo.value = res.data
|
userInfo.value = res.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getWallet() {
|
async function getWallet() {
|
||||||
let res = await UserUtil.getWalletInfo()
|
let res = await UserUtil.getWalletInfo();
|
||||||
userWallet.value = res.data
|
userWallet.value = res.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNumData() {}
|
function getNumData() {}
|
||||||
|
|
||||||
function setToken(token, refreshToken) {
|
function setToken(token, refreshToken) {
|
||||||
if (token === '') {
|
if (token === "") {
|
||||||
isLogin.value = false
|
isLogin.value = false;
|
||||||
uni.removeStorageSync('token')
|
uni.removeStorageSync("token");
|
||||||
uni.removeStorageSync('refresh-token')
|
uni.removeStorageSync("refresh-token");
|
||||||
} else {
|
} else {
|
||||||
isLogin.value = true
|
isLogin.value = true;
|
||||||
uni.setStorageSync('token', token)
|
uni.setStorageSync("token", token);
|
||||||
uni.setStorageSync('refresh-token', refreshToken)
|
uni.setStorageSync("refresh-token", refreshToken);
|
||||||
// 成功后处理
|
// 成功后处理
|
||||||
loginAfter()
|
loginAfter();
|
||||||
}
|
}
|
||||||
return isLogin.value
|
return isLogin.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetUserData() {
|
function resetUserData() {
|
||||||
setToken('')
|
setToken("");
|
||||||
userInfo.value = cloneDeep(defaultUserInfo)
|
userInfo.value = cloneDeep(defaultUserInfo);
|
||||||
userWallet.value = clone(defaultWallet)
|
userWallet.value = clone(defaultWallet);
|
||||||
userNumData.value = cloneDeep(defaultNumData)
|
userNumData.value = cloneDeep(defaultNumData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateUserData() {
|
async function updateUserData() {
|
||||||
const nowTime = new Date().getTime()
|
const nowTime = new Date().getTime();
|
||||||
if (lastUpdateTime.value + 5000 > nowTime) {
|
if (lastUpdateTime.value + 5000 > nowTime) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
lastUpdateTime.value = nowTime
|
lastUpdateTime.value = nowTime;
|
||||||
await Promise.all([getUserInfo(), getWallet(), getNumData()])
|
await Promise.all([getUserInfo(), getWallet(), getNumData()]);
|
||||||
return userInfo.value
|
return userInfo.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loginAfter() {
|
async function loginAfter() {
|
||||||
await updateUserData()
|
await updateUserData();
|
||||||
$share.getShareInfo()
|
$share.getShareInfo();
|
||||||
$router.go('/pages/index/index')
|
$router.go("/pages/index/index");
|
||||||
}
|
}
|
||||||
|
|
||||||
function logOut() {
|
function logOut() {
|
||||||
resetUserData()
|
resetUserData();
|
||||||
return !isLogin.value
|
return !isLogin.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
userInfo,
|
userInfo,
|
||||||
userWallet,
|
userWallet,
|
||||||
isLogin,
|
isLogin,
|
||||||
|
lastRoutePage,
|
||||||
setToken,
|
setToken,
|
||||||
logOut,
|
logOut,
|
||||||
loginAfter,
|
loginAfter,
|
||||||
lastRoutePage,
|
getWallet,
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
persist: {
|
persist: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
strategies: [
|
strategies: [
|
||||||
{
|
{
|
||||||
key: 'user-store',
|
key: "user-store",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
|
|
||||||
export default useUserStore
|
export default useUserStore;
|
||||||
|
|
|
@ -1,24 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<pb-fixed
|
<pb-fixed :noFixed="props.noFixed" :alway="props.alway" :bgStyles="props.bgStyles" :val="0" :index="props.zIndex"
|
||||||
:noFixed="props.noFixed"
|
noNav :bg="props.bg" :ui="props.ui" :opacity="props.opacity" :placeholder="props.placeholder">
|
||||||
:alway="props.alway"
|
|
||||||
:bgStyles="props.bgStyles"
|
|
||||||
:val="0"
|
|
||||||
:index="props.zIndex"
|
|
||||||
noNav
|
|
||||||
:bg="props.bg"
|
|
||||||
:ui="props.ui"
|
|
||||||
:opacity="props.opacity"
|
|
||||||
:placeholder="props.placeholder"
|
|
||||||
>
|
|
||||||
<pb-status-bar />
|
<pb-status-bar />
|
||||||
|
|
||||||
<view class="ui-navbar-box">
|
<view class="ui-navbar-box">
|
||||||
<view
|
<view class="ui-bar ss-p-x-20" :class="state.isDark ? 'text-white' : 'text-black'"
|
||||||
class="ui-bar ss-p-x-20"
|
:style="[{ height: sys_navBar - sys_statusBar + 'px' }]">
|
||||||
:class="state.isDark ? 'text-white' : 'text-black'"
|
|
||||||
:style="[{ height: sys_navBar - sys_statusBar + 'px' }]"
|
|
||||||
>
|
|
||||||
<view v-if="leftIcon" class="icon-box ss-flex">
|
<view v-if="leftIcon" class="icon-box ss-flex">
|
||||||
<view class="icon-button icon-button-left ss-flex ss-row-center" @tap="onClickLeft">
|
<view class="icon-button icon-button-left ss-flex ss-row-center" @tap="onClickLeft">
|
||||||
<text class="sicon-back" v-if="hasHistory" />
|
<text class="sicon-back" v-if="hasHistory" />
|
||||||
|
@ -30,7 +17,7 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<slot name="center">
|
<slot name="center">
|
||||||
<view class="center navbar-title">{{ title }}</view>
|
<view :style="{ color: themeColor }" class="center navbar-title">{{ title }}</view>
|
||||||
</slot>
|
</slot>
|
||||||
<!-- #ifdef MP -->
|
<!-- #ifdef MP -->
|
||||||
<view :style="[state.capsuleStyle]"></view>
|
<view :style="[state.capsuleStyle]"></view>
|
||||||
|
@ -74,9 +61,17 @@ const state = reactive({
|
||||||
})
|
})
|
||||||
|
|
||||||
const sys_statusBar = peach.$platform.device.statusBarHeight
|
const sys_statusBar = peach.$platform.device.statusBarHeight
|
||||||
const sys_navBar = peach.$platform.navbar
|
const sys_navBar = peach.$platform.navBar
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
dark: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
zIndex: {
|
zIndex: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 100,
|
default: 100,
|
||||||
|
@ -130,13 +125,20 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
bgStyles: {
|
bgStyles: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default() {},
|
default() { },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const emits = defineEmits(['navback', 'clickLeft'])
|
const emits = defineEmits(['navback', 'clickLeft'])
|
||||||
const hasHistory = peach.$router.hasHistory()
|
const hasHistory = peach.$router.hasHistory()
|
||||||
|
|
||||||
|
const themeColor = computed(() => {
|
||||||
|
if (props.dark) {
|
||||||
|
return props.color ? props.color : '#fff'
|
||||||
|
}
|
||||||
|
return props.color || '#333'
|
||||||
|
})
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
init()
|
init()
|
||||||
})
|
})
|
||||||
|
@ -180,39 +182,49 @@ const init = () => {
|
||||||
height: 56rpx;
|
height: 56rpx;
|
||||||
margin-left: 8rpx;
|
margin-left: 8rpx;
|
||||||
border: 1px solid rgba(#fff, 0.4);
|
border: 1px solid rgba(#fff, 0.4);
|
||||||
|
|
||||||
.line {
|
.line {
|
||||||
width: 2rpx;
|
width: 2rpx;
|
||||||
height: 24rpx;
|
height: 24rpx;
|
||||||
background: #e5e5e7;
|
background: #e5e5e7;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sicon-back {
|
.sicon-back {
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sicon-home {
|
.sicon-home {
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sicon-more {
|
.sicon-more {
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-button {
|
.icon-button {
|
||||||
width: 67rpx;
|
width: 67rpx;
|
||||||
height: 56rpx;
|
height: 56rpx;
|
||||||
|
|
||||||
&-left:hover {
|
&-left:hover {
|
||||||
background: rgba(0, 0, 0, 0.16);
|
background: rgba(0, 0, 0, 0.16);
|
||||||
border-radius: 30rpx 0px 0px 30rpx;
|
border-radius: 30rpx 0px 0px 30rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-right:hover {
|
&-right:hover {
|
||||||
background: rgba(0, 0, 0, 0.16);
|
background: rgba(0, 0, 0, 0.16);
|
||||||
border-radius: 0px 30rpx 30rpx 0px;
|
border-radius: 0px 30rpx 30rpx 0px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar-title {
|
.navbar-title {
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tools-icon {
|
.tools-icon {
|
||||||
font-size: 40rpx;
|
font-size: 40rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ui-navbar-box {
|
.ui-navbar-box {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -323,6 +335,7 @@ const init = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
&.isFristPage {
|
&.isFristPage {
|
||||||
|
|
||||||
.capsule-back,
|
.capsule-back,
|
||||||
&::after {
|
&::after {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
|
@ -2,21 +2,12 @@
|
||||||
<view class="page-app" :class="['theme-' + sys.mode, 'main-' + sys.theme, 'font-' + sys.fontSize]">
|
<view class="page-app" :class="['theme-' + sys.mode, 'main-' + sys.theme, 'font-' + sys.fontSize]">
|
||||||
<view class="page-main" :style="[bgMain]">
|
<view class="page-main" :style="[bgMain]">
|
||||||
<!-- 顶部导航栏-情况1:默认通用顶部导航栏 -->
|
<!-- 顶部导航栏-情况1:默认通用顶部导航栏 -->
|
||||||
<pb-navbar
|
<pb-navbar v-if="navbar === 'normal'" :title="title" :leftIcon="leftIcon" statusBar :color="color" :tools="tools"
|
||||||
v-if="navbar === 'normal'"
|
:opacityBgUi="opacityBgUi" @search="(e) => emits('search', e)" :defaultSearch="defaultSearch" />
|
||||||
:title="title"
|
|
||||||
:leftIcon="leftIcon"
|
|
||||||
statusBar
|
|
||||||
:color="color"
|
|
||||||
:tools="tools"
|
|
||||||
:opacityBgUi="opacityBgUi"
|
|
||||||
@search="(e) => emits('search', e)"
|
|
||||||
:defaultSearch="defaultSearch"
|
|
||||||
/>
|
|
||||||
<view class="page-body" :style="[bgBody]">
|
<view class="page-body" :style="[bgBody]">
|
||||||
<!-- 顶部导航栏-情况2:沉浸式头部 -->
|
<!-- 顶部导航栏-情况2:沉浸式头部 -->
|
||||||
<pb-inner-navbar v-if="navbar === 'inner'" :title="title" :leftIcon="leftIcon" />
|
<pb-inner-navbar v-if="navbar === 'inner'" :color="color" :title="title" :leftIcon="leftIcon" />
|
||||||
<view v-if="navbar === 'inner'" :style="[{ paddingTop: peach.$platform.navbar + 'px' }]"></view>
|
<view v-if="navbar === 'inner'" :style="[{ paddingTop: peach.$platform.navBar + 'px' }]"></view>
|
||||||
|
|
||||||
<!-- 页面内容插槽 -->
|
<!-- 页面内容插槽 -->
|
||||||
<slot />
|
<slot />
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
Loading…
Reference in New Issue