form.vue 5.3 KB

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