index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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="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" :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: '#2ab4e5'
  37. },
  38. userInfoData: null, // 用户信息
  39. userAvatarUrl: '' // 用户头像
  40. };
  41. },
  42. onShow() {
  43. this.getUserInfo()
  44. },
  45. onLoad() {
  46. },
  47. methods:{
  48. // 获取用户信息
  49. getUserInfo(){
  50. getUserInfo().then(res => {
  51. if(res.status == 200){
  52. this.userInfoData = res.data
  53. }else{
  54. this.userInfoData = null
  55. }
  56. })
  57. },
  58. // 打开对应的页面
  59. toPage(index){
  60. let pageUrl=[
  61. '/pages/agreement/agreement?fromPage=usercenter',
  62. '/pages/userCenter/aboutUs',
  63. '/pages/userCenter/changePwd'
  64. ]
  65. uni.navigateTo({
  66. url: pageUrl[index]
  67. })
  68. },
  69. // 跳转
  70. toUserPage(){
  71. // 未登录跳转登录,已登录跳转用户信息页
  72. uni.navigateTo({
  73. url: '/pages/userCenter/userInfo/userInfo'
  74. })
  75. },
  76. // 乐豆明细
  77. toLdPage(){
  78. uni.navigateTo({
  79. url: '/pages/userCenter/ldDetailed'
  80. })
  81. },
  82. bindGetUserInfo(res){
  83. console.log(res)
  84. },
  85. // 退出登录
  86. quitSys(){
  87. let _this = this
  88. uni.showModal({
  89. title: '提示',
  90. content: '您确定要退出登录吗?',
  91. success(res) {
  92. if (res.confirm) {
  93. logout({}).then(res => {
  94. getApp().globalData.token = ''
  95. _this.$u.vuex('vuex_token','')
  96. // 关闭socket
  97. // _this.$store.commit("$closeWebsocket")
  98. uni.reLaunch({
  99. url: '/pages/login/login'
  100. })
  101. })
  102. }
  103. }
  104. })
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss">
  110. .user-content{
  111. width: 100%;
  112. .user-head{
  113. background: #2ab4e5;
  114. display: flex;
  115. align-items: center;
  116. padding: 35rpx 55rpx;
  117. .user-photo{
  118. flex-shrink: 0;
  119. margin-right: 5rpx;
  120. width: 130rpx;
  121. height: 130rpx;
  122. border-radius: 50%;
  123. overflow: hidden;
  124. }
  125. .user-info{
  126. flex-grow: 1;
  127. padding: 0 20rpx;
  128. color: #FFFFFF;
  129. .user-name{
  130. display: block;
  131. font-size: 30rpx;
  132. margin-bottom: 20rpx;
  133. }
  134. .user-phone{
  135. display: block;
  136. font-size: 26rpx;
  137. }
  138. }
  139. }
  140. .user-list{
  141. border-radius: 15upx;
  142. margin: 20upx;
  143. overflow: hidden;
  144. box-shadow: 0upx 3upx 6upx #eee;
  145. }
  146. .user-btn{
  147. padding: 85rpx 200rpx;
  148. }
  149. }
  150. </style>