register.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. <template>
  2. <view class="container">
  3. <nav-bar :title="steps == 0?'注册1/2':'创建账号密码2/2'" color="#000"></nav-bar>
  4. <view class="line-box">
  5. <view class="line line-bg" @click="steps = 0"></view>
  6. <view class="line" :class="[ steps == 1?'line-bg':'' ]" @click="steps = 1"></view>
  7. </view>
  8. <view class="wrapper">
  9. <view class="input-content">
  10. <!-- <view class="item-label">用户名</view>
  11. <view class="cu-form-group">
  12. <input
  13. :value="userName"
  14. placeholder="请输入用户名"
  15. data-key="userName"
  16. @input="inputChange"
  17. />
  18. </view> -->
  19. <view class="item-label" v-show="steps == 0">手机号码</view>
  20. <view class="cu-form-group" v-show="steps == 0">
  21. <input
  22. type="number"
  23. :value="phone"
  24. placeholder="请输入登录的手机号码"
  25. maxlength="11"
  26. data-key="phone"
  27. @input="inputChange"
  28. />
  29. </view>
  30. <view class="item-label" v-show="steps == 0">验证码</view>
  31. <view class="cu-form-group padding-right-xs" v-show="steps == 0">
  32. <input
  33. type="number"
  34. :value="code"
  35. placeholder="请输入验证码"
  36. maxlength="6"
  37. data-key="code"
  38. @input="inputChange"
  39. @confirm="toLogin"
  40. />
  41. <text class="send-msg" @click="sendMsg" :disabled="sending">
  42. {{ sendTime }}
  43. </text>
  44. </view>
  45. <view class="item-label" v-show="steps == 1">密码</view>
  46. <view class="cu-form-group" v-show="steps == 1">
  47. <input
  48. :value="password"
  49. :password="showPassword"
  50. placeholder="输入密码"
  51. placeholder-class="input-empty"
  52. maxlength="20"
  53. minlength="8"
  54. data-key="password"
  55. @input="inputChange"
  56. @confirm="toLogin"
  57. />
  58. <u-icon @click="changePassword" class="eye" :class="{ 'eye-active': !showPassword }" name="eye-fill"></u-icon>
  59. </view>
  60. <view v-show="steps == 1">
  61. <u-line-progress class="line-progress" :show-percent="false" :active-color="progressColor" :percent="passwordStrength * 33.3"></u-line-progress>
  62. <view class="password-rules">
  63. <view class="rule-item" v-for="(item, index) in list" :key="index" :class="{ 'rule-valid': item.checked }">
  64. <image
  65. src="@/static/images/jobApplicant/check.svg"
  66. v-if="item.checked"
  67. mode="scaleToFill"
  68. />
  69. <image
  70. src="@/static/images/jobApplicant/border.svg"
  71. v-else
  72. mode="scaleToFill"
  73. />
  74. <text class="rule-text">{{item.label}}</text>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- <view class="cu-form-group" style="margin-top: 32rpx" v-if="required == '是'">
  79. <view class="item-label-code">邀请码</view>
  80. <input
  81. type=""
  82. maxlength="6"
  83. :value="invitation"
  84. placeholder="请填写邀请码(必填)"
  85. data-key="invitation"
  86. @input="inputChange"
  87. @confirm="toLogin"
  88. />
  89. </view> -->
  90. <!-- <view class="cu-form-group" style="margin-top: 32rpx" v-if="required == '否'">
  91. <view class="item-label-code">邀请码</view>
  92. <input
  93. type=""
  94. maxlength="6"
  95. :value="invitation"
  96. placeholder="请填写邀请码(选填)"
  97. data-key="invitation"
  98. @input="inputChange"
  99. @confirm="toLogin"
  100. />
  101. </view> -->
  102. </view>
  103. <button class="confirm-btn" @click="nextStep" v-if="steps == 0">下一步</button>
  104. <button class="confirm-btn" @click="toLogin" v-if="steps == 1">继续</button>
  105. <!-- <view class="footer">
  106. <text
  107. @tap="isShowAgree"
  108. class="cuIcon"
  109. :class="showAgree ? 'cuIcon-radiobox' : 'cuIcon-round'"
  110. >同意</text
  111. >
  112. <navigator url="/my/setting/mimi" open-type="navigate">《隐私政策》</navigator>
  113. <navigator url="/my/setting/xieyi" open-type="navigate"
  114. >《用户服务协议》</navigator
  115. >
  116. </view> -->
  117. </view>
  118. </view>
  119. </template>
  120. <script>
  121. import navBar from "@/components/nav-bar/index.vue";
  122. export default {
  123. data() {
  124. return {
  125. userName: "",
  126. showAgree: false,
  127. code: "",
  128. phone: "",
  129. password: "",
  130. showPassword:true,
  131. required: "否",
  132. sending: false,
  133. sendTime: "获取验证码",
  134. count: 60,
  135. relation: "",
  136. state: "",
  137. invitation: "",
  138. platform: "",
  139. steps:0,
  140. passwordStrength: 0, // 当前满足的条件数
  141. list: [
  142. { name: 'length', label: '最少8位数',checked: false, },
  143. { name: 'number', label: '至少包含1个数字',checked: false, },
  144. { name: 'upper', label: '至少包含一个大写字母',checked: false, }
  145. ],
  146. valueBackup: [],
  147. };
  148. },
  149. components: {
  150. navBar,
  151. },
  152. onLoad() {
  153. // this.invitation = this.$queue.getData('inviterCode') ? this.$queue.getData('inviterCode') : '';
  154. this.invitation = this.$queue.getData("invitation")
  155. ? this.$queue.getData("invitation")
  156. : "";
  157. // #ifdef APP-PLUS
  158. this.platform = "app";
  159. //#endif
  160. //#ifdef H5
  161. this.platform = "H5";
  162. // #endif
  163. },
  164. computed: {
  165. progressColor() {
  166. switch (this.passwordStrength) {
  167. case 1:
  168. return 'rgba(214, 44, 1, 1)';
  169. case 2:
  170. return 'rgba(250, 174, 22, 1)';
  171. case 3:
  172. return 'rgba(1, 107, 246, 1)';
  173. default:
  174. return 'rgba(237, 236, 239, 1)';
  175. }
  176. },
  177. },
  178. methods: {
  179. showMa() {
  180. //查询官方邀请码
  181. this.$Request.getT("/app/common/type/4").then((res) => {
  182. if (res.code == 0) {
  183. this.invitationCode = res.data.value;
  184. }
  185. });
  186. },
  187. // 注册邀请码必填
  188. invitationMa() {
  189. this.$Request.getT("/app/common/type/3").then((res) => {
  190. if (res.code == 0) {
  191. this.required = res.data.value;
  192. }
  193. });
  194. },
  195. // 获取新用户优惠券数量
  196. newMa() {
  197. this.$Request.getT("/app/common/type/119").then((res) => {
  198. if (res.code == 0) {
  199. this.amount = res.data.value;
  200. }
  201. });
  202. },
  203. isShowAgree() {
  204. //是否选择协议
  205. this.showAgree = !this.showAgree;
  206. },
  207. sendMsg() {
  208. const { phone } = this;
  209. if (!phone) {
  210. this.$queue.showToast("请输入手机号");
  211. } else if (phone.length !== 11) {
  212. this.$queue.showToast("请输入正确的手机号");
  213. } else if(this.sendTime != '获取验证码'){
  214. return;
  215. }else {
  216. this.$queue.showLoading("正在发送验证码...");
  217. this.$Request.getT("/app/Login/sendMsg/" + phone + "/1").then((res) => {
  218. if (res.code === 0) {
  219. this.sending = true;
  220. this.$queue.showToast("验证码发送成功请注意查收");
  221. this.countDown();
  222. uni.hideLoading();
  223. } else {
  224. uni.hideLoading();
  225. uni.showModal({
  226. showCancel: false,
  227. title: "短信发送失败",
  228. content: res.msg ? res.msg : "请一分钟后再获取验证码",
  229. });
  230. }
  231. });
  232. }
  233. },
  234. countDown() {
  235. const { count } = this;
  236. if (count === 1) {
  237. this.count = 60;
  238. this.sending = false;
  239. this.sendTime = "获取验证码";
  240. } else {
  241. this.count = count - 1;
  242. this.sending = true;
  243. this.sendTime = count - 1 + "秒后重新获取";
  244. setTimeout(this.countDown.bind(this), 1000);
  245. }
  246. },
  247. inputChange(e) {
  248. const key = e.currentTarget.dataset.key;
  249. this[key] = e.detail.value;
  250. if(key == 'password'){
  251. this.checkPasswordStrength(this.password);
  252. }
  253. },
  254. checkPasswordStrength(pwd) {
  255. let strength = 0;
  256. this.list.forEach(item => {
  257. if (item.name === 'length') {
  258. item.checked = pwd.length >= 8;
  259. if (item.checked) strength++;
  260. } else if (item.name === 'number') {
  261. item.checked = /[0-9]/.test(pwd);
  262. if (item.checked) strength++;
  263. } else if (item.name === 'upper') {
  264. item.checked = /[A-Z]/.test(pwd);
  265. if (item.checked) strength++;
  266. }
  267. });
  268. this.passwordStrength = strength;
  269. this.valueBackup = this.list.map(i => i.checked);
  270. },
  271. navBack() {
  272. uni.navigateBack();
  273. },
  274. navTo(url) {
  275. uni.navigateTo({
  276. url,
  277. });
  278. },
  279. // 下一步
  280. nextStep(){
  281. const { phone,code } = this;
  282. if (!phone) {
  283. this.$queue.showToast("请输入手机号");
  284. } else if (!code) {
  285. this.$queue.showToast("请输入验证码");
  286. }else{
  287. this.steps = 1;
  288. }
  289. },
  290. changePassword(){
  291. this.showPassword = !this.showPassword;
  292. },
  293. // 注册
  294. toLogin() {
  295. const { userName, phone, password, code, showAgree, invitation } = this;
  296. if (!phone) {
  297. this.$queue.showToast("请输入手机号");
  298. } else if (!code) {
  299. this.$queue.showToast("请输入验证码");
  300. } else if (!password) {
  301. this.$queue.showToast("请设置密码");
  302. } else if (password.length < 8) {
  303. this.$queue.showToast("密码位数必须大于八位");
  304. } else if (!/(?=.*[A-Z])(?=.*\d)/.test(password)) {
  305. this.$queue.showToast("密码必须包含至少一个大写字母和一个数字");
  306. }else {
  307. // this.invitation = "";
  308. this.logining = true;
  309. this.$queue.showLoading("注册中...");
  310. this.$Request
  311. .post(`/app/Login/registApp`, {
  312. userName: phone,
  313. password: password,
  314. phone: phone,
  315. wxOpenId: this.$queue.getData("openId") ? this.$queue.getData("openId") : "",
  316. // invitation: this.invitation,
  317. platform: this.platform,
  318. msg: code,
  319. })
  320. .then((res) => {
  321. if (res.code === 0) {
  322. return this.dealUserData(res)
  323. this.$queue.showToast("注册成功");
  324. this.$queue.setData("token", res.token);
  325. this.$queue.setData("userId", res.user.userId);
  326. this.$queue.setData("userName", res.user.userName);
  327. this.$queue.setData("phone", res.user.phone);
  328. this.$queue.setData(
  329. "avatar",
  330. res.user.avatar ? res.user.avatar : "../../static/logo.png"
  331. );
  332. this.getUserInfo();
  333. // setTimeout(function () {
  334. // // 这里判断一下看是否是第一次登录如果是就跳到引导页,如果不是就正常跳
  335. // // let firstLogin = uni.getStorageSync("firstLogin") || false;
  336. // console.log("userType:",res.user.userType)
  337. // if (!res.user.userType) {
  338. // uni.navigateTo({
  339. // url: "/pages/my/jobApplicant/guidePage",
  340. // });
  341. // } else {
  342. // uni.switchTab({
  343. // url: "/pages/index/index",
  344. // });
  345. // }
  346. // }, 1000);
  347. } else {
  348. uni.hideLoading();
  349. uni.showModal({
  350. showCancel: false,
  351. title: "注册失败",
  352. content: res.msg,
  353. });
  354. }
  355. });
  356. }
  357. // else {
  358. // this.logining = true;
  359. // this.$queue.showLoading("注册中...");
  360. // this.$Request
  361. // .post(`/app/Login/registApp?msg=${code}`, {
  362. // userName: userName,
  363. // password: password,
  364. // phone: phone,
  365. // openId: this.$queue.getData("openId") ? this.$queue.getData("openId") : "",
  366. // invitation: this.invitation,
  367. // platform: this.platform,
  368. // })
  369. // .then((res) => {
  370. // if (res.code === 0) {
  371. // this.$queue.setData("token", res.token);
  372. // this.$queue.setData("userId", res.user.userId);
  373. // this.$queue.setData("userName", res.user.userName);
  374. // this.$queue.setData("phone", res.user.phone);
  375. // this.$queue.setData(
  376. // "avatar",
  377. // res.user.avatar ? res.user.avatar : "../../static/logo.png"
  378. // );
  379. // this.$queue.setData("invitationCode", res.user.invitationCode);
  380. // this.$queue.setData("inviterCode", res.user.inviterCode);
  381. // this.getUserInfo();
  382. // setTimeout(function () {
  383. // uni.switchTab({
  384. // url: "/pages/index/index",
  385. // });
  386. // }, 1000);
  387. // } else {
  388. // uni.showModal({
  389. // showCancel: false,
  390. // title: "注册失败",
  391. // content: res.msg,
  392. // });
  393. // }
  394. // uni.hideLoading();
  395. // });
  396. // }
  397. },
  398. //获取用户信息
  399. getUserInfo() {
  400. this.$Request.get("/app/user/selectUserById").then((res) => {
  401. if (res.code == 0) {
  402. uni.hideLoading();
  403. this.$queue.setData(
  404. "avatar",
  405. res.data.avatar ? res.data.avatar : "../../static/logo.png"
  406. );
  407. this.$queue.setData("userId", res.data.userId);
  408. this.$queue.setData("userName", res.data.userName);
  409. this.$queue.setData("phone", res.data.phone);
  410. this.$queue.setData("invitationCode", res.data.invitationCode);
  411. this.$queue.setData("inviterCode", res.data.inviterCode);
  412. this.userName = res.data.userName;
  413. this.invitationCode = res.data.invitationCode;
  414. uni.setStorageSync("invitationCode", res.data.invitationCode);
  415. /* setTimeout(function () {
  416. uni.reLaunch({
  417. url: "/pages/my/jobApplicant/registerSuccess",//pages/my/jobApplicant/registerSuccess
  418. });
  419. }, 1000); */
  420. return
  421. } else {
  422. uni.showModal({
  423. showCancel: false,
  424. title: "登录失败",
  425. content: res.msg,
  426. });
  427. this.$queue.logout();
  428. }
  429. });
  430. },
  431. dealUserData(res){
  432. this.$queue.setData("userId", res.user.userId);
  433. this.$queue.setData("token", res.token);
  434. this.$queue.setData("phone", res.user.phone);
  435. this.$queue.setData("userName", res.user.userName);
  436. this.$queue.setData("avatar", res.user.avatar);
  437. if(res.user.invitationCode)
  438. this.$queue.setData("invitationCode", res.user.invitationCode);
  439. if(res.user.inviterCode)
  440. this.$queue.setData("inviterCode", res.user.inviterCode);
  441. this.$queue.setData("isVip", false);
  442. uni.hideLoading();
  443. if(res.user.userType)
  444. this.$queue.setData("userType", res.user.userType);
  445. this.$queue.connectSocket()
  446. //判断是否开启身份选择 是/否
  447. this.$Request.get("/app/common/type/339").then((rest) => {
  448. if (rest.code == 0) {
  449. if (rest.data.value == "是") {
  450. // 这里是跳转到选择职场身份的界面
  451. uni.reLaunch({
  452. url: "/pages/public/selectIdentity/selectIdentity",
  453. });
  454. } else {
  455. if (res.user.userType == 2) { //企业
  456. // 原有的。判断第一次根据userType ==null
  457. uni.reLaunch({
  458. url: "/pages/my/index",
  459. });
  460. // 这里判断一下看是否是第一次登录如果是就跳到引导页,如果不是就正常跳
  461. // let firstLogin = uni.getStorageSync("firstLogin") || false;
  462. // if (!firstLogin) {
  463. // uni.navigateTo({
  464. // url: "/pages/my/jobApplicant/guidePage",
  465. // });
  466. // } else {
  467. // uni.reLaunch({
  468. // url: "/pages/my/index",
  469. // });
  470. // }
  471. } else if (res.user.userType == 1) {
  472. uni.reLaunch({
  473. url: "/pages/my/index",
  474. });
  475. // 这里判断一下看是否是第一次登录如果是就跳到引导页,如果不是就正常跳
  476. // let firstLogin = uni.getStorageSync("firstLogin") || false;
  477. // if (!firstLogin) {
  478. // uni.navigateTo({
  479. // url: "/pages/my/jobApplicant/guidePage",
  480. // });
  481. // } else {
  482. // uni.reLaunch({
  483. // url: "/pages/my/index",
  484. // });
  485. // }
  486. } else {
  487. //表示是第一次进来,走引导页
  488. uni.navigateTo({
  489. url: "/pages/my/jobApplicant/guidePage",
  490. });
  491. }
  492. }
  493. } else {
  494. if (res.user.userType == 2) { //企业
  495. // 原有的。判断第一次根据userType ==null
  496. uni.reLaunch({
  497. url: "/pages/my/index",
  498. });
  499. } else if (res.user.userType == 1) {
  500. uni.reLaunch({
  501. url: "/pages/my/index",
  502. });
  503. } else {
  504. //表示是第一次进来,走引导页
  505. uni.navigateTo({
  506. url: "/pages/my/jobApplicant/guidePage",
  507. });
  508. }
  509. }
  510. });
  511. }
  512. },
  513. };
  514. </script>
  515. <style lang="scss" scoped>
  516. ::v-deep .input-placeholder,.uni-input-placeholder {
  517. color: #9ea1a8;
  518. font-family: DM Sans;
  519. font-size: 28rpx;
  520. font-weight: 400;
  521. text-align: left;
  522. }
  523. page {
  524. height: 100%;
  525. background: #ffffff !important;
  526. }
  527. .item-label {
  528. color: rgba(18, 26, 44, 1);
  529. font-family: Roboto;
  530. font-size: 32rpx;
  531. font-weight: 400;
  532. line-height: 51.2rpx;
  533. letter-spacing: 0px;
  534. text-align: left;
  535. padding-bottom: 8rpx;
  536. margin-top: 32rpx;
  537. }
  538. .cu-form-group {
  539. position: relative;
  540. box-sizing: border-box;
  541. border: 2rpx solid rgba(158, 161, 168, 1);
  542. border-radius: 24rpx;
  543. background: rgba(255, 255, 255, 1);
  544. padding: 8rpx 24rpx !important;
  545. height: 96rpx;
  546. }
  547. .eye{
  548. position: absolute;
  549. top: 50%;
  550. right: 24rpx;
  551. font-size: 48rpx;
  552. transform: translateY(-50%);
  553. }
  554. .eye-active{
  555. color: #016bf6;
  556. }
  557. .line-progress{
  558. margin: 32rpx 0;
  559. }
  560. .footer {
  561. padding-left: 140rpx;
  562. margin-top: 32rpx;
  563. text-align: center;
  564. display: flex;
  565. // color: #FFFFFF;
  566. }
  567. .send-msg {
  568. color: rgba(1, 107, 246, 1);
  569. font-size: 28rpx;
  570. font-weight: 400;
  571. }
  572. .container {
  573. padding-top: 32rpx;
  574. position: relative;
  575. width: 100%;
  576. height: 100%;
  577. overflow: hidden;
  578. background: #ffffff !important;
  579. }
  580. .line-box{
  581. display: flex;
  582. align-items: center;
  583. justify-content: center;
  584. gap: 10rpx;
  585. }
  586. .line{
  587. width: 20px;
  588. height: 4px;
  589. border-radius: 20px;
  590. background-color: rgba(153, 196, 250, 1);
  591. }
  592. .line-bg{
  593. background-color: #016BF6;
  594. }
  595. ::v-deep .u-checkbox__label{
  596. margin-left: 20rpx;
  597. color: rgba(76, 74, 83, 1);
  598. font-family: Roboto;
  599. font-size: 32rpx;
  600. font-weight: 400;
  601. }
  602. .wrapper {
  603. position: relative;
  604. z-index: 90;
  605. background: #ffffff;
  606. padding-bottom: 20px;
  607. }
  608. .input-content {
  609. padding: 32rpx;
  610. box-sizing: border-box;
  611. }
  612. .confirm-btn {
  613. margin: 0 32rpx;
  614. height: 80rpx;
  615. line-height: 80rpx;
  616. border-radius: 60rpx;
  617. background: #016bf6;
  618. color: #fff;
  619. font-size: 32rpx;
  620. font-weight: 400;
  621. &:after {
  622. border-radius: 60px;
  623. }
  624. }
  625. // 密码要求列表
  626. .rule-item {
  627. display: flex;
  628. align-items: center;
  629. margin-bottom: 8rpx;
  630. image{
  631. width: 32rpx;
  632. height: 32rpx;
  633. margin-right: 16rpx;
  634. }
  635. }
  636. .rule-text {
  637. color: #4c4a53;
  638. font-family: Roboto;
  639. font-size: 32rpx;
  640. font-weight: 400;
  641. line-height: 51.2rpx;
  642. text-align: left;
  643. }
  644. .rule-valid .rule-text {
  645. color: #4c4a53;
  646. }
  647. .input-box {
  648. position: relative;
  649. }
  650. .next-btn-active {
  651. background: #2979ff;
  652. }
  653. ::v-deep .u-input {
  654. text-align: left !important;
  655. }
  656. .progress-box {
  657. display: flex;
  658. justify-content: center;
  659. align-items: center;
  660. gap: 24rpx;
  661. padding-top: 40rpx;
  662. box-sizing: border-box;
  663. .progress-item {
  664. width: 40rpx;
  665. height: 8rpx;
  666. background-color: #016bf6;
  667. border-radius: 40rpx;
  668. }
  669. }
  670. </style>