login.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <!-- 微信公众号的登录回调页 -->
  2. <template>
  3. <!-- 空登陆页 -->
  4. <view />
  5. </template>
  6. <script setup>
  7. import sheep from '@/sheep';
  8. import {
  9. onLoad
  10. } from '@dcloudio/uni-app';
  11. import {
  12. showAuthModal,
  13. closeAuthModal,
  14. } from '@/sheep/hooks/useModal';
  15. onLoad(async (options) => {
  16. // #ifdef H5
  17. // 将 search 参数赋值到 options 中,方便下面解析
  18. new URLSearchParams(location.search).forEach((value, key) => {
  19. options[key] = value;
  20. });
  21. const event = options.event;
  22. const code = options.code;
  23. const state = options.state;
  24. if (event === 'login') { // 场景一:登录
  25. await sheep.$platform.useProvider().login(code, state).then((res)=>{
  26. console.log(res)
  27. if (!res) {
  28. console.log("返回第一次登录了", res)
  29. showAuthModal("officialAccountFirstLogin")
  30. return false
  31. }
  32. });
  33. } else if (event === 'bind') { // 场景二:绑定
  34. sheep.$platform.useProvider().bind(code, state);
  35. }
  36. // 检测 H5 登录回调
  37. let returnUrl = uni.getStorageSync('returnUrl');
  38. if (returnUrl) {
  39. uni.removeStorage('returnUrl');
  40. location.replace(returnUrl);
  41. } else {
  42. uni.switchTab({
  43. url: '/',
  44. });
  45. }
  46. // #endif
  47. });
  48. </script>
  49. <style lang="scss" scoped>
  50. @keyframes title-animation {
  51. 0% {
  52. font-size: 32rpx;
  53. }
  54. 100% {
  55. font-size: 36rpx;
  56. }
  57. }
  58. .login-wrap {
  59. padding: 50rpx 34rpx;
  60. min-height: 500rpx;
  61. background-color: #fff;
  62. border-radius: 20rpx 20rpx 0 0;
  63. }
  64. .head-box {
  65. .head-title {
  66. min-width: 160rpx;
  67. font-size: 36rpx;
  68. font-weight: bold;
  69. color: #333333;
  70. line-height: 36rpx;
  71. }
  72. .head-title-active {
  73. width: 160rpx;
  74. font-size: 32rpx;
  75. font-weight: 600;
  76. color: #999;
  77. line-height: 36rpx;
  78. }
  79. .head-title-animation {
  80. animation-name: title-animation;
  81. animation-duration: 0.1s;
  82. animation-timing-function: ease-out;
  83. animation-fill-mode: forwards;
  84. }
  85. .head-title-line {
  86. position: relative;
  87. &::before {
  88. content: '';
  89. width: 1rpx;
  90. height: 34rpx;
  91. background-color: #e4e7ed;
  92. position: absolute;
  93. left: -30rpx;
  94. top: 50%;
  95. transform: translateY(-50%);
  96. }
  97. }
  98. .head-subtitle {
  99. font-size: 26rpx;
  100. font-weight: 400;
  101. color: #afb6c0;
  102. text-align: left;
  103. display: flex;
  104. }
  105. }
  106. // .code-btn[disabled] {
  107. // background-color: #fff;
  108. // }
  109. .code-btn-start {
  110. width: 160rpx;
  111. height: 56rpx;
  112. line-height: normal;
  113. border: 2rpx solid var(--ui-BG-Main);
  114. border-radius: 28rpx;
  115. font-size: 26rpx;
  116. font-weight: 400;
  117. color: var(--ui-BG-Main);
  118. opacity: 1;
  119. }
  120. .forgot-btn {
  121. width: 160rpx;
  122. line-height: 56rpx;
  123. font-size: 30rpx;
  124. font-weight: 500;
  125. color: #999;
  126. }
  127. .login-btn-start {
  128. width: 158rpx;
  129. height: 56rpx;
  130. line-height: normal;
  131. background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  132. border-radius: 28rpx;
  133. font-size: 26rpx;
  134. font-weight: 500;
  135. color: #fff;
  136. }
  137. .type-btn {
  138. padding: 20rpx;
  139. margin: 40rpx auto;
  140. width: 200rpx;
  141. font-size: 30rpx;
  142. font-weight: 500;
  143. color: #999999;
  144. }
  145. .auto-login-box {
  146. width: 100%;
  147. .auto-login-btn {
  148. width: 68rpx;
  149. height: 68rpx;
  150. border-radius: 50%;
  151. margin: 0 30rpx;
  152. }
  153. .auto-login-img {
  154. width: 68rpx;
  155. height: 68rpx;
  156. border-radius: 50%;
  157. }
  158. }
  159. .agreement-box {
  160. margin: 80rpx auto 0;
  161. .protocol-check {
  162. transform: scale(0.7);
  163. }
  164. .agreement-text {
  165. font-size: 26rpx;
  166. font-weight: 500;
  167. color: #999999;
  168. .tcp-text {
  169. color: var(--ui-BG-Main);
  170. }
  171. }
  172. }
  173. // 修改密码
  174. .editPwd-btn-box {
  175. .save-btn {
  176. width: 690rpx;
  177. line-height: 70rpx;
  178. background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  179. border-radius: 35rpx;
  180. font-size: 28rpx;
  181. font-weight: 500;
  182. color: #ffffff;
  183. }
  184. .forgot-btn {
  185. width: 690rpx;
  186. line-height: 70rpx;
  187. font-size: 28rpx;
  188. font-weight: 500;
  189. color: #999999;
  190. }
  191. }
  192. .code-btn-start {
  193. color: #55b774;
  194. border: 1px solid #55b774;
  195. }
  196. .agreement-box {
  197. margin: 20rpx 0;
  198. }
  199. .login-btn-start {
  200. background: rgb(14, 147, 46);
  201. width: 100%;
  202. height: 80rpx;
  203. font-size: 32rpx;
  204. }
  205. .loginUniForm {
  206. border: 1rpx solid #d6d6d6;
  207. padding: 10rpx 15rpx;
  208. border-radius: 10rpx;
  209. }
  210. .loginUniFormItem:first-child {
  211. border-bottom: 1rpx solid #d6d6d6;
  212. padding-bottom: 10rpx;
  213. }
  214. .loginUniFormItem:last-child {
  215. // border-bottom: 1rpx solid #d6d6d6;
  216. padding-top: 10rpx;
  217. }
  218. ::v-deep .loginUniFormItem .uni-forms-item__inner {
  219. padding-bottom: 0;
  220. }
  221. ::v-deep .loginUniFormItem .uni-error-message {
  222. bottom: -20rpx;
  223. }
  224. </style>