bannerIndex.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <script setup lang="ts">
  2. import { articleHotListApi, pcHomeBannerApi, pcHomeConfigApi } from '~/server/homeApi'
  3. import { useUserStore } from '~/stores/user'
  4. import { linkNavigateTo } from '~/utils/util'
  5. import useOrder from '~/composables/useOrder'
  6. import { useAppStore } from '~/stores/app'
  7. import {reactive, ref, shallowRef} from 'vue'
  8. import { GlobalDatas } from '~/types/user'
  9. import {useNuxtApp} from "nuxt/app";
  10. const userStore = useUserStore()
  11. const { handleIntoPage } = useOrder()
  12. //获取全局配置数据
  13. const appStore = useAppStore()
  14. const globalData = computed(() => reactive<GlobalDatas>(<GlobalDatas>appStore?.globalData))
  15. //首页banner数据
  16. const { data: bannerList } = await useAsyncData(async () => pcHomeBannerApi(), {
  17. default: () => [],
  18. })
  19. //资讯热门列表
  20. const { data: articleList } = await useAsyncData(async () => articleHotListApi(), {
  21. default: () => [],
  22. })
  23. const menuList = ref<Array<string>>([
  24. {
  25. name: '宝贝收藏',
  26. icon: 'icon-baobeishoucang',
  27. url: '/users/collect_products',
  28. id: '3',
  29. },
  30. {
  31. name: '关注店铺',
  32. icon: 'icon-guanzhudianpu',
  33. url: '/users/collect_merchant',
  34. id: '4',
  35. },
  36. {
  37. name: '我的足迹',
  38. icon: 'icon-zuji',
  39. url: '/users/browsing_history',
  40. id: '8',
  41. },
  42. ])
  43. /**
  44. * 登录
  45. */
  46. const nuxtApp = useNuxtApp()
  47. const userLoginRef = shallowRef()
  48. const handlerLogin = async () => {
  49. if (!userStore.isLogin) {
  50. await nuxtApp.$onHandlerLogin()
  51. }
  52. }
  53. const handlerNuxtLink = async (url: string, type: number) => {
  54. if (!userStore.isLogin) {
  55. await nuxtApp.$onHandlerLogin()
  56. } else {
  57. await linkNavigateTo(url, { type: type })
  58. }
  59. }
  60. </script>
  61. <template>
  62. <div class="bannerIndex h-410px bg-#FFFFFF w-100% mb-30px">
  63. <div class="min_wrapper_1200 acea-row">
  64. <!--分类组件-->
  65. <classify-card></classify-card>
  66. <!--轮播-->
  67. <div class="w-730px h-360px mt-20px ml-220px 70ba6a">
  68. <el-carousel :interval="5000" height="360px" arrow="always">
  69. <el-carousel-item v-for="item in bannerList" :key="item" class="w-730px h-360px el-image">
  70. <a v-if="item.linkUrl" :href="item.linkUrl" target="_blank">
  71. <el-image :src="item.imageUrl" class="w-730px h-360px el-image b-rd-12px" fit="fill" />
  72. </a>
  73. <el-image v-else :src="item.imageUrl" class="w-730px h-360px el-image b-rd-12px" fit="fill" />
  74. </el-carousel-item>
  75. </el-carousel>
  76. </div>
  77. <!--登录-->
  78. <div class="ml-30px w-220px mt-20px">
  79. <div class="flex-col-center relative">
  80. <img
  81. v-if="!userStore.isLogin"
  82. @click="handlerLogin"
  83. class="cursors w-60px h-60px b-rd-50% mb-10px 3cfea756"
  84. src="@/assets/images/morentou.png"
  85. />
  86. <div v-else>
  87. <img
  88. :src="userStore.userInfo.avatar"
  89. @click="linkNavigateTo('/users/user_info', { type: 11 })"
  90. class="w-60px h-60px b-rd-50% mb-10px cursors"
  91. />
  92. <img
  93. v-show="globalData.userIsPaidMember"
  94. :src="`${globalData.imageDomain}/crmebimage/presets/viptu.png`"
  95. class="w-20px h-20px absolute top-40px right-77px"
  96. />
  97. </div>
  98. <div
  99. v-if="!userStore.isLogin"
  100. @click="handlerLogin"
  101. class="cursors mb-20px line1 w-218px text-center text-#666 text-16px"
  102. >
  103. Hi~<span class="text-#333">你好</span>
  104. </div>
  105. <div v-else class="mb-20px line1 w-218px text-center text-#666 text-16px cursors">
  106. Hi~<span class="text-#333" @click="linkNavigateTo('/users/user_info', { type: 11 })">{{
  107. userStore.userInfo.nickname
  108. }}</span>
  109. </div>
  110. <div class="flex-x-center mb-20px">
  111. <div
  112. v-if="!userStore.isLogin"
  113. class="handleBtn w-105px h-32px lh-31px mr-10px cursors"
  114. @click="handlerLogin"
  115. >
  116. 登录/注册
  117. </div>
  118. <div
  119. class="handleBtnBorder borderSolE9 w-105px h-32px lh-31px font-color cursors 48bfb4a"
  120. @click="handlerNuxtLink('/merchant/merchant_settled', 0)"
  121. >
  122. 商户入驻
  123. </div>
  124. </div>
  125. <div class="flex flex-justify-between w-200px">
  126. <div
  127. v-for="(item, index) in menuList"
  128. :key="index"
  129. class="flex-col-center cursors"
  130. @click="handlerNuxtLink(item.url, item.id)"
  131. >
  132. <div class="iconfont font-color mb-8px" :class="item.icon" style="font-size: 18px"></div>
  133. <div class="text-12px text-#333">{{ item.name }}</div>
  134. </div>
  135. </div>
  136. <el-divider border-style="dashed" />
  137. </div>
  138. <div v-if="articleList && articleList.length">
  139. <div
  140. @click="handleIntoPage('/activity/information_info', { informationId: item.id })"
  141. v-for="item in articleList.length === 2 ? articleList : articleList.slice(0, 3)"
  142. class="acea-row items-center cursors mb-12px af90db"
  143. >
  144. <div class="text-12px font-color bg-#FDEAE9 px-4px py-3px b-rd-2px mr-6px line-heightOne">资讯</div>
  145. <div class="text-14px text-#666 line1 w-180px fontFamilyOPPOSans">{{ item.title }}</div>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. </template>
  152. <style scoped lang="scss">
  153. .bannerIndex {
  154. :deep(.el-carousel__indicators) {
  155. display: flex;
  156. justify-content: center;
  157. align-items: center;
  158. }
  159. :deep(.el-carousel__container) {
  160. width: 100%;
  161. height: 100%;
  162. border-radius: 12px;
  163. overflow: hidden;
  164. }
  165. }
  166. </style>