index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view class="user-content">
  3. <!-- 头部 -->
  4. <view class="user-head">
  5. <view class="user-photo">
  6. <u-image width="90rpx" shape="circle" height="90rpx" :src="userInfo&&userInfo.avatarUrl"></u-image>
  7. </view>
  8. <view class="user-info">
  9. {{userInfo&&userInfo.nickName}}
  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. userInfo: {
  33. avatarUrl:'',
  34. nickName:''
  35. }
  36. };
  37. },
  38. onShow() {
  39. let _this = this
  40. uni.getUserInfo({
  41. provider: 'weixin',
  42. success(e) {
  43. console.log(e)
  44. _this.userInfo = e.userInfo
  45. }
  46. })
  47. },
  48. methods:{
  49. // 打开对应的页面
  50. toPage(index){
  51. let pageUrl=['/pages/coupon/index/index','/pages/order/order','/pages/agreement/agreement?fromPage=usercenter']
  52. uni.navigateTo({
  53. url: pageUrl[index]
  54. })
  55. },
  56. // 退出登录
  57. quitSys(){
  58. let _this = this
  59. uni.showModal({
  60. title: '提示',
  61. content: '您确定要退出登录吗?',
  62. success(res) {
  63. if (res.confirm) {
  64. logout({}).then(res => {
  65. getApp().globalData.token = ''
  66. _this.$u.vuex('vuex_token','')
  67. uni.reLaunch({
  68. url: '/pages/index/index'
  69. });
  70. });
  71. }
  72. }
  73. });
  74. },
  75. bindGetUserInfo(res){
  76. console.log(res)
  77. },
  78. }
  79. }
  80. </script>
  81. <style lang="scss">
  82. .user-content{
  83. width: 100%;
  84. .user-head{
  85. display: flex;
  86. align-items: center;
  87. padding: 35rpx;
  88. .user-info{
  89. flex-grow: 1;
  90. padding: 0 20rpx;
  91. }
  92. }
  93. .user-list{
  94. padding:0 20rpx;
  95. }
  96. .user-btn{
  97. padding: 85rpx 100rpx;
  98. }
  99. }
  100. </style>