loginphone.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <view class="container">
  3. <view class="wrapper">
  4. <nav-bar title="注册登录" color="#000"></nav-bar>
  5. <!-- <view style="text-align: center;">
  6. <image src="../../static/logo.png" style="border-radius: 64upx;"></image>
  7. </view>
  8. -->
  9. <view class="input-content">
  10. <view class="item-label">手机号码</view>
  11. <view class="cu-form-group">
  12. <view class="input-box">
  13. <input type="number" :value="phone" placeholder="请输入登录的手机号码" maxlength="11" data-key="phone"
  14. @input="inputChange" />
  15. </view>
  16. </view>
  17. <view class="item-label">{{type == 1?'登录密码':'验证码'}}</view>
  18. <view class="cu-form-group" v-if="type == 1">
  19. <input placeholder="请输入密码" maxlength="20" :value="password" :password="showPassword"
  20. data-key="password" @input="inputChange" @confirm="toLogin" />
  21. <u-icon @click="changePassword" class="eye" :class="{ 'eye-active': !showPassword }"
  22. name="eye-fill"></u-icon>
  23. </view>
  24. <view class="cu-form-group" v-if="type == 2">
  25. <input type="number" :value="code" placeholder="请输入验证码" maxlength="6" data-key="code"
  26. @input="inputChange" @confirm="toLogin" />
  27. <text class="send-msg" @click="sendMsg" :disabled="sending">
  28. {{ sendTime }}
  29. </text>
  30. </view>
  31. <view class="forgot-password" v-if="type ==1">
  32. <view @click="forget">忘记密码</view>
  33. </view>
  34. <button class="confirm-btn" @click="toLogin">下一步</button>
  35. <!-- view style="margin-top: 32rpx; text-align: center">
  36. <view>
  37. <text class="register-section" @click="register()">注册</text>
  38. </view>
  39. </view> -->
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import navBar from "@/components/nav-bar/index.vue";
  46. export default {
  47. data() {
  48. return {
  49. code: "",
  50. phone: "",
  51. password: "",
  52. showPassword: true,
  53. banners: [],
  54. invitation: "",
  55. loginName: "",
  56. sending: false,
  57. sendTime: "获取验证码",
  58. count: 60,
  59. type: 0,
  60. scene: 0, // 0 默认,1 H5邀请
  61. inviteCode: '', // 邀请码
  62. };
  63. },
  64. components: {
  65. navBar,
  66. },
  67. onLoad(options) {
  68. console.log(options);
  69. this.type = options.type;
  70. if (options.scene) {
  71. this.scene = options.scene
  72. }
  73. if (options.inviteCode) {
  74. this.inviteCode = options.inviteCode
  75. }
  76. },
  77. methods: {
  78. forget() {
  79. uni.navigateTo({
  80. url: "/pages/public/forgetPwd",
  81. });
  82. },
  83. // register() {
  84. // uni.navigateTo({
  85. // url: "/pages/public/register",
  86. // });
  87. // },
  88. inputChange(e) {
  89. const key = e.currentTarget.dataset.key;
  90. this[key] = e.detail.value;
  91. },
  92. navBack() {
  93. uni.navigateBack();
  94. },
  95. changePassword() {
  96. this.showPassword = !this.showPassword;
  97. },
  98. sendMsg() {
  99. const {
  100. phone
  101. } = this;
  102. if (!phone) {
  103. this.$queue.showToast("请输入手机号");
  104. } else if (phone.length !== 11) {
  105. this.$queue.showToast("请输入正确的手机号");
  106. } else if(this.sendTime != '获取验证码'){
  107. return;
  108. }else {
  109. this.$queue.showLoading("正在发送验证码...");
  110. this.$Request.getT("/app/Login/sendMsg/" + phone + "/forget").then((res) => {
  111. if (res.code === 0) {
  112. this.sending = true;
  113. this.$queue.showToast("验证码发送成功请注意查收");
  114. this.countDown();
  115. uni.hideLoading();
  116. } else {
  117. uni.hideLoading();
  118. uni.showModal({
  119. showCancel: false,
  120. title: "短信发送失败",
  121. content: res.msg ? res.msg : "请一分钟后再获取验证码",
  122. });
  123. }
  124. });
  125. }
  126. },
  127. countDown() {
  128. const { count } = this;
  129. if (count === 1) {
  130. this.count = 60;
  131. this.sending = false;
  132. this.sendTime = "获取验证码";
  133. } else {
  134. this.count = count - 1;
  135. this.sending = true;
  136. this.sendTime = count - 1 + "秒后重新获取";
  137. setTimeout(this.countDown.bind(this), 1000);
  138. }
  139. },
  140. toLogin() {
  141. this.$queue.loginClear();
  142. const {
  143. phone,
  144. password,
  145. code
  146. } = this;
  147. if (!password && this.type == 1) {
  148. this.$queue.showToast("请输入密码");
  149. return;
  150. }
  151. if (!code && this.type == 2) {
  152. this.$queue.showToast("请输入验证码");
  153. return;
  154. }
  155. if (!phone) {
  156. this.$queue.showToast("请输入手机号");
  157. } else if (phone.length != 11) {
  158. this.$queue.showToast("请输入正确的手机号");
  159. } else {
  160. this.$queue.showLoading("正在登录中...");
  161. let params = {
  162. phone: phone,
  163. wxOpenId: this.$queue.getData("openId") || '',
  164. }
  165. let url = ''
  166. if (this.type == 1) {
  167. params = {
  168. ...params,
  169. password: password,
  170. }
  171. url = '/app/Login/loginApp'
  172. }
  173. if (this.type == 2) {
  174. params = {
  175. ...params,
  176. msg: code,
  177. inviteCode: this.inviteCode
  178. }
  179. // url = '/app/Login/registerCode'
  180. url = '/app/Login/registerAndLogin'
  181. }
  182. this.$Request
  183. .post(url, params)
  184. .then((res) => {
  185. if (res.code == 0) {
  186. this.$queue.setData("userId", res.user.userId);
  187. this.$queue.setData("token", res.token);
  188. this.$queue.setData("phone", res.user.phone);
  189. this.$queue.setData("userName", res.user.userName);
  190. this.$queue.setData("avatar", res.user.avatar);
  191. this.$queue.setData("invitationCode", res.user.invitationCode);
  192. this.$queue.setData("inviterCode", res.user.inviterCode);
  193. this.getIsVip();
  194. uni.hideLoading();
  195. this.$queue.setData("userType", res.user.userType);
  196. this.$queue.connectSocket()
  197. // 手机验证码&H5邀请
  198. if (this.type == 2 && this.scene == 1) {
  199. // 跳转至基本信息页面
  200. uni.redirectTo({
  201. url: `/package/jobIntention/basicInfo?scene=${this.scene}`
  202. });
  203. } else {
  204. //判断是否开启身份选择 是/否
  205. this.$Request.get("/app/common/type/339").then((rest) => {
  206. if (rest.code == 0) {
  207. if (rest.data.value == "是") {
  208. // 这里是跳转到选择职场身份的界面
  209. uni.reLaunch({
  210. url: "/pages/public/selectIdentity/selectIdentity",
  211. });
  212. } else {
  213. if (res.user.userType == 2) { //企业
  214. // 原有的。判断第一次根据userType ==null
  215. uni.reLaunch({
  216. url: "/pages/my/index",
  217. });
  218. // 这里判断一下看是否是第一次登录如果是就跳到引导页,如果不是就正常跳
  219. // let firstLogin = uni.getStorageSync("firstLogin") || false;
  220. // if (!firstLogin) {
  221. // uni.navigateTo({
  222. // url: "/pages/my/jobApplicant/guidePage",
  223. // });
  224. // } else {
  225. // uni.reLaunch({
  226. // url: "/pages/my/index",
  227. // });
  228. // }
  229. } else if (res.user.userType == 1) {
  230. uni.reLaunch({
  231. url: "/pages/my/index",
  232. });
  233. // 这里判断一下看是否是第一次登录如果是就跳到引导页,如果不是就正常跳
  234. // let firstLogin = uni.getStorageSync("firstLogin") || false;
  235. // if (!firstLogin) {
  236. // uni.navigateTo({
  237. // url: "/pages/my/jobApplicant/guidePage",
  238. // });
  239. // } else {
  240. // uni.reLaunch({
  241. // url: "/pages/my/index",
  242. // });
  243. // }
  244. } else {
  245. //表示是第一次进来,走引导页
  246. uni.navigateTo({
  247. url: "/pages/my/jobApplicant/guidePage",
  248. });
  249. }
  250. }
  251. } else {
  252. if (res.user.userType == 2) { //企业
  253. // 原有的。判断第一次根据userType ==null
  254. uni.reLaunch({
  255. url: "/pages/my/index",
  256. });
  257. } else if (res.user.userType == 1) {
  258. uni.reLaunch({
  259. url: "/pages/my/index",
  260. });
  261. } else {
  262. //表示是第一次进来,走引导页
  263. uni.navigateTo({
  264. url: "/pages/my/jobApplicant/guidePage",
  265. });
  266. }
  267. }
  268. });
  269. // uni.switchTab({
  270. // url: '/pages/my/index'
  271. // })
  272. }
  273. } else {
  274. uni.hideLoading();
  275. this.$queue.showToast(res.msg);
  276. }
  277. }).catch((err) => {
  278. uni.hideLoading();
  279. console.log('错误信息',err)
  280. console.error("微信登录接口异常:", err);
  281. });
  282. }
  283. },
  284. getIsVip() {
  285. this.$Request.get("/app/UserVip/isUserVip").then((res) => {
  286. if (res.code == 0) {
  287. // this.isVip = res.data
  288. console.log(res.data);
  289. this.$queue.setData("isVip", res.data);
  290. }
  291. });
  292. },
  293. },
  294. };
  295. </script>
  296. <style lang="scss" scoped>
  297. ::v-deep .input-placeholder {
  298. color: #9ea1a8;
  299. font-family: DM Sans;
  300. font-size: 28rpx;
  301. font-weight: 400;
  302. text-align: left;
  303. }
  304. page {
  305. height: 100%;
  306. background: #fff;
  307. }
  308. .send-msg {
  309. color: rgba(1, 107, 246, 1);
  310. font-size: 28rpx;
  311. font-weight: 400;
  312. }
  313. .forgot-password {
  314. text-align: left;
  315. margin-top: 8rpx;
  316. color: rgba(102, 112, 133, 1);
  317. font-family: Inter;
  318. font-size: 24rpx;
  319. font-weight: 400;
  320. line-height: 40rpx;
  321. }
  322. .item-label {
  323. color: rgba(18, 26, 44, 1);
  324. font-family: Roboto;
  325. font-size: 32rpx;
  326. font-weight: 400;
  327. line-height: 51.2rpx;
  328. letter-spacing: 0px;
  329. text-align: left;
  330. padding-bottom: 8rpx;
  331. margin-top: 32rpx;
  332. }
  333. .cu-form-group {
  334. position: relative;
  335. box-sizing: border-box;
  336. border: 2rpx solid rgba(158, 161, 168, 1);
  337. border-radius: 24rpx;
  338. background: rgba(255, 255, 255, 1);
  339. padding: 8rpx 24rpx !important;
  340. height: 96rpx;
  341. }
  342. .eye {
  343. position: absolute;
  344. top: 50%;
  345. right: 24rpx;
  346. font-size: 48rpx;
  347. transform: translateY(-50%);
  348. }
  349. .eye-active {
  350. color: #016bf6;
  351. }
  352. .bg {
  353. background-color: #ffffff;
  354. }
  355. // .send-msg {
  356. // border-radius: 30px;
  357. // color: black;
  358. // background: white;
  359. // height: 30px;
  360. // font-size: 14px;
  361. // line-height: 30px;
  362. // }
  363. .container {
  364. top: 0;
  365. padding-top: 32upx;
  366. position: relative;
  367. width: 100%;
  368. height: 100%;
  369. overflow: hidden;
  370. background: #ffffff !important;
  371. }
  372. .wrapper {
  373. position: relative;
  374. z-index: 90;
  375. background: #ffffff;
  376. padding-bottom: 32upx;
  377. }
  378. .input-content {
  379. padding: 32rpx;
  380. box-sizing: border-box;
  381. }
  382. .confirm-btn {
  383. border-radius: 60rpx;
  384. margin-top: 32rpx;
  385. background: #016bf6;
  386. color: rgba(255, 255, 255, 1);
  387. font-family: DM Sans;
  388. font-size: 32rpx;
  389. font-weight: 400;
  390. &:after {
  391. border-radius: 60px;
  392. }
  393. }
  394. .register-section {
  395. display: flex;
  396. justify-content: center;
  397. align-items: center;
  398. color: #016bf6;
  399. font-family: Inter;
  400. font-size: 12px;
  401. font-weight: 400;
  402. line-height: 20px;
  403. letter-spacing: 0%;
  404. text-align: right;
  405. text-decoration-line: underline;
  406. }
  407. .input-box{
  408. width: 100%;
  409. }
  410. </style>