index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view class="user-content">
  3. <!-- 头部 -->
  4. <view class="user-head">
  5. <view class="user-photo">
  6. <open-data type="userAvatarUrl" class="avatar"></open-data>
  7. </view>
  8. <view class="user-info">
  9. <text class="user-name">{{userInfoData.parentOrgName}}</text>
  10. <text class="user-phone">{{userInfoData.userNameCN || ''}} {{userInfoData.username || ''}}</text>
  11. </view>
  12. </view>
  13. <!-- 列表 -->
  14. <view class="user-list">
  15. <u-cell-group>
  16. <u-cell-item icon="file-text" icon-size="40" :icon-style="{color:'#ffaa00'}" index="0" @click="toPage" title="服务协议及隐私政策"></u-cell-item>
  17. <u-cell-item icon="info-circle" icon-size="38" :icon-style="{color:'#55aa00'}" index="1" @click="toPage" title="关于我们"></u-cell-item>
  18. <u-cell-item icon="lock" icon-size="38" :icon-style="{color:'#00aaff'}" index="2" @click="toPage" title="修改密码"></u-cell-item>
  19. </u-cell-group>
  20. </view>
  21. <!-- 退出 -->
  22. <view class="user-btn">
  23. <u-button type="success" hover-class="none" :custom-style="quitButton" @click="quitSys" shape="circle">退出登录</u-button>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import {logout} from '@/api/login.js'
  29. import { getUserInfo } from '@/api/user.js'
  30. export default {
  31. data() {
  32. return {
  33. quitButton: {
  34. borderRadius:'100rpx',
  35. fontSize:'30rpx',
  36. background: '#e84131'
  37. },
  38. userInfoData: null, // 用户信息
  39. userAvatarUrl: '' // 用户头像
  40. };
  41. },
  42. onShow() {
  43. this.getUserInfo()
  44. },
  45. onLoad() {
  46. },
  47. methods:{
  48. // 获取用户信息
  49. getUserInfo(){
  50. this.userInfoData = this.$store.state.vuex_userData
  51. // getUserInfo().then(res => {
  52. // if(res.status == 200){
  53. // this.userInfoData = res.data
  54. // }else{
  55. // this.userInfoData = null
  56. // }
  57. // })
  58. },
  59. // 打开对应的页面
  60. toPage(index){
  61. let pageUrl=[
  62. '/pages/agreement/agreement?fromPage=usercenter',
  63. '/pages/userCenter/aboutUs',
  64. '/pages/userCenter/changePwd'
  65. ]
  66. uni.navigateTo({
  67. url: pageUrl[index]
  68. })
  69. },
  70. // 退出登录
  71. quitSys(){
  72. let _this = this
  73. uni.showModal({
  74. title: '提示',
  75. content: '您确定要退出登录吗?',
  76. success(ret) {
  77. if (ret.confirm) {
  78. console.log(111)
  79. _this.logoutFun()
  80. }
  81. }
  82. })
  83. },
  84. logoutFun(){
  85. const _this = this
  86. logout({}).then(res => {
  87. console.log(222)
  88. getApp().globalData.token = ''
  89. _this.$u.vuex('vuex_token','')
  90. _this.$u.vuex('vuex_userData','')
  91. // 关闭socket
  92. // _this.$store.commit("$closeWebsocket")
  93. uni.reLaunch({
  94. url: '/pages/login/login'
  95. })
  96. })
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss">
  102. .user-content{
  103. width: 100%;
  104. .user-head{
  105. background: #e84131;
  106. display: flex;
  107. align-items: center;
  108. padding: 55rpx 55rpx;
  109. .user-photo{
  110. flex-shrink: 0;
  111. margin-right: 5rpx;
  112. width: 130rpx;
  113. height: 130rpx;
  114. border-radius: 50%;
  115. overflow: hidden;
  116. }
  117. .user-info{
  118. flex-grow: 1;
  119. padding: 0 20rpx;
  120. color: #FFFFFF;
  121. .user-name{
  122. display: block;
  123. font-size: 30rpx;
  124. margin-bottom: 20rpx;
  125. }
  126. .user-phone{
  127. display: block;
  128. font-size: 26rpx;
  129. }
  130. }
  131. }
  132. .user-list{
  133. border-radius: 15rpx;
  134. margin: 20rpx;
  135. overflow: hidden;
  136. box-shadow: 0rpx 3rpx 6rpx #eee;
  137. }
  138. .user-btn{
  139. padding: 85rpx 200rpx;
  140. }
  141. }
  142. </style>