index.vue 2.9 KB

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