This commit is contained in:
@@ -42,7 +42,12 @@
|
|||||||
<view class="dot"/>
|
<view class="dot"/>
|
||||||
<view class="dot"/>
|
<view class="dot"/>
|
||||||
</view>
|
</view>
|
||||||
<text v-else>登录</text>
|
<text v-else>立即登录</text>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button class="btn-scan" @tap="handleScanLogin">
|
||||||
|
<image src="/static/scan-code.png" mode="aspectFit" class="scan-icon"></image>
|
||||||
|
<text>扫一扫登录</text>
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -72,6 +77,8 @@
|
|||||||
if (token) {
|
if (token) {
|
||||||
uni.reLaunch({ url: '/pages/index/index' });
|
uni.reLaunch({ url: '/pages/index/index' });
|
||||||
}
|
}
|
||||||
|
handleWechatCallback();
|
||||||
|
getPathDeviceId();
|
||||||
});
|
});
|
||||||
|
|
||||||
const identifier = ref('');
|
const identifier = ref('');
|
||||||
@@ -118,6 +125,46 @@
|
|||||||
doLogin();
|
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 () => {
|
const doLogin = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
@@ -341,6 +388,32 @@
|
|||||||
box-shadow: 0 2rpx 8rpx rgba(10, 132, 255, 0.2);
|
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 {
|
.loading {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
BIN
static/scan-code.png
Normal file
BIN
static/scan-code.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
Reference in New Issue
Block a user