index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. if (!this.isLoginState) {
  105. uni.navigateTo({
  106. url: '/pages/user/login'
  107. })
  108. } else {
  109. uni.navigateTo({
  110. url: '/pages/user/setting'
  111. })
  112. }
  113. },
  114. onClickUserInfo(){
  115. if (!this.isLoginState) {
  116. uni.navigateTo({
  117. url: '/pages/user/login'
  118. })
  119. }
  120. }
  121. }
  122. }
  123. </script>
  124. <style lang="scss">
  125. .user-index{
  126. .user-info{
  127. display: flex;
  128. align-items: center;
  129. .user-avator{
  130. @include display-flex-center;
  131. width: 111rpx;
  132. height: 111rpx;
  133. border-radius: 50%;
  134. overflow: hidden;
  135. margin-right: 23rpx;
  136. background-color: $buttonPrimaryColor;
  137. .icon{
  138. color: #ffffff;
  139. opacity: 0.67;
  140. font-size: 70rpx;
  141. }
  142. }
  143. .user-name{
  144. font-size: 30rpx;
  145. color: #333333;
  146. }
  147. .user-phone{
  148. font-size: $fontSize3;
  149. color: #7d7d7d;
  150. }
  151. }
  152. .user-grid-menu{
  153. display: grid;
  154. grid-template-columns: repeat(4, 1fr);
  155. height: 192rpx;
  156. margin-top: 60rpx;
  157. background-color: #FFFFFF;
  158. &>view{
  159. @include display-flex-center;
  160. flex-direction: column;
  161. font-size: $fontSize3;
  162. color: #333333;
  163. &.active{
  164. background-color: rgba(0, 0, 0, 0.05)
  165. }
  166. }
  167. .iconfont{
  168. margin-bottom: 19rpx;
  169. font-size: 44rpx;
  170. }
  171. .icon-Heart,.icon-xiaochengxu-toupiaoicon{
  172. font-size: 48rpx;
  173. }
  174. }
  175. .user-list-item{
  176. margin-top: 23rpx;
  177. .van-cell{
  178. --cell-horizontal-padding: 58rpx;
  179. }
  180. }
  181. .ad-space{
  182. height: 180rpx;
  183. margin-top: 23rpx;
  184. }
  185. }
  186. </style>