loginphone.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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 + "/bind").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. inviterCode: this.inviteCode
  178. }
  179. // url = '/app/Login/registerCode'
  180. url = '/app/Login/registerAndLogin'
  181. }
  182. // #ifdef H5
  183. params.platform = 'H5'
  184. // #endif
  185. this.$Request
  186. .post(url, params)
  187. .then((res) => {
  188. if (res.code == 0) {
  189. this.$queue.setData("userId", res.user.userId);
  190. this.$queue.setData("token", res.token);
  191. this.$queue.setData("phone", res.user.phone);
  192. this.$queue.setData("userName", res.user.userName);
  193. this.$queue.setData("avatar", res.user.avatar);
  194. this.$queue.setData("invitationCode", res.user.invitationCode);
  195. this.$queue.setData("inviterCode", res.user.inviterCode);
  196. this.getIsVip();
  197. uni.hideLoading();
  198. this.$queue.setData("userType", res.user.userType);
  199. this.$queue.connectSocket()
  200. // 手机验证码&H5邀请
  201. if (this.type == 2 && this.scene == 1) {
  202. // 跳转至基本信息页面
  203. uni.redirectTo({
  204. url: `/package/jobIntention/basicInfo?scene=${this.scene}`
  205. });
  206. } else {
  207. //判断是否开启身份选择 是/否
  208. this.$Request.get("/app/common/type/339").then((rest) => {
  209. if (rest.code == 0) {
  210. if (rest.data.value == "是") {
  211. // 这里是跳转到选择职场身份的界面
  212. uni.reLaunch({
  213. url: "/pages/public/selectIdentity/selectIdentity",
  214. });
  215. } else {
  216. if (res.user.userType == 2) { //企业
  217. // 原有的。判断第一次根据userType ==null
  218. uni.reLaunch({
  219. url: "/pages/my/index",
  220. });
  221. // 这里判断一下看是否是第一次登录如果是就跳到引导页,如果不是就正常跳
  222. // let firstLogin = uni.getStorageSync("firstLogin") || false;
  223. // if (!firstLogin) {
  224. // uni.navigateTo({
  225. // url: "/pages/my/jobApplicant/guidePage",
  226. // });
  227. // } else {
  228. // uni.reLaunch({
  229. // url: "/pages/my/index",
  230. // });
  231. // }
  232. } else if (res.user.userType == 1) {
  233. uni.reLaunch({
  234. url: "/pages/my/index",
  235. });
  236. // 这里判断一下看是否是第一次登录如果是就跳到引导页,如果不是就正常跳
  237. // let firstLogin = uni.getStorageSync("firstLogin") || false;
  238. // if (!firstLogin) {
  239. // uni.navigateTo({
  240. // url: "/pages/my/jobApplicant/guidePage",
  241. // });
  242. // } else {
  243. // uni.reLaunch({
  244. // url: "/pages/my/index",
  245. // });
  246. // }
  247. } else {
  248. uni.navigateTo({
  249. url: "/package/jobIntention/basicInfo",
  250. });
  251. }
  252. }
  253. } else {
  254. if (res.user.userType == 2) { //企业
  255. // 原有的。判断第一次根据userType ==null
  256. uni.reLaunch({
  257. url: "/pages/my/index",
  258. });
  259. } else if (res.user.userType == 1) {
  260. uni.reLaunch({
  261. url: "/pages/my/index",
  262. });
  263. } else {
  264. //表示是第一次进来,走引导页
  265. uni.navigateTo({
  266. url: "/pages/my/jobApplicant/guidePage",
  267. });
  268. }
  269. }
  270. });
  271. // uni.switchTab({
  272. // url: '/pages/my/index'
  273. // })
  274. }
  275. } else {
  276. uni.hideLoading();
  277. this.$queue.showToast(res.msg);
  278. }
  279. }).catch((err) => {
  280. uni.hideLoading();
  281. console.log('错误信息',err)
  282. console.error("微信登录接口异常:", err);
  283. });
  284. }
  285. },
  286. getIsVip() {
  287. this.$Request.get("/app/UserVip/isUserVip").then((res) => {
  288. if (res.code == 0) {
  289. // this.isVip = res.data
  290. console.log(res.data);
  291. this.$queue.setData("isVip", res.data);
  292. }
  293. });
  294. },
  295. },
  296. };
  297. </script>
  298. <style lang="scss" scoped>
  299. ::v-deep .input-placeholder {
  300. color: #9ea1a8;
  301. font-family: DM Sans;
  302. font-size: 28rpx;
  303. font-weight: 400;
  304. text-align: left;
  305. }
  306. page {
  307. height: 100%;
  308. background: #fff;
  309. }
  310. .send-msg {
  311. color: rgba(1, 107, 246, 1);
  312. font-size: 28rpx;
  313. font-weight: 400;
  314. }
  315. .forgot-password {
  316. text-align: left;
  317. margin-top: 8rpx;
  318. color: rgba(102, 112, 133, 1);
  319. font-family: Inter;
  320. font-size: 24rpx;
  321. font-weight: 400;
  322. line-height: 40rpx;
  323. }
  324. .item-label {
  325. color: rgba(18, 26, 44, 1);
  326. font-family: Roboto;
  327. font-size: 32rpx;
  328. font-weight: 400;
  329. line-height: 51.2rpx;
  330. letter-spacing: 0px;
  331. text-align: left;
  332. padding-bottom: 8rpx;
  333. margin-top: 32rpx;
  334. }
  335. .cu-form-group {
  336. position: relative;
  337. box-sizing: border-box;
  338. border: 2rpx solid rgba(158, 161, 168, 1);
  339. border-radius: 24rpx;
  340. background: rgba(255, 255, 255, 1);
  341. padding: 8rpx 24rpx !important;
  342. height: 96rpx;
  343. }
  344. .eye {
  345. position: absolute;
  346. top: 50%;
  347. right: 24rpx;
  348. font-size: 48rpx;
  349. transform: translateY(-50%);
  350. }
  351. .eye-active {
  352. color: #016bf6;
  353. }
  354. .bg {
  355. background-color: #ffffff;
  356. }
  357. // .send-msg {
  358. // border-radius: 30px;
  359. // color: black;
  360. // background: white;
  361. // height: 30px;
  362. // font-size: 14px;
  363. // line-height: 30px;
  364. // }
  365. .container {
  366. top: 0;
  367. padding-top: 32upx;
  368. position: relative;
  369. width: 100%;
  370. height: 100%;
  371. overflow: hidden;
  372. background: #ffffff !important;
  373. }
  374. .wrapper {
  375. position: relative;
  376. z-index: 90;
  377. background: #ffffff;
  378. padding-bottom: 32upx;
  379. }
  380. .input-content {
  381. padding: 32rpx;
  382. box-sizing: border-box;
  383. }
  384. .confirm-btn {
  385. border-radius: 60rpx;
  386. margin-top: 32rpx;
  387. background: #016bf6;
  388. color: rgba(255, 255, 255, 1);
  389. font-family: DM Sans;
  390. font-size: 32rpx;
  391. font-weight: 400;
  392. &:after {
  393. border-radius: 60px;
  394. }
  395. }
  396. .register-section {
  397. display: flex;
  398. justify-content: center;
  399. align-items: center;
  400. color: #016bf6;
  401. font-family: Inter;
  402. font-size: 12px;
  403. font-weight: 400;
  404. line-height: 20px;
  405. letter-spacing: 0%;
  406. text-align: right;
  407. text-decoration-line: underline;
  408. }
  409. .input-box{
  410. width: 100%;
  411. }
  412. </style>