minForm.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <div>
  3. <p class="errorP">&nbsp{{ errorMsg }}</p>
  4. <div class="imputWrap">
  5. <input
  6. class="minINput"
  7. type="text"
  8. v-model="form.name"
  9. placeholder="机构名称"
  10. />
  11. </div>
  12. <div class="imputWrap">
  13. <input
  14. class="minINput"
  15. type="text"
  16. v-model="form.city"
  17. placeholder="所在城市"
  18. />
  19. </div>
  20. <div class="imputWrap">
  21. <input
  22. class="minINput"
  23. type="text"
  24. v-model="form.linkman"
  25. placeholder="联系人姓名"
  26. />
  27. </div>
  28. <div class="halfBox">
  29. <div class="imputWrap">
  30. <input
  31. class="minINput halfe"
  32. type="text"
  33. v-model="form.mobileNo"
  34. placeholder="手机号码"
  35. />
  36. </div>
  37. <div class="imputWrap">
  38. <input class="minINput halfe" type="text" v-model="form.smsCode" placeholder="验证码" />
  39. <div class="line"></div>
  40. <div class="codeBox" @click="getCode">
  41. {{ time > 0 ? `${time}秒` : "发送验证码" }}
  42. </div>
  43. </div>
  44. </div>
  45. <div class="submitBtn" @click="submitInfo">申请免费试用</div>
  46. </div>
  47. </template>
  48. <script>
  49. import axios from "axios";
  50. import qs from "qs";
  51. export default {
  52. data() {
  53. return {
  54. errorMsg: "",
  55. form: {
  56. name: "",
  57. city: "",
  58. linkman: "",
  59. mobileNo: "",
  60. smsCode: "",
  61. },
  62. time: 0,
  63. url: "https://kj.colexiu.com/",
  64. maskRules: {
  65. name: [{ required: true, message: "请输入机构名称" }],
  66. city: [{ required: true, message: "请输入所在城市" }],
  67. linkman: [{ required: true, message: "请输入联系人姓名" }],
  68. mobileNo: [
  69. { required: true, message: "请输入手机号" },
  70. {
  71. pattern: /^1[3456789]\d{9}$/,
  72. message: "请输入正确的手机号",
  73. trigger: "blur",
  74. },
  75. ],
  76. smsCode: [{ required: true, message: "请输入验证码" }],
  77. },
  78. };
  79. },
  80. methods: {
  81. submitInfo() {
  82. // let url = "https://test.kj.colexiu.com/";
  83. // if (location.hostname == "colexiu.com") {
  84. // url = "https://kj.colexiu.com/";
  85. // }
  86. if (!this.validate()) {
  87. return;
  88. }
  89. axios({
  90. url: this.url + "api-user/tenantApply/add",
  91. method: "post",
  92. data: qs.stringify(this.form),
  93. headers: {
  94. "Content-type": "application/x-www-form-urlencoded",
  95. "Access-Control-Allow-Origin": "*",
  96. },
  97. }).then((res) => {
  98. if (res.data.code === 200) {
  99. this.$toast("提交成功");
  100. this.$emit('close')
  101. } else {
  102. this.$toast(res.data.msg);
  103. }
  104. });
  105. },
  106. getCode() {
  107. console.log("获取验证码");
  108. if (this.time > 0) {
  109. return;
  110. }
  111. if (!this.form.mobileNo) {
  112. this.errorMsg = "请输入手机号";
  113. return false;
  114. } else if (!this.form.mobileNo.match(/^1[3456789]\d{9}$/)) {
  115. this.errorMsg = "请输入正确的手机号";
  116. return false;
  117. } else {
  118. this.errorMsg = "";
  119. }
  120. axios({
  121. url: this.url + "api-auth/code/sendSms",
  122. method: "post",
  123. data: qs.stringify({ mobile: this.form.mobileNo }),
  124. headers: {
  125. "Content-type": "application/x-www-form-urlencoded",
  126. "Access-Control-Allow-Origin": "*",
  127. },
  128. }).then((res) => {
  129. if (res.data.code == 200) {
  130. this.time = 60
  131. this.$toast("发送成功");
  132. const timer = setInterval(() => {
  133. if (this.time > 0) {
  134. this.time--;
  135. } else {
  136. this.time = 0;
  137. clearInterval(timer);
  138. }
  139. }, 1000);
  140. } else {
  141. this.$toast("发送失败");
  142. }
  143. });
  144. },
  145. validate() {
  146. if (!this.form.name) {
  147. this.errorMsg = "请输入机构名称";
  148. return false;
  149. } else if (!this.form.city) {
  150. this.errorMsg = "请输入所在城市";
  151. return false;
  152. } else if (!this.form.linkman) {
  153. this.errorMsg = "请输入联系人姓名";
  154. return false;
  155. } else if (!this.form.mobileNo) {
  156. this.errorMsg = "请输入手机号";
  157. return false;
  158. } else if (!this.form.mobileNo.match(/^1[3456789]\d{9}$/)) {
  159. this.errorMsg = "请输入正确的手机号";
  160. return false;
  161. } else if (!this.form.smsCode) {
  162. this.errorMsg = "请输入验证码";
  163. return false;
  164. } else {
  165. this.errorMsg = "";
  166. return true;
  167. }
  168. },
  169. },
  170. };
  171. </script>
  172. <style lang="less" scoped>
  173. /deep/input::-webkit-input-placeholder,
  174. textarea::-webkit-input-placeholder {
  175. /* WebKit browsers */
  176. color: #808080;
  177. }
  178. /deep/input:-moz-placeholder,
  179. textarea:-moz-placeholder {
  180. /* Mozilla Firefox 4 to 18 */
  181. color: #808080;
  182. }
  183. /deep/input::-moz-placeholder,
  184. textarea::-moz-placeholder {
  185. /* Mozilla Firefox 19+ */
  186. color: #808080;
  187. }
  188. /deep/input:-ms-input-placeholder,
  189. textarea:-ms-input-placeholder {
  190. /* Internet Explorer 10+ */
  191. color: #808080;
  192. }
  193. .errorP {
  194. font-size: 0.26rem;
  195. color: red;
  196. text-align: center;
  197. }
  198. .halfBox {
  199. display: flex;
  200. flex-direction: row;
  201. align-items: center;
  202. justify-content: space-between;
  203. }
  204. .imputWrap {
  205. position: relative;
  206. margin: 0;
  207. padding: 0;
  208. display: block;
  209. margin-bottom: 0.18rem;
  210. // height: 0.78rem;
  211. input {
  212. display: block;
  213. border: none;
  214. -webkit-appearance: none;
  215. }
  216. .halfe.minINput {
  217. width: 3.3rem;
  218. }
  219. .minINput {
  220. background-color: #fbfaff;
  221. width: 6.7rem;
  222. height: 0.77rem;
  223. border: 1px solid #e5e5e5;
  224. font-size: 0.26rem;
  225. box-sizing: border-box;
  226. padding-left: 0.25rem;
  227. border-radius: 0.07rem;
  228. }
  229. }
  230. .line {
  231. position: absolute;
  232. width: 1px;
  233. height: 0.21rem;
  234. background: #e5e5e5;
  235. right: 1.82rem;
  236. top: 0.25rem;
  237. z-index: 10;
  238. }
  239. .codeBox {
  240. width: 1.7rem;
  241. height: 0.72rem;
  242. background-color: #fbfaff;
  243. line-height: 0.72rem;
  244. position: absolute;
  245. right: 1px;
  246. top: 1px;
  247. cursor: pointer;
  248. color: #808080;
  249. text-align: center;
  250. font-size: 0.24rem;
  251. padding: 0 0.1rem;
  252. }
  253. .submitBtn {
  254. width: 5.82rem;
  255. height: 0.84rem;
  256. border-radius: 0.42rem;
  257. text-align: center;
  258. color: #fff;
  259. font-size: 0.28rem;
  260. font-weight: bold;
  261. background-color: #2dc7aa;
  262. line-height: 0.84rem;
  263. margin: 0.45rem auto 0;
  264. }
  265. </style>