index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view class="user-index">
  3. <nav-bar title="个人中心" @init="onInitNavbar"></nav-bar>
  4. <u-scroll-view :tabbar-conflict="true">
  5. <view class="main-container">
  6. <view class="user-info" @click="onClickUserInfo">
  7. <view class="user-avator">
  8. <image v-if="isLoginState && avatar" :src="avatar" />
  9. <van-icon v-else class="icon" name="user" />
  10. </view>
  11. <view class="user-title">
  12. <view class="user-name">
  13. <template v-if="isLoginState">{{ nickName || phone }}</template>
  14. <template v-else>请登录/注册</template>
  15. </view>
  16. <view v-if="isLoginState && nickName" class="user-phone">手机号:{{ phone }}</view>
  17. </view>
  18. </view>
  19. <view class="user-grid-menu">
  20. <view hover-class="active" @click="navigateTo('/pages/user/like')">
  21. <view class="iconfont icon-heart1"></view>
  22. <view>点赞</view>
  23. </view>
  24. <view hover-class="active" @click="navigateTo('/pages/user/favorites')">
  25. <view class="iconfont icon-Favourites-Add-Large"></view>
  26. <view>收藏</view>
  27. </view>
  28. <view hover-class="active" @click="navigateTo('/pages/user/vote')">
  29. <view class="iconfont icon-xiaochengxu-toupiaoicon"></view>
  30. <view>投票</view>
  31. </view>
  32. <view hover-class="active" @click="showAlertDialog('功能未开通')">
  33. <view class="iconfont icon-xiaochengxu-guanzhongyudengjiicon"></view>
  34. <view>预登记</view>
  35. </view>
  36. </view>
  37. <view class="user-list-item">
  38. <van-cell-group>
  39. <van-cell title="设置" is-link @click="onClickSetting">
  40. <view slot="icon" class="iconfont icon-setting" />
  41. </van-cell>
  42. </van-cell-group>
  43. </view>
  44. <view class="ad-space">
  45. <image src="https://oss.starify.cn/prod/starify/up/0001018678/20241108/672da70adbdbe.png?x-oss-process=image/resize,w_200" mode="aspectFill" />
  46. </view>
  47. </view>
  48. </u-scroll-view>
  49. </view>
  50. </template>
  51. <script>
  52. import NavBar from '@/components/layout/nav-bar'
  53. import UScrollView from '@/components/common/u-scroll-view'
  54. import VanCell from '@/wxcomponents/vant/cell/index'
  55. import VanCellGroup from '@/wxcomponents/vant/cell-group/index'
  56. export default {
  57. options: {
  58. styleIsolation: 'shared'
  59. },
  60. components: {
  61. NavBar,
  62. UScrollView,
  63. VanCell,
  64. VanCellGroup
  65. },
  66. computed: {
  67. isLoginState() {
  68. return this.$store.getters.user !== null
  69. },
  70. avatar() {
  71. const user = this.$store.getters.user
  72. if (user) {
  73. return user.avatar
  74. } else {
  75. return ''
  76. }
  77. },
  78. nickName() {
  79. const user = this.$store.getters.user
  80. if (user) {
  81. return user.nick_name
  82. } else {
  83. return ''
  84. }
  85. },
  86. phone() {
  87. const user = this.$store.getters.user
  88. if (user) {
  89. return user.phone
  90. } else {
  91. return ''
  92. }
  93. }
  94. },
  95. data() {
  96. return {
  97. }
  98. },
  99. created() {},
  100. onShow() {
  101. },
  102. methods: {
  103. onClickSetting() {
  104. this.navigateTo('/pages/user/setting')
  105. },
  106. onClickUserInfo(){
  107. this.navigateTo('/pages/user/info')
  108. }
  109. }
  110. }
  111. </script>
  112. <style lang="scss">
  113. .user-index{
  114. .user-info{
  115. display: flex;
  116. align-items: center;
  117. .user-avator{
  118. @include display-flex-center;
  119. width: 111rpx;
  120. height: 111rpx;
  121. border-radius: 50%;
  122. overflow: hidden;
  123. margin-right: 23rpx;
  124. background-color: $buttonPrimaryColor;
  125. .icon{
  126. color: #ffffff;
  127. opacity: 0.67;
  128. font-size: 70rpx;
  129. }
  130. }
  131. .user-name{
  132. font-size: 30rpx;
  133. color: #333333;
  134. }
  135. .user-phone{
  136. font-size: $fontSize3;
  137. color: #7d7d7d;
  138. }
  139. }
  140. .user-grid-menu{
  141. display: grid;
  142. grid-template-columns: repeat(4, 1fr);
  143. height: 192rpx;
  144. margin-top: 60rpx;
  145. background-color: #FFFFFF;
  146. &>view{
  147. @include display-flex-center;
  148. flex-direction: column;
  149. font-size: $fontSize3;
  150. color: #333333;
  151. cursor: pointer;
  152. &.active{
  153. background-color: rgba(0, 0, 0, 0.05)
  154. }
  155. }
  156. .iconfont{
  157. margin-bottom: 19rpx;
  158. font-size: 44rpx;
  159. }
  160. .icon-Heart,.icon-xiaochengxu-toupiaoicon{
  161. font-size: 48rpx;
  162. }
  163. }
  164. .user-list-item{
  165. margin-top: 23rpx;
  166. .van-cell{
  167. --cell-horizontal-padding: 58rpx;
  168. }
  169. }
  170. .ad-space{
  171. height: 180rpx;
  172. margin-top: 23rpx;
  173. }
  174. }
  175. </style>