index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view class="user-content">
  3. <!-- 头部 -->
  4. <view class="user-head" @click="toUserPage">
  5. <view class="user-photo">
  6. <open-data type="userAvatarUrl"></open-data>
  7. </view>
  8. <view class="user-info">
  9. <open-data type="userNickName"></open-data>
  10. </view>
  11. <view class="user-jifen">
  12. <view>乐豆:<text>345</text></view>
  13. <u-image mode="scaleToFill" width="35rpx" height="35rpx" src="/static/ledou.png"></u-image>
  14. </view>
  15. </view>
  16. <!-- 列表 -->
  17. <view class="user-list">
  18. <u-cell-group>
  19. <u-cell-item icon="order" icon-size="38" :icon-style="{color:'#ff5500'}" index="1" @click="toPage" title="我的订单"></u-cell-item>
  20. <u-cell-item icon="gift" icon-size="40" :icon-style="{color:'#00aaff'}" index="0" @click="toPage" title="投递记录"></u-cell-item>
  21. <u-cell-item icon="file-text" icon-size="40" :icon-style="{color:'#ffaa00'}" index="2" @click="toPage" title="服务协议"></u-cell-item>
  22. <u-cell-item icon="info-circle" icon-size="38" :icon-style="{color:'#55aa00'}" 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: '#01c9b2'
  40. }
  41. };
  42. },
  43. onShow() {
  44. },
  45. onLoad() {
  46. },
  47. methods:{
  48. // 打开对应的页面
  49. toPage(index){
  50. let pageUrl=[
  51. '/pages/coupon/index/index',
  52. '/pages/order/order',
  53. '/pages/agreement/agreement?fromPage=usercenter',
  54. '/pages/userCenter/aboutUs'
  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. quitSys(){
  69. let _this = this
  70. uni.showModal({
  71. title: '提示',
  72. content: '您确定要退出登录吗?',
  73. success(res) {
  74. if (res.confirm) {
  75. logout({}).then(res => {
  76. getApp().globalData.token = ''
  77. _this.$u.vuex('vuex_token','')
  78. // 关闭socket
  79. _this.$store.commit("$closeWebsocket")
  80. uni.reLaunch({
  81. url: '/pages/index/index'
  82. });
  83. });
  84. }
  85. }
  86. });
  87. },
  88. bindGetUserInfo(res){
  89. console.log(res)
  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;
  102. .user-info{
  103. flex-grow: 1;
  104. padding: 0 20rpx;
  105. color: #FFFFFF;
  106. }
  107. .user-photo{
  108. width: 100rpx;
  109. height: 100rpx;
  110. border-radius: 50%;
  111. overflow: hidden;
  112. margin-right: 5rpx;
  113. }
  114. .user-jifen{
  115. color: #FFFFFF;
  116. display: flex;
  117. align-items: center;
  118. text{
  119. font-size: 40upx;
  120. font-weight: bold;
  121. }
  122. >view{
  123. &:first-child{
  124. display: flex;
  125. align-items: center;
  126. }
  127. }
  128. }
  129. }
  130. .user-list{
  131. padding:20rpx 0;
  132. }
  133. .user-btn{
  134. padding: 85rpx 200rpx;
  135. }
  136. }
  137. </style>