s-auth-modal.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <!-- 规格弹窗 -->
  3. <su-popup :show="authType !== ''" round="10" :showClose="true" @close="closeAuthModal">
  4. <view class="login-wrap">
  5. <!-- 1. 账号密码登录 accountLogin -->
  6. <account-login
  7. v-if="authType === 'accountLogin'"
  8. :agreeStatus="state.protocol"
  9. ></account-login>
  10. <!-- 2.短信登录 smsLogin -->
  11. <sms-login v-if="authType === 'smsLogin'" :agreeStatus="state.protocol"></sms-login>
  12. <!-- 3.短信注册 smsRegister-->
  13. <sms-register v-if="authType === 'smsRegister'" :agreeStatus="state.protocol"></sms-register>
  14. <!-- 4.忘记密码 resetPassword-->
  15. <reset-password v-if="authType === 'resetPassword'"></reset-password>
  16. <!-- 5.绑定手机号 changeMobile -->
  17. <change-mobile v-if="authType === 'changeMobile'"></change-mobile>
  18. <!-- 6.修改密码 changePassword-->
  19. <change-passwrod v-if="authType === 'changePassword'"></change-passwrod>
  20. <!-- 7.修改用户名 changeUsername-->
  21. <change-username v-if="authType === 'changeUsername'"></change-username>
  22. <!-- 第三方登录 -->
  23. <view
  24. v-if="['accountLogin', 'smsLogin'].includes(authType)"
  25. class="auto-login-box ss-flex ss-row-center ss-col-center"
  26. >
  27. <!-- 微信小程序登录 -->
  28. <button
  29. v-if="sheep.$platform.name === 'WechatMiniProgram'"
  30. open-type="getPhoneNumber"
  31. @getphonenumber="thirdLogin('wechat', $event)"
  32. class="ss-reset-button auto-login-btn"
  33. >
  34. <image
  35. class="auto-login-img"
  36. :src="sheep.$url.static('/static/img/shop/platform/wechat.png')"
  37. ></image>
  38. </button>
  39. <!-- 公众号|App微信登录 -->
  40. <button
  41. v-if="
  42. ['WechatOfficialAccount', 'App'].includes(sheep.$platform.name) &&
  43. sheep.$platform.isWechatInstalled
  44. "
  45. @tap="thirdLogin('wechat')"
  46. class="ss-reset-button auto-login-btn"
  47. >
  48. <image
  49. class="auto-login-img"
  50. :src="sheep.$url.static('/static/img/shop/platform/wechat.png')"
  51. ></image>
  52. </button>
  53. <!-- iOS登录 -->
  54. <button
  55. v-if="sheep.$platform.os === 'ios' && sheep.$platform.name === 'App'"
  56. @tap="thirdLogin('apple')"
  57. class="ss-reset-button auto-login-btn"
  58. >
  59. <image
  60. class="auto-login-img"
  61. :src="sheep.$url.static('/static/img/shop/platform/apple.png')"
  62. ></image>
  63. </button>
  64. </view>
  65. <view
  66. v-if="['accountLogin', 'smsLogin', 'smsRegister'].includes(authType)"
  67. class="agreement-box ss-flex ss-row-center"
  68. >
  69. <label class="radio ss-flex" @tap="onChange">
  70. <radio
  71. :checked="state.protocol"
  72. color="var(--ui-BG-Main)"
  73. style="transform: scale(0.8)"
  74. />
  75. <view class="agreement-text ss-flex ss-col-center">
  76. 我已阅读并遵守
  77. <view
  78. class="tcp-text"
  79. @tap.stop="onProtocol(appInfo.user_protocol.id, appInfo.user_protocol.title)"
  80. >
  81. 《{{ appInfo.user_protocol.title }}》
  82. </view>
  83. <view class="agreement-text">与</view>
  84. <view
  85. class="tcp-text"
  86. @tap.stop="onProtocol(appInfo.privacy_protocol.id, appInfo.privacy_protocol.title)"
  87. >
  88. 《{{ appInfo.privacy_protocol.title }}》
  89. </view>
  90. </view>
  91. </label>
  92. </view>
  93. <view class="safe-box"></view>
  94. </view>
  95. </su-popup>
  96. </template>
  97. <script setup>
  98. import { computed, reactive } from 'vue';
  99. import sheep from '@/sheep';
  100. import accountLogin from './components/account-login.vue';
  101. import smsLogin from './components/sms-login.vue';
  102. import smsRegister from './components/sms-register.vue';
  103. import resetPassword from './components/reset-password.vue';
  104. import changeMobile from './components/change-mobile.vue';
  105. import changePasswrod from './components/change-password.vue';
  106. import changeUsername from './components/change-username.vue';
  107. import { closeAuthModal } from '@/sheep/hooks/useModal';
  108. const appInfo = computed(() => sheep.$store('app').info);
  109. const modalStore = sheep.$store('modal');
  110. // 授权弹窗类型
  111. const authType = computed(() => modalStore.auth);
  112. const state = reactive({
  113. protocol: false,
  114. });
  115. //勾选协议
  116. function onChange() {
  117. state.protocol = !state.protocol;
  118. }
  119. // 查看协议
  120. function onProtocol(id, title) {
  121. closeAuthModal();
  122. sheep.$router.go('/pages/public/richtext', {
  123. id,
  124. title,
  125. });
  126. }
  127. // 第三方授权登陆
  128. const thirdLogin = async (provider, event = null) => {
  129. if (!state.protocol) {
  130. sheep.$helper.toast('请勾选同意');
  131. return;
  132. }
  133. const loginRes = await sheep.$platform.useProvider(provider).login(event?.detail || null);
  134. if (loginRes) {
  135. closeAuthModal();
  136. const userInfo = await sheep.$store('user').getInfo();
  137. }
  138. };
  139. </script>
  140. <style lang="scss" scoped>
  141. @import './index.scss';
  142. .safe-box {
  143. height: calc(constant(safe-area-inset-bottom) / 5 * 3);
  144. height: calc(env(safe-area-inset-bottom) / 5 * 3);
  145. }
  146. .tcp-text {
  147. color: var(--ui-BG-Main);
  148. }
  149. .agreement-text {
  150. color: $dark-9;
  151. }
  152. </style>