registration.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. <template>
  2. <div class="registration2">
  3. <div class="title">
  4. <!-- 注册账号 -->
  5. <p class="p1">{{ $t("Key23") }}</p>
  6. <!-- 用户信息 -->
  7. <p class="p2">{{ $t("Key24") }}</p>
  8. </div>
  9. <div class="form" v-loading="loading">
  10. <!--
  11. :show-message="false"
  12. -->
  13. <el-form
  14. :model="ruleForm"
  15. :rules="rules"
  16. ref="ruleForm"
  17. :class="['demo-ruleForm', language_type == 'AR' ? 'ruleForm' : '']"
  18. :hide-required-asterisk="true"
  19. :show-message="false"
  20. >
  21. <el-form-item prop="Username">
  22. <span slot="label" class="lable">
  23. <img src="../../assets/login/singin1.png" alt="" />
  24. <span> <!-- 用户名 -->{{ $t("Key25") }} </span>
  25. </span>
  26. <el-input
  27. :placeholder="$t('Key26')"
  28. v-model="ruleForm.Username"
  29. @input="trimInput('Username')"
  30. ></el-input>
  31. </el-form-item>
  32. <el-form-item prop="Realname">
  33. <span slot="label" class="lable">
  34. <img src="../../assets/login/singin2.png" alt="" />
  35. <span> <!-- 真实姓名 -->{{ $t("Key27") }} </span>
  36. </span>
  37. <el-input
  38. :placeholder="$t('Key28')"
  39. v-model="ruleForm.Realname"
  40. @input="trimInput('Realname')"
  41. ></el-input>
  42. </el-form-item>
  43. <el-form-item prop="FromWhereCode" class="Noafter">
  44. <span slot="label" class="lable">
  45. <img src="../../assets/login/singin3.png" alt="" />
  46. <span> <!-- 地区 -->{{ $t("Key29") }} </span>
  47. </span>
  48. <el-select
  49. v-model="ruleForm.FromWhereCode"
  50. :placeholder="$t('Key30')"
  51. >
  52. <el-option
  53. v-for="(item, i) in TimeZoneList"
  54. :key="i + item"
  55. :value="item.code"
  56. :label="item.name"
  57. >
  58. </el-option>
  59. </el-select>
  60. </el-form-item>
  61. <el-form-item prop="org_id">
  62. <span slot="label" class="lable">
  63. <img src="../../assets/login/singin4.png" alt="" />
  64. <span> {{ $t("Key31") }} </span>
  65. </span>
  66. <el-select
  67. v-model="ruleForm.org_id"
  68. :placeholder="$t('Key32')"
  69. v-loadmore="SelectScroll"
  70. v-loading="SelectLoading"
  71. >
  72. <el-option
  73. v-for="item in institutionList.org_list"
  74. :key="item.id"
  75. :value="item.id"
  76. :label="item.name"
  77. ></el-option>
  78. </el-select>
  79. </el-form-item>
  80. <hr />
  81. <div class="title2">
  82. <!-- 注册信息 -->
  83. {{ $t("Key84") }}
  84. </div>
  85. <el-form-item prop="user_type">
  86. <span slot="label" class="lable">
  87. <img src="../../assets/login/singin5.png" alt="" />
  88. <span>
  89. <!-- 身份 -->
  90. {{ $t("Key33") }}
  91. </span>
  92. </span>
  93. <el-radio-group style="width: 334px" v-model="ruleForm.user_type">
  94. <el-radio label="TEACHER">
  95. <span style="color: black"> 老师 </span>
  96. </el-radio>
  97. <el-radio label="STUDENT">
  98. <span style="color: black"> 学生 </span>
  99. </el-radio>
  100. </el-radio-group>
  101. </el-form-item>
  102. <el-form-item prop="email">
  103. <span slot="label" class="lable">
  104. <img src="../../assets/login/singin6.png" alt="" />
  105. <span> {{ $t("Key34") }} </span>
  106. </span>
  107. <el-input
  108. @change="ChangeEmail"
  109. v-model="ruleForm.email"
  110. :placeholder="$t('Key34')"
  111. @input="trimInput('email')"
  112. />
  113. </el-form-item>
  114. <el-form-item prop="verification_code">
  115. <span slot="label" class="lable">
  116. <img src="../../assets/login/singin7.png" alt="" />
  117. <span> {{ $t("Key36") }} </span>
  118. </span>
  119. <el-input
  120. style="width: 202px"
  121. v-model="ruleForm.verification_code"
  122. :placeholder="$t('Key36')"
  123. @input="verification_codeChange"
  124. maxlength="6"
  125. />
  126. <button v-if="VerificationCodeShow" class="waitTime" disabled>
  127. {{ time + "s" }}
  128. </button>
  129. <button
  130. type="button"
  131. v-else
  132. @click.prevent="getVerificationCode"
  133. :class="[
  134. 'getVerification',
  135. language_type == 'AR' ? 'marginRight' : '',
  136. ]"
  137. >
  138. 获取
  139. </button>
  140. </el-form-item>
  141. <el-form-item prop="password">
  142. <span slot="label" class="lable">
  143. <img src="../../assets/login/singin9.png" alt="" />
  144. <span>
  145. <!-- 密码 -->
  146. {{ $t("Key14") }}
  147. </span>
  148. </span>
  149. <el-input
  150. v-model="ruleForm.password"
  151. :placeholder="$t('Key14')"
  152. :type="parsswordType"
  153. @change="changeParssword"
  154. @input="trimInput('password')"
  155. />
  156. <img
  157. v-show="parsswordType == 'password'"
  158. @click="lookParssowrd(1)"
  159. :class="['rightimg', language_type == 'AR' ? 'posLeft' : '']"
  160. src="../../assets/login/password1.png"
  161. alt=""
  162. />
  163. <img
  164. v-show="parsswordType == 'text'"
  165. @click="lookParssowrd(1)"
  166. :class="['rightimg', language_type == 'AR' ? 'posLeft' : '']"
  167. src="../../assets/login/password2.png"
  168. alt=""
  169. />
  170. <p :class="passwordError ? 'textRed' : 'psswordHint'">
  171. <!-- 请输入8-12位大写字母、小写字母、数字和组合。 -->
  172. {{ $t("Key17") }}
  173. </p>
  174. </el-form-item>
  175. <el-form-item prop="Twopassword">
  176. <span slot="label" class="lable" style="width: 200px">
  177. <img src="../../assets/login/singin9.png" alt="" />
  178. <span>
  179. <!-- 重复 -->
  180. {{ $t("Key15") }}
  181. </span>
  182. </span>
  183. <el-input
  184. v-model="ruleForm.Twopassword"
  185. :placeholder="$t('Key16')"
  186. :type="twoPasswordType"
  187. @change="Changetowpassword"
  188. @input="trimInput('Twopassword')"
  189. />
  190. <img
  191. v-show="twoPasswordType == 'password'"
  192. @click="lookParssowrd(2)"
  193. :class="['rightimg', language_type == 'AR' ? 'posLeft' : '']"
  194. src="../../assets/login/password1.png"
  195. alt=""
  196. />
  197. <img
  198. v-show="twoPasswordType == 'text'"
  199. @click="lookParssowrd(2)"
  200. :class="['rightimg', language_type == 'AR' ? 'posLeft' : '']"
  201. src="../../assets/login/password2.png"
  202. alt=""
  203. />
  204. <p :class="passwordErrorTwo ? 'textRed' : 'psswordHint'">
  205. <!-- 请再次输入密码。这两个项必须相同。 -->
  206. {{ $t("Key18") }}
  207. </p>
  208. </el-form-item>
  209. <hr />
  210. <div class="agreementAndRemeberMeAndForgetparssword">
  211. <!-- 同意协议 -->
  212. <div class="agreement">
  213. <el-checkbox v-model="ageeemnt">
  214. <span style="color: black">
  215. <!-- 我已阅读并同意 -->
  216. {{ $t("Key21") }}
  217. </span>
  218. <span>
  219. <!-- 用户协议 -->
  220. {{ $t("Key22") }}
  221. </span>
  222. </el-checkbox>
  223. </div>
  224. <!-- 我有账户 -->
  225. <!-- <div class="remeberMeAndForgetparssword">
  226. <p>I have an account. Log in.</p>
  227. </div> -->
  228. </div>
  229. <div class="sumit">
  230. <button v-if="isLogin">
  231. <img src="../../assets/login/Ellipse87.png" alt="" />
  232. </button>
  233. <button v-else type="button" @click.prevent="submitForm('ruleForm')">
  234. <!-- 注册 -->{{ $t("Key10") }}
  235. </button>
  236. </div>
  237. </el-form>
  238. </div>
  239. </div>
  240. </template>
  241. <script>
  242. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  243. //例如:import 《组件名称》from ‘《组件路径》';
  244. import { getLogin } from "@/api/api";
  245. import { mapGetters } from "vuex";
  246. export default {
  247. //import引入的组件需要注入到对象中才能使用
  248. components: {},
  249. props: ["changeLoginReg"],
  250. data() {
  251. //这里存放数据
  252. return {
  253. ruleForm: {
  254. Username: "",
  255. Realname: "",
  256. FromWhereCode: "",
  257. org_id: "",
  258. user_type: "STUDENT",
  259. email: "",
  260. verification_code: "",
  261. password: "",
  262. Twopassword: "",
  263. },
  264. register: "邮箱",
  265. ageeemnt: false,
  266. rules: {
  267. Username: [
  268. { required: true, message: "Please enter", trigger: "blur" },
  269. ],
  270. Realname: [
  271. {
  272. required: true,
  273. message: "Please enter your real name",
  274. trigger: "blur",
  275. },
  276. ],
  277. // FromWhere: [
  278. // {
  279. // required: true,
  280. // message: "Select country and region",
  281. // trigger: "blur",
  282. // },
  283. // ],
  284. org_id: [
  285. {
  286. required: true,
  287. message: "Selection mechanism",
  288. trigger: "blur",
  289. },
  290. ],
  291. user_type: [
  292. {
  293. required: true,
  294. },
  295. ],
  296. email: [
  297. {
  298. required: true,
  299. },
  300. ],
  301. verification_code: [
  302. {
  303. required: true,
  304. },
  305. ],
  306. password: [
  307. {
  308. required: true,
  309. },
  310. ],
  311. Twopassword: [
  312. {
  313. required: true,
  314. },
  315. ],
  316. },
  317. parsswordType: "password",
  318. twoPasswordType: "password",
  319. VerificationCodeShow: false,
  320. time: 60,
  321. EmailError: null, //邮箱是否正确
  322. loading: false,
  323. SelectLoading: false,
  324. institutionList: [], //机构列表
  325. inPage: 1,
  326. inPageSize: 10,
  327. isLogin: false,
  328. passwordError: false,
  329. passwordErrorTwo: false,
  330. TimeZoneList: null, //时区列表
  331. };
  332. },
  333. //计算属性 类似于data概念
  334. computed: {
  335. ...mapGetters(["language_type"]),
  336. },
  337. //监控data中数据变化
  338. watch: {},
  339. //方法集合
  340. methods: {
  341. // 去除空格
  342. trimInput(key) {
  343. console.log(key);
  344. this.ruleForm[key] = this.ruleForm[key].trim();
  345. },
  346. // 提交
  347. submitForm(formName) {
  348. let flag = false;
  349. this.$refs[formName].validate((valid) => {
  350. if (valid) {
  351. } else {
  352. flag = true;
  353. return false;
  354. }
  355. });
  356. // 是否勾选了同意协议
  357. if (!this.ageeemnt) {
  358. this.$message.warning("阅读并同意用户协议");
  359. return;
  360. }
  361. if (this.ruleForm.Twopassword != this.ruleForm.password) {
  362. this.$message.warning("请重新输入密码。两个条目必须相同");
  363. return;
  364. }
  365. if (this.passwordError) {
  366. this.$message.warning(this.$t("Key17"));
  367. return;
  368. }
  369. if (flag) {
  370. return;
  371. }
  372. this.isLogin = true;
  373. let MethodName = "user_manager-RegisterUser";
  374. let data = {
  375. user_type: this.ruleForm.user_type,
  376. user_name: this.ruleForm.Username,
  377. real_name: this.ruleForm.Realname,
  378. org_id: this.ruleForm.org_id,
  379. country_code: this.ruleForm.FromWhereCode, //所属地区编码
  380. password: this.ruleForm.password,
  381. verification_type: this.register == "邮箱" ? "EMAIL" : "SMS",
  382. phone_or_email: this.ruleForm.email,
  383. verification_code: this.ruleForm.verification_code,
  384. };
  385. getLogin(MethodName, data)
  386. .then((res) => {
  387. this.$message.success("success");
  388. this.isLogin = false;
  389. this.$router.push({
  390. path: "/",
  391. query: {
  392. type: "login",
  393. },
  394. });
  395. })
  396. .catch((err) => {
  397. this.isLogin = false;
  398. });
  399. },
  400. // 验证密码
  401. changeParssword() {
  402. if (this.ruleForm.password) {
  403. let reg = /^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{8,12}$/;
  404. let result = reg.test(this.ruleForm.password);
  405. if (result) {
  406. this.passwordError = false;
  407. } else {
  408. this.passwordError = true;
  409. }
  410. }
  411. },
  412. // 验证第二次密码是否一样
  413. Changetowpassword() {
  414. if (this.ruleForm.Twopassword) {
  415. if (this.ruleForm.Twopassword != this.ruleForm.password) {
  416. this.passwordErrorTwo = true;
  417. return;
  418. } else {
  419. this.passwordErrorTwo = false;
  420. }
  421. }
  422. },
  423. // 验证邮箱
  424. ChangeEmail() {
  425. let reg = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/; //验证邮箱的正则
  426. this.EmailError = reg.test(this.ruleForm.email);
  427. if (!this.EmailError) {
  428. this.EmailError = false;
  429. this.$message.error("邮箱格式不正确");
  430. }
  431. },
  432. // 获取验证码
  433. getVerificationCode() {
  434. if (!this.EmailError) {
  435. this.EmailError = false;
  436. this.$message.error("邮箱格式不正确");
  437. return;
  438. }
  439. let this_ = this;
  440. let timer;
  441. if (this_.ruleForm.email) {
  442. this_.VerificationCodeShow = true;
  443. let MethodName = "user_manager-SendVerificationCode";
  444. let data = {
  445. verification_type: this.register == "邮箱" ? "EMAIL" : "SMS",
  446. phone_or_email: this_.ruleForm.email,
  447. };
  448. getLogin(MethodName, data).then((res) => {
  449. console.log(res);
  450. timer = setInterval(() => {
  451. this_.time--;
  452. if (this_.time == 0) {
  453. this_.VerificationCodeShow = false;
  454. clearInterval(timer);
  455. timer = null;
  456. this_.time = 60;
  457. }
  458. }, 1000);
  459. });
  460. } else {
  461. this_.$message.warning("请先输入邮箱或手机号码");
  462. }
  463. },
  464. // 验证码的验证只能输入数字
  465. verification_codeChange() {
  466. this.ruleForm.verification_code = this.ruleForm.verification_code.replace(
  467. /[^\d]/g,
  468. ""
  469. );
  470. },
  471. // 查看密码
  472. lookParssowrd(number) {
  473. if (number == 1) {
  474. if (this.parsswordType == "text") {
  475. this.parsswordType = "password";
  476. } else {
  477. this.parsswordType = "text";
  478. }
  479. } else {
  480. if (this.twoPasswordType == "text") {
  481. this.twoPasswordType = "password";
  482. } else {
  483. this.twoPasswordType = "text";
  484. }
  485. }
  486. },
  487. // 获取机构列表
  488. getinstitutionList() {
  489. this.loading = true;
  490. let MethodName = "org_manager-PageQueryOrgIndexList_OpenQuery";
  491. let data = {
  492. name: this.inName,
  493. page_capacity: this.inPageSize,
  494. cur_page: this.inPage,
  495. };
  496. getLogin(MethodName, data).then((res) => {
  497. this.loading = false;
  498. this.institutionList = res;
  499. });
  500. },
  501. // 滚动加载
  502. SelectScroll() {
  503. if (
  504. this.institutionList.org_list.length == this.institutionList.total_count
  505. ) {
  506. // this.$message.warning("No more data");
  507. return;
  508. }
  509. this.SelectLoading = true;
  510. this.inPage++;
  511. let MethodName = "org_manager-PageQueryOrgIndexList_OpenQuery";
  512. let data = {
  513. name: this.inName,
  514. page_capacity: this.inPageSize,
  515. cur_page: this.inPage,
  516. };
  517. getLogin(MethodName, data).then((res) => {
  518. res.org_list.forEach((item) => {
  519. this.institutionList.org_list.push(item);
  520. });
  521. this.SelectLoading = false;
  522. });
  523. },
  524. // 获取时区列表
  525. getTimeZone() {
  526. let MethodName = "dict_manager-GetCountryList";
  527. getLogin(MethodName).then((res) => {
  528. this.TimeZoneList = res.country_list;
  529. });
  530. },
  531. },
  532. //生命周期 - 创建完成(可以访问当前this实例)
  533. created() {
  534. this.getinstitutionList();
  535. this.getTimeZone();
  536. },
  537. //生命周期 - 挂载完成(可以访问DOM元素)
  538. mounted() {},
  539. //生命周期-创建之前
  540. beforeCreated() {},
  541. //生命周期-挂载之前
  542. beforeMount() {},
  543. //生命周期-更新之前
  544. beforUpdate() {},
  545. //生命周期-更新之后
  546. updated() {},
  547. //生命周期-销毁之前
  548. beforeDestory() {},
  549. //生命周期-销毁完成
  550. destoryed() {},
  551. //如果页面有keep-alive缓存功能,这个函数会触发
  552. activated() {},
  553. };
  554. </script>
  555. <style lang="scss" scoped>
  556. /* @import url(); 引入css类 */
  557. .registration2 {
  558. width: 1200px;
  559. background: white;
  560. margin: 40px 60px 40px 60px;
  561. padding: 40px 40px 40px 40px;
  562. border-radius: 8px;
  563. .title {
  564. p {
  565. margin: 0;
  566. padding: 0;
  567. }
  568. .p1 {
  569. font-size: 24px;
  570. color: #ff9900;
  571. }
  572. .p2 {
  573. margin-top: 40px;
  574. font-size: 20px;
  575. color: #000000;
  576. }
  577. }
  578. .form {
  579. margin-top: 50px;
  580. .title2 {
  581. font-weight: 600;
  582. font-size: 20px;
  583. color: #000000;
  584. margin: 20px 0;
  585. }
  586. hr {
  587. margin: 0;
  588. width: 474px;
  589. height: 1px;
  590. background: #d9d9d9;
  591. }
  592. .el-input,
  593. .el-select {
  594. width: 334px;
  595. }
  596. .el-form-item {
  597. width: 1140px;
  598. display: flex;
  599. .lable {
  600. display: inline-block;
  601. width: 120px !important;
  602. text-align: left;
  603. img {
  604. width: 24px;
  605. vertical-align: middle;
  606. }
  607. span {
  608. margin: 0 10px;
  609. }
  610. }
  611. }
  612. .el-form-item::after {
  613. content: "*";
  614. color: red;
  615. position: relative;
  616. left: 5px;
  617. top: 10px;
  618. }
  619. .ruleForm .el-form-item::after {
  620. left: -8px;
  621. }
  622. .getVerification {
  623. width: 116px;
  624. height: 40px;
  625. margin-left: 16px;
  626. border-radius: 4px;
  627. cursor: pointer;
  628. box-sizing: border-box;
  629. background: #ff9900;
  630. border: 1px solid #ff9900;
  631. color: white;
  632. &.marginRight {
  633. margin-right: 16px;
  634. margin-left: 0px;
  635. }
  636. }
  637. .waitTime {
  638. width: 116px;
  639. height: 40px;
  640. margin-left: 16px;
  641. border-radius: 4px;
  642. cursor: pointer;
  643. box-sizing: border-box;
  644. background: #f0f0f0;
  645. color: black;
  646. border: none;
  647. }
  648. .rightimg {
  649. width: 24px;
  650. position: absolute;
  651. right: 10px;
  652. top: 10px;
  653. cursor: pointer;
  654. &.posLeft {
  655. right: auto;
  656. left: 10px;
  657. }
  658. }
  659. .psswordHint {
  660. width: 334px;
  661. margin: 0;
  662. padding: 0;
  663. font-size: 14px;
  664. color: #000000;
  665. opacity: 0.3;
  666. line-height: 20px;
  667. margin-top: 5px;
  668. }
  669. .textRed {
  670. width: 334px;
  671. margin: 0;
  672. padding: 0;
  673. font-size: 14px;
  674. color: red;
  675. opacity: 1;
  676. line-height: 20px;
  677. margin-top: 5px;
  678. }
  679. .sumit {
  680. width: 474px;
  681. text-align: right;
  682. button {
  683. width: 337px;
  684. height: 48px;
  685. background: #ff9900;
  686. border-radius: 4px;
  687. cursor: pointer;
  688. border: none;
  689. outline: none;
  690. color: white;
  691. img {
  692. vertical-align: middle;
  693. animation: rotated 1s linear infinite;
  694. }
  695. }
  696. }
  697. .agreementAndRemeberMeAndForgetparssword {
  698. width: 474px;
  699. display: flex;
  700. justify-content: flex-end;
  701. > div {
  702. margin: 20px 0;
  703. width: 334px;
  704. position: relative;
  705. }
  706. .agreement {
  707. span {
  708. color: #ff9900;
  709. }
  710. }
  711. }
  712. .remeberMeAndForgetparssword {
  713. p {
  714. margin: 0;
  715. color: #ff9900;
  716. cursor: pointer;
  717. text-align: right;
  718. }
  719. }
  720. .Noafter::after {
  721. content: "";
  722. }
  723. }
  724. @keyframes rotated {
  725. 0% {
  726. transform: rotateZ(0deg);
  727. }
  728. 100% {
  729. transform: rotateZ(360deg);
  730. }
  731. }
  732. }
  733. </style>
  734. <style lang="scss">
  735. .registration2 {
  736. .el-form-item__label {
  737. padding: 0;
  738. }
  739. .agreement {
  740. .el-checkbox__label {
  741. padding: 0 10px;
  742. }
  743. }
  744. }
  745. </style>