index.vue 3.0 KB

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