index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="user-content">
  3. <!-- 头部 -->
  4. <view class="user-head">
  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>
  12. <!-- 列表 -->
  13. <view class="user-list">
  14. <u-cell-group>
  15. <u-cell-item icon="gift" index="0" @click="toPage" title="我的优惠卷"></u-cell-item>
  16. <u-cell-item icon="order" index="1" @click="toPage" title="我的订单"></u-cell-item>
  17. <u-cell-item icon="file-text" index="2" @click="toPage" title="服务协议"></u-cell-item>
  18. <!-- <u-cell-item icon="info-circle" index="3" @click="toPage" title="关于我们"></u-cell-item> -->
  19. </u-cell-group>
  20. </view>
  21. <!-- 退出 -->
  22. <view class="user-btn">
  23. <u-button type="error" @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. };
  33. },
  34. onShow() {
  35. },
  36. onLoad() {
  37. },
  38. methods:{
  39. // 打开对应的页面
  40. toPage(index){
  41. let pageUrl=['/pages/coupon/index/index','/pages/order/order','/pages/agreement/agreement?fromPage=usercenter']
  42. uni.navigateTo({
  43. url: pageUrl[index]
  44. })
  45. },
  46. // 退出登录
  47. quitSys(){
  48. let _this = this
  49. uni.showModal({
  50. title: '提示',
  51. content: '您确定要退出登录吗?',
  52. success(res) {
  53. if (res.confirm) {
  54. logout({}).then(res => {
  55. getApp().globalData.token = ''
  56. _this.$u.vuex('vuex_token','')
  57. // 关闭socket
  58. _this.$store.commit("$closeWebsocket")
  59. uni.reLaunch({
  60. url: '/pages/index/index'
  61. });
  62. });
  63. }
  64. }
  65. });
  66. },
  67. bindGetUserInfo(res){
  68. console.log(res)
  69. },
  70. }
  71. }
  72. </script>
  73. <style lang="scss">
  74. .user-content{
  75. width: 100%;
  76. .user-head{
  77. display: flex;
  78. align-items: center;
  79. padding: 35rpx;
  80. .user-info{
  81. flex-grow: 1;
  82. padding: 0 20rpx;
  83. }
  84. .user-photo{
  85. width: 100rpx;
  86. height: 100rpx;
  87. border-radius: 50%;
  88. overflow: hidden;
  89. margin-right: 30rpx;
  90. }
  91. }
  92. .user-list{
  93. padding:0 20rpx;
  94. }
  95. .user-btn{
  96. padding: 85rpx 100rpx;
  97. }
  98. }
  99. </style>