| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- <template>
- <view class="page-body">
- <view class="header">
- <view>个人中心</view>
- </view>
- <view class="person">
- <view class="row1">
- <view class="avatar">
- <img src="https://pic2.zhimg.com/50/v2-48ad5fee92cb9fc7292db33223452313_hd.png" alt="" srcset="">
- </view>
- <view class="col">
- <text>{{ users.nickname }}</text>
- <text>沉迷工作ing...</text>
- </view>
- <view class="right-icon font-icons"></view>
- </view>
- <view class="system-row">
- <text class="system-row-item">系统环境</text>
- <view class="system-row-item font-icons" style="margin-right: 24px;">{{ osName }}</view>
- </view>
- <view class="system-row">
- <text class="system-row-item">设备型号</text>
- <view class="system-row-item font-icons" style="margin-right: 24px;">{{ deviceModel }}</view>
- </view>
- <view class="system-row">
- <text class="system-row-item">设备环境</text>
- <view class="system-row-item font-icons" style="margin-right: 24px;">{{ systemType }}</view>
- </view>
- <view class="row2" style="margin-top: 4px;">
- <view class="left-icon font-icons" style="color: darkorange;"></view>
- <text>我的待办</text>
- <view class="right-icon font-icons"></view>
- </view>
- <view class="row2">
- <view class="left-icon font-icons"></view>
- <text>账户设置</text>
- <view class="right-icon font-icons"></view>
- </view>
- <view class="row3" @click="showModal">
- <view class="left-icon font-icons"></view>
- <text>退出登录</text>
- </view>
- </view>
- <uni-popup ref="modalForm" type="dialog">
- <uni-popup-dialog
- type="error"
- cancel-text="取消"
- confirm-text="确认"
- title="提示"
- content="确定要登出当前账户吗?"
- @confirm="handleLoginOutConfirm"
- @close="handleLoginOutCancel"
- />
- </uni-popup>
- </view>
- </template>
- <script>
- import {
- defineComponent,
- ref,
- onMounted,
- reactive,
- toRefs
- } from 'vue'
- import Bluetooth from '@/unit/print/bluetooth.js'
- const bluetooth = new Bluetooth()
- export default defineComponent({
- setup() {
- const users = ref({
- nickname: '',
- avatar: ''
- })
- const modalForm = ref()
- const systemInfo = reactive({
- systemType: '',
- deviceModel: '',
- osName: ''
- })
- onMounted(() => {
- uni.getSystemInfo({
- success(res) {
- systemInfo.deviceModel = res.deviceModel.toLocaleUpperCase()
- systemInfo.osName = res.osName
- }
- })
- if (uni.$isPad) {
- systemInfo.systemType = '平板'
- }
- if (uni.$isPda) {
- systemInfo.systemType = '手持终端'
- }
- if (uni.$isPhone) {
- systemInfo.systemType = '手机'
- }
- const userInfo = JSON.parse(uni.getStorageSync('userInfo') ?? {})
- users.value.nickname = userInfo?.username
- users.value.avatar = userInfo?.avatar
- })
- const showModal = function() {
- modalForm.value.open()
- }
- const handleLoginOutConfirm = function() {
- modalForm.value.close()
- // #ifdef APP-PLUS
- // 页面卸载是关闭蓝牙链接
- bluetooth.closeBLEConnection()
- bluetooth.closeBluetoothAdapter()
- // #endif
- uni.setStorageSync('whetherRestart', 'true')
- uni.removeStorageSync('token')
- uni.removeStorageSync('user')
- uni.removeStorageSync('userInfo')
- uni.removeStorageSync('permissions')
- uni.removeStorageSync('selectedIndex')
- uni.removeStorageSync('registerRecods')
- // #ifdef H5
- uni.redirectTo({
- url: '/pages/login/loginPage'
- })
- // #endif
- // #ifdef APP-PLUS
- setTimeout(() => {
- plus.runtime.restart()
- }, 600)
- // #endif
- }
- const handleLoginOutCancel = function() {
- modalForm.value.close()
- }
- const handleNavigateToAccountConfig = function() {
- uni.navigateTo({
- url: '/pages/personCenter/accountConfig'
- })
- }
- return {
- ...toRefs(systemInfo),
- users,
- modalForm,
- showModal,
- handleLoginOutConfirm,
- handleLoginOutCancel,
- handleNavigateToAccountConfig
- }
- }
- })
- </script>
- <style lang="scss" scoped>
- .page-body {
- background-color: #e9e9e9;
- }
- .header {
- position: fixed;
- top: 0;
- width: 100vw;
- height: 40px;
- padding-top: 30px;
- font-size: 16px;
- font-weight: bold;
- text-align: center;
- color: black;
- background-color: #ebebeb;
- view {
- padding-top: 10px;
- }
- }
- .person {
- margin-top: 72px;
- .row1 {
- height: 100px;
- display: grid;
- grid-template-columns: 2fr 5fr 1fr;
- align-items: center;
- margin-bottom: 4px;
- background-color: white;
- .avatar {
- display: flex;
- justify-content: center;
- align-items: center;
- img {
- width: 55px;
- height: 55px;
- }
- }
- .col {
- padding: 0 8px;
- display: grid;
- grid-template-rows: 1fr 1fr;
- uni-text {
- height: 50px;
- }
- uni-text:nth-of-type(1) {
- display: flex;
- align-items: flex-end;
- color: #539cf8;
- font-size: 18px;
- font-weight: bold;
- }
- uni-text:nth-of-type(2) {
- color: gray;
- }
- }
- .right-icon {
- display: flex;
- justify-content: center;
- }
- }
- .row2 {
- height: 60px;
- display: grid;
- grid-template-columns: 1.5fr 5fr 0.55fr;
- align-items: center;
- background-color: white;
- .left-icon {
- font-size: 32px;
- color: gray;
- display: flex;
- justify-content: center;
- }
- }
- .row3 {
- height: 50px;
- margin: 4px 0;
- display: grid;
- grid-template-columns: 1fr 1.25fr;
- align-items: center;
- color: #f85661;
- background-color: white;
- .left-icon {
- font-size: 24px;
- display: flex;
- justify-content: flex-end;
- }
- }
- }
- .system-row {
- height: 40px;
- display: grid;
- flex-direction: row;
- grid-template-columns: 1.2fr 5fr;
- align-items: center;
- background-color: white;
- .system-row-item {
- text-align: right;
- }
- }
- </style>
|