index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <page-layout 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" @tap="navigateToAdLink(adInfo.ad_link)">
  45. <image :src="adInfo.ad_file" />
  46. </view>
  47. </view>
  48. </u-scroll-view>
  49. </page-layout></template>
  50. <script>
  51. import NavBar from '@/components/layout/nav-bar'
  52. import UScrollView from '@/components/common/u-scroll-view'
  53. import VanCell from '@/wxcomponents/vant/cell/index'
  54. import VanCellGroup from '@/wxcomponents/vant/cell-group/index'
  55. import PageLayout from "@/components/layout/page-layout";
  56. import {
  57. getAdInfo
  58. } from '@/api' export default {
  59. options: {
  60. styleIsolation: 'shared'
  61. },
  62. components: {
  63. PageLayout,
  64. NavBar,
  65. UScrollView,
  66. VanCell,
  67. VanCellGroup
  68. },
  69. computed: {
  70. isLoginState() {
  71. return this.$store.getters.user !== null
  72. },
  73. avatar() {
  74. const user = this.$store.getters.user
  75. if (user) {
  76. return user.avatar
  77. } else {
  78. return ''
  79. }
  80. },
  81. nickName() {
  82. const user = this.$store.getters.user
  83. if (user) {
  84. return user.nick_name
  85. } else {
  86. return ''
  87. }
  88. },
  89. phone() {
  90. const user = this.$store.getters.user
  91. if (user) {
  92. return user.phone
  93. } else {
  94. return ''
  95. }
  96. }
  97. },
  98. data() {
  99. return {
  100. adInfo: {
  101. ad_file: 'https://oss.starify.cn/prod/starify/up/0001018678/20241108/672da70a6c76a.png?x-oss-process=image/resize,w_200'
  102. }
  103. }
  104. },
  105. created() {
  106. this.getAdData()},
  107. }, methods: {
  108. onClickSetting() {
  109. this.navigateTo('/pages/user/setting')
  110. },
  111. onClickUserInfo() {
  112. this.navigateTo('/pages/user/info')
  113. },
  114. getAdData() {
  115. getAdInfo({
  116. number: "UserCenter001"
  117. }).then(res => {
  118. this.adInfo = res.data[0]
  119. })
  120. },
  121. navigateToAdLink(href) {
  122. this.navigateTo(href)
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss">
  128. .user-info{
  129. display: flex;
  130. align-items: center;
  131. .user-avator {
  132. @include display-flex-center;
  133. width: 111rpx;
  134. height: 111rpx;
  135. border-radius: 50%;
  136. overflow: hidden;
  137. margin-right: 23rpx;
  138. background-color: $buttonPrimaryColor;
  139. .icon {
  140. color: #ffffff;
  141. opacity: 0.67;
  142. font-size: 70rpx;
  143. }
  144. }
  145. .user-name {
  146. font-size: 30rpx;
  147. color: #333333;
  148. }
  149. .user-phone {
  150. font-size: $fontSize3;
  151. color: #7d7d7d;
  152. }
  153. }
  154. .user-grid-menu {
  155. display: grid;
  156. grid-template-columns: repeat(4, 1fr);
  157. height: 192rpx;
  158. margin-top: 60rpx;
  159. background-color: #FFFFFF;
  160. &>view {
  161. @include display-flex-center;
  162. flex-direction: column;
  163. font-size: $fontSize3;
  164. color: #333333;
  165. cursor: pointer;
  166. &.active {
  167. background-color: rgba(0, 0, 0, 0.05)
  168. }
  169. }
  170. .iconfont {
  171. margin-bottom: 19rpx;
  172. font-size: 44rpx;
  173. }
  174. .icon-Heart,
  175. .icon-xiaochengxu-toupiaoicon {
  176. font-size: 48rpx;
  177. }
  178. }
  179. .user-list-item {
  180. margin-top: 23rpx;
  181. .van-cell {
  182. --cell-horizontal-padding: 58rpx;
  183. }
  184. }
  185. .ad-space {
  186. height: 180rpx;
  187. margin-top: 23rpx;
  188. }
  189. }</style>