index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div class="login-container">
  3. <!-- Logo区域 -->
  4. <div class="logo-box">
  5. <img src="@/static/logo.png" alt="logo" class="logo">
  6. <div class="app-name">Yeswash</div>
  7. </div>
  8. <!-- 登录按钮 -->
  9. <div class="login-box">
  10. <!-- <div class="wechat-login-btn" @click="handleWechatLogin">
  11. <img src="@/assets/wechat-icon.png" alt="微信" class="wechat-icon">
  12. 微信一键登录
  13. </div>-->
  14. <uv-button :disabled="!isAgreePrivacy||isAgreePrivacy.length===0"
  15. class="phone-login-btn" type="primary" color="#19A497"
  16. @getphonenumber="handleGetPhone" open-type="getPhoneNumber">
  17. 手机号一键登录
  18. </uv-button>
  19. </div>
  20. <!-- 隐私协议 -->
  21. <div class="privacy-box">
  22. <view style="display: inline-flex" class="agreement">
  23. <!-- <uv-checkbox v-model="isAgreePrivacy" @change="handlePrivacyChange"></uv-checkbox>-->
  24. <uv-checkbox-group
  25. v-model="isAgreePrivacy"
  26. shape="circle">
  27. <uv-checkbox
  28. :name="'aa'"
  29. ></uv-checkbox>
  30. </uv-checkbox-group>
  31. <view class="text">
  32. 我已阅读并同意
  33. <view class="link" @click="showUserAgreement">《用户协议》</view>
  34. <view class="link" @click="showPrivacyPolicy">《隐私政策》</view>
  35. </view>
  36. </view>
  37. </div>
  38. </div>
  39. </template>
  40. <script setup lang="ts">
  41. import { ref } from 'vue'
  42. import { useRouter } from 'vue-router'
  43. import {login} from "@/utils/auth";
  44. import {onLoad} from "@dcloudio/uni-app";
  45. const router = useRouter()
  46. const isAgreePrivacy = ref([])
  47. const redirectUrl =ref ("")
  48. const shortId =ref ("")
  49. onLoad((options:any)=>{
  50. console.log(options)
  51. redirectUrl.value = options?.redirectUrl
  52. shortId.value = options?.shortId
  53. })
  54. // 处理微信登录
  55. const handleWechatLogin = () => {
  56. if (!isAgreePrivacy.value) {
  57. alert('请先同意用户协议和隐私政策')
  58. return
  59. }
  60. // 这里添加微信登录逻辑
  61. console.log('微信登录')
  62. }
  63. // 处理手机号登录
  64. const handlePhoneLogin = () => {
  65. if (!isAgreePrivacy.value) {
  66. alert('请先同意用户协议和隐私政策')
  67. return
  68. }
  69. router.push('/phone-login')
  70. }
  71. // 处理隐私协议变更
  72. const handlePrivacyChange = () => {
  73. console.log('隐私协议同意状态:', isAgreePrivacy.value)
  74. }
  75. // 显示用户协议
  76. const showUserAgreement = () => {
  77. uni.navigateTo({
  78. url:'/pages-user/agreement/index'
  79. })
  80. }
  81. // 显示隐私政策
  82. const showPrivacyPolicy = () => {
  83. uni.navigateTo({
  84. url:'/pages-user/policy/index'
  85. })
  86. }
  87. const handleGetPhone = (e:any) => {
  88. console.log(e)
  89. if(shortId.value){
  90. e.shortId=shortId.value;
  91. }
  92. login(e).then((token: string) => {
  93. console.log(">>>>>>>>>",token)
  94. uni.navigateBack()
  95. // if(redirectUrl.value){
  96. // uni.redirectTo({
  97. // url:redirectUrl.value+"?shortId="+shortId.value
  98. // })
  99. // }else{
  100. // uni.navigateBack()
  101. // // uni.switchTab({
  102. // // url:"/pages/index/index"
  103. // // })
  104. // }
  105. })
  106. }
  107. </script>
  108. <style scoped lang="scss">
  109. .login-container {
  110. min-height: 100vh;
  111. display: flex;
  112. flex-direction: column;
  113. align-items: center;
  114. padding: 60px 30px;
  115. background: #ffffff;
  116. }
  117. .logo-box {
  118. margin-bottom: 80px;
  119. text-align: center;
  120. }
  121. .logo {
  122. width: 120px;
  123. height: 120px;
  124. margin-bottom: 20px;
  125. }
  126. .app-name {
  127. font-size: 24px;
  128. font-weight: bold;
  129. color: #333;
  130. }
  131. .login-box {
  132. width: 100%;
  133. margin-bottom: 40px;
  134. }
  135. .wechat-login-btn,
  136. .phone-login-btn {
  137. color:#19A497 !important;
  138. width: 100%;
  139. height: 44px;
  140. border-radius: 2px;
  141. display: flex;
  142. align-items: center;
  143. justify-content: center;
  144. font-size: 16px;
  145. margin-bottom: 15px;
  146. cursor: pointer;
  147. }
  148. .wechat-login-btn {
  149. background: #07c160;
  150. color: white;
  151. }
  152. .phone-login-btn {
  153. background: #f5f5f5;
  154. color: #333;
  155. }
  156. .wechat-icon {
  157. width: 24px;
  158. height: 24px;
  159. margin-right: 8px;
  160. }
  161. .privacy-box {
  162. position: fixed;
  163. bottom: 30px;
  164. left: 0;
  165. right: 0;
  166. padding: 0 30px;
  167. }
  168. .agreement {
  169. display: flex;
  170. align-items: center;
  171. font-size: 14px;
  172. color: #666;
  173. position: relative;
  174. }
  175. .agreement input {
  176. position: absolute;
  177. opacity: 0;
  178. cursor: pointer;
  179. height: 0;
  180. width: 0;
  181. }
  182. .text {
  183. display: inline-flex;
  184. line-height: 1.4;
  185. }
  186. .link {
  187. color:$uni-color-primary
  188. }
  189. </style>