loginphone.vue 10 KB

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