登录修改、推广页分享

master
Lee 2023-01-06 15:08:04 +08:00
parent 3ab4416f34
commit 795b8f35cc
4 changed files with 289 additions and 61 deletions

View File

@ -4,24 +4,63 @@
<image class="infoImg" mode="aspectFill" :src="userInfo.avatarUrl || imgSrc"></image> <image class="infoImg" mode="aspectFill" :src="userInfo.avatarUrl || imgSrc"></image>
<view class="logo-name">{{appletName}}</view> <view class="logo-name">{{appletName}}</view>
</view> </view>
<view class="login-footer"> <view class="login-footer" v-if="ifEnter">
<view class="login-btn" type='primary' @tap="bindGetUserInfo"></view> <view class="login-btn" type='primary' @tap="empowerShow=true" v-if="!isActive"></view>
<view class="login-btn" type='primary' @tap="bindGetUserInfo('other')" v-else></view>
<view class="agreement-box">如您点击授权您将同意授权<text @tap="toAgreement" class="agreement">免责声明</text></view> <view class="agreement-box">如您点击授权您将同意授权<text @tap="toAgreement" class="agreement">免责声明</text></view>
</view> </view>
<!-- 获取头像&昵称 -->
<view class="pop-up-bg" v-if="empowerShow"> <!-- v-if="empowerShow" -->
<view class="user-info-box">
<view class="info">
<view class="cover">
<image :src="imgSrc" mode="aspectFit"></image>
</view>
<view class="name">{{appletName}}</view>
<view class="tips">
<view>邀请您补全个人信息</view>
<view>(昵称头像)</view>
</view>
</view>
<view class="msg">
<view class="item">
<text>头像</text>
<button class="avatar" open-type="chooseAvatar" @chooseavatar="chooseAvatar">
<view class="img"><image :src="userInfo.avatarUrl || logoAvatar" mode="aspectFit"></image></view>
</button>
</view>
<view class="item">
<text>昵称</text>
<input class="nick-name" type="nickname" @blur="nickNameInput" v-model="userInfo.nickName" placeholder="请输入昵称" placeholder-style="color:#999"/>
</view>
</view>
<view class="empower-btns">
<view class="btn" @tap="refuseEv"></view>
<view class="btn" @tap="bindGetUserInfo('other')"></view>
</view>
</view>
</view>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
userInfo: {}, // userInfo: {
nickName:'',
avatarUrl:''
}, //
imgSrc: '/static/public/logo.jpg', //logo imgSrc: '/static/public/logo.jpg', //logo
logoAvatar:'/static/public/logo-avatar.png',//
appletName:'萌狮武术', // appletName:'萌狮武术', //
isShowP:false, empowerShow:false, //
isActive:false, //
ifEnter:false,//
}; };
}, },
onLoad() { onLoad() {
//
this.bindGetUserInfo('enter');
}, },
methods: { methods: {
// //
@ -30,73 +69,130 @@
url:'/pagesB/disclaimers/disclaimers' url:'/pagesB/disclaimers/disclaimers'
}) })
}, },
//
uploadImg(url){
uni.showLoading({
title: '上传中'
});
this.$requst.upload('/api/file/upload/image',{path:url}).then(res=>{
if(res.code==0) {
this.userInfo.avatarUrl = `${getApp().globalData.hostapi}`+res.data.src;
}
uni.hideLoading();
})
},
//
chooseAvatar(e){
//
this.uploadImg(e.detail.avatarUrl)
},
//
nickNameInput(e){
this.userInfo.nickName = e.detail.value
},
//
refuseEv(){
this.$toolAll.tools.showToast('您已拒绝授权');
this.empowerShow = false;
},
//
checkForm(){
if(!this.isActive){
if(this.userInfo.avatarUrl==''){
this.$toolAll.tools.showToast('请选择头像!')
return false;
}else if(this.userInfo.nickName==''){
this.$toolAll.tools.showToast('请输入昵称!')
return false;
}else{
return true;
}
}else{
return true;
}
},
// //
bindGetUserInfo(e) { bindGetUserInfo(status) {
let ya = this; let ya = this;
// //
uni.getUserProfile({ uni.login({
desc: '登录', provider: 'weixin',
lang: 'zh_CN', success: (res)=> {
success: (res) => { if (res.code) {
ya.userInfo = res.userInfo; ya.updateUserInfo(res.code,status);
uni.login({ } else {
provider: 'weixin', uni.showToast({
success: (res)=> { title: '登录失败!',
if (res.code) { duration: 2000
ya.updateUserInfo(res.code); });
} else { }
uni.showToast({
title: '登录失败!',
duration: 2000
});
}
},
});
}, },
fail: (res) => {}
}); });
}, },
// //
updateUserInfo(code) { updateUserInfo(code,status) {
let ya = this; let ya = this;
uni.showToast({ if(status=='enter'){
title: '登录中...', this.$requst.post('/api/user/login',{code:code}).then(res => {
icon:'loading', if(res.code == 0){
duration:10000 console.log(res,'进入登录信息');
}) if(res.data.is_active==1){
var params = { this.isActive = true;
code:code, }else{
nickname: ya.userInfo.nickName,// uni.setStorageSync('token',res.data.token) //token
headimgurl: ya.userInfo.avatarUrl,// }
country: ya.userInfo.country,// this.ifEnter = true;
province: ya.userInfo.province,//
city: ya.userInfo.city,//
gender: ya.userInfo.gender,//
language:ya.userInfo.language,//
invite_code:uni.getStorageSync('invite_code')?uni.getStorageSync('invite_code'):'',
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/tabbar/pagehome/pagehome'
})
} }
},error => {
})
}
if(status=='other'){
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('invite_code')?uni.getStorageSync('invite_code'):'',
is_active:1
} }
},error => {}) 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/tabbar/pagehome/pagehome'
})
}
}
},error => {})
}
} }
} }
} }
@ -152,4 +248,119 @@
.agreement{ .agreement{
color: #e42417; color: #e42417;
} }
/* 授权弹窗 */
.pop-up-bg{
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
width: 100vw;
height: 100vh;
background-color: rgba(0,0,0,.5);
position: fixed;
left: 0;
top: 0;
z-index: 999;
}
.user-info-box{
box-sizing: border-box;
width: calc(100% - 200rpx);
border-radius: 10rpx;
padding: 40rpx 45rpx 35rpx;
background-color: #ffffff;
}
.user-info-box .info{
font-size: 26rpx;
text-align: center;
}
.user-info-box .cover{
width: 150rpx;
height: 150rpx;
border-radius: 100%;
box-shadow: 0px 0px 20rpx 4rpx rgba(228,36,23,.1);
margin: 0 auto;
overflow: hidden;
}
.user-info-box .cover image{
width: 100%;
height: 100%;
}
.user-info-box .name{
font-size: 30rpx;
line-height: 1.5;
margin: 8rpx 0 15rpx;
}
.user-info-box .tips{
font-size: 26rpx;
line-height: 1.6;
color: #666666;
}
.user-info-box .tips view:last-child{
font-size: 24rpx;
color: #e42417;
}
.user-info-box .msg{
font-size: 26rpx;
}
.user-info-box .item{
display: flex;
align-items: center;
justify-content: space-between;
padding: 10rpx 0;
border-bottom: 2rpx solid #f1f5f9;
}
.user-info-box .item text{
line-height: 1.8;
}
.user-info-box .avatar{
display: flex;
justify-content: flex-end;
width: calc(100% - 80rpx);
height: 100rpx;
padding: 0;
margin: 0;
background: none;
}
.user-info-box .avatar::after{
display: none;
}
.user-info-box .avatar .img{
width: 100rpx;
height: 100rpx;
border-radius: 100%;
overflow: hidden;
}
.user-info-box .avatar image{
width: 100%;
height: 100%;
}
.user-info-box .nick-name{
width: calc(100% - 80rpx);
height: 60rpx;
text-align: right;
}
.user-info-box .empower-btns{
display: flex;
align-items: center;
margin-top: 20rpx;
}
.user-info-box .empower-btns .btn{
width: 50%;
text-align: center;
align-items: 1.5;
padding-top: 20rpx;
color: #666666;
font-size: 30rpx;
}
.user-info-box .empower-btns .btn:nth-of-type(2){
color: #e42417;
}
</style> </style>

View File

@ -72,6 +72,14 @@
this.getExtend(); this.getExtend();
} }
}, },
onShareAppMessage(res) {
var shareObj = {
     title: ``, // (slogan)
     path: `${uni.getStorageSync('page-path-options')}?invite_code=${uni.getStorageSync('invite_code')}`, // /
     imageUrl: ``//PNGJPG imageUrl 使 5:4
  };
  return shareObj;
},
methods: { methods: {
getPath(path){ getPath(path){
this.personCode = path; this.personCode = path;
@ -85,6 +93,7 @@
} }
this.$requst.get('/api/user/sales',params).then(res=>{ this.$requst.get('/api/user/sales',params).then(res=>{
if(res.code==0){ if(res.code==0){
console.log(res,'推广人信息')
this.scoreInfo = res.data.promotion_score; this.scoreInfo = res.data.promotion_score;
this.total = res.data.list.total; this.total = res.data.list.total;
if(this.page==1){this.dataList=[];} if(this.page==1){this.dataList=[];}

View File

@ -77,6 +77,14 @@
this.getExtend(); this.getExtend();
} }
}, },
onShareAppMessage(res) {
var shareObj = {
     title: ``, // (slogan)
     path: `${uni.getStorageSync('page-path-options')}?invite_code=${uni.getStorageSync('invite_code')}`, // /
     imageUrl: ``//PNGJPG imageUrl 使 5:4
  };
  return shareObj;
},
methods: { methods: {
getPath(path){ getPath(path){
this.personCode = path; this.personCode = path;

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB