cardHome.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <div class="back">
  3. <el-form :inline="true" :model="formInline" class="formCard">
  4. <!-- <el-form-item label="读卡">
  5. <el-input
  6. v-model="formInline.user"
  7. ref="input"
  8. placeholder="读卡"
  9. ></el-input>
  10. </el-form-item> -->
  11. <el-form-item>
  12. <!-- <el-button type="primary" @click="onSubmit" :disabled="flag"
  13. >查询</el-button
  14. > -->
  15. <el-image :src="start" @click="onSubmit"></el-image>
  16. </el-form-item>
  17. </el-form>
  18. <el-dialog
  19. :visible.sync="dialogVisible"
  20. width="70%"
  21. :show-close="false"
  22. style="margintop: 25vh"
  23. >
  24. <lottie
  25. :options="defaultOptions"
  26. :height="300"
  27. :width="300"
  28. v-on:animCreated="handleAnimation"
  29. />
  30. </el-dialog>
  31. </div>
  32. </template>
  33. <script>
  34. import * as animationData from "../assets/loding.json";
  35. import { newUpload, getLonLat } from "../api/home";
  36. import start from "../assets/start.png";
  37. import qs from "qs";
  38. export default {
  39. name: "cardHome",
  40. data() {
  41. return {
  42. start,
  43. formInline: {
  44. user: "",
  45. },
  46. flag: false,
  47. chipData: null,
  48. formChip: {
  49. dateTime: this.etCurrentTime(),
  50. chipNumber: null, //7218开头52位
  51. vaccinationCipher: null, //完整的报文
  52. longitude: "12958160.97", //经度
  53. latitude: "4825907.72", //纬度
  54. inoculators: "",
  55. agin: true,
  56. incs: "",
  57. temperatureData: null,
  58. },
  59. latModel: {
  60. ak: "n1B7YBnthymcNeuLL9vdPF69m2SA5cHq",
  61. },
  62. dialogVisible: false,
  63. newUrl:
  64. "http://evvmapi.vandh.org/file/pdf/7218ee5b49cbcd0e2a707a20c0756263c38f99b4df9af78e61cea1a2a3a4a5a6a7a83caf84f96583.pdf",
  65. set: null,
  66. defaultOptions: { animationData: animationData },
  67. animationSpeed: 1,
  68. anim: {},
  69. };
  70. },
  71. created() {
  72. // if (this.formInline !== "") {
  73. // this.$nextTick(() => {
  74. // this.$refs.input.focus();
  75. // });
  76. // }
  77. // this.ipLL();
  78. },
  79. methods: {
  80. onSubmit() {
  81. this.flag = true;
  82. // $.ajax({
  83. // type: "get",
  84. // url: "http://localhost:9000/readChip",
  85. // success: function (res) {
  86. // console.log(res);
  87. // },
  88. // });
  89. //this.$api +
  90. this.$http
  91. .get(
  92. this.$api + "/readChip",
  93. {
  94. headers: { "Content-Type": "application/x-www-form-urlencoded" },
  95. },
  96. { withCredentials: true }
  97. )
  98. .then((res) => {
  99. console.log(res);
  100. if (res.body.code == 200) {
  101. this.flag = false;
  102. this.dialogVisible = true;
  103. // const loading = this.$loading({
  104. // lock: true,
  105. // text: "Loading",
  106. // spinner: "el-icon-loading",
  107. // background: "rgba(0, 0, 0, 0.7)",
  108. // });
  109. this.chipData = res.body.data;
  110. this.formChip.chipNumber = this.chipData.chipNumber;
  111. this.formChip.vaccinationCipher = this.chipData.vaccinationCipher;
  112. this.formChip.temperatureStr = this.chipData.list;
  113. this.upLoad();
  114. // loading.close();
  115. }
  116. });
  117. },
  118. upLoad() {
  119. newUpload(qs.stringify(this.formChip)).then((res) => {
  120. // setTimeout(() => {
  121. // this.dialogVisible = false;
  122. // }, 3000);
  123. if (res.code == 200) {
  124. this.set = setTimeout(() => {
  125. this.dialogVisible = false;
  126. window.open(
  127. "http://evvmapi.vandh.org/file/pdf/" +
  128. res.data.chipNumber +
  129. "_.pdf",
  130. "_blank"
  131. );
  132. }, 3000);
  133. // window.open(
  134. // "http://evvmapi.vandh.org/file/pdf/7218ee5b49cbcd0e2a707a20c0756263c38f99b4df9af78e61cea1a2a3a4a5a6a7a83caf84f96583.pdf",
  135. // "_blank"
  136. // );
  137. } else if (res.code == 1628) {
  138. this.dialogVisible = false;
  139. }
  140. });
  141. },
  142. etCurrentTime() {
  143. //获取当前时间并打印
  144. let yy = new Date().getFullYear();
  145. let mm = new Date().getMonth() + 1;
  146. let dd = new Date().getDate();
  147. let hh = new Date().getHours();
  148. let mf =
  149. new Date().getMinutes() < 10
  150. ? "0" + new Date().getMinutes()
  151. : new Date().getMinutes();
  152. let ss =
  153. new Date().getSeconds() < 10
  154. ? "0" + new Date().getSeconds()
  155. : new Date().getSeconds();
  156. var gettime = yy + "/" + mm + "/" + dd + " " + hh + ":" + mf + ":" + ss;
  157. return gettime;
  158. },
  159. ipLL() {
  160. getLonLat(this.latModel).then((res) => {
  161. console.log(res);
  162. });
  163. },
  164. handleAnimation: function (anim) {
  165. this.anim = anim;
  166. console.log(anim); //这里可以看到 lottie 对象的全部属性
  167. },
  168. },
  169. };
  170. </script>
  171. <style lang="less" scoped>
  172. .back {
  173. padding: 0;
  174. margin: 0;
  175. background-image: url("../assets/5g.png");
  176. background-repeat: no-repeat;
  177. height: 100vh;
  178. background-size: 100% 100%;
  179. position: relative;
  180. width: 100%;
  181. .formCard {
  182. width: 1250px;
  183. height: 200px;
  184. position: absolute;
  185. top: 50%;
  186. left: 50%;
  187. transform: translate(-50%, -50%);
  188. }
  189. .iframe {
  190. width: 100%;
  191. height: 1200px;
  192. }
  193. /deep/.el-dialog,
  194. .el-pager li {
  195. background: none;
  196. box-shadow: none;
  197. }
  198. /deep/.el-dialog {
  199. background: none;
  200. box-shadow: none;
  201. margin-top: 25vh;
  202. }
  203. }
  204. </style>