<template>
|
<view class="main-container user-container">
|
<!-- <view>
|
我的
|
</view> -->
|
<!-- 背景图 -->
|
<view class="top-bg" :style="{'padding-top':(StatusBar)+'px','line-height':CustomBar+'rpx' }">
|
<view class="title" style="position: relative;" @click="changedefaulttype">
|
我<uni-icons type="settings"></uni-icons>
|
<!-- <view style="position: absolute;left: 32rpx;top: 0;">
|
<uni-icons type="settings" @click="changedefaulttype"></uni-icons>
|
</view> -->
|
</view>
|
<view class="icons">
|
<image class="icon1" src="../../static/imgs/user/usr-icon1.png" mode="aspectFit"></image>
|
<image class="icon2" src="../../static/imgs/home/home-shop-top-icon.png" mode="aspectFit"></image>
|
</view>
|
<view class="flex m-20 user-info" @click="goto('/pages/user/user-info/user-info',true)"
|
v-if="currentInfo&&(currentInfo.id)">
|
<!-- 头像 -->
|
<image class="user-icon" v-if="!currentInfo.picture" src="../../static/imgs/home/home-shop-top-icon.png"
|
mode="aspectFit"></image>
|
<image class="user-icon" v-if="currentInfo.picture" :src="currentInfo.picture" mode="aspectFit"></image>
|
|
<view class="name">
|
{{currentInfo.nickName || '-'}}
|
</view>
|
<uni-icons class="right-icon" type="right"></uni-icons>
|
</view>
|
<view class="flex m-20 user-info" v-else @click="toLogin">
|
<!-- <button open-type="getUserInfo" style="background-color: #fff" @tap="getUserProfile"
|
class="title-bold h2">{{'请点击授权登录~'}}</button> -->
|
前往登录
|
</view>
|
|
|
</view>
|
|
|
|
<view style="padding-bottom:200rpx">
|
</view>
|
<bussincess-footer flg="1"></bussincess-footer>
|
|
</view>
|
</template>
|
|
<script>
|
import storage from '@/plugins/storage.js'
|
|
export default {
|
data() {
|
return {
|
CustomBar: uni.getStorageSync('CustomBar'),
|
StatusBar: uni.getStorageSync('StatusBar'),
|
// StatusBar:0
|
};
|
},
|
created() {
|
console.log('created bu')
|
|
},
|
mounted() {
|
console.log('mounted bu')
|
|
},
|
methods: {
|
toLogin() {
|
uni.navigateTo({
|
url: '/pages/home/rider-login/rider-login'
|
})
|
},
|
async changedefaulttype() {
|
await this.$message.confirm('前往学生端吗?')
|
//清空数据
|
const res = await this.$store.dispatch('logout');
|
|
uni.reLaunch({
|
url: '/pages/user/user'
|
})
|
},
|
async getUserProfile(e) {
|
const res = await wx.getUserProfile({
|
desc: '用于完善会员资料',
|
});
|
console.log(res);
|
this.login_Wx(res.userInfo.avatarUrl, res.userInfo.nickName)
|
},
|
login_Wx(imgurl, nickname) {
|
//获取openId
|
// /wx/jscode2session
|
const tmp = this;
|
this.$message.showLoading()
|
this.openid = this.$storage.getItem('openid');
|
this.tel = this.$storage.getItem('tel');
|
console.log('info,info,info,info,info,info', this.openid, this.tel);
|
if (!!this.openid && !!this.tel) {
|
// this.login = true;
|
} else {
|
// this.login = false;
|
console.log('wx.login');
|
wx.login({
|
success: async res => {
|
if (res.code) {
|
//微信登录成功 已拿到code
|
// tmp.login = true;
|
// tmp.jsCode = res.code; //保存获取到的code
|
console.log('abcd', res.code);
|
// this.$http.request('post',`/api/login/wechat`,{data:{code:tmp.jsCode}})
|
this.$storage.setItem('jsCode', res.code);
|
const res2 = await wx.getUserInfo();
|
console.log('res', res2);
|
|
await this.$store.dispatch('loginwx', {
|
code: res.code,
|
imgurl: imgurl,
|
nickname: nickname
|
});
|
tmp.$message.hideLoading()
|
|
this.$forceUpdate()
|
} else {
|
tmp.$message.hideLoading()
|
tmp.$message.showToast('微信登录失败');
|
|
}
|
},
|
error: res => {
|
console.log('wx.login error', res);
|
tmp.$message.hideLoading()
|
|
tmp.$message.showToast('微信授权失败');
|
}
|
});
|
}
|
},
|
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import "./user.scss";
|
</style>
|