Files
cmgd-mini-app/pages/mine/index.vue
2026-01-17 02:33:39 +08:00

136 lines
2.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="page-content">
<view class="user-inner" v-if="uid > 0">
<view>
<nut-avatar size="large">用户</nut-avatar>
</view>
<view class="user-info-style">
<text class="nickname">{{ staffName }}</text>
<text class="user-id">UID{{ uid }}</text>
</view>
</view>
<view class="content">
<nut-cell-group title="">
<nut-grid>
<nut-grid-item text="订单管理" @click="navigateTo('/pages/order/index?tab=0')">
<nut-icon name="order"></nut-icon>
</nut-grid-item>
<nut-grid-item v-if="staffRole == 1" text="运营数据" @click="navigateTo('/pages/data/index')">
<nut-icon name="eye"></nut-icon>
</nut-grid-item>
</nut-grid>
</nut-cell-group>
</view>
</view>
</template>
<script setup>
// 导入Vue的响应式函数
import {
reactive,
ref
} from 'vue';
import {
onLoad,
onShow,
} from '@dcloudio/uni-app';
import {
navigateTo
} from '@/utils/helper';
import {
fetchRooms,
fetchBooking,
fetchUnBooking,
fetchUserInfo,
} from '@/api/index';
// 用户ID
const uid = ref(0);
const staffName = ref('');
const staffRole = ref(0);
onLoad(options => {
init();
});
// 获取配置
const init = () => {
fetchUserInfo().then(res => {
console.log(res);
uni.setStorageSync('uid', res.user_id)
uni.setStorageSync('user_name', res.user_name)
uni.setStorageSync('role', res.role.value)
uni.setStorageSync('staff_name', res.staff_name)
})
let user_name = uni.getStorageSync('user_name')
let staff_name = uni.getStorageSync('staff_name')
let role = uni.getStorageSync('role')
let user_id = uni.getStorageSync('uid');
console.log("staff_name", staff_name);
uid.value = user_id
staffName.value = staff_name
staffRole.value = role
}
/**
* 页面显示生命周期钩子
* 每次页面显示时都会执行
*/
onShow(() => {
console.log('init');
init();
});
</script>
<style scoped lang="scss">
.page-content {
min-height: 100vh;
background-color: #f2f3f5;
}
.user-inner {
background: linear-gradient(30deg, rgba(198, 77, 255, 0.99), rgba(102, 204, 255, 0.99));
height: 300rpx;
width: calc(100% - 40rpx);
display: flex;
align-items: center;
padding: 0px 20rpx;
gap: 30rpx;
}
.user-info-style {
display: flex;
flex-direction: column;
align-items: flex-start;
}
.nickname {
font-size: 28rpx;
color: #333;
margin-bottom: 10rpx;
}
.user-id {
font-size: 26rpx;
color: #fff;
}
.content {
display: flex;
flex-direction: column;
background-color: #f2f3f5;
padding: 0px 20rpx;
}
</style>