Sprinkler-app/pages/login/login.vue

160 lines
3.4 KiB
Vue
Raw Normal View History

2024-03-13 10:54:22 +08:00
<template>
2024-10-09 16:52:44 +08:00
<view>
<image src="https://api.ccttiot.com/smartmeter/img/static/uZUV03nVfyr3MvcLKUfs" class="bj" mode=""></image>
<view class="anniu">
2025-09-22 15:24:01 +08:00
<!-- <view class="zhuce" @click="btnzc">
2024-10-09 16:52:44 +08:00
注册
2025-09-22 15:24:01 +08:00
</view> -->
<!-- <view class="denglu" @click="denglu">
2024-10-09 16:52:44 +08:00
登录
2025-09-22 15:24:01 +08:00
</view> -->
<button class="denglu" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
<!-- <image src="https://api.ccttiot.com/smartmeter/img/static/uxWMldLMb888YHm0qOgN" mode=""></image> -->
快捷登录
</button>
2025-04-17 10:20:41 +08:00
<view class="zhuce" style="margin-top: 30rpx;" @click="denglus">
暂不登录
</view>
2024-10-09 16:52:44 +08:00
</view>
2024-03-13 10:54:22 +08:00
</view>
</template>
<script>
2025-04-17 10:20:41 +08:00
var xBlufi = require("@/components/blufi/xBlufi.js")
2024-03-13 10:54:22 +08:00
export default {
2024-10-09 16:52:44 +08:00
data() {
return {
2024-03-13 10:54:22 +08:00
}
},
2024-10-18 17:59:38 +08:00
// 分享到好友(会话)
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
}
},
// 分享到朋友圈
onShareTimeline: function() {
return {
title: '绿小能',
query: '',
path: '/pages/index/index'
}
},
2024-10-09 16:52:44 +08:00
onLoad() {
2025-04-17 10:20:41 +08:00
wx.openBluetoothAdapter({
success: function (res) {
console.log('蓝牙适配器初始化成功');
},
fail: function (err) {
console.error('蓝牙适配器初始化失败,可能是因为没有权限', err);
// uni.showToast({
// title: '蓝牙适配器初始化失败,可能是因为没有权限',
// icon: 'none',
// duration:2000
// })
}
})
xBlufi.initXBlufi(1)
2024-03-13 10:54:22 +08:00
},
2024-10-09 16:52:44 +08:00
methods:{
2025-09-22 15:24:01 +08:00
// 点击微信一键登录
getPhoneNumber(e) {
this.jsCode = e.detail.code
let that = this;
const wxLoginAsync = () => {
return new Promise((resolve, reject) => {
wx.login({
success(res) {
if (res.code) {
that.mobileCode = res.code
let data = {
jsCode: e.detail.code,
mobileCode: res.code,
}
resolve(data);
} else {
reject(res.errMsg)
}
},
fail(err) {
reject(err)
}
})
})
}
wxLoginAsync().then(async (data) => {
this.$u.post(`/wxlogin?mobileCode=${this.jsCode}&jsCode=${this.mobileCode}`, data).then((res) => {
if (res.code == 200) {
wx.setStorageSync('token', res.token)
uni.switchTab({
url:'/pages/index/index'
})
}
})
}).catch((err) => {
console.error(err)
})
},
2024-11-02 17:59:26 +08:00
// 跳转到注册页
2024-10-09 16:52:44 +08:00
btnzc(){
uni.navigateTo({
url:'/pages/login/zhuce'
2024-03-25 19:46:07 +08:00
})
2024-10-09 16:52:44 +08:00
},
2024-11-02 17:59:26 +08:00
// 跳转到登录页
2024-10-09 16:52:44 +08:00
denglu(){
uni.navigateTo({
url:'/pages/login/denglu'
})
2025-04-17 10:20:41 +08:00
},
denglus(){
uni.switchTab({
url:'/pages/index/index'
})
2024-10-09 16:52:44 +08:00
}
}
2024-03-13 10:54:22 +08:00
}
</script>
2024-10-09 16:52:44 +08:00
<style lang="less">
.bj{
width: 100%;
height: 100vh;
position: fixed;
top: 0;
left: 0;
2024-03-13 10:54:22 +08:00
}
2024-10-09 16:52:44 +08:00
.anniu{
position: fixed;
left: 50%;
2025-04-17 10:20:41 +08:00
bottom: 140rpx;
2024-10-09 16:52:44 +08:00
transform: translateX(-50%);
.zhuce{
width: 614rpx;
height: 102rpx;
border-radius: 14rpx 14rpx 14rpx 14rpx;
border: 4rpx solid #FFFFFF;
font-size: 48rpx;
2024-03-13 10:54:22 +08:00
color: #FFFFFF;
2024-10-09 16:52:44 +08:00
font-weight: 600;
text-align: center;
line-height: 102rpx;
}
.denglu{
width: 614rpx;
height: 102rpx;
background: #FFFFFF;
border-radius: 14rpx 14rpx 14rpx 14rpx;
font-size: 48rpx;
color: #48893B;
font-weight: 600;
text-align: center;
line-height: 102rpx;
margin-top: 22rpx;
2024-03-13 10:54:22 +08:00
}
}
2024-10-09 16:52:44 +08:00
</style>