form.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. // 1-家庭(专柜)1-逻辑狗思维游戏HOME&PLUS馆 2-思维芯游戏室 2-“思维芯”四大课程体系 4-逻辑狗·探索小镇
  69. projectList: [
  70. {
  71. id: 1,
  72. value: 1,
  73. title: '家庭(专柜)'
  74. },
  75. {
  76. id: 2,
  77. value: 1,
  78. title: '逻辑狗思维游戏HOME&PLUS馆'
  79. },
  80. {
  81. id: 3,
  82. value: 2,
  83. title: '思维芯游戏室'
  84. },
  85. {
  86. id: 4,
  87. value: 2,
  88. title: '“思维芯”四大课程体系'
  89. },
  90. {
  91. id: 5,
  92. value: 4,
  93. title: '逻辑狗·探索小镇'
  94. }
  95. ],
  96. }
  97. },
  98. methods: {
  99. async handleSubmit(formName) {
  100. this.$refs[formName].validate(async (valid) => {
  101. if (valid) {
  102. // 根据选项获取选项的value
  103. // const index = this.projectList.findIndex(item => {
  104. // return item.id === this.form.project;
  105. // })
  106. // if(index == -1) {
  107. // this.$notify({
  108. // title: '失败',
  109. // message: '选择数据有误',
  110. // type: 'info'
  111. // });
  112. // return
  113. // }
  114. this.loading = true;
  115. this.disabled = true;
  116. const { data } = await axios.post(`${this.$store.state.wordpressAPI}/official-api/joinIn`,{
  117. ...this.form
  118. });
  119. if(data.status == 200 ) {
  120. this.$notify({
  121. title: '成功',
  122. message: '提交成功',
  123. type: 'success'
  124. });
  125. this.$refs[formName].resetFields();
  126. } else {
  127. this.$notify({
  128. title: '失败',
  129. message: '提交失败',
  130. type: 'info'
  131. });
  132. }
  133. this.loading = false;
  134. this.disabled = false;
  135. // this.$message.success('提交成功');
  136. } else {
  137. this.loading = false;
  138. this.disabled = false;
  139. console.log('err');
  140. return false;
  141. }
  142. });
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss">
  148. .submit-area {
  149. background: #FFFFFF;
  150. border-radius: 20px;
  151. padding: 32px 38px 32px;
  152. .label {
  153. text-align: left;
  154. font-size: 14px;
  155. font-family: PingFangSC-Regular, sans-serif;
  156. font-weight: 400;
  157. color: #000000;
  158. margin-bottom: 7px;
  159. }
  160. .phone-num {
  161. display: flex;
  162. align-items: center;
  163. img {
  164. width: 22px;
  165. height: 22px;
  166. display: block;
  167. margin-right: 15px;
  168. }
  169. .num {
  170. font-size: 26px;
  171. font-family: PingFangSC-Medium, sans-serif;
  172. font-weight: bold;
  173. color: rgba(0, 0, 0, 1);
  174. }
  175. }
  176. .form {
  177. margin-top: 20px;
  178. display: flex;
  179. flex-direction: column;
  180. justify-content: space-between;
  181. align-items: center;
  182. .el-input {
  183. width: 250px;
  184. height: 44px;
  185. }
  186. .el-form-item__error {
  187. color: #cd2026;
  188. // left: 124px;
  189. }
  190. .el-form-item {
  191. &.is-error {
  192. .el-input__inner {
  193. border-color: #dcdfe6;
  194. }
  195. }
  196. }
  197. .el-button {
  198. border: none;
  199. }
  200. .submit {
  201. margin: 0 auto;
  202. text-align: center;
  203. font-size: 14px;
  204. color: #fff;
  205. width: 148px;
  206. height: 34px;
  207. background: linear-gradient(180deg, #4482FE 0%, #004DE7 100%);
  208. box-shadow: 0px 7px 14px 0px rgba(136, 176, 254, 0.79);
  209. border-radius: 32px;
  210. }
  211. img {
  212. width: 176px;
  213. height: 55px;
  214. }
  215. }
  216. }
  217. </style>