index.vue 3.5 KB

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