index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. 111
  3. <view class="login-container">
  4. <view class="login-box">
  5. <!-- Logo区域 -->
  6. <view class="logo-area">
  7. <image class="logo" src="/static/login.png" mode="aspectFit"></image>
  8. <text class="title">小鹅通</text>
  9. <text class="slogan">让知识分享更简单</text>
  10. </view>
  11. <!-- 登录方式区域 -->
  12. <view class="login-methods">
  13. <!-- 微信登录按钮 -->
  14. <button class="login-btn wechat" @click="handleWechatLogin">
  15. <text class="iconfont icon-wechat"></text>
  16. 微信一键登录
  17. </button>
  18. <!-- 其他登录方式 -->
  19. <view class="other-login">
  20. <text class="divider">其他登录方式</text>
  21. <view class="login-options">
  22. <view class="option" @click="navigateToVerifyCodeLogin">
  23. <text class="iconfont icon-verify"></text>
  24. <text>手机号码登录</text>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <!-- 协议区域 -->
  30. <view class="agreement">
  31. <checkbox-group @change="handleAgreementChange">
  32. <label class="agreement-label">
  33. <checkbox :checked="isAgreed" color="#007AFF" />
  34. <text class="agreement-text">
  35. 我已阅读并同意
  36. <text class="link" @click="openServiceAgreement">《服务协议》</text>
  37. <text class="link" @click="openPrivacyPolicy">《隐私政策》</text>
  38. </text>
  39. </label>
  40. </checkbox-group>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. isAgreed: false
  50. }
  51. },
  52. methods: {
  53. // 处理协议勾选
  54. handleAgreementChange(e) {
  55. this.isAgreed = e.detail.value.length > 0
  56. },
  57. // 微信登录
  58. async handleWechatLogin() {
  59. if (!this.isAgreed) {
  60. uni.showToast({
  61. title: '请先同意服务协议和隐私政策',
  62. icon: 'none'
  63. })
  64. return
  65. }
  66. // 前端代码示例(微信小程序)
  67. wx.login({
  68. success: function (res) {
  69. if (res.code) {
  70. console.log(res.code);
  71. // 将 code 发送给后端
  72. wx.request({
  73. url: 'http://localhost:9527/api/wx-login',
  74. method: 'POST',
  75. // 设置请求头,指定请求体为 JSON 格式
  76. header: {
  77. 'content-type': 'application/json'
  78. },
  79. data: {
  80. code: res.code
  81. },
  82. success: function (response) {
  83. console.log(response.data);
  84. },
  85. fail: function (err) {
  86. console.error(err);
  87. }
  88. });
  89. } else {
  90. console.log('获取 code 失败!' + res.errMsg);
  91. }
  92. }
  93. });
  94. },
  95. // // 跳转到密码登录页面
  96. // navigateToPasswordLogin() {
  97. // uni.navigateTo({
  98. // url: '/pages/login/password'
  99. // })
  100. // },
  101. // 跳转到验证码登录页面
  102. navigateToVerifyCodeLogin() {
  103. uni.navigateTo({
  104. url: '/pages/login/verify-code'
  105. })
  106. },
  107. // 打开服务协议
  108. openServiceAgreement() {
  109. uni.navigateTo({
  110. url: '/pages/agreement/service'
  111. })
  112. },
  113. // 打开隐私政策
  114. openPrivacyPolicy() {
  115. uni.navigateTo({
  116. url: '/pages/agreement/privacy'
  117. })
  118. }
  119. }
  120. }
  121. </script>
  122. <style lang="scss">
  123. .login-container {
  124. min-height: 100vh;
  125. background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
  126. display: flex;
  127. align-items: center;
  128. justify-content: center;
  129. padding: 40rpx;
  130. }
  131. .login-box {
  132. width: 100%;
  133. max-width: 750rpx;
  134. background: rgba(255, 255, 255, 0.98);
  135. border-radius: 40rpx;
  136. padding: 80rpx 60rpx;
  137. box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.08);
  138. backdrop-filter: blur(10px);
  139. transform: translateY(0);
  140. transition: transform 0.3s ease;
  141. margin: 0 auto;
  142. &:hover {
  143. transform: translateY(-5rpx);
  144. }
  145. }
  146. .logo-area {
  147. text-align: center;
  148. margin-bottom: 60rpx;
  149. .logo {
  150. width: 240rpx;
  151. height: 240rpx;
  152. margin-bottom: 30rpx;
  153. filter: drop-shadow(0 4rpx 8rpx rgba(0, 0, 0, 0.1));
  154. }
  155. .title {
  156. font-size: 48rpx;
  157. font-weight: 800;
  158. background: linear-gradient(45deg, #2c3e50, #3498db);
  159. -webkit-background-clip: text;
  160. color: transparent;
  161. letter-spacing: 4rpx;
  162. margin-bottom: 20rpx;
  163. display: block;
  164. }
  165. .slogan {
  166. font-size: 32rpx;
  167. color: #666;
  168. font-weight: 500;
  169. letter-spacing: 2rpx;
  170. font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  171. background: linear-gradient(45deg, #34495e, #7f8c8d);
  172. -webkit-background-clip: text;
  173. color: transparent;
  174. }
  175. }
  176. .login-methods {
  177. margin-top: 80rpx;
  178. .login-btn {
  179. width: 100%;
  180. height: 100rpx;
  181. border-radius: 50rpx;
  182. display: flex;
  183. align-items: center;
  184. justify-content: center;
  185. margin-bottom: 40rpx;
  186. font-size: 36rpx;
  187. font-weight: 600;
  188. border: none;
  189. transition: all 0.3s ease;
  190. box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.08);
  191. .iconfont {
  192. margin-right: 16rpx;
  193. font-size: 44rpx;
  194. }
  195. &.primary {
  196. background: linear-gradient(45deg, #2c3e50, #3498db);
  197. color: #ffffff;
  198. &:active {
  199. transform: scale(0.98);
  200. box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.08);
  201. }
  202. }
  203. &.wechat {
  204. background: linear-gradient(45deg, #07C160, #0a9d4e);
  205. color: #ffffff;
  206. &:active {
  207. transform: scale(0.98);
  208. box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.08);
  209. }
  210. }
  211. }
  212. }
  213. .other-login {
  214. margin-top: 60rpx;
  215. .divider {
  216. display: block;
  217. text-align: center;
  218. color: #666666;
  219. font-size: 30rpx;
  220. margin-bottom: 50rpx;
  221. position: relative;
  222. font-weight: 500;
  223. &::before,
  224. &::after {
  225. content: '';
  226. position: absolute;
  227. top: 50%;
  228. width: 140rpx;
  229. height: 1px;
  230. background: linear-gradient(90deg, transparent, #666666, transparent);
  231. }
  232. &::before {
  233. left: 50%;
  234. margin-left: -200rpx;
  235. }
  236. &::after {
  237. right: 50%;
  238. margin-right: -200rpx;
  239. }
  240. }
  241. .login-options {
  242. display: flex;
  243. justify-content: center;
  244. gap: 100rpx;
  245. .option {
  246. display: flex;
  247. flex-direction: column;
  248. align-items: center;
  249. color: #444444;
  250. font-size: 30rpx;
  251. transition: all 0.3s ease;
  252. padding: 24rpx;
  253. border-radius: 24rpx;
  254. &:active {
  255. background: rgba(0, 0, 0, 0.05);
  256. }
  257. .iconfont {
  258. font-size: 64rpx;
  259. margin-bottom: 16rpx;
  260. color: #2c3e50;
  261. transition: transform 0.3s ease;
  262. }
  263. &:hover .iconfont {
  264. transform: scale(1.1);
  265. }
  266. }
  267. }
  268. }
  269. .agreement {
  270. margin-top: 80rpx;
  271. text-align: center;
  272. .agreement-label {
  273. display: inline-flex;
  274. align-items: center;
  275. font-size: 26rpx;
  276. color: #666666;
  277. }
  278. .agreement-text {
  279. margin-left: 10rpx;
  280. }
  281. .link {
  282. color: #3498db;
  283. text-decoration: none;
  284. font-weight: 500;
  285. position: relative;
  286. &::after {
  287. content: '';
  288. position: absolute;
  289. bottom: -2rpx;
  290. left: 0;
  291. width: 100%;
  292. height: 1px;
  293. background: #3498db;
  294. transform: scaleX(0);
  295. transition: transform 0.3s ease;
  296. }
  297. &:active::after {
  298. transform: scaleX(1);
  299. }
  300. }
  301. }
  302. </style>