index.vue 3.6 KB

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