registration.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  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"> {{ $t("Key540") }} </span>
  96. </el-radio>
  97. <el-radio label="STUDENT">
  98. <span style="color: black"> {{ $t("Key541") }} </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('Key37')"
  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. <!-- 获取 -->{{ $t("Key542") }}
  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("Key121") }}
  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. // "阅读并同意用户协议"
  359. this.$message.warning(this.$t("Key543"));
  360. return;
  361. }
  362. if (this.ruleForm.Twopassword != this.ruleForm.password) {
  363. //Key544
  364. this.$message.warning(this.$t("Key544"));
  365. return;
  366. }
  367. if (this.passwordError) {
  368. this.$message.warning(this.$t("Key17"));
  369. return;
  370. }
  371. if (flag) {
  372. return;
  373. }
  374. this.isLogin = true;
  375. let MethodName = "user_manager-RegisterUser";
  376. let data = {
  377. user_type: this.ruleForm.user_type,
  378. user_name: this.ruleForm.Username,
  379. real_name: this.ruleForm.Realname,
  380. org_id: this.ruleForm.org_id,
  381. country_code: this.ruleForm.FromWhereCode, //所属地区编码
  382. password: this.ruleForm.password,
  383. verification_type: this.register == "邮箱" ? "EMAIL" : "SMS",
  384. phone_or_email: this.ruleForm.email,
  385. verification_code: this.ruleForm.verification_code,
  386. };
  387. getLogin(MethodName, data)
  388. .then((res) => {
  389. this.$message.success("success");
  390. this.isLogin = false;
  391. this.$router.push({
  392. path: "/",
  393. query: {
  394. type: "login",
  395. },
  396. });
  397. })
  398. .catch((err) => {
  399. this.isLogin = false;
  400. });
  401. },
  402. // 验证密码
  403. changeParssword() {
  404. if (this.ruleForm.password) {
  405. let reg = /^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{8,12}$/;
  406. let result = reg.test(this.ruleForm.password);
  407. if (result) {
  408. this.passwordError = false;
  409. } else {
  410. this.passwordError = true;
  411. }
  412. }
  413. },
  414. // 验证第二次密码是否一样
  415. Changetowpassword() {
  416. if (this.ruleForm.Twopassword) {
  417. if (this.ruleForm.Twopassword != this.ruleForm.password) {
  418. this.passwordErrorTwo = true;
  419. return;
  420. } else {
  421. this.passwordErrorTwo = false;
  422. }
  423. }
  424. },
  425. // 验证邮箱
  426. ChangeEmail() {
  427. let reg = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/; //验证邮箱的正则
  428. this.EmailError = reg.test(this.ruleForm.email);
  429. if (!this.EmailError) {
  430. this.EmailError = false;
  431. // 邮箱格式不正确
  432. this.$message.error(this.$t("Key545"));
  433. }
  434. },
  435. // 获取验证码
  436. getVerificationCode() {
  437. if (!this.EmailError) {
  438. this.EmailError = false;
  439. this.$message.error(this.$t("Key545"));
  440. return;
  441. }
  442. let this_ = this;
  443. let timer;
  444. if (this_.ruleForm.email) {
  445. this_.VerificationCodeShow = true;
  446. let MethodName = "user_manager-SendVerificationCode";
  447. let data = {
  448. verification_type: this.register == "邮箱" ? "EMAIL" : "SMS",
  449. phone_or_email: this_.ruleForm.email,
  450. };
  451. getLogin(MethodName, data).then((res) => {
  452. console.log(res);
  453. timer = setInterval(() => {
  454. this_.time--;
  455. if (this_.time == 0) {
  456. this_.VerificationCodeShow = false;
  457. clearInterval(timer);
  458. timer = null;
  459. this_.time = 60;
  460. }
  461. }, 1000);
  462. });
  463. } else {
  464. // 请先输入邮箱或手机号码"
  465. this_.$message.warning(this.$t("Key546"));
  466. }
  467. },
  468. // 验证码的验证只能输入数字
  469. verification_codeChange() {
  470. this.ruleForm.verification_code = this.ruleForm.verification_code.replace(
  471. /[^\d]/g,
  472. ""
  473. );
  474. },
  475. // 查看密码
  476. lookParssowrd(number) {
  477. if (number == 1) {
  478. if (this.parsswordType == "text") {
  479. this.parsswordType = "password";
  480. } else {
  481. this.parsswordType = "text";
  482. }
  483. } else {
  484. if (this.twoPasswordType == "text") {
  485. this.twoPasswordType = "password";
  486. } else {
  487. this.twoPasswordType = "text";
  488. }
  489. }
  490. },
  491. // 获取机构列表
  492. getinstitutionList() {
  493. this.loading = true;
  494. let MethodName = "org_manager-PageQueryOrgIndexList_OpenQuery";
  495. let data = {
  496. name: this.inName,
  497. page_capacity: this.inPageSize,
  498. cur_page: this.inPage,
  499. };
  500. getLogin(MethodName, data).then((res) => {
  501. this.loading = false;
  502. this.institutionList = res;
  503. });
  504. },
  505. // 滚动加载
  506. SelectScroll() {
  507. if (
  508. this.institutionList.org_list.length == this.institutionList.total_count
  509. ) {
  510. // this.$message.warning("No more data");
  511. return;
  512. }
  513. this.SelectLoading = true;
  514. this.inPage++;
  515. let MethodName = "org_manager-PageQueryOrgIndexList_OpenQuery";
  516. let data = {
  517. name: this.inName,
  518. page_capacity: this.inPageSize,
  519. cur_page: this.inPage,
  520. };
  521. getLogin(MethodName, data).then((res) => {
  522. res.org_list.forEach((item) => {
  523. this.institutionList.org_list.push(item);
  524. });
  525. this.SelectLoading = false;
  526. });
  527. },
  528. // 获取时区列表
  529. getTimeZone() {
  530. let MethodName = "dict_manager-GetCountryList";
  531. getLogin(MethodName).then((res) => {
  532. this.TimeZoneList = res.country_list;
  533. });
  534. },
  535. },
  536. //生命周期 - 创建完成(可以访问当前this实例)
  537. created() {
  538. this.getinstitutionList();
  539. this.getTimeZone();
  540. },
  541. //生命周期 - 挂载完成(可以访问DOM元素)
  542. mounted() {},
  543. //生命周期-创建之前
  544. beforeCreated() {},
  545. //生命周期-挂载之前
  546. beforeMount() {},
  547. //生命周期-更新之前
  548. beforUpdate() {},
  549. //生命周期-更新之后
  550. updated() {},
  551. //生命周期-销毁之前
  552. beforeDestory() {},
  553. //生命周期-销毁完成
  554. destoryed() {},
  555. //如果页面有keep-alive缓存功能,这个函数会触发
  556. activated() {},
  557. };
  558. </script>
  559. <style lang="scss" scoped>
  560. /* @import url(); 引入css类 */
  561. .registration2 {
  562. width: 1200px;
  563. background: white;
  564. margin: 40px 60px 40px 60px;
  565. padding: 40px 40px 40px 40px;
  566. border-radius: 8px;
  567. .title {
  568. p {
  569. margin: 0;
  570. padding: 0;
  571. }
  572. .p1 {
  573. font-size: 24px;
  574. color: #ff9900;
  575. }
  576. .p2 {
  577. margin-top: 40px;
  578. font-size: 20px;
  579. color: #000000;
  580. }
  581. }
  582. .form {
  583. margin-top: 50px;
  584. .title2 {
  585. font-weight: 600;
  586. font-size: 20px;
  587. color: #000000;
  588. margin: 20px 0;
  589. }
  590. hr {
  591. margin: 0;
  592. width: 474px;
  593. height: 1px;
  594. background: #d9d9d9;
  595. }
  596. .el-input,
  597. .el-select {
  598. width: 334px;
  599. }
  600. .el-form-item {
  601. width: 1140px;
  602. display: flex;
  603. .lable {
  604. display: flex;
  605. width: 120px !important;
  606. text-align: left;
  607. img {
  608. width: 24px;
  609. height: 24px;
  610. vertical-align: middle;
  611. }
  612. span {
  613. margin: 0 10px;
  614. line-height: 24px;
  615. }
  616. }
  617. }
  618. .el-form-item::after {
  619. content: "*";
  620. color: red;
  621. position: relative;
  622. left: 5px;
  623. top: 10px;
  624. }
  625. .ruleForm .el-form-item::after {
  626. left: -8px;
  627. }
  628. .getVerification {
  629. width: 116px;
  630. height: 40px;
  631. margin-left: 16px;
  632. border-radius: 4px;
  633. cursor: pointer;
  634. box-sizing: border-box;
  635. background: #ff9900;
  636. border: 1px solid #ff9900;
  637. color: white;
  638. &.marginRight {
  639. margin-right: 16px;
  640. margin-left: 0px;
  641. }
  642. }
  643. .waitTime {
  644. width: 116px;
  645. height: 40px;
  646. margin-left: 16px;
  647. border-radius: 4px;
  648. cursor: pointer;
  649. box-sizing: border-box;
  650. background: #f0f0f0;
  651. color: black;
  652. border: none;
  653. }
  654. .rightimg {
  655. width: 24px;
  656. position: absolute;
  657. right: 10px;
  658. top: 10px;
  659. cursor: pointer;
  660. &.posLeft {
  661. right: auto;
  662. left: 10px;
  663. }
  664. }
  665. .psswordHint {
  666. width: 334px;
  667. margin: 0;
  668. padding: 0;
  669. font-size: 14px;
  670. color: #000000;
  671. opacity: 0.3;
  672. line-height: 20px;
  673. margin-top: 5px;
  674. }
  675. .textRed {
  676. width: 334px;
  677. margin: 0;
  678. padding: 0;
  679. font-size: 14px;
  680. color: red;
  681. opacity: 1;
  682. line-height: 20px;
  683. margin-top: 5px;
  684. }
  685. .sumit {
  686. width: 474px;
  687. text-align: right;
  688. button {
  689. width: 337px;
  690. height: 48px;
  691. background: #ff9900;
  692. border-radius: 4px;
  693. cursor: pointer;
  694. border: none;
  695. outline: none;
  696. color: white;
  697. img {
  698. vertical-align: middle;
  699. animation: rotated 1s linear infinite;
  700. }
  701. }
  702. }
  703. .agreementAndRemeberMeAndForgetparssword {
  704. width: 474px;
  705. display: flex;
  706. justify-content: flex-end;
  707. > div {
  708. margin: 20px 0;
  709. width: 334px;
  710. position: relative;
  711. }
  712. .agreement {
  713. span {
  714. color: #ff9900;
  715. }
  716. }
  717. }
  718. .remeberMeAndForgetparssword {
  719. p {
  720. margin: 0;
  721. color: #ff9900;
  722. cursor: pointer;
  723. text-align: right;
  724. }
  725. }
  726. .Noafter::after {
  727. content: "";
  728. }
  729. }
  730. @keyframes rotated {
  731. 0% {
  732. transform: rotateZ(0deg);
  733. }
  734. 100% {
  735. transform: rotateZ(360deg);
  736. }
  737. }
  738. }
  739. </style>
  740. <style lang="scss">
  741. .registration2 {
  742. .el-form-item__label {
  743. padding: 0;
  744. padding: 10px 0;
  745. line-height: 20px;
  746. }
  747. .agreement {
  748. .el-checkbox__label {
  749. padding: 0 10px;
  750. }
  751. }
  752. }
  753. </style>