powerbank/pages/login/login.vue

138 lines
3.1 KiB
Vue
Raw Normal View History

2024-03-13 10:54:22 +08:00
<template>
<view class="page">
2024-05-11 10:57:53 +08:00
<u-navbar :is-back="false" :title="tittxt" :border-bottom="false" :background="bgc" title-color='#000' title-size='36' height='36' >
2024-03-13 10:54:22 +08:00
</u-navbar>
<view class="imgbox">
2024-05-11 10:57:53 +08:00
<image src="https://api.ccttiot.com/smartmeter/img/static/uGPwljIaEppyKAT1iQaW" mode=""></image>
2024-03-13 10:54:22 +08:00
</view>
2024-05-11 10:57:53 +08:00
<button class="button" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" >
授权登录
</button>
2024-03-13 10:54:22 +08:00
<view class="tip">
2024-05-15 18:01:50 +08:00
<!-- <image src="https://api.ccttiot.com/smartmeter/img/static/u4LEl3cUFgF9uN30ESnF" mode=""></image> -->
<u-checkbox-group>
<u-checkbox v-model="checked" active-color="#25CE88"></u-checkbox>
</u-checkbox-group>
2024-05-11 10:57:53 +08:00
我已同意并阅读服务条款法律条款及隐私政策
2024-03-13 10:54:22 +08:00
</view>
</view>
</template>
<script>
export default {
data() {
return {
bgc: {
2024-05-15 18:01:50 +08:00
backgroundColor: "#25CE88",
2024-03-13 10:54:22 +08:00
},
2024-05-11 10:57:53 +08:00
tittxt:"登录",
2024-03-13 10:54:22 +08:00
chooseType:true,
usertype:'',
2024-05-15 18:01:50 +08:00
login:false,
checked:false
2024-03-13 10:54:22 +08:00
}
},
methods: {
userType(num){
this.chooseType=false
this.login=true
if(num==1){
this.usertype='01'
2024-03-25 19:46:07 +08:00
}else{
this.usertype='00'
2024-03-13 10:54:22 +08:00
}
},
getPhoneNumber(e) {
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 = {
2024-05-15 18:01:50 +08:00
loginCode: res.code,
2024-03-13 10:54:22 +08:00
mobileCode: e.detail.code,
};
resolve(data);
} else {
reject(res.errMsg);
}
},
fail(err) {
reject(err);
}
});
});
};
wxLoginAsync()
.then(async (data) => {
this.$u.post("/app/auth/wxLogin",data).then((res) => {
if (res.code == 200) {
2024-05-15 18:01:50 +08:00
uni.setStorageSync('token', res.token);
2024-03-13 10:54:22 +08:00
that.ceshi()
}
});
})
.catch((err) => {
console.error(err);
});
},
2024-05-15 18:01:50 +08:00
ceshi() {
2024-03-13 10:54:22 +08:00
this.$u.get("/app/user/userInfo").then((res) => {
console.log('进入跳转');
2024-03-25 19:46:07 +08:00
uni.switchTab({
url: '/pages/index/index'
})
2024-03-13 10:54:22 +08:00
});
},
}
}
</script>
<style lang="scss" >
page{
background: #FFFFFF;
}
.page {
position: relative; /* 添加相对定位 */
}
.imgbox {
2024-05-11 10:57:53 +08:00
margin:102rpx auto ;
width: 730rpx;
height: 422rpx;
2024-03-13 10:54:22 +08:00
z-index: 0;
image {
2024-05-11 10:57:53 +08:00
width: 730rpx;
height: 422rpx;
2024-03-13 10:54:22 +08:00
}
}
2024-05-11 10:57:53 +08:00
.button{
margin-top: 200rpx;
width: 586rpx;
height: 90rpx;
2024-05-15 18:01:50 +08:00
background: #25CE88;
2024-05-11 10:57:53 +08:00
border-radius: 54rpx 54rpx 54rpx 54rpx;
2024-03-13 10:54:22 +08:00
font-weight: 500;
2024-05-11 10:57:53 +08:00
font-size: 40rpx;
2024-03-13 10:54:22 +08:00
color: #FFFFFF;
}
2024-05-11 10:57:53 +08:00
.tip{
margin-top:128rpx ;
display: flex;
flex-wrap: nowrap;
align-items: center;
justify-content: center;
font-weight: 400;
2024-05-15 18:01:50 +08:00
font-size: 24rpx;
2024-05-11 10:57:53 +08:00
color: #979797;
2024-03-13 10:54:22 +08:00
}
2024-05-11 10:57:53 +08:00
2024-03-13 10:54:22 +08:00
</style>