diff --git a/pages/login/login.vue b/pages/login/login.vue index bf7b4e7..d498ec4 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -42,7 +42,12 @@ - 登录 + 立即登录 + + + @@ -72,6 +77,8 @@ if (token) { uni.reLaunch({ url: '/pages/index/index' }); } + handleWechatCallback(); + getPathDeviceId(); }); const identifier = ref(''); @@ -118,6 +125,46 @@ doLogin(); }; + const handleScanLogin = () => { + // #ifdef H5 + if (typeof wx === 'undefined' || !wx.scanQRCode) { + uni.showToast({ title: '请在微信中打开', icon: 'none' }); + return; + } + wx.scanQRCode({ + needResult: 1, + scanType: ['qrCode', 'barCode'], + success: (res) => { + const result = res.resultStr; + if (result && result.includes('device_id')) { + const match = result.match(/device_id[=]([^&]*)/); + if (match && match[1]) { + identifier.value = match[1]; + handleLogin(); + } + } else { + uni.showToast({ title: '无效的二维码', icon: 'none' }); + } + }, + fail: () => { + uni.showToast({ title: '扫码失败', icon: 'none' }); + } + }); + // #endif + // #ifndef H5 + uni.showToast({ title: '请在微信中打开', icon: 'none' }); + // #endif + }; + + const getPathDeviceId = () => { + const params = new URLSearchParams(window.location.search); + const deviceId = params.get('device_id'); + if (deviceId) { + identifier.value = deviceId; + handleLogin(); + } + }; + const doLogin = async () => { loading.value = true; try { @@ -341,6 +388,32 @@ box-shadow: 0 2rpx 8rpx rgba(10, 132, 255, 0.2); } + .btn-scan { + width: 100%; + height: 88rpx; + background: var(--bg-primary); + border: 2rpx solid var(--primary); + border-radius: var(--radius-medium); + font-size: 30rpx; + font-weight: 500; + color: var(--primary); + display: flex; + align-items: center; + justify-content: center; + gap: 12rpx; + margin-top: 24rpx; + transition: all 0.3s ease; + } + + .btn-scan:active { + background: rgba(10, 132, 255, 0.05); + } + + .scan-icon { + width: 40rpx; + height: 40rpx; + } + .loading { display: flex; align-items: center; diff --git a/static/scan-code.png b/static/scan-code.png new file mode 100644 index 0000000..5d81824 Binary files /dev/null and b/static/scan-code.png differ