index.vue 3.2 KB

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