form.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div class="submit-area">
  3. <div class="label">加盟申请</div>
  4. <div class="phone-num">
  5. <img
  6. src="http://res.training.luojigou.vip/FmUjRlN7yn8o8HkXV21yOAJt-2C0?imageView2/0/q/50|imageslim"
  7. alt="" />
  8. <div class="num">400-6807300</div>
  9. </div>
  10. <div class="form">
  11. <el-form :model="form" :rules="rules" ref="ruleForm">
  12. <el-form-item prop="name">
  13. <el-input placeholder="姓名" v-model="form.name"></el-input>
  14. </el-form-item>
  15. <el-form-item prop="phone">
  16. <el-input placeholder="手机号" v-model="form.phone"></el-input>
  17. </el-form-item>
  18. <el-form-item prop="email">
  19. <el-input placeholder="邮箱地址" v-model="form.email"></el-input>
  20. </el-form-item>
  21. <el-form-item prop="city">
  22. <el-input placeholder="加盟城市" v-model="form.city"></el-input>
  23. </el-form-item>
  24. <el-form-item prop="project">
  25. <el-select placeholder="合作项目" v-model="form.project">
  26. <el-option
  27. v-for="(item, index) in projectList"
  28. :key="index"
  29. :label="item.title"
  30. :value="item.title">
  31. </el-option>
  32. </el-select>
  33. </el-form-item>
  34. <div class="submit" @click="handleSubmit('ruleForm')">提交申请</div>
  35. </el-form>
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. import axios from "axios";
  41. export default {
  42. data() {
  43. return {
  44. form: {},
  45. rules: {
  46. name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
  47. phone: [
  48. { required: true, message: "请输入手机号", trigger: "blur" },
  49. {
  50. pattern: /^1[345789]\d{9}$/,
  51. message: "请输入正确手机号",
  52. trigger: "blur",
  53. },
  54. ],
  55. email: [
  56. { required: true, message: "请输入邮箱地址", trigger: "blur" },
  57. {
  58. type: "email",
  59. message: "请输入正确的邮箱地址",
  60. trigger: ["blur", "change"],
  61. },
  62. ],
  63. city: [{ required: true, message: "请输入加盟城市", trigger: "blur" }],
  64. },
  65. projectList: [
  66. {
  67. id: 1,
  68. title: '逻辑狗·探索小镇'
  69. },
  70. {
  71. id: 2,
  72. title: '逻辑狗专柜'
  73. },
  74. {
  75. id: 3,
  76. title: '逻辑狗思维体验Plus'
  77. },
  78. {
  79. id: 4,
  80. title: '逻辑狗思维体验Home'
  81. },
  82. {
  83. id: 5,
  84. title: '逻辑狗体验中心'
  85. }
  86. ]
  87. }
  88. },
  89. methods: {
  90. async handleSubmit(formName) {
  91. this.$refs[formName].validate(async (valid) => {
  92. if (valid) {
  93. const { data } = await axios.post(`${this.$store.state.wordpressAPI}/official-api/joinIn`,{
  94. ...this.form
  95. });
  96. if(data.status == 200 ) {
  97. this.$notify({
  98. title: '成功',
  99. message: '提交成功',
  100. type: 'success'
  101. });
  102. this.$refs[formName].resetFields();
  103. } else {
  104. this.$notify({
  105. title: '失败',
  106. message: '提交失败',
  107. type: 'info'
  108. });
  109. }
  110. // this.$message.success('提交成功');
  111. } else {
  112. console.log('err');
  113. return false;
  114. }
  115. });
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss">
  121. .submit-area {
  122. background: #FFFFFF;
  123. border-radius: 20px;
  124. padding: 32px 38px 32px;
  125. .label {
  126. font-size: 14px;
  127. font-family: PingFangSC-Regular, sans-serif;
  128. font-weight: 400;
  129. color: rgba(91, 95, 93, 1);
  130. margin-bottom: 7px;
  131. }
  132. .phone-num {
  133. display: flex;
  134. align-items: center;
  135. img {
  136. width: 22px;
  137. height: 22px;
  138. display: block;
  139. margin-right: 15px;
  140. }
  141. .num {
  142. font-size: 26px;
  143. font-family: PingFangSC-Medium, sans-serif;
  144. font-weight: bold;
  145. color: rgba(0, 0, 0, 1);
  146. }
  147. }
  148. .form {
  149. margin-top: 20px;
  150. display: flex;
  151. flex-direction: column;
  152. justify-content: space-between;
  153. align-items: center;
  154. .el-input {
  155. width: 250px;
  156. height: 44px;
  157. }
  158. .el-form-item__error {
  159. color: #cd2026;
  160. // left: 124px;
  161. }
  162. .el-form-item {
  163. &.is-error {
  164. .el-input__inner {
  165. border-color: #dcdfe6;
  166. }
  167. }
  168. }
  169. .submit {
  170. margin: 0 auto;
  171. text-align: center;
  172. font-size: 14px;
  173. color: #fff;
  174. width: 148px;
  175. height: 34px;
  176. line-height: 34px;
  177. background: linear-gradient(180deg, #4482FE 0%, #004DE7 100%);
  178. box-shadow: 0px 7px 14px 0px rgba(136, 176, 254, 0.79);
  179. border-radius: 32px;
  180. }
  181. img {
  182. width: 176px;
  183. height: 55px;
  184. }
  185. }
  186. }
  187. </style>