loginphone.vue 9.7 KB

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