This commit is contained in:
浅念
2026-02-06 14:39:37 +08:00
parent 423fc8b7e1
commit bf3d85de0d
28 changed files with 5631 additions and 1164 deletions
+180 -231
View File
@@ -1,263 +1,212 @@
<template>
<view class="content">
<image class="logo" src="/static/image/bg.jpg"></image>
<view class="contop">
<text class="text">2025 USED CAR</text>
<text class="cont">
河南合塑实业有限公司
</text>
</view>
<view class="foot">
<button v-if="is_login" class="btn" @click="mini_login">一键登录</button>
<button v-else="is_login" class="btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">一键登录</button>
<view class="check">
<checkbox-group name="" style="width: 28px;">
<label>
<checkbox :checked="selfChecked" activeBackgroundColor="#3F435B" style="transform:scale(0.7);border-radius: 50%"/>
</label>
</checkbox-group>
我同意并遵守<text class="argeen" @click="gouser">《用户服务协议》</text>以及<text class="argeen" @click="goprivacy">《隐私政策》</text>
<view class="auth-page">
<view class="auth-card">
<!-- 这里如果你有站点 logo,可替换为自己的路径;没有也不影响 -->
<!-- <image class="logo" src="/static/logo.png" mode="heightFix"></image> -->
<view class="spinner"></view>
<view class="text-wrap">
<text class="title">{{ title }}</text>
<text class="desc">{{ desc }}<text class="dots">{{ dots }}</text></text>
</view>
<view class="progress">
<view class="bar"></view>
</view>
</view>
</view>
</template>
<script>
import { request,showToast } from '@/api/apiT.js'
import { request, showToast } from '@/api/apiT.js'
export default {
data() {
return {
selfChecked: false,
is_login:false,
corp_abbr: '',
corp_id: '',
title: '正在为你登录',
desc: '加载中',
dots: '',
_dotTimer: null,
// 最短停留时间,避免“闪一下就跳”的割裂感
minStayMs: 600,
_startedAt: 0
}
},
onLoad() {
// this.Props.statusBarHeight = getApp().globalData.statusBarHeight
// console.log(this.Props.statusBarHeight)
// this.Props.capsuleTop = getApp().globalData.capsuleTop
// this.getbg()
onLoad(options) {
this.corp_abbr = options.corp_abbr || '';
this.corp_id = options.corp_id || '';
uni.setStorageSync('corp_abbr', this.corp_abbr);
uni.setStorageSync('corp_id', this.corp_id);
// uni.setStorageSync('token', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZGVzay5obnhpbnlvdWhlLmNvbSIsImp0aSI6ImEwNzFlYTE1ODQ1NWNmYzA1YTkyOTgxOWUxNzQwNTJkIiwic3ViIjoidXNlcl8xIiwiYXVkIjoiZmRlc2siLCJpYXQiOjE3Njc2NjM0MTcsIm5iZiI6MTc2NzY2MzQxNywiZXhwIjoxNzcwMjU1NDE3LCJ0eXAiOiJhY2Nlc3MiLCJ1aWQiOjEsInVuYW1lIjoiXHU2NzRlXHU0ZjczXHU1MzVhIiwicm9sZV9pZHMiOlsxLDIsNF0sInN5c3RlbV9pZHMiOlsxLDIsM119.vyhbWUVIvEF4VGv1hHi3-4cja9r8q7K8dhSW1ejhKgk')
// console.log(uni.getStorageSync('token'))
this._startedAt = Date.now()
this.startDots()
this.silentAuth()
},
onShow() {
// #ifdef MP-WEIXIN
//小程序登录检测
this.mini_login()
// #endif
// #ifndef MP-WEIXIN
this.is_login = true
// #endif
onUnload() {
this.stopDots()
},
methods: {
selfChangde(e) {
this.selfChecked = !this.selfChecked;
startDots() {
this.stopDots()
let n = 0
this._dotTimer = setInterval(() => {
n = (n + 1) % 4
this.dots = '.'.repeat(n)
}, 350)
},
goprivacy(){
uni.navigateTo({
url: '/pages/login/agreement',// 替换为你要跳转的页面路径
});
stopDots() {
if (this._dotTimer) {
clearInterval(this._dotTimer)
this._dotTimer = null
}
},
gouser(){
uni.navigateTo({
url: '/pages/login/agreementuser',// 替换为你要跳转的页面路径
});
},
getPhoneNumber(e) {
console.log(e.detail.code) // 动态令牌
let that = this;
request({
url:'miniapp/phone',
// url:'customerLogin',
method:'POST',
data:{
phone_code: e.detail.code,
async silentAuth() {
try {
// 1) 如果本地已有 token,直接进首页(丝滑)
const token = uni.getStorageSync('token')
if (token) {
this.title = '已登录'
this.desc = '正在进入首页'
return this.goHomeSmooth()
}
}).then(res => {
console.log(res.data.data)
if (res.data.code == -1) {
uni.showToast({
title: res.data.msg,
icon: 'none'
});
} else if (res.data.code == 0) {
//返回数据接收成功
this.mini_login();
// 2) 获取飞书授权跳转地址(静默授权/免登)
this.title = '正在跳转飞书授权'
this.desc = '准备中'
const res = await request({
url: 'common/auth/feishu/scope',
method: 'get',
data:{is_mob:1}
})
const auth_url = res?.data?.data?.auth_url
if (!auth_url) {
throw new Error('未获取到授权地址')
}
})
// 3) 给一点点过渡时间,让动画先跑起来再跳转
await this.sleep(180)
// 仅 H5 才能用 window.location
// #ifdef H5
window.location.replace(auth_url)
// #endif
// #ifndef H5
showToast && showToast('仅 H5 环境支持飞书静默授权')
// #endif
} catch (err) {
console.error('[feishu silentAuth] error:', err)
uni.showToast({ title: err?.message || '登录失败', icon: 'none' })
}
},
mini_login() {
let that = this;
// if(!this.selfChecked){
// uni.showToast({
// title:'请先勾选同意用户服务协议以及隐私政策',
// icon: 'none'
// });
// return false
// }
uni.login({
provider: 'weixin',
success: loginRes => {
console.log(loginRes);
that.code = loginRes.code;
// 2. 将用户登录code传递到后台置换用户SessionKey、OpenId等信息
request({
url:'miniapp/login',
method:'POST',
data:{
code: loginRes.code
}
}).then(res => {
console.log(res.data);
uni.hideLoading()
if (res.data.code == 0) {
//存取session
uni.setStorageSync('openid', res.data.data.openid);
uni.setStorageSync('token', res.data.data.token);
if(res.data.data.phone&&res.data.data.phone!=''&&res.data.data.phone!=null){
uni.reLaunch({
url: '/pages/index/index',// 替换为你要跳转的页面路径
});
this.is_login = true;
}
} else {
uni.showToast({
title: res.data.msg,
icon: 'none'
})
}
})
},
fail: () => {
uni.showToast({
title: '获取 code 失败',
icon: 'none'
});
}
});
},
pd_login(openid) {
let that = this;
request({
url:'miniapp/phone',
method:'POST',
data:{
phone_code: openid
}
}).then(res => {
console.log(res.data)
goHomeSmooth() {
const elapsed = Date.now() - this._startedAt
const wait = Math.max(0, this.minStayMs - elapsed)
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/index',// 替换为你要跳转的页面路径
});
// if (res.data.code == -1) {
// //unionid在数据库没有记录 记录就可以不需要操作
// console.log('unionid在数据库没有记录 记录就可以不需要操作')
// } else if (res.data.code == 0) {
// var userid = res.data.data;
// this.is_login = true;
// this.getCard(openid);
// }
})
url: '/pages/index/index'
})
}, wait)
},
sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
}
}
</script>
<style scoped>
>>>checkbox .wx-checkbox-input {
border-radius: 50% !important;
border: 2rpx solid #3F435B !important;
}
>>>checkbox .wx-checkbox-input.wx-checkbox-input-checked {
border: 2rpx solid #3F435B !important;
background-color:#3F435B !important;
color: #FFFFFF !important;
}
>>>checkbox .wx-checkbox-input.wx-checkbox-input-checked::before {
color: #FFFFFF !important;
}
>>>uni-checkbox .uni-checkbox-input {
margin-right: 0;
border-radius: 50%;
border: 2rpx solid #3F435B;
}
>>>uni-checkbox .uni-checkbox-input:empty {
border: 2rpx solid #3F435B;
background-color: #5FFFFFF;
opacity: 0.5;
}
>>>uni-checkbox .uni-checkbox-input:not(:empty) {
border: 2rpx solid #3F435B;
background-color: #3F435B;
color: #FFFFFF;
}
.argeen{
color: #3F435B;
}
.content{
height: 100%;
width: 100%;
position: relative;
background-color: white;
}
.logo{
width: 100%;
height: 830rpx;
}
.contop{
position: absolute;
top: 16%;
text-align: center;
}
.text{
font-size: 32px;
font-weight: bold;
background: linear-gradient(120deg, #B9773C 0%, #67450D 100%);
-webkit-background-clip: text;
color: transparent;
background-clip: text;
display: inline-block;
}
.cont{
background-image: linear-gradient(#4C392B, #0A0604);
padding: 4px 15px;
color: #FFEBCC;
text-align: center;
border-radius: 6px;
display: inline-block;
margin-top: 12px;
font-size: 16px;
}
.foot{
width: 88%;
margin: 30px auto;
text-align: center;
}
.foot label{
color: #929292;
}
.check{
<style scoped lang="scss">
.auth-page {
min-height: 100vh;
display: flex;
align-items: center;
font-size: 26rpx;
justify-content: center;
padding: 40rpx;
box-sizing: border-box;
/* 更“高级”的登录背景 */
background: linear-gradient(180deg, #3074F7 0%, #F4F6F8 38%, #F4F6F8 100%);
}
.btn{
background-color: #3F435B;
color: white;
border-radius: 50px;
.auth-card {
width: 100%;
margin-bottom: 40px;
height: 50px;
line-height: 50px;
max-width: 640rpx;
background: rgba(255, 255, 255, 0.92);
border-radius: 20rpx;
padding: 44rpx 36rpx 32rpx;
box-shadow: 0 10rpx 40rpx rgba(0, 0, 0, 0.08);
display: flex;
flex-direction: column;
align-items: center;
backdrop-filter: blur(10px);
}
.radio{
color: #929292;
font-size: 12px;
.logo {
height: 72rpx;
margin-bottom: 26rpx;
}
</style>
.spinner {
width: 88rpx;
height: 88rpx;
border-radius: 50%;
border: 8rpx solid rgba(48, 116, 247, 0.18);
border-top-color: rgba(48, 116, 247, 1);
animation: spin 0.9s linear infinite;
margin-bottom: 24rpx;
}
.text-wrap {
text-align: center;
}
.title {
display: block;
font-size: 34rpx;
color: #1f2937;
font-weight: 600;
margin-bottom: 8rpx;
}
.desc {
display: block;
font-size: 26rpx;
color: #6b7280;
}
.dots {
display: inline-block;
width: 40rpx; /* 固定宽度避免文字抖动 */
text-align: left;
}
.progress {
width: 100%;
height: 10rpx;
border-radius: 999rpx;
background: rgba(48, 116, 247, 0.10);
overflow: hidden;
margin-top: 26rpx;
}
.progress .bar {
height: 100%;
width: 40%;
border-radius: 999rpx;
background: rgba(48, 116, 247, 0.55);
animation: move 1.1s ease-in-out infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
@keyframes move {
0% { transform: translateX(-60%); }
50% { transform: translateX(140%); }
100% { transform: translateX(-60%); }
}
</style>