ProductDetailPage.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. <template>
  2. <q-page>
  3. <div class="row" style="background-color: #e5f2fa; height: 50px">
  4. <div class="col-sm-3"></div>
  5. <div
  6. class="col-12 col-sm-9 text-body1 q-pl-md flex"
  7. style="align-items: center"
  8. >
  9. Travel shop > {{ productTypeName }} > {{ productName }}
  10. </div>
  11. </div>
  12. <div class="row q-pa-md" style="min-height: 340px">
  13. <div class="col-12 col-sm-4" style="height: 340px">
  14. <q-carousel
  15. v-if="renderComponent"
  16. v-model="slide"
  17. animated
  18. navigation
  19. infinite
  20. height="100%"
  21. :autoplay="autoplay"
  22. arrows
  23. transition-prev="slide-right"
  24. transition-next="slide-left"
  25. @mouseenter="autoplay = false"
  26. @mouseleave="autoplay = 2000"
  27. >
  28. <q-carousel-slide
  29. v-for="(imageUrl, index) in imageContainer.imageList"
  30. :key="index"
  31. :name="index"
  32. :img-src="imageUrl"
  33. >
  34. </q-carousel-slide>
  35. </q-carousel>
  36. </div>
  37. <div class="col-12 col-sm-8 column" style="height: 340px">
  38. <div class="text-h4 q-pl-md" style="min-height: 50px">
  39. {{ productName }}
  40. </div>
  41. <div class="q-ml-md q-pl-md col" style="background-color: #fff9c6">
  42. {{ removeHtmlTag(productDescription).substring(0, 300) }}...
  43. </div>
  44. </div>
  45. </div>
  46. <div class="row" style="min-height: 500px">
  47. <div class="col-12 col-sm-4 row justify-center" style="height: 500px">
  48. <!-- https://github.com/shubhadip/vuejs3-datepicker#install -->
  49. <datepicker
  50. v-if="renderComponent && productTypeId != LOCALSPECIALTYPRODUCTTYPE"
  51. @selected="handleSelectDate"
  52. :use-utc="shouldUseUtc"
  53. :disabled-dates="state.disabledDates"
  54. v-model="selectedDate"
  55. :prevent-disable-date-selection="true"
  56. :inline="shouldInline"
  57. :icon-width="40"
  58. calendar-class="calendarclass"
  59. ></datepicker>
  60. </div>
  61. <div
  62. class="col-12 col-sm-8 q-pl-xl q-pt-md column"
  63. style="min-height: 500px"
  64. >
  65. <div class="row">
  66. <div class="col-3 col-sm-2 text-weight-bold text-h4">Days:</div>
  67. <div
  68. v-if="productTypeId != FLIGHTPRODUCTTYPE"
  69. class="col-11 col-sm-10 flex text-h6 q-pl-sm"
  70. style="align-items: center"
  71. >
  72. {{ days - 1 }} nights {{ days }} days
  73. </div>
  74. <div
  75. v-if="productTypeId === FLIGHTPRODUCTTYPE"
  76. class="col-11 col-sm-10 flex text-h6 q-pl-sm"
  77. style="align-items: center"
  78. >
  79. {{ days }} days
  80. </div>
  81. </div>
  82. <div class="row">
  83. <div class="col-3 col-sm-2 text-weight-bold text-h4">Option:</div>
  84. <div
  85. class="col-11 col-sm-10 flex text-h6 q-pl-sm"
  86. style="align-items: center"
  87. >
  88. <q-btn-toggle
  89. v-if="productTypeId != LOCALSPECIALTYPRODUCTTYPE"
  90. v-model="activeIndex"
  91. spread
  92. no-caps
  93. toggle-color="blue-6"
  94. color="white"
  95. text-color="black"
  96. @click="
  97. setActiveCate(packageCategories[activeIndex], activeIndex)
  98. "
  99. :options="labelValuePair(packageCategories)"
  100. />
  101. <q-btn-toggle
  102. v-if="productTypeId === LOCALSPECIALTYPRODUCTTYPE"
  103. v-model="activeIndex"
  104. spread
  105. no-caps
  106. toggle-color="blue-6"
  107. color="white"
  108. text-color="black"
  109. @click="
  110. setActiveCateForLocalSpecialty(
  111. packageCategories[activeIndex],
  112. activeIndex
  113. )
  114. "
  115. :options="labelValuePair(packageCategories)"
  116. />
  117. </div>
  118. </div>
  119. <div
  120. v-if="
  121. productTypeId == 'd7b95089-e278-4522-8f71-dacac41ba32f' ||
  122. productTypeId == '3a53caed-b788-4290-896d-7922532ad769' ||
  123. productTypeId == 'e05d07a3-a717-45b8-b009-47a349890e41'
  124. "
  125. class="row text-weight-bold text-h4 q-mt-xl"
  126. >
  127. Passengers
  128. </div>
  129. <div
  130. v-if="productTypeId == HOTELPRODUCTTYPE"
  131. class="row text-weight-bold text-h4 q-mt-xl"
  132. >
  133. Rooms
  134. </div>
  135. <div class="row q-mt-md" style="border-top: 2px solid black">
  136. <div
  137. v-if="productTypeId != LOCALSPECIALTYPRODUCTTYPE"
  138. class="row col-12 q-pr-md q-mt-md"
  139. >
  140. <div class="col-11 col-sm-4 q-pr-md">
  141. <q-input
  142. label="Adult Count"
  143. v-model.number="adultCount"
  144. type="number"
  145. min="1"
  146. outlined
  147. />
  148. </div>
  149. <div class="col-11 col-sm-4 q-pr-md">
  150. <q-input
  151. label="Child Count"
  152. v-model.number="childCount"
  153. type="number"
  154. min="0"
  155. outlined
  156. />
  157. </div>
  158. <div class="col-11 col-sm-4 q-pr-md">
  159. <q-input
  160. label="Infant Count(less than 2 years old)"
  161. v-model.number="infantCount"
  162. type="number"
  163. min="0"
  164. outlined
  165. />
  166. </div>
  167. </div>
  168. <div
  169. v-if="productTypeId === LOCALSPECIALTYPRODUCTTYPE"
  170. class="row col-12 q-pr-md q-mt-md"
  171. >
  172. <div class="col-4 q-pr-md">
  173. <q-input
  174. label="Count"
  175. v-model.number="buyCount"
  176. type="number"
  177. min="1"
  178. outlined
  179. />
  180. </div>
  181. </div>
  182. <div class="row col-12" style="height: 50px"></div>
  183. <div
  184. class="row col-12 q-pr-md q-mt-md"
  185. style="background-color: #e9e9e9; min-height: 50px"
  186. >
  187. <div
  188. class="col-4 text-blue-6 text-h5 flex"
  189. style="align-items: center; height: 50px"
  190. >
  191. CNY
  192. </div>
  193. <div
  194. v-if="
  195. productTypeId != LOCALSPECIALTYPRODUCTTYPE &&
  196. productTypeId != HOTELPRODUCTTYPE
  197. "
  198. class="col-4 col-sm-3 flex"
  199. style="align-items: center; height: 50px"
  200. >
  201. {{
  202. adultCount * adultUnitPrice +
  203. childCount * childUnitPrice +
  204. infantCount * infantUnitPrice
  205. }}
  206. </div>
  207. <div
  208. v-if="
  209. productTypeId == LOCALSPECIALTYPRODUCTTYPE ||
  210. productTypeId == HOTELPRODUCTTYPE
  211. "
  212. class="col-4 col-sm-3 flex"
  213. style="align-items: center; height: 50px"
  214. >
  215. {{ generalPrice * buyCount }}
  216. </div>
  217. <div
  218. class="col-7 col-sm-3 flex"
  219. style="align-items: center; height: 50px"
  220. >
  221. <q-btn
  222. class="glossy"
  223. rounded
  224. color="deep-orange"
  225. @click="goPage('/contact')"
  226. label="Pre-book Consult"
  227. />
  228. </div>
  229. <div
  230. class="col-5 col-sm-2 flex"
  231. style="align-items: center; height: 50px"
  232. >
  233. <q-btn
  234. class="glossy"
  235. @click="collectConfigAndGoPage()"
  236. rounded
  237. color="blue-6"
  238. label="Book Now"
  239. />
  240. </div>
  241. </div>
  242. </div>
  243. </div>
  244. </div>
  245. <div
  246. class="row q-pa-md"
  247. style="min-height: 500px; background-color: #d9d9d9"
  248. >
  249. <div
  250. class="col-12"
  251. style="background-color: white"
  252. v-html="productDescription"
  253. ></div>
  254. </div>
  255. </q-page>
  256. </template>
  257. <script>
  258. import { ref, onMounted, nextTick, getCurrentInstance } from "vue";
  259. import { api } from "boot/axios";
  260. import { useSeoMeta } from "unhead";
  261. import { useQuasar } from "quasar";
  262. import { useRoute, useRouter } from "vue-router";
  263. import Datepicker from "vuejs3-datepicker";
  264. import { bookParamStore } from "stores/bookParamStore";
  265. export default {
  266. name: "ProductDetailPage",
  267. components: {
  268. Datepicker,
  269. },
  270. setup() {
  271. const store = bookParamStore();
  272. const instance = getCurrentInstance();
  273. const app = instance.appContext.app;
  274. const gp = app.config.globalProperties;
  275. const $q = useQuasar();
  276. const route = useRoute();
  277. const router = useRouter();
  278. const buyCount = ref(1);
  279. const adultCount = ref(1);
  280. const childCount = ref(0);
  281. const infantCount = ref(0);
  282. const skusInGroup = { skus: [] };
  283. const productName = ref("");
  284. const productDescription = ref("");
  285. const productTypeId = ref("");
  286. const productTypeName = ref("");
  287. const packageCategories = ref([]);
  288. const imageList = ref([]);
  289. const days = ref("");
  290. const imageContainer = { imageList: [] };
  291. const activeCategory = ref("");
  292. const filteredSkuIndex = ref([]);
  293. const activeIndex = ref(0);
  294. const adultUnitPrice = ref(0);
  295. const generalPrice = ref(0);
  296. const childUnitPrice = ref(0);
  297. const infantUnitPrice = ref(0);
  298. const singleMatchedSku = ref({});
  299. const selectedDate = ref(new Date());
  300. const maxNum = ref(1000000);
  301. const renderComponent = ref(true);
  302. const totalPrice = ref(0);
  303. const TYPEOFPACKAGEPROP = "11cd8b32-c4f6-47db-8b8a-486c992bf43b";
  304. const LOCALSPECIALTYPRODUCTTYPE = "fd264cab-ee8d-4571-a477-03d7e7c090b3";
  305. const HOTELPRODUCTTYPE = "a9f5adbe-c09b-49bc-a614-8a1c5d5e5337";
  306. const MAXNUM = "720f4f2e-e114-4003-9806-bc56a9366278";
  307. const PRODUCTIMAGEURLPROP = "2dea54f4-9b9c-413a-8b3a-0caf273283d2";
  308. const DAYSPROP = "8cc865ff-b30f-4f00-b426-9e64418e5100";
  309. const AVAILABLEDATEPROP = "f0b807e5-d1a6-4454-a400-7905a4fea492";
  310. const TOURPRODUCTTYPE = "3a53caed-b788-4290-896d-7922532ad769";
  311. const FLIGHTHOTELPRODUCTTYPE = "e05d07a3-a717-45b8-b009-47a349890e41";
  312. const FLIGHTPRODUCTTYPE = "d7b95089-e278-4522-8f71-dacac41ba32f";
  313. const GENERALPRICE = "e16df480-b17d-4442-91c2-d6c30d0d7ab0";
  314. const ADULTPRICEPROP = "e228b843-e054-41f8-91dd-19663460df54";
  315. const CHILDPRICEPROP = "c4c845a7-4bef-46d8-a5ad-d72a5464e8b1";
  316. const INFANTPRICEPROP = "448406cb-b68f-439e-9da8-148d78ae8404";
  317. const forceRerender = async () => {
  318. // Remove MyComponent from the DOM
  319. renderComponent.value = false;
  320. // Wait for the change to get flushed to the DOM
  321. await nextTick();
  322. // Add the component back in
  323. renderComponent.value = true;
  324. };
  325. function getTotalPrice() {
  326. if (
  327. productTypeId.value != LOCALSPECIALTYPRODUCTTYPE &&
  328. productTypeId.value != HOTELPRODUCTTYPE
  329. ) {
  330. totalPrice.value =
  331. adultCount.value * adultUnitPrice.value +
  332. childCount.value * childUnitPrice.value +
  333. infantCount.value * infantUnitPrice.value;
  334. } else {
  335. totalPrice.value = generalPrice.value * buyCount.value;
  336. }
  337. console.log("this is the total price:");
  338. console.log(totalPrice.value);
  339. return totalPrice.value;
  340. }
  341. function collectConfigAndGoPage() {
  342. if (singleMatchedSku.value == null) {
  343. gp.$generalNotify($q, false, "Not all required config are selected");
  344. return;
  345. }
  346. var params = {};
  347. params.productTypeId = productTypeId.value;
  348. params.productName = productName.value;
  349. params.productSkuId =
  350. singleMatchedSku.value["hichinaProductBasicDTO"]["skuId"];
  351. params.productSkuGroupId = route.params.skuGroupId;
  352. params.packageCategory = activeCategory.value;
  353. params.productTypeName = productTypeName.value;
  354. params.profileImageUrl = extractAttributeValueFromProductPropertyBag(
  355. singleMatchedSku.value,
  356. PRODUCTIMAGEURLPROP
  357. );
  358. params.totalPrice = getTotalPrice();
  359. //params.totalPrice = 1;
  360. if (productTypeId.value != LOCALSPECIALTYPRODUCTTYPE) {
  361. params.adultCount = adultCount.value;
  362. params.childCount = childCount.value;
  363. params.infantCount = infantCount.value;
  364. }
  365. if (LOCALSPECIALTYPRODUCTTYPE != productTypeId.value) {
  366. params.selectedDate = selectedDate.value.toISOString().split("T")[0];
  367. }
  368. if (
  369. productTypeId.value == LOCALSPECIALTYPRODUCTTYPE ||
  370. productTypeId.value == HOTELPRODUCTTYPE
  371. ) {
  372. params.buyCount = buyCount.value;
  373. }
  374. console.log("params collected from product");
  375. console.log(params);
  376. // gp.$goPageWithParams(val, params);
  377. // router.push({ name: val, state: params });
  378. gp.$goPage("/book");
  379. store.setOrderDetail(params);
  380. }
  381. function handleSelectDate(dt) {
  382. console.log("dt");
  383. console.log(dt);
  384. console.log("filteredSkuIndex.value");
  385. console.log(filteredSkuIndex.value);
  386. console.log("skusInGroup.skus");
  387. console.log(skusInGroup.skus);
  388. var matchedIndex = -1;
  389. for (var i in filteredSkuIndex.value) {
  390. var index = filteredSkuIndex.value[i];
  391. var availableDatesInString =
  392. extractAttributeValueFromProductPropertyBag(
  393. skusInGroup.skus[index],
  394. AVAILABLEDATEPROP
  395. );
  396. console.log("availableDatesInString");
  397. console.log(availableDatesInString);
  398. var dateObjArray = multiDateString2DateObjectArray(
  399. availableDatesInString
  400. );
  401. console.log("dateObjArray");
  402. console.log(dateObjArray);
  403. if (dateObjArray.some((e) => e.toDateString() == dt.toDateString())) {
  404. matchedIndex = index;
  405. break;
  406. }
  407. }
  408. console.log("matchedIndex");
  409. console.log(matchedIndex);
  410. singleMatchedSku.value = skusInGroup.skus[matchedIndex];
  411. maxNum.value = extractAttributeValueFromProductPropertyBag(
  412. singleMatchedSku.value,
  413. MAXNUM
  414. );
  415. console.log("maxNum");
  416. console.log(maxNum.value);
  417. setPrice(singleMatchedSku.value);
  418. }
  419. var state = {
  420. disabledDates: {
  421. to: new Date(2023, 3, 15), // Disable all dates up to specific date
  422. from: new Date(2023, 4, 20), // Disable all dates after specific date
  423. dates: [
  424. // Disable an array of dates
  425. new Date(2016, 9, 16),
  426. new Date(2016, 9, 17),
  427. new Date(2016, 9, 18),
  428. ],
  429. preventDisableDateSelection: true,
  430. },
  431. };
  432. function logPv() {
  433. api
  434. .post(
  435. "/api/public/pagestats/pv/product-detail-" + route.params.skuGroupId
  436. )
  437. .then((res) => {
  438. console.log("log pv:");
  439. console.log(res.data);
  440. })
  441. .catch((err) => {
  442. console.error("Error:", err);
  443. });
  444. }
  445. function logView() {
  446. api
  447. .post("/api/public/pagestats/view-product/" + route.params.skuGroupId)
  448. .then((res) => {
  449. console.log("view cnt of this product:");
  450. console.log(res.data);
  451. })
  452. .catch((err) => {
  453. console.error("Error:", err);
  454. });
  455. }
  456. function extractAttributeValueFromProductPropertyBag(inputObject, attrId) {
  457. var valArray = inputObject.productPropertyBag.filter((obj) => {
  458. return obj.attributeId == attrId;
  459. });
  460. if (valArray.length > 0) {
  461. return valArray[0].attributeValue;
  462. }
  463. return null;
  464. }
  465. function getFilteredSkuIndexAndSetActiveValue(item, index) {
  466. activeCategory.value = item;
  467. filteredSkuIndex.value = [];
  468. for (var i in skusInGroup.skus) {
  469. var sku = skusInGroup.skus[i];
  470. var selectedSkuPropertyBags = sku["productPropertyBag"].filter(
  471. (obj) => {
  472. return obj.attributeId == TYPEOFPACKAGEPROP;
  473. }
  474. );
  475. if (selectedSkuPropertyBags[0].attributeValue == item) {
  476. filteredSkuIndex.value.push(i);
  477. }
  478. }
  479. activeIndex.value = index;
  480. }
  481. function multiDateString2DateObjectArray(candidateAvailableDates) {
  482. var dateObjArray = [];
  483. var datestringArray = candidateAvailableDates.split(";");
  484. for (var i in datestringArray) {
  485. var datestr = datestringArray[i];
  486. if (datestr != null && datestr.length > 0) {
  487. var dateObj = new Date(datestr);
  488. // console.log("...converting string to date:"+ datestr)
  489. // console.log(dateObj)
  490. dateObjArray.push(dateObj);
  491. }
  492. }
  493. return dateObjArray;
  494. }
  495. function compareDate(a, b) {
  496. if (a.getDate() < b.getDate()) {
  497. return -1;
  498. }
  499. if (a.getDate() > b.getDate()) {
  500. return 1;
  501. }
  502. return 0;
  503. }
  504. function setCandidateAvailableDates(indexArray) {
  505. var candidateAvailableDates = "";
  506. for (var i in indexArray) {
  507. var availableDates = extractAttributeValueFromProductPropertyBag(
  508. skusInGroup.skus[indexArray[i]],
  509. AVAILABLEDATEPROP
  510. );
  511. candidateAvailableDates = candidateAvailableDates + availableDates;
  512. }
  513. var dateObjArray = multiDateString2DateObjectArray(
  514. candidateAvailableDates
  515. );
  516. dateObjArray = dateObjArray.sort((a, b) => a - b);
  517. console.log("dateObjArray");
  518. console.log(dateObjArray);
  519. var minDate = dateObjArray[0];
  520. var maxDate = dateObjArray.slice(-1)[0];
  521. state.disabledDates.to = minDate;
  522. var nextDayOfMax = new Date(maxDate);
  523. nextDayOfMax.setDate(nextDayOfMax.getDate() + 1);
  524. state.disabledDates.from = nextDayOfMax;
  525. var segmentDisabledDates = [];
  526. var pointer = new Date(minDate);
  527. while (pointer < maxDate) {
  528. // check contains
  529. if (
  530. !dateObjArray.some((e) => e.toDateString() == pointer.toDateString())
  531. ) {
  532. segmentDisabledDates.push(new Date(pointer));
  533. } else {
  534. }
  535. // update pointer
  536. pointer.setDate(pointer.getDate() + 1);
  537. }
  538. state.disabledDates.dates = segmentDisabledDates;
  539. forceRerender();
  540. }
  541. function setPrice(sku) {
  542. if (sku == null) {
  543. if (
  544. productTypeId.value == LOCALSPECIALTYPRODUCTTYPE ||
  545. productTypeId.value == HOTELPRODUCTTYPE
  546. ) {
  547. console.log("001");
  548. generalPrice.value = 0;
  549. } else {
  550. adultUnitPrice.value = 0;
  551. childUnitPrice.value = 0;
  552. infantUnitPrice.value = 0;
  553. }
  554. } else {
  555. if (
  556. productTypeId.value == LOCALSPECIALTYPRODUCTTYPE ||
  557. productTypeId.value == HOTELPRODUCTTYPE
  558. ) {
  559. console.log("003");
  560. generalPrice.value = extractAttributeValueFromProductPropertyBag(
  561. sku,
  562. GENERALPRICE
  563. );
  564. } else {
  565. console.log("004");
  566. adultUnitPrice.value = extractAttributeValueFromProductPropertyBag(
  567. sku,
  568. ADULTPRICEPROP
  569. );
  570. childUnitPrice.value = extractAttributeValueFromProductPropertyBag(
  571. sku,
  572. CHILDPRICEPROP
  573. );
  574. infantUnitPrice.value = extractAttributeValueFromProductPropertyBag(
  575. sku,
  576. INFANTPRICEPROP
  577. );
  578. }
  579. }
  580. }
  581. function setActiveDescription() {
  582. var indexToFilter =
  583. filteredSkuIndex.value.length < 1 ? 0 : filteredSkuIndex.value[0];
  584. productDescription.value =
  585. skusInGroup.skus[indexToFilter]["hichinaProductBasicDTO"][
  586. "productContent"
  587. ];
  588. }
  589. function setActiveCate(item, index) {
  590. console.log("picking package cate: " + item);
  591. console.log("index of it is: " + index);
  592. getFilteredSkuIndexAndSetActiveValue(item, index);
  593. setCandidateAvailableDates(filteredSkuIndex.value);
  594. setPrice(null);
  595. selectedDate.value = new Date();
  596. singleMatchedSku.value = null;
  597. setActiveDescription();
  598. }
  599. function setTourProductData(inputArray) {
  600. packageCategories.value = [];
  601. imageList.value = [];
  602. for (var index in inputArray) {
  603. var packageCat = extractAttributeValueFromProductPropertyBag(
  604. inputArray[index],
  605. TYPEOFPACKAGEPROP
  606. );
  607. if (packageCat != null) {
  608. packageCategories.value.push(packageCat);
  609. }
  610. var url = extractAttributeValueFromProductPropertyBag(
  611. inputArray[index],
  612. PRODUCTIMAGEURLPROP
  613. );
  614. if (url != null) {
  615. // imageContainer.imageList.push(url);
  616. imageList.value.push(url);
  617. }
  618. // this if means only need to calculate days once because all this property in the same sku group should be same
  619. if (days.value == "") {
  620. days.value = extractAttributeValueFromProductPropertyBag(
  621. inputArray[index],
  622. DAYSPROP
  623. );
  624. }
  625. }
  626. imageContainer.imageList = imageList.value;
  627. forceRerender();
  628. // trick: remove duplicates
  629. packageCategories.value = [...new Set(packageCategories.value)];
  630. // force select the first package category on entering page
  631. setActiveCate(packageCategories.value[0], 0);
  632. }
  633. function labelValuePair(valArray) {
  634. var ret = [];
  635. valArray.forEach((x, i) => {
  636. var obj = { label: x, value: i };
  637. ret.push(obj);
  638. });
  639. return ret;
  640. }
  641. function setFlightHotelProductData(inputArray) {
  642. setTourProductData(inputArray);
  643. }
  644. function setHotelProductData(inputArray) {
  645. setTourProductData(inputArray);
  646. }
  647. function setFligtProductData(inputArray) {
  648. setTourProductData(inputArray);
  649. }
  650. function setLocalSpecialtyProductData(inputArray) {
  651. packageCategories.value = [];
  652. imageList.value = [];
  653. for (var index in inputArray) {
  654. var packageCat = extractAttributeValueFromProductPropertyBag(
  655. inputArray[index],
  656. TYPEOFPACKAGEPROP
  657. );
  658. if (packageCat != null) {
  659. packageCategories.value.push(packageCat);
  660. }
  661. var url = extractAttributeValueFromProductPropertyBag(
  662. inputArray[index],
  663. PRODUCTIMAGEURLPROP
  664. );
  665. if (url != null) {
  666. imageList.value.push(url);
  667. }
  668. }
  669. imageContainer.imageList = imageList.value;
  670. // trick: remove duplicates
  671. packageCategories.value = [...new Set(packageCategories.value)];
  672. // force select the first package category on entering page
  673. setActiveCateForLocalSpecialty(packageCategories.value[0], 0);
  674. }
  675. function processSkuGroups(inputArray) {
  676. if (inputArray.length > 0) {
  677. productName.value =
  678. inputArray[0]["hichinaProductBasicDTO"]["productName"];
  679. productTypeId.value =
  680. inputArray[0]["hichinaProductBasicDTO"]["productTypeId"];
  681. productTypeName.value =
  682. inputArray[0]["hichinaProductBasicDTO"]["productTypeName"];
  683. useSeoMeta({
  684. title: productName.value,
  685. description: productName.value,
  686. ogDescription: productName.value,
  687. ogTitle: productName.value,
  688. ogImage: "https://www.hichinatravel.com/static/png/name-67280b81.png",
  689. twitterCard: "summary_large_image",
  690. });
  691. if (productTypeId.value === TOURPRODUCTTYPE) {
  692. // 跟团游,则按照跟团游的页面模板来设置各个参数
  693. setTourProductData(inputArray);
  694. } else if (productTypeId.value === FLIGHTHOTELPRODUCTTYPE) {
  695. // 机票酒店套餐
  696. setFlightHotelProductData(inputArray);
  697. } else if (productTypeId.value === FLIGHTPRODUCTTYPE) {
  698. // 机票
  699. setFligtProductData(inputArray);
  700. } else if (productTypeId.value === HOTELPRODUCTTYPE) {
  701. // 酒店
  702. setHotelProductData(inputArray);
  703. } else if (productTypeId.value === LOCALSPECIALTYPRODUCTTYPE) {
  704. // 本地土特产
  705. setLocalSpecialtyProductData(inputArray);
  706. }
  707. }
  708. }
  709. function loadSkusInGroup() {
  710. var params = {};
  711. params.skuGroupId = route.params.skuGroupId;
  712. api
  713. .get("/api/public/productsku/bygroupidwithpropertybag", {
  714. params: params,
  715. })
  716. .then(function (response) {
  717. skusInGroup.skus = response.data.data;
  718. console.log("skusInGroup.skus in loadSkusInGroup");
  719. console.log(skusInGroup.skus);
  720. processSkuGroups(skusInGroup.skus);
  721. })
  722. .catch(function (error) {
  723. console.log(error);
  724. });
  725. }
  726. onMounted(() => {
  727. logPv();
  728. logView();
  729. loadSkusInGroup();
  730. });
  731. return {
  732. productTypeName,
  733. productName,
  734. productTypeId,
  735. days,
  736. slide: ref(0),
  737. autoplay: ref(true),
  738. imageContainer,
  739. productDescription,
  740. handleSelectDate,
  741. selectedDate,
  742. state,
  743. renderComponent,
  744. LOCALSPECIALTYPRODUCTTYPE,
  745. FLIGHTPRODUCTTYPE,
  746. HOTELPRODUCTTYPE,
  747. packageCategories,
  748. labelValuePair,
  749. setActiveCate,
  750. activeIndex,
  751. adultCount,
  752. childCount,
  753. infantCount,
  754. adultUnitPrice,
  755. childUnitPrice,
  756. infantUnitPrice,
  757. generalPrice,
  758. buyCount,
  759. shouldUseUtc: ref(true),
  760. shouldInline: ref(true),
  761. collectConfigAndGoPage,
  762. };
  763. },
  764. };
  765. </script>