baodeng_xcx/pages/login/login.vue

241 lines
5.4 KiB
Vue
Raw Normal View History

2024-03-13 10:54:22 +08:00
<template>
<view class="page">
<u-navbar :is-back="false" :title="tittxt" :border-bottom="false" :background="bgc" title-color='#fff' title-size='36' height='36' >
</u-navbar>
<view class="imgbox">
2025-05-14 15:14:12 +08:00
<image src="https://api.ccttiot.com/smartmeter/img/static/uGfU2kTWiHxXEWrNAOuA" mode=""></image>
2024-03-13 10:54:22 +08:00
</view>
2025-06-19 17:41:39 +08:00
<button class="ceshi" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" v-if="checked">
2025-05-14 15:14:12 +08:00
授权登录
</button>
2025-06-19 17:41:39 +08:00
<button class="ceshi" @click="btndl" v-else>授权登录</button>
2025-05-14 15:14:12 +08:00
<button class="zanbu" @click="btnzanbu">暂不登录</button>
2025-06-19 17:41:39 +08:00
<view class="tip" @click="btnxz">
2025-05-14 15:14:12 +08:00
<u-checkbox-group>
2025-06-19 17:41:39 +08:00
<u-checkbox @change.stop="checkboxGroupChange" v-model="checked" shape="circle" active-color="#FF8998" size="26"></u-checkbox>
2025-05-17 08:42:24 +08:00
</u-checkbox-group> <text style="color: #FF8998;" @click="btabout"></text>
2024-03-13 10:54:22 +08:00
</view>
</view>
</template>
<script>
export default {
data() {
return {
bgc: {
2025-05-14 15:14:12 +08:00
backgroundColor: "#010000",
2024-03-13 10:54:22 +08:00
},
2025-05-14 15:14:12 +08:00
tittxt:"登录",
2024-03-13 10:54:22 +08:00
chooseType:true,
usertype:'',
2025-05-14 15:14:12 +08:00
login:false,
checked:false,
2025-06-19 17:41:39 +08:00
fxid:'',
yi:true
2025-06-06 11:14:06 +08:00
}
},
onLoad(option) {
console.log(option);
if(option.fxid){ //判断是否分享未登录 进入登录页
this.fxid = option.fxid
2024-03-13 10:54:22 +08:00
}
},
methods: {
2025-05-17 08:42:24 +08:00
btabout(){
console.log(11);
uni.navigateTo({
url:'/page_shanghu/about?tit=' + '服务协议' + '&type=4'
})
},
2025-06-19 17:41:39 +08:00
checkboxGroupChange(e) {
console.log(e);
this.yi = false
setTimeout(()=>{
this.yi = true
},2000)
},
btnxz(){
if(this.yi == true){
this.checked = !this.checked
console.log(11);
}
console.log(22);
},
2025-05-14 15:14:12 +08:00
// 测试登录
btndl(){
if(this.checked == false){
uni.showToast({
2025-05-17 08:42:24 +08:00
title: '请勾选《服务协议》',
2025-05-14 15:14:12 +08:00
icon: 'none',
duration:2000
})
2024-03-13 10:54:22 +08:00
}
},
2025-05-14 15:14:12 +08:00
// 暂不登录
btnzanbu(){
uni.switchTab({
url:'/pages/index/index'
})
},
2024-03-13 10:54:22 +08:00
getPhoneNumber(e) {
2025-05-14 15:14:12 +08:00
if(this.checked == false){
uni.showToast({
title: '请勾选服务协议,法律条款以及隐私政策',
icon: 'none',
duration:2000
})
return
}
2024-03-13 10:54:22 +08:00
let that = this;
console.log("eeeeeeee", e);
const wxLoginAsync = () => {
return new Promise((resolve, reject) => {
wx.login({
success(res) {
if (res.code) {
console.log('登录!', res);
let data = {
2025-05-14 15:14:12 +08:00
loginCode: res.code,
2024-03-13 10:54:22 +08:00
mobileCode: e.detail.code,
2025-05-14 15:14:12 +08:00
appId:that.$store.state.appid
2024-03-13 10:54:22 +08:00
};
resolve(data);
} else {
reject(res.errMsg);
}
},
fail(err) {
reject(err);
}
});
});
};
wxLoginAsync()
.then(async (data) => {
2025-05-14 15:14:12 +08:00
this.$u.post("/wxLogin",data).then((res) => {
2024-03-13 10:54:22 +08:00
if (res.code == 200) {
console.log(res,'resres');
wx.setStorageSync('token', res.token);
that.ceshi()
}
});
})
.catch((err) => {
console.error(err);
});
},
async ceshi() {
2025-05-14 15:14:12 +08:00
this.$u.get("/getInfo").then((res) => {
2024-03-13 10:54:22 +08:00
console.log('进入跳转');
2025-06-06 11:14:06 +08:00
let that = this
if(res.code == 200){
console.log(that.fxid,'121212121');
if(that.fxid){ //判断是否有分享id有则直接跳转拼桌详情页
uni.setStorageSync('user',res.user)
uni.reLaunch({
url: '/page_user/pingzhuo/zhuozixq?fxid=' + that.fxid
})
}else{
uni.setStorageSync('user',res.user)
uni.switchTab({
url: '/pages/index/index'
})
}
}else{
uni.showToast({
title: res.msg,
icon: 'none',
duration:2000
})
}
2024-03-13 10:54:22 +08:00
});
},
}
}
</script>
<style lang="scss" >
page{
2025-05-14 15:14:12 +08:00
// background: #010000;
2024-03-13 10:54:22 +08:00
}
.page {
position: relative; /* 添加相对定位 */
}
2025-05-14 15:14:12 +08:00
.zanbu{
font-weight: 600;
font-size: 36rpx;
color: #808080;
position: fixed;
bottom: 292rpx;
left: 50%;
transform: translateX(-50%);
background-color: transparent;
}
.ceshi{
width: 614rpx;
height: 108rpx;
border-radius: 54rpx 54rpx 54rpx 54rpx;
border: 2rpx solid #FF8998;
background-color: transparent;
font-weight: 600;
font-size: 36rpx;
color: #FF8998;
display: flex;
align-items: center;
justify-content: center;
position: fixed;
bottom: 398rpx;
left: 50%;
transform: translateX(-50%);
}
2024-03-13 10:54:22 +08:00
.imgbox {
2025-05-14 15:14:12 +08:00
width: 100%;
height: 100vh;
2024-03-13 10:54:22 +08:00
z-index: 0;
2025-05-14 15:14:12 +08:00
position: fixed;
top: 0;
left: 0;
2024-03-13 10:54:22 +08:00
image {
2025-05-14 15:14:12 +08:00
width: 100%;
height: 100%;
2024-03-13 10:54:22 +08:00
}
}
2025-05-14 15:14:12 +08:00
.button{
margin-top: 200rpx;
width: 586rpx;
height: 90rpx;
background: #4C97E7;
border-radius: 54rpx 54rpx 54rpx 54rpx;
2024-03-13 10:54:22 +08:00
font-weight: 500;
2025-05-14 15:14:12 +08:00
font-size: 40rpx;
2024-03-13 10:54:22 +08:00
color: #FFFFFF;
}
2025-05-14 15:14:12 +08:00
/deep/ .u-checkbox{
width: 40rpx !important;
}
.tip{
display: flex;
flex-wrap: nowrap;
align-items: center;
justify-content: center;
font-size: 24rpx;
color: #FFFFFF;
position: fixed;
left: 50%;
transform: translateX(-50%);
2025-06-19 17:41:39 +08:00
bottom: 100rpx;
height: 200rpx;
2025-05-14 15:14:12 +08:00
z-index: 1;
width: 100%;
image{
width: 26rpx;
height: 26rpx;
2024-03-13 10:54:22 +08:00
}
}
2025-05-14 15:14:12 +08:00
2024-03-13 10:54:22 +08:00
</style>