loginphone.vue 11 KB

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