index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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="navigateToAdLink('/pages/user/info')">
  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 class="user-option" @click.stop="navigateToAdLink('/pages/user/setting')">
  19. <view class="iconfont icon-setting"></view>
  20. <view>设置</view>
  21. </view>
  22. </view>
  23. <view class="user-grid-menu">
  24. <view hover-class="active" @click="navigateToAdLink('/pages/user/like')">
  25. <view class="iconfont icon-heart1"></view>
  26. <view>点赞</view>
  27. </view>
  28. <view hover-class="active" @click="navigateToAdLink('/pages/user/favorites')">
  29. <view class="iconfont icon-Favourites-Add-Large"></view>
  30. <view>收藏</view>
  31. </view>
  32. <view hover-class="active" @click="navigateToAdLink('/pages/user/vote')">
  33. <view class="iconfont icon-xiaochengxu-toupiaoicon"></view>
  34. <view>投票</view>
  35. </view>
  36. <view hover-class="active" @click="navigateTo('https://pc.global-eservice.com/h5/?lang=cn&channel=xcx#/')">
  37. <view class="iconfont icon-bishi"></view>
  38. <view>参观登记</view>
  39. </view>
  40. </view>
  41. <view class="user-list-item">
  42. <van-cell-group>
  43. <van-cell title="隐私政策" is-link @click="navigateToAdLink('/pages/disclaimer/privacy')">
  44. </van-cell>
  45. <van-cell title="法律信息" is-link @click="navigateToAdLink('/pages/disclaimer/legalNotice')">
  46. </van-cell>
  47. </van-cell-group>
  48. </view>
  49. <view class="ad-space" v-if="adInfo && adInfo.ad_file" @tap="navigateToAdLink(adInfo.ad_link)">
  50. <image :src="adInfo.ad_file" mode="widthFix"/>
  51. </view>
  52. </view>
  53. </u-scroll-view>
  54. </page-layout>
  55. </template>
  56. <script>
  57. import NavBar from '@/components/layout/nav-bar'
  58. import UScrollView from '@/components/common/u-scroll-view'
  59. import VanCell from '@/wxcomponents/vant/cell/index'
  60. import VanCellGroup from '@/wxcomponents/vant/cell-group/index'
  61. import PageLayout from "@/components/layout/page-layout";
  62. import {getAdInfo} from '@/api'
  63. import store from "@/store";
  64. export default {
  65. options: {
  66. styleIsolation: 'shared'
  67. },
  68. components: {
  69. PageLayout,
  70. NavBar,
  71. UScrollView,
  72. VanCell,
  73. VanCellGroup
  74. },
  75. computed: {
  76. isLoginState() {
  77. return this.$store.getters.user !== null
  78. },
  79. avatar() {
  80. const user = this.$store.getters.user
  81. if (user) {
  82. return user.avatar
  83. } else {
  84. return ''
  85. }
  86. },
  87. nickName() {
  88. const user = this.$store.getters.user
  89. if (user) {
  90. return user.nick_name
  91. } else {
  92. return ''
  93. }
  94. },
  95. phone() {
  96. const user = this.$store.getters.user
  97. if (user) {
  98. return user.phone
  99. } else {
  100. return ''
  101. }
  102. }
  103. },
  104. data() {
  105. return {
  106. adInfo: {
  107. ad_file: ''
  108. }
  109. }
  110. },
  111. created() {
  112. this.getAdData()
  113. },
  114. methods: {
  115. getAdData() {
  116. getAdInfo({
  117. number: "UserCenter001"
  118. }).then(res => {
  119. this.adInfo = res.data[0]
  120. })
  121. },
  122. navigateToAdLink(href) {
  123. if (!store.getters.user) {
  124. this.navigateTo('/pages/user/login?redirect=' + encodeURIComponent(href))
  125. return false
  126. } else {
  127. this.navigateTo(href)
  128. }
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss">
  134. .user-info {
  135. display: flex;
  136. align-items: center;
  137. .user-title {
  138. flex: 1;
  139. min-width: 1px;
  140. }
  141. .user-option {
  142. display: flex;
  143. align-items: center;
  144. grid-gap: 6px;
  145. font-size: 28rpx;
  146. padding-left: 30rpx;
  147. height: 100rpx;
  148. padding-right: 20rpx;
  149. .iconfont {
  150. font-size: 36rpx;
  151. }
  152. }
  153. .user-avator {
  154. @include display-flex-center;
  155. width: 111rpx;
  156. height: 111rpx;
  157. border-radius: 50%;
  158. overflow: hidden;
  159. margin-right: 23rpx;
  160. background-color: $buttonPrimaryColor;
  161. .icon {
  162. color: #ffffff;
  163. opacity: 0.67;
  164. font-size: 70rpx;
  165. }
  166. }
  167. .user-name {
  168. font-size: 30rpx;
  169. color: #333333;
  170. //height: 100rpx;
  171. }
  172. .user-phone {
  173. font-size: $fontSize3;
  174. color: #7d7d7d;
  175. }
  176. }
  177. .user-grid-menu {
  178. display: grid;
  179. grid-template-columns: repeat(4, 1fr);
  180. height: 192rpx;
  181. margin-top: 60rpx;
  182. background-color: #FFFFFF;
  183. & > view {
  184. @include display-flex-center;
  185. flex-direction: column;
  186. font-size: $fontSize3;
  187. color: #333333;
  188. cursor: pointer;
  189. &.active {
  190. background-color: rgba(0, 0, 0, 0.05)
  191. }
  192. }
  193. .iconfont {
  194. margin-bottom: 19rpx;
  195. font-size: 44rpx;
  196. }
  197. .icon-Heart,
  198. .icon-xiaochengxu-toupiaoicon {
  199. font-size: 48rpx;
  200. }
  201. }
  202. .user-list-item {
  203. margin-top: 23rpx;
  204. .van-cell {
  205. --cell-horizontal-padding: 58rpx;
  206. }
  207. }
  208. .ad-space {
  209. width: 100%;
  210. margin-top: 23rpx;
  211. }
  212. </style>