TopContent.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <div class="head-content">
  3. <div class="head-content-logo">
  4. <img :src="Logo" />
  5. </div>
  6. <div class="head-content-wrap">
  7. <span class="head-content-wrap__label">市场迷雾?罗经开路!</span>
  8. <span class="head-content-wrap__title">
  9. Lookeen 是一个服务于首次出海客户的 AI 商情系统(GTM Analytics
  10. Tools 市场进入分析工具)。目的是提供客户自己的产品品类在目标市场的商业情报,降低用户对产品在目标市场的不确定性。
  11. </span>
  12. <div class="head-content-wrap__step">
  13. <span class="label">只需三步</span>
  14. <span class="tip">(每月可免费获取3次商品分析)</span>
  15. </div>
  16. <div class="head-content-wrap__info">
  17. <CountrySelct ref="CountrySelctRef" v-show="currentStep === 1"></CountrySelct>
  18. <ProductDescription
  19. ref="ProductDescriptionRef"
  20. v-show="currentStep === 2"
  21. ></ProductDescription>
  22. <CompetitorWebsite
  23. ref="CompetitorWebsiteRef"
  24. v-show="currentStep === 3"
  25. ></CompetitorWebsite>
  26. <el-button v-if="currentStep !== 1" @click="prevStep">上一步</el-button>
  27. <el-button v-if="currentStep !== 3" @click="nextStep">下一步</el-button>
  28. <el-button v-if="currentStep === 3" :loading="btnLoading" @click="acceptRecod"
  29. >获取报告</el-button
  30. >
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script lang="ts" setup>
  36. import { ref, computed, nextTick } from 'vue';
  37. import { useMainStore } from '../store';
  38. import { useRouter } from 'vue-router';
  39. import CountrySelct from '@/components/CountrySelct.vue';
  40. import ProductDescription from '@/components/ProductDescription.vue';
  41. import CompetitorWebsite from '@/components/CompetitorWebsite.vue';
  42. import Logo from '@/assets/images/logo.png';
  43. import { showMessage } from '@/utils/common';
  44. const mainStore = useMainStore();
  45. const router = useRouter();
  46. const currentStep = computed(() => mainStore.getCurrentStep);
  47. const CountrySelctRef = ref();
  48. const ProductDescriptionRef = ref();
  49. const CompetitorWebsiteRef = ref();
  50. const btnLoading = ref<boolean>(false);
  51. const validate = () => {
  52. const { locationName, productName, description } = getFormData();
  53. let message: string = '';
  54. switch (currentStep.value) {
  55. case 1:
  56. if (!productName) {
  57. message = '请输入产品名称';
  58. break;
  59. }
  60. // if (!locationName) {
  61. // message = '请选择目标区域市场';
  62. // break;
  63. // }
  64. break;
  65. // case 2:
  66. // if (!description) {
  67. // message = '请输入产品描述';
  68. // break;
  69. // }
  70. // break;
  71. default:
  72. break;
  73. }
  74. return message;
  75. };
  76. const nextStep = () => {
  77. const message = validate();
  78. if (message) {
  79. return showMessage({
  80. type: 'error',
  81. message
  82. });
  83. }
  84. mainStore.setCurrentStep(currentStep.value + 1);
  85. };
  86. const prevStep = () => {
  87. mainStore.setCurrentStep(currentStep.value - 1);
  88. };
  89. const getFormData = () => {
  90. const locationName = CountrySelctRef.value.getLocationName();
  91. const productName = CountrySelctRef.value.getProductName();
  92. const description = ProductDescriptionRef.value.getDescription();
  93. const competitorWebsite = CompetitorWebsiteRef.value.getWebsite();
  94. return {
  95. locationName,
  96. productName,
  97. description,
  98. competitorWebsite
  99. };
  100. };
  101. const isValidUrl = (url: string) => {
  102. const pattern = /^(https?:\/\/|ftp:\/\/)([a-zA-Z0-9.-]+)(:[0-9]+)?(\/[^\s]*)?$/;
  103. return pattern.test(url);
  104. };
  105. const validateCompetitorWebsite = (site: string) => {
  106. if (!site.trim()) return true;
  107. const list = site.split(',');
  108. return list.every((item) => isValidUrl(item));
  109. };
  110. const acceptRecod = async () => {
  111. btnLoading.value = true;
  112. const formData = getFormData();
  113. const { competitorWebsite } = formData;
  114. const result = validateCompetitorWebsite(competitorWebsite);
  115. if (!result) {
  116. showMessage({
  117. type: 'error',
  118. message: '请输入正确的竞品网站'
  119. });
  120. btnLoading.value = false;
  121. return;
  122. }
  123. mainStore.setFormData(formData);
  124. router.push('/record');
  125. };
  126. </script>
  127. <style lang="scss" scoped>
  128. .head-content {
  129. width: 100%;
  130. height: 100%;
  131. position: relative;
  132. &-logo {
  133. position: absolute;
  134. width: 320px;
  135. height: 88px;
  136. left: 260px;
  137. top: 32px;
  138. img {
  139. width: 100%;
  140. height: 100%;
  141. object-fit: cover;
  142. }
  143. }
  144. &-wrap {
  145. position: absolute;
  146. display: flex;
  147. flex-direction: column;
  148. width: 663px;
  149. height: 548px;
  150. left: 280px;
  151. top: 125px;
  152. &__label {
  153. font-weight: bold;
  154. font-size: 40px;
  155. color: #282e30;
  156. margin-top: 60px;
  157. }
  158. &__title {
  159. display: inline-block;
  160. width: 100%;
  161. height: 66px;
  162. font-weight: 400;
  163. font-size: 16px;
  164. color: #282e30;
  165. line-height: 22px;
  166. overflow: hidden;
  167. text-overflow: ellipsis;
  168. margin-top: 20px;
  169. }
  170. &__step {
  171. margin-top: 60px;
  172. .label {
  173. font-weight: bold;
  174. font-size: 24px;
  175. color: var(--promotion--color-primary);
  176. }
  177. .tip {
  178. font-weight: 400;
  179. font-size: 12px;
  180. color: #282e30;
  181. margin-left: 10px;
  182. }
  183. }
  184. &__info {
  185. display: flex;
  186. align-items: center;
  187. height: 68px;
  188. margin-top: 10px;
  189. :deep(.el-button) {
  190. width: 110px;
  191. height: 48px;
  192. background-color: var(--promotion--color-primary);
  193. font-weight: 400;
  194. font-size: 16px;
  195. color: #ffffff;
  196. border-radius: 0;
  197. margin-left: 10px;
  198. }
  199. }
  200. }
  201. }
  202. </style>