新增登录页,个人信息调取

master
Lee-1203 2022-08-05 11:08:36 +08:00
parent 2b2afbb814
commit da5ae60764
7 changed files with 261 additions and 20 deletions

View File

@ -124,7 +124,9 @@
uni.reLaunch({url:'/pages/tabbar/video/video'})
break;
case 4:
uni.reLaunch({url:'/pages/tabbar/my/my'})
if(this.$toolAll.tools.judgeAuth()) {
uni.reLaunch({url:'/pages/tabbar/my/my'})
}
break;
}
}

View File

@ -1,8 +1,198 @@
<template>
<view>
<view class='login-header'>
<image class="infoImg" mode="aspectFill" :src="userInfo.avatarUrl || imgSrc"></image>
<view class="logo-name">{{appletName}}</view>
</view>
<view class="login-footer">
<view class="login-btn" type='primary' @tap="bindGetUserInfo"></view>
<view class="agreement-box">如您点击授权您将同意授权<text @tap="toAgreement" class="agreement">免责声明</text></view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
userInfo: {}, //
canIGetUserProfile: false,
imgSrc: '/static/public/logo.jpg', //logo
appletName:'传武佳', //
isShowP:false,
};
},
onLoad() {
if (uni.getUserProfile) {
this.canIGetUserProfile = true;
}
},
methods: {
// logo
setLogo(){
this.$requst.get('index/base-config').then(res=>{
this.imgSrc = this.$http + res.data.logo;
this.appletName = res.data.appletName;
})
},
//
refuse(){
this.isShowP=false;
this.$toolAll.tools.showToast('登录成功','success')
uni.reLaunch({url:'/pages/tabbar/index/index'})
},
//
getphonenumber(e){
let ya = this;
wx.login({
success:(res)=>{
this.$requst.post('/api/user/login',{code:res.code}).then(result => {
if(e.detail.errMsg=="getPhoneNumber:ok"){
this.$requst.post('user/bind-phone',{openid: result.data.openid,session_key:result.data.session_key, iv:e.detail.iv,encryptedData:e.detail.encryptedData}).then(res=>{
console.log('手机号信息:',res);
if(res.code==0){
this.$toolAll.tools.showToast('手机号绑定成功');
this.isShowP = true;
} else this.$toolAll.tools.showToast(res.msg);
},error=>{})
} else {
this.$toolAll.tools.showToast('取消授权手机号');
}
}).catch(err=>{
console.log(err);
})
}
})
},
//
toAgreement(){
uni.navigateTo({
url:'/pagesB/disclaimers/disclaimers'
})
},
//
bindGetUserInfo(e) {
let ya = this;
//
uni.getUserProfile({
desc: '登录',
lang: 'zh_CN',
success: (res) => {
ya.userInfo = res.userInfo;
uni.login({
provider: 'weixin',
success: (res)=> {
if (res.code) {
ya.updateUserInfo(res.code);
} else {
uni.showToast({
title: '登录失败!',
duration: 2000
});
}
},
});
},
fail: (res) => {}
});
},
//
updateUserInfo(code) {
let ya = this;
uni.showToast({
title: '登录中...',
icon:'loading',
duration:10000
})
var params = {
code:code,
nickname: ya.userInfo.nickName,//
headimgurl: ya.userInfo.avatarUrl,//
country: ya.userInfo.country,//
province: ya.userInfo.province,//
city: ya.userInfo.city,//
gender: ya.userInfo.gender,//
language:ya.userInfo.language,//
invite_code:uni.getStorageSync('inviteCode')?uni.getStorageSync('inviteCode'):'',
is_active:1
}
this.$requst.post('/api/user/login',params).then(res => {
if(res.code == 0){
uni.setStorageSync('userId',res.data.account_id)
uni.setStorageSync('token',res.data.token)//token
uni.setStorageSync('openid',res.data.openid)//openid
uni.setStorageSync('expire',res.data.expire)//
uni.setStorageSync('phone_active',res.data.phone_active)//
uni.setStorageSync('is_active',res.data.is_active)//
uni.setStorageSync('invite_code',res.data.invite_code)//
if(uni.getStorageSync('page-path-options')) {
uni.reLaunch({ //
url:uni.getStorageSync('page-path-options')
})
} else {
uni.reLaunch({
url:'/pages/index/index'
})
}
}
},error => {})
}
}
}
</script>
<style>
<style scoped>
.login-header {
justify-content: center;
align-items: center;
flex-direction: column;
margin-top: 0;
position: fixed;
left: 50%;
top: 40%;
transform: translate(-50%,-50%);
}
.infoImg {
width: 224rpx;
height: 224rpx;
border-radius: 100%;
border: 2rpx solid #d8d8d8;
}
.logo-name {
margin-top: 20rpx;
font-size: 30rpx;
font-weight: bold;
text-align: center;
letter-spacing: 4rpx;
text-indent: 4rpx;
}
.login-footer {
width: 100%;
text-align: center;
position: fixed;
left: 0;
bottom: 120rpx;
}
.login-btn {
width: calc(100% - 80rpx);
line-height: 100rpx;
margin: 0 auto;
background-color: #e42417;
border-radius: 20rpx;
color: #ffffff;
font-size: 34rpx;
letter-spacing: 4rpx;
text-indent: 4rpx;
box-shadow: 0rpx 8rpx 20rpx rgba(228,36,23,.5);
}
.agreement-box{
margin-top: 25rpx;
font-size: 28rpx;
}
.agreement{
color: #e42417;
}
</style>

View File

@ -1,30 +1,30 @@
<template>
<view>
<view v-if="isLoading">
<view class="" :style="{paddingTop:statusBarHeight+'px'}">
<image src="/static/tabbar/my-back.png" mode="" class="width100 posia" style="top: 0;z-index: -1;" lazy-load :style="{height:newHeight+'px'}"></image>
<view class="disac colf fon42" style="height: 42px;padding: 0 30rpx;">个人中心</view>
</view>
<view class="disjbac colf pad-zy40 mar-sx30">
<view class="disac">
<image class="radius_100 flexs" src="https://s6.jpg.cm/2022/02/14/L4oDhy.jpg" mode="aspectFill" lazy-load style="width: 100rpx;height: 100rpx;border: 6rpx solid #FFFFFF;background-color: #FFFFFF;"></image>
<view class="fon32 mar-z20">郑珊珊12562</view>
<image class="radius_100 flexs" :src="userInfo.headimgurl" mode="aspectFill" lazy-load style="width: 100rpx;height: 100rpx;border: 6rpx solid #FFFFFF;background-color: #FFFFFF;"></image>
<view class="fon32 mar-z20">{{userInfo.nickname}}</view>
</view>
<view class="disac pad-zy12 pad-sx8 radius4" style="border: 2rpx solid #fccf6d;">
<view class="disac pad-zy12 pad-sx8 radius4" style="border: 2rpx solid #fccf6d;" @tap="$toolAll.tools.goPage('/pagesA/my-sign/my-sign')">
<image src="/static/tabbar/icon-rili.png" mode="" style="width: 24rpx;height: 24rpx;" lazy-load></image>
<view class="fon24 mar-z10" @tap="$toolAll.tools.goPage('/pagesA/my-sign/my-sign')"></view>
<view class="fon24 mar-z10"></view>
</view>
</view>
<view class="pad-zy30">
<view class="disjbac pad-sx30" style="background: linear-gradient(to bottom, #fefcfc 0%, #f8efed 100%);border-radius: 24rpx 24rpx 0 0;">
<view class="width33 disjcac fc">
<view class="fon20" style="color: #3e3e3e;">我的积分</view>
<view class="fon36 bold">99999</view>
<view class="fon36 bold">{{userInfo.score}}</view>
</view>
<view class="width33 disjcac fc" style="border-left: 2rpx solid #f1e8e7;border-right: 2rpx solid #f1e8e7;">
<view class="fon20" style="color: #3e3e3e;">我的优惠券()</view>
<view class="fon36 bold">99</view>
<view class="fon36 bold">{{userInfo.coupon_count}}</view>
</view>
<view class="width33 disjcac">
<view class="width33 disjcac" @tap="$toolAll.tools.goPage('/pages/tabbar/shop/shop')">
<view class="fon24 col-e42417 radius30 flexs disjcac" style="width: 180rpx;height: 60rpx;border: 2rpx solid #e42417;">积分商城</view>
</view>
</view>
@ -54,8 +54,9 @@
components:{'foot-tab' :footTab},
data() {
return {
statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
newHeight:uni.getSystemInfoSync().screenHeight,
statusBarHeight: uni.getSystemInfoSync().statusBarHeight, //
newHeight:uni.getSystemInfoSync().screenHeight, //
isLoading:false, //
funList:[
{src:'/static/tabbar/icon-set.png',title:'个人资料'},
{src:'/static/tabbar/icon-course.png',title:'我的课程'},
@ -65,13 +66,34 @@
{src:'/static/tabbar/icon-score.png',title:'我的积分'},
{src:'/static/tabbar/icon-address.png',title:'我的地址'},
{src:'/static/tabbar/icon-znz.png',title:'我的推广'},
]
], //
userInfo:{}, //
}
},
onLoad() {
},
onShow() {
//
this.getUserInfo();
},
methods: {
//
getUserInfo(){
uni.showLoading({
title:'加载中'
});
this.$requst.get('/api/user/info').then(res=>{
console.log(res,'用户信息')
if(res.code==0) {
this.userInfo = res.data;
}
uni.hideLoading();
this.isLoading = true;
})
},
//
chooseFun(index){
let list = [
'/pagesA/my-data/my-data',

View File

@ -43,16 +43,40 @@
]
}
},
onShow() {
//
this.getCouresList();
},
methods: {
//
getCouresList(){
uni.showLoading({
title:'加载中'
});
this.$requst.get('/api/spu/course').then(res=>{
console.log(res,'课程列表')
if(res.code==0) {
this.userInfo = res.data;
}
uni.hideLoading();
this.isLoading = true;
})
},
}
}
</script>
<style>
.used-item{
border-top: 2rpx solid ;
}
.noshow{transform: rotate(-90deg);transition: all .3s linear;}
.isshow{transform: rotate(90deg);transition: all .3s linear;}
.used-item{
border-top: 2rpx solid ;
}
.noshow{
transform: rotate(-90deg);
transition: all .3s linear;
}
.isshow{
transform: rotate(90deg);
transition: all .3s linear;
}
</style>

View File

@ -53,6 +53,7 @@
}
},
methods: {
//
chooseEv(index){
this.showType = index;
this.tipsTitle = index==5?'真实姓名':'电话号码';
@ -67,6 +68,8 @@
this.$refs.refFrame.tempText = JSON.parse(JSON.stringify(this.phone || ''));
}
},
//
returnEv(obj){
if(this.showType==5){
this.realName = obj.content;

BIN
static/public/logo.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

BIN
static/public/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB