login.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import PhonePopup from '../../components/phone-popup/phone-popup.vue';
  2. import { ref } from 'vue';
  3. export default {
  4. components: {
  5. PhonePopup
  6. },
  7. setup() {
  8. const isAgree = ref(false);
  9. const showPhonePopup = ref(false);
  10. const showAgreementModal = ref(false);
  11. const onAgreeChange = (e) => {
  12. isAgree.value = e.detail.value.length > 0;
  13. };
  14. const closeAgreementModal = () => {
  15. showAgreementModal.value = false;
  16. };
  17. const confirmAgreement = () => {
  18. isAgree.value = true;
  19. showAgreementModal.value = false;
  20. // Proceed to login
  21. handleLogin();
  22. };
  23. const handleLogin = () => {
  24. if (!isAgree.value) {
  25. showAgreementModal.value = true;
  26. return;
  27. }
  28. // Show customized bottom popup as designed in Image 2
  29. showPhonePopup.value = true;
  30. };
  31. const onAllowLogin = () => {
  32. showPhonePopup.value = false;
  33. uni.showToast({
  34. title: '登录成功',
  35. icon: 'success'
  36. });
  37. setTimeout(() => {
  38. // Go to next page as flow
  39. uni.navigateTo({
  40. url: '/pages/profile/profile'
  41. });
  42. }, 1000);
  43. };
  44. return {
  45. isAgree,
  46. showPhonePopup,
  47. showAgreementModal,
  48. closeAgreementModal,
  49. confirmAgreement,
  50. onAgreeChange,
  51. handleLogin,
  52. onAllowLogin
  53. };
  54. }
  55. }