personCenter.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <view class="page-body">
  3. <view class="header">
  4. <view>个人中心</view>
  5. </view>
  6. <view class="person">
  7. <view class="row1">
  8. <view class="avatar">
  9. <img src="https://pic2.zhimg.com/50/v2-48ad5fee92cb9fc7292db33223452313_hd.png" alt="" srcset="">
  10. </view>
  11. <view class="col">
  12. <text>{{ users.nickname }}</text>
  13. <text>沉迷工作ing...</text>
  14. </view>
  15. <view class="right-icon font-icons">&#xe66b;</view>
  16. </view>
  17. <view class="system-row">
  18. <text class="system-row-item">系统环境</text>
  19. <view class="system-row-item font-icons" style="margin-right: 24px;">{{ osName }}</view>
  20. </view>
  21. <view class="system-row">
  22. <text class="system-row-item">设备型号</text>
  23. <view class="system-row-item font-icons" style="margin-right: 24px;">{{ deviceModel }}</view>
  24. </view>
  25. <view class="system-row">
  26. <text class="system-row-item">设备环境</text>
  27. <view class="system-row-item font-icons" style="margin-right: 24px;">{{ systemType }}</view>
  28. </view>
  29. <view class="row2" style="margin-top: 4px;">
  30. <view class="left-icon font-icons" style="color: darkorange;">&#xe7e0;</view>
  31. <text>我的待办</text>
  32. <view class="right-icon font-icons">&#xe66b;</view>
  33. </view>
  34. <view class="row2">
  35. <view class="left-icon font-icons">&#xe6bc;</view>
  36. <text>账户设置</text>
  37. <view class="right-icon font-icons">&#xe66b;</view>
  38. </view>
  39. <view class="row3" @click="showModal">
  40. <view class="left-icon font-icons">&#xe6e4;</view>
  41. <text>退出登录</text>
  42. </view>
  43. </view>
  44. <uni-popup ref="modalForm" type="dialog">
  45. <uni-popup-dialog
  46. type="error"
  47. cancel-text="取消"
  48. confirm-text="确认"
  49. title="提示"
  50. content="确定要登出当前账户吗?"
  51. @confirm="handleLoginOutConfirm"
  52. @close="handleLoginOutCancel"
  53. />
  54. </uni-popup>
  55. </view>
  56. </template>
  57. <script>
  58. import {
  59. defineComponent,
  60. ref,
  61. onMounted,
  62. reactive,
  63. toRefs
  64. } from 'vue'
  65. import Bluetooth from '@/unit/print/bluetooth.js'
  66. const bluetooth = new Bluetooth()
  67. export default defineComponent({
  68. setup() {
  69. const users = ref({
  70. nickname: '',
  71. avatar: ''
  72. })
  73. const modalForm = ref()
  74. const systemInfo = reactive({
  75. systemType: '',
  76. deviceModel: '',
  77. osName: ''
  78. })
  79. onMounted(() => {
  80. uni.getSystemInfo({
  81. success(res) {
  82. systemInfo.deviceModel = res.deviceModel.toLocaleUpperCase()
  83. systemInfo.osName = res.osName
  84. }
  85. })
  86. if (uni.$isPad) {
  87. systemInfo.systemType = '平板'
  88. }
  89. if (uni.$isPda) {
  90. systemInfo.systemType = '手持终端'
  91. }
  92. if (uni.$isPhone) {
  93. systemInfo.systemType = '手机'
  94. }
  95. const userInfo = JSON.parse(uni.getStorageSync('userInfo') ?? {})
  96. users.value.nickname = userInfo?.username
  97. users.value.avatar = userInfo?.avatar
  98. })
  99. const showModal = function() {
  100. modalForm.value.open()
  101. }
  102. const handleLoginOutConfirm = function() {
  103. modalForm.value.close()
  104. // #ifdef APP-PLUS
  105. // 页面卸载是关闭蓝牙链接
  106. bluetooth.closeBLEConnection()
  107. bluetooth.closeBluetoothAdapter()
  108. // #endif
  109. uni.setStorageSync('whetherRestart', 'true')
  110. uni.removeStorageSync('token')
  111. uni.removeStorageSync('user')
  112. uni.removeStorageSync('userInfo')
  113. uni.removeStorageSync('permissions')
  114. uni.removeStorageSync('selectedIndex')
  115. uni.removeStorageSync('registerRecods')
  116. // #ifdef H5
  117. uni.redirectTo({
  118. url: '/pages/login/loginPage'
  119. })
  120. // #endif
  121. // #ifdef APP-PLUS
  122. setTimeout(() => {
  123. plus.runtime.restart()
  124. }, 600)
  125. // #endif
  126. }
  127. const handleLoginOutCancel = function() {
  128. modalForm.value.close()
  129. }
  130. const handleNavigateToAccountConfig = function() {
  131. uni.navigateTo({
  132. url: '/pages/personCenter/accountConfig'
  133. })
  134. }
  135. return {
  136. ...toRefs(systemInfo),
  137. users,
  138. modalForm,
  139. showModal,
  140. handleLoginOutConfirm,
  141. handleLoginOutCancel,
  142. handleNavigateToAccountConfig
  143. }
  144. }
  145. })
  146. </script>
  147. <style lang="scss" scoped>
  148. .page-body {
  149. background-color: #e9e9e9;
  150. }
  151. .header {
  152. position: fixed;
  153. top: 0;
  154. width: 100vw;
  155. height: 40px;
  156. padding-top: 30px;
  157. font-size: 16px;
  158. font-weight: bold;
  159. text-align: center;
  160. color: black;
  161. background-color: #ebebeb;
  162. view {
  163. padding-top: 10px;
  164. }
  165. }
  166. .person {
  167. margin-top: 72px;
  168. .row1 {
  169. height: 100px;
  170. display: grid;
  171. grid-template-columns: 2fr 5fr 1fr;
  172. align-items: center;
  173. margin-bottom: 4px;
  174. background-color: white;
  175. .avatar {
  176. display: flex;
  177. justify-content: center;
  178. align-items: center;
  179. img {
  180. width: 55px;
  181. height: 55px;
  182. }
  183. }
  184. .col {
  185. padding: 0 8px;
  186. display: grid;
  187. grid-template-rows: 1fr 1fr;
  188. uni-text {
  189. height: 50px;
  190. }
  191. uni-text:nth-of-type(1) {
  192. display: flex;
  193. align-items: flex-end;
  194. color: #539cf8;
  195. font-size: 18px;
  196. font-weight: bold;
  197. }
  198. uni-text:nth-of-type(2) {
  199. color: gray;
  200. }
  201. }
  202. .right-icon {
  203. display: flex;
  204. justify-content: center;
  205. }
  206. }
  207. .row2 {
  208. height: 60px;
  209. display: grid;
  210. grid-template-columns: 1.5fr 5fr 0.55fr;
  211. align-items: center;
  212. background-color: white;
  213. .left-icon {
  214. font-size: 32px;
  215. color: gray;
  216. display: flex;
  217. justify-content: center;
  218. }
  219. }
  220. .row3 {
  221. height: 50px;
  222. margin: 4px 0;
  223. display: grid;
  224. grid-template-columns: 1fr 1.25fr;
  225. align-items: center;
  226. color: #f85661;
  227. background-color: white;
  228. .left-icon {
  229. font-size: 24px;
  230. display: flex;
  231. justify-content: flex-end;
  232. }
  233. }
  234. }
  235. .system-row {
  236. height: 40px;
  237. display: grid;
  238. flex-direction: row;
  239. grid-template-columns: 1.2fr 5fr;
  240. align-items: center;
  241. background-color: white;
  242. .system-row-item {
  243. text-align: right;
  244. }
  245. }
  246. </style>