index.vue 4.4 KB

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