App.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <template>
  2. <div class="app" id="app" v-cloak ref="vueDom">
  3. <div class="bigbox">
  4. <div class="noHome">
  5. <home-header></home-header>
  6. <div :class="$route.meta.fullScreen ? 'content' :'content_app'">
  7. <!-- <keep-alive include="AntigenPreparation"> -->
  8. <router-view :key="key"/>
  9. <!-- </keep-alive> -->
  10. </div>
  11. <footerbox></footerbox>
  12. </div>
  13. <div class="fixed-message" @click="dialogVisible = true">
  14. <img src="@/assets/img/messageFixed.png" alt="">
  15. <div class="fixed-message-text">
  16. Contact with<br/>
  17. our experts
  18. </div>
  19. </div>
  20. </div>
  21. <!-- loading -->
  22. <div class="loading" v-show="loading">
  23. <div class="lod_c">
  24. <i class="el-icon-loading"></i>
  25. <div class="lod_name">{{ $t("message.Loading") }}</div>
  26. </div>
  27. </div>
  28. <el-dialog
  29. title=""
  30. v-if="!$util.isMobileDevice()"
  31. :visible.sync="dialogVisible"
  32. width="1200px">
  33. <div class="production_bottom_box">
  34. <p class="production_bottom_title">Leave Message</p>
  35. <div class="submit_box">
  36. <el-form label-position="left" ref="form" :model="form" label-width="130px">
  37. <div class="el_input">
  38. <el-form-item label="Name:" required>
  39. <el-input v-model="form.name"></el-input>
  40. </el-form-item>
  41. <el-form-item label="Company name:" required>
  42. <el-input v-model="form.company"></el-input>
  43. </el-form-item>
  44. </div>
  45. <div class="el_input">
  46. <el-form-item label="Email:" required>
  47. <el-input v-model="form.email"></el-input>
  48. </el-form-item>
  49. <el-form-item label="Tel:">
  50. <el-input v-model="form.phone"></el-input>
  51. </el-form-item>
  52. </div>
  53. <div class="el_input_message">
  54. <el-form-item label="Leave a message:">
  55. <el-input v-model="form.message" type="textarea" :rows="3"></el-input>
  56. </el-form-item>
  57. </div>
  58. </el-form>
  59. <div class="submit_bottom">
  60. <p class="submit_bottom_text">Thank you for contacting us, we will reach you out in 24hr by email</p>
  61. <p class="submit_bottom_button" @click="postSubmit" v-loading.fullscreen.lock="fullscreenLoading">Submit</p>
  62. </div>
  63. </div>
  64. </div>
  65. </el-dialog>
  66. <!-- 移动端 -->
  67. <el-dialog
  68. v-if="$util.isMobileDevice()"
  69. title="Leave Message"
  70. :visible.sync="dialogVisible"
  71. width="90%">
  72. <div class="production_bottom_box">
  73. <!-- <p class="production_bottom_title">Leave Message</p> -->
  74. <div class="submit_box">
  75. <el-form label-position="left" ref="form" :model="form" label-width="140px">
  76. <div class="el_input">
  77. <el-form-item label="Name:" required>
  78. <el-input v-model="form.name"></el-input>
  79. </el-form-item>
  80. </div>
  81. <div class="el_input">
  82. <el-form-item label="Company name:" required>
  83. <el-input v-model="form.company"></el-input>
  84. </el-form-item>
  85. </div>
  86. <div class="el_input">
  87. <el-form-item label="Email:" required>
  88. <el-input v-model="form.email"></el-input>
  89. </el-form-item>
  90. </div>
  91. <div class="el_input">
  92. <el-form-item label="Tel:">
  93. <el-input v-model="form.phone"></el-input>
  94. </el-form-item>
  95. </div>
  96. <div class="el_input_message">
  97. <el-form-item label="Leave a message:">
  98. <el-input v-model="form.message" type="textarea" :rows="3"></el-input>
  99. </el-form-item>
  100. </div>
  101. </el-form>
  102. <div class="submit_bottom">
  103. <p class="submit_bottom_text">Thank you for contacting us, we will reach you out in 24hr by email</p>
  104. <p class="submit_bottom_button" @click="postSubmit" v-loading.fullscreen.lock="fullscreenLoading">Submit</p>
  105. </div>
  106. </div>
  107. </div>
  108. </el-dialog>
  109. </div>
  110. </template>
  111. <script>
  112. import homeHeader from "@/components/homeHeader";
  113. import footerbox from "@/components/footerbox";
  114. export default {
  115. name: "App",
  116. components: {
  117. homeHeader,
  118. footerbox
  119. },
  120. data() {
  121. return {
  122. tempBool: true,
  123. prayTimer: null,
  124. loading: true,
  125. isRouterAlive: true,
  126. dialogVisible: false,
  127. form: {
  128. name: "",
  129. company: "",
  130. email: "",
  131. phone: "",
  132. message: ""
  133. },
  134. fullscreenLoading: false
  135. };
  136. },
  137. computed: {
  138. key() {
  139. if (this.$route.meta.pageTitle) {
  140. return this.$route.path + new Date().getTime();
  141. } else {
  142. return 1;
  143. }
  144. }
  145. },
  146. methods: {
  147. startPray() {
  148. var timeFun = () => {
  149. if (this.prayTimer) clearTimeout(this.prayTimer);
  150. var stime = new Date("2020/04/04 00:00:00").getTime();
  151. var etime = new Date("2020/04/04 23:59:59").getTime();
  152. var now = new Date().getTime();
  153. this.prayTimer = setTimeout(() => {
  154. if (now < etime) {
  155. if (now > stime) {
  156. document.getElementsByTagName("html")[0].style.filter =
  157. "grayscale(1)";
  158. } else {
  159. document.getElementsByTagName("html")[0].style.filter = "";
  160. }
  161. timeFun();
  162. } else {
  163. document.getElementsByTagName("html")[0].style.filter = "";
  164. timeFun = null;
  165. this.prayTimer = null;
  166. }
  167. }, 1000);
  168. };
  169. timeFun();
  170. },
  171. findAllCategory() {
  172. // 字典
  173. this.$api.post("category/findAllCategory").then(res => {
  174. if (res.code === 0) {
  175. this.$store.commit("setDictionary", res.data);
  176. }
  177. });
  178. },
  179. findAllMolecule() {
  180. this.$api.post("molecule/findAllMolecule").then(res => {
  181. if (res.code === 0) {
  182. this.$store.commit("setProductDictionary", res.data);
  183. }
  184. });
  185. },
  186. getinfo() {
  187. if (JSON.parse(localStorage.getItem("token"))) {
  188. this.$api.post("auth/info").then(res => {
  189. if (res.code === 0) {
  190. localStorage.setItem("info", JSON.stringify(res.data));
  191. }
  192. });
  193. }
  194. },
  195. // 验证
  196. verification() {
  197. if (this.form.name == "") {
  198. this.$message.error(
  199. this.$t("input.fullname") + this.$t("message.empty")
  200. );
  201. return false;
  202. } else if (this.form.company == "") {
  203. this.$message.error(
  204. this.$t("input.company") + this.$t("message.empty")
  205. );
  206. return false;
  207. } else if (this.form.email == "") {
  208. this.$message.error(this.$t("input.email") + this.$t("message.empty"));
  209. return false;
  210. } else if (!this.$util.isEmail(this.form.email)) {
  211. this.$message.error(this.$t("input.email") + this.$t("message.email"));
  212. return false;
  213. } else {
  214. return true;
  215. }
  216. },
  217. postSubmit() {
  218. if (this.verification()) {
  219. this.fullscreenLoading = true;
  220. this.$api.post("antibody/saveMessage", this.form).then(res => {
  221. if (res.code == 0) {
  222. this.$message({
  223. message: this.$t("message.YourMessage"),
  224. type: "success"
  225. });
  226. this.form = {
  227. company: "",
  228. email: "",
  229. name: "",
  230. phone: "",
  231. message: ""
  232. };
  233. this.fullscreenLoading = false;
  234. this.dialogVisible = false
  235. window.gtag && window.gtag("event", "submit_message");
  236. } else {
  237. this.$message.error(res.msg);
  238. this.fullscreenLoading = false;
  239. this.dialogVisible = false
  240. }
  241. });
  242. }
  243. }
  244. },
  245. created() {
  246. this.loading = true;
  247. var timer = null;
  248. window.onresize = () => {
  249. clearTimeout(timer);
  250. timer = setTimeout(() => {
  251. this.$store.commit("setWinInfo", {
  252. width: document.documentElement.clientWidth,
  253. height: document.documentElement.clientHeight
  254. });
  255. }, 250);
  256. };
  257. // this.startPray()
  258. this.findAllCategory();
  259. this.getinfo();
  260. },
  261. mounted() {
  262. this.findAllMolecule();
  263. let that = this;
  264. setTimeout(() => {
  265. that.loading = false;
  266. this.tempBool = false;
  267. that.$refs.vueDom.style.display = "block";
  268. // document.getElementById('id').style.display = 'block'
  269. }, 1000);
  270. }
  271. };
  272. </script>
  273. <style lang="scss" scoped>
  274. v-cloak {
  275. display: none;
  276. }
  277. .loading {
  278. position: fixed;
  279. top: 0;
  280. left: 0;
  281. right: 0;
  282. bottom: 0;
  283. background-color: rgba(255, 255, 255, 1);
  284. z-index: 9999;
  285. .lod_c {
  286. position: absolute;
  287. top: 50%;
  288. left: 50%;
  289. transform: translate(-50%, -50%);
  290. .el-icon-loading {
  291. font-size: 2rem;
  292. color: #ccc;
  293. text-align: center;
  294. margin-left: 6px;
  295. }
  296. .lod_name {
  297. text-align: center;
  298. font-size: 16px;
  299. }
  300. }
  301. }
  302. .fixed-message{
  303. position: fixed;
  304. bottom: 10px;
  305. right: 20px;
  306. z-index: 9;
  307. background: #065ba9;
  308. display: flex;
  309. align-items: center;
  310. // width: 175px;
  311. // height: 64px;
  312. padding: 8px 15px;
  313. border-radius: 30px;
  314. cursor: pointer;
  315. .fixed-message-text{
  316. font-size: 14px;
  317. color: #fff;
  318. text-align: center;
  319. margin-left: 10px;
  320. }
  321. }
  322. .production_bottom_box{
  323. width: 90%;
  324. margin: 0 auto;
  325. overflow: hidden;
  326. .production_bottom_title{
  327. font-family: Source Han Sans CN;
  328. font-weight: bold;
  329. font-size: 18px;
  330. color: #000;
  331. line-height: 36px;
  332. }
  333. .submit_box /deep/{
  334. width: 100%;
  335. border-radius: 1px;
  336. background: rgba(255, 255, 255, .9);
  337. overflow: hidden;
  338. .el-form{
  339. width: 100%;
  340. margin: 46px auto 0;
  341. .el_input{
  342. display: flex;
  343. align-items: center;
  344. justify-content: space-between;
  345. .el-input__inner{
  346. border: 1px solid #0466b5;
  347. }
  348. .el-form-item{
  349. width: 48%;
  350. }
  351. }
  352. .el_input_message{
  353. .el-textarea__inner{
  354. border: 1px solid #0466b5;
  355. }
  356. .el-form-item{
  357. width: 100%;
  358. }
  359. }
  360. }
  361. .submit_bottom{
  362. margin: 20px 0 20px 130px;
  363. width: 914px;
  364. display: flex;
  365. align-items: center;
  366. justify-content: space-between;
  367. .submit_bottom_text{
  368. font-family: Source Han Sans CN;
  369. font-weight: 500;
  370. font-size: 16px;
  371. color: #0466B5;
  372. line-height: 36px;
  373. }
  374. .submit_bottom_button{
  375. width: 330px;
  376. height: 45px;
  377. line-height: 45px;
  378. background: #0466B5;
  379. font-family: Source Han Sans CN;
  380. font-weight: 500;
  381. font-size: 18px;
  382. color: #FFFFFF;
  383. text-align: center;
  384. cursor: pointer;
  385. }
  386. }
  387. }
  388. }
  389. @media screen and (min-width: 751px) and (max-width: 9999px) {
  390. .app {
  391. // display: flex;
  392. // flex-direction: column;
  393. }
  394. .bigbox {
  395. height: 100%;
  396. }
  397. .home_b {
  398. height: 100%;
  399. }
  400. .noHome {
  401. min-height: 100%;
  402. display: flex;
  403. flex-direction: column;
  404. .header {
  405. position: sticky;
  406. top: 0;
  407. z-index: 9;
  408. }
  409. }
  410. .content_app {
  411. flex: 1;
  412. width: 1200px;
  413. margin: 0 auto;
  414. padding: 20px 0
  415. }
  416. .content{
  417. width: 100%;
  418. }
  419. }
  420. @media screen and (max-width: 1200px) {
  421. .content_app {
  422. width: 100% !important;
  423. padding: 20px;
  424. }
  425. }
  426. @media screen and (min-width: 0px) and (max-width: 750px) {
  427. .app /deep/{
  428. // display: flex;
  429. // flex-direction: column;
  430. min-height: 6rem;
  431. .el-icon-loading {
  432. font-size: 0.6rem !important;
  433. color: #ccc;
  434. text-align: center;
  435. margin-left: 0px !important;
  436. }
  437. .el-dialog__title{
  438. font-family: Source Han Sans CN;
  439. font-weight: bold;
  440. font-size: 18px;
  441. color: #000;
  442. }
  443. }
  444. .production_bottom_box{
  445. width: 100% !important;
  446. .production_bottom_title{
  447. line-height: 1;
  448. }
  449. .submit_box /deep/{
  450. .el-form{
  451. margin-top: 0 !important;
  452. }
  453. .el_input{
  454. width: 100%;
  455. .el-form-item{
  456. width: 100% !important;
  457. .el-form-item__label{
  458. font-size: 12px !important;
  459. }
  460. }
  461. }
  462. .submit_bottom{
  463. width: 100% !important;
  464. margin: 0;
  465. padding-left: 140px;
  466. flex-wrap: wrap;
  467. .submit_bottom_text{
  468. width: 100% !important;
  469. font-size: 12px;
  470. line-height: 20px;
  471. }
  472. .submit_bottom_button{
  473. margin-top: 0.1rem;
  474. }
  475. }
  476. }
  477. }
  478. .bigbox {
  479. height: 100%;
  480. }
  481. .home_b {
  482. height: 100%;
  483. }
  484. .noHome {
  485. height: 100%;
  486. display: flex;
  487. flex-direction: column;
  488. }
  489. .content {
  490. flex: 1;
  491. width: 100%;
  492. margin: 0 auto;
  493. // padding: 0.2rem;
  494. }
  495. .content_app {
  496. flex: 1;
  497. width: 100%;
  498. margin: 0 auto;
  499. // padding: 0.2rem;
  500. }
  501. .fixed-message{
  502. position: fixed;
  503. bottom: .6rem;
  504. right: .1rem;
  505. z-index: 9;
  506. background: #065ba9;
  507. display: flex;
  508. align-items: center;
  509. // width: 175px;
  510. // height: 64px;
  511. padding: 0.05rem .1rem;
  512. border-radius: 30px;
  513. cursor: pointer;
  514. img{
  515. width: 0.2rem;
  516. }
  517. .fixed-message-text{
  518. font-size: .12rem;
  519. color: #fff;
  520. text-align: center;
  521. margin-left: .1rem;
  522. }
  523. }
  524. }
  525. // loading
  526. </style>