index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. <template >
  2. <div class="scrollbar">
  3. <div class="swiper">
  4. <div class="swiper-wrapper">
  5. <swiper-container autoplay-delay="2000" loop="true" css-mode="true" navigation="true" pagination="true" scrollbar="true">
  6. <swiper-slide style="cursor: pointer" class="banner " v-for="(item,index) in sliders " :key="index" @click="goToBlog(item.linkToBlog)" >
  7. <p class="title">{{ item.title }}</p>
  8. <p class="info">{{ item.subTitle }}</p>
  9. <v-lazy-image :src="item.imageUrl" alt="" />
  10. </swiper-slide>
  11. </swiper-container>
  12. </div>
  13. </div>
  14. <section class="wrapper mt-84">
  15. <div class="item-title pd-20 flex-between">
  16. <p>Destinations</p>
  17. <p class="more-destinations flex-between" @click="goPage('/destination')">More destinations
  18. <el-icon>
  19. <ArrowRight/>
  20. </el-icon>
  21. </p>
  22. </div>
  23. <p class="bat pd-20">Places to go in China!</p>
  24. <div class="wrapper-img flex-between mt-38">
  25. <!-- <x-hover-item class="wrapper-item" v-for="i in 6"/> -->
  26. <div v-for="item in randDestinations" :key="item.destinationId" class="item radius wrapper-item" @mouseenter="hoverFlag = true"
  27. @mouseleave="hoverFlag = false">
  28. <v-lazy-image class="destination-profile" @click="goPage('/destination-detail/'+item.destinationId)" :src="normalizeMultiImageUrl(item.destinationProfileImage)" alt="" />
  29. <div class="notice" :class="{ open: hoverFlag }">
  30. <slot>
  31. <p>{{item.destinationName}}</p>
  32. <span class="parent-info">{{item.parentDestinationName}}</span>
  33. </slot>
  34. </div>
  35. </div>
  36. </div>
  37. <div class="pd-20">
  38. <button class="help">Want a Tailor Made Trip to China? Click Here for help</button>
  39. </div>
  40. <div class="banner-center pd-20 mt-20">
  41. <div class="title">
  42. <p>Editor's Choice</p>
  43. <p class="info">What's New this Week?</p>
  44. </div>
  45. <v-lazy-image src="https://photoprism.hichinatravel.com/api/v1/t/d76cacc7070ef1b96516c5f82cbb6f277df9fc4e/32mcf2k4/fit_2048" alt="" />
  46. </div>
  47. <div class="item-title pd-20 flex-between mt-36">
  48. <p>People are traveling</p>
  49. </div>
  50. <p class="bat pd-20">What's in China</p>
  51. </section>
  52. <div class="float pd-20 mt-28" v-loading="loading">
  53. <template v-for="(item, index) in globalUnifiedItemList" v-bind:key="index">
  54. <div v-if="item.type === 'video'" class="video-content">
  55. <video src="http://mp42.china.com.cn/video_tide/video/2023/3/13/20233131678679710349_367_2.mp4" controls></video>
  56. <p class="video-info">From Blog Title My 30 days of Going to Tibet</p>
  57. </div>
  58. <blog-item class="product-item" :blog="item.value" v-if="item.type==='blog'" float/>
  59. <other-product-item :productSummary="item.value" class="other-item" v-if="item.type === 'product'" float/>
  60. <special-product-item class="scale-item" :special="item.value" v-if="item.type==='scaleblog'" float/>
  61. </template>
  62. </div>
  63. <div style="width: 100%;">
  64. <el-button type="primary" plain class="get-more mt-100" @click="loadMore" style="cursor: pointer;">Click to load more</el-button>
  65. </div>
  66. </div>
  67. </template>
  68. <script setup>
  69. import VLazyImage from "v-lazy-image";
  70. import BlogItem from '../home/components/BlogItem'
  71. import {AXIOS} from '@/common/http-commons'
  72. import ProductItem from './components/ProductItem'
  73. import XHoverItem from '@/components/XHoverItem'
  74. import OtherProductItem from './components/OtherProductItem'
  75. import SpecialProductItem from './components/SpecialProductItem'
  76. import { useRouter } from 'vue-router';
  77. const sliders = ref([])
  78. const randDestinations = ref([])
  79. const activeIndex = ref(1)
  80. const imgPopupShowFlag = ref([false, false, false, false, false, false])
  81. const router = useRouter()
  82. const currentPage = ref(1)
  83. const loading= ref(false)
  84. const blogPageSizePage = ref(15)
  85. const productPageSizePage = ref(5)
  86. const bloglist =ref([])
  87. const productlist = ref([])
  88. const totalBlogCount=ref(-1)
  89. const globalUnifiedItemList = ref([])
  90. const unifiedItemList = ref([])
  91. function loadMore(){
  92. currentPage.value+=1
  93. var maxPage = totalBlogCount.value/blogPageSizePage.value
  94. if(currentPage.value<=maxPage+1){
  95. loadBlogList()
  96. }
  97. }
  98. function normalizeMultiImageUrl(input){
  99. if(input.indexOf(',')>-1){
  100. return input.split(',').shift();
  101. }else if(input.indexOf(';')>-1){
  102. return input.split(';').shift();
  103. }
  104. return input;
  105. }
  106. function loadBlogList(){
  107. loading.value = true;
  108. unifiedItemList.value=[]
  109. var params = {}
  110. params.pageSize = blogPageSizePage.value;
  111. params.query="";
  112. console.log("loading page: "+currentPage.value)
  113. params.page = currentPage.value;
  114. AXIOS.get("/api/public/blog/list", {params: params}).then(function (response) {
  115. console.log("blog list:")
  116. console.log(response.data)
  117. if(totalBlogCount.value==-1){
  118. totalBlogCount.value = response.data.data.total
  119. }
  120. bloglist.value = response.data.data.data
  121. for(var index in bloglist.value){
  122. var obj = {}
  123. // obj.type=parseInt(Math.random() * 2)==0?'blog':'scaleblog';
  124. obj.type='blog';
  125. obj.value = bloglist.value[index]
  126. unifiedItemList.value.push(obj)
  127. }
  128. loadProducts();
  129. })
  130. .catch(function (error) {
  131. console.log(error);
  132. });
  133. }
  134. function shuffleArray(anyarr){
  135. if(anyarr==null || anyarr.length<=1){
  136. return
  137. }else{
  138. for (let i = 0; i < 20; i++) {
  139. var left = parseInt(Math.random() * anyarr.length )
  140. var right = parseInt(Math.random() * anyarr.length )
  141. var tmp = anyarr[left]
  142. anyarr[left]=anyarr[right]
  143. anyarr[right]=tmp
  144. }
  145. }
  146. }
  147. function loadProducts(){
  148. var params = {}
  149. params.pageSize = productPageSizePage.value;
  150. params.query="";
  151. params.page = currentPage.value;
  152. params.productTypeId=""
  153. AXIOS.get("/api/public/productsku/productskugrouplist", {params: params}).then(function (response) {
  154. // console.log("product list:")
  155. // console.log(response.data)
  156. productlist.value = response.data.data.data
  157. for(var index in productlist.value){
  158. var obj = {}
  159. obj.type='product';
  160. obj.value = productlist.value[index]
  161. unifiedItemList.value.push(obj)
  162. }
  163. // console.log("unifiedItemList.value")
  164. // console.log(unifiedItemList.value)
  165. // shuffleArray(unifiedItemList.value)
  166. globalUnifiedItemList.value=globalUnifiedItemList.value.concat(unifiedItemList.value)
  167. // console.log("globalUnifiedItemList.value")
  168. // console.log(globalUnifiedItemList.value)
  169. loading.value = false;
  170. })
  171. .catch(function (error) {
  172. console.log(error);
  173. });
  174. }
  175. function goPage(val){
  176. router.push({ path: val })
  177. }
  178. function loadHomeSliders(){
  179. AXIOS.get('/api/public/pagecontent/homesliders').then(response=>{
  180. sliders.value = response.data.data
  181. loadBlogList()
  182. }).catch(e=>{
  183. console.log(e)
  184. })
  185. }
  186. function loadRand6Destinations(){
  187. AXIOS.get('/api/public/destination/rand6').then(response=>{
  188. randDestinations.value = response.data.data
  189. }).catch(e=>{
  190. alert(e)
  191. })
  192. }
  193. onMounted(() => {
  194. // load slider
  195. loadHomeSliders()
  196. // load destination
  197. loadRand6Destinations()
  198. })
  199. const hoverFlag = ref(false)
  200. const arr = getRandomArr()
  201. function getRandomArr() {
  202. // 这是你xiaopiu上的默认布局,下面的20个是随机生成
  203. const arr = [0, 1, 1, 3, 2, 2, 2, 2, 2, 2]
  204. for (let i = 0; i < 20; i++) {
  205. arr.push(parseInt(Math.random() * 4 ))
  206. }
  207. return arr
  208. }
  209. function goToBlog(url){
  210. window.location.href = url
  211. }
  212. </script>
  213. <style scoped lang="scss">
  214. .scrollbar{
  215. overflow: scroll;
  216. }
  217. .float {
  218. max-width: $min-width;
  219. margin: 0 auto;
  220. overflow: hidden;
  221. &::after {
  222. height: 0;
  223. content: '';
  224. display: block;
  225. clear: both;
  226. }
  227. }
  228. .banner {
  229. position: relative;
  230. height: 547px;
  231. overflow: hidden;
  232. .title {
  233. position: absolute;
  234. left: 107px;
  235. top: 175px;
  236. color: rgba(255, 255, 255, 1);
  237. font-size: 111px;
  238. line-height: 150%;
  239. text-align: left;
  240. }
  241. .info {
  242. position: absolute;
  243. width: 498px;
  244. height: 63px;
  245. left: 112px;
  246. top: 342px;
  247. color: rgba(255, 255, 255, 1);
  248. font-size: 21px;
  249. line-height: 150%;
  250. text-align: left;
  251. }
  252. img {
  253. width: 100%;
  254. height: auto;
  255. max-height: 547px;
  256. }
  257. }
  258. .bat {
  259. color: rgba(80, 80, 80, 1);
  260. font-size: 48px;
  261. line-height: 150%;
  262. }
  263. .wrapper-img {
  264. .wrapper-item {
  265. width: 208px;
  266. height: 276px;
  267. }
  268. }
  269. .help {
  270. margin-top: 73px;
  271. width: 100%;
  272. height: 78px;
  273. left: 260px;
  274. top: 293px;
  275. text-indent: 31px;
  276. color: rgba(255, 255, 255, 1);
  277. background-color: rgba(42, 130, 228, 1);
  278. border-radius: 14px;
  279. font-size: 22px;
  280. line-height: 150%;
  281. text-align: center;
  282. font-weight: bold;
  283. }
  284. .video {
  285. float: left;
  286. margin-bottom: 20px;
  287. width: 997px;
  288. height: 595px;
  289. }
  290. .banner-center {
  291. position: relative;
  292. height: 192px;
  293. img {
  294. width: 100%;
  295. height: 100%;
  296. }
  297. .title {
  298. position: absolute;
  299. top: 29px;
  300. left: 55px;
  301. color: rgba(255, 255, 255, 1);
  302. font-size: 66px;
  303. font-weight: bold;
  304. }
  305. .info {
  306. color: rgba(255, 255, 255, 1);
  307. font-size: 24px;
  308. font-weight: 400;
  309. }
  310. }
  311. .list {
  312. flex-wrap: wrap;
  313. .product {
  314. margin-right: 25px;
  315. }
  316. }
  317. .get-more {
  318. margin: 0 auto;
  319. color: rgba(80, 80, 80, 1);
  320. font-size: 14px;
  321. width: 100%;
  322. text-align: center;
  323. }
  324. .item {
  325. position: relative;
  326. width: 244px;
  327. height: 324px;
  328. overflow: hidden;
  329. &.radius {
  330. border-radius: 10px;
  331. }
  332. }
  333. .notice {
  334. position: absolute;
  335. width: 100%;
  336. height: 74px;
  337. padding: 17px 14px 7px;
  338. left: 0;
  339. bottom: -74px;
  340. color: white;
  341. background-color: rgba(153, 153, 153, .51);
  342. border-radius: 2px;
  343. font-size: 23px;
  344. transition: .3s;
  345. line-height: 23px;
  346. &.open {
  347. bottom: 0;
  348. }
  349. }
  350. .parent-info {
  351. color: rgba(255, 235, 235, 1);
  352. font-size: 13px;
  353. }
  354. .destination-profile {
  355. cursor: pointer;
  356. width: 100%;
  357. height: 100%;
  358. box-shadow: 0px 7px 7px 0px rgba(0, 0, 0, 0.5);
  359. object-fit: cover;
  360. }
  361. .more-destinations{
  362. cursor: pointer;
  363. color: rgba(42, 130, 228, 1);
  364. font-size: 14px;
  365. line-height: 150%;
  366. }
  367. </style>