初始化

This commit is contained in:
hezhidong
2025-03-28 09:19:45 +08:00
parent a920f6f06a
commit 91514490ea
25 changed files with 7952 additions and 0 deletions
+133
View File
@@ -0,0 +1,133 @@
<template>
<view class="container">
<view style="text-align: center;">
<image style="width: 120upx;height: 120upx;margin-top: 140upx;border-radius:50%;border: 1px solid #dedfe0;" src="../../static/logo.png"></image>
<view style="font-size: 28upx;margin-top: 32upx">泸州市江阳区新时代文明实践中心</view>
<button class="confirm-btn" @click="wxGetUserInfo">微信登录</button>
<view class="cancal-btn" @click="onClickCancal">取消登录</view>
</view>
</view>
</template>
<script>
import { login, postLogin } from '@/api/user/userApi.js'; //用户中心接口
export default {
data() {
return {
user: {
//用户信息
headerImg: '', //头像
username: '', //昵称 username
isEnterprise: 0 // 0 是用户 1是商家
},
isBackUrl: false // 返回哪里 true 返回领取页面 false 返回 user页面
};
},
onLoad(option) {
this.isBackUrl = option.isback;
},
methods: {
// 点击取消
onClickCancal() {
uni.navigateBack();
},
//授权获取微信用户信息
wxGetUserInfo() {
//新版本使用
var self = this;
uni.getUserProfile({
desc: '登录',
success: data1 => {
uni.login({
provider: 'weixin',
success: loginRes => {
console.log(loginRes);
const code = loginRes.code; //获取code
uni.showLoading({ title: '正在登录' });
postLogin(code).then(res => {
console.log(res);
if (res.code == 200) {
self.$com.setCacheToken('userInfo', res.userInfo); //储存用户信息
self.$com.setCacheToken('token', res.data.access_token); //储存用户token
uni.showToast({ title: '登录成功' });
uni.navigateBack();
}
uni.hideLoading();
});
}
});
},
fail: error => {
uni.showToast({
title: '您取消了授权,登录失败',
icon: 'none'
});
return false;
}
});
return false;
}
}
};
</script>
<style lang="scss">
.footer {
padding-left: 140upx;
margin-top: 32upx;
font-size: 24upx;
color: #666666;
text-align: center;
display: flex;
}
page {
background: #fff;
}
.send-msg {
border-radius: 30px;
color: black;
background: white;
height: 30px;
font-size: 14px;
line-height: 30px;
}
.container {
top: 0;
padding-top: 50px;
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
background: #fff;
image {
margin: 0 auto;
}
}
.cancal-btn {
width: 200px;
height: 42px;
line-height: 42px;
border-radius: 30px;
margin: 0 auto;
margin-top: 60upx;
border: 2rpx solid rgb(220, 223, 230);
color: rgb(220, 223, 230);
}
.confirm-btn {
width: 200px;
height: 42px;
line-height: 42px;
border-radius: 30px;
margin-top: 260upx;
// background-color: $main-color;
color: #fff;
// font-size: $font-lg;
&:after {
border-radius: 60px;
}
}
</style>