index.vue 3.4 KB

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