|
|
@ -6,12 +6,13 @@ |
|
|
<view class="bg-right"></view> |
|
|
<view class="bg-right"></view> |
|
|
<view class="ocupy"></view> |
|
|
<view class="ocupy"></view> |
|
|
<view class="lf-flex lf-p-32 lf-row-between"> |
|
|
<view class="lf-flex lf-p-32 lf-row-between"> |
|
|
<view class="lf-row-between" @click="$url('/pages/user/my/setting')"> |
|
|
|
|
|
<view> |
|
|
|
|
|
<image src="https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png" mode="aspectFill" class="center-img"></image> |
|
|
|
|
|
|
|
|
<view class="lf-row-between"> |
|
|
|
|
|
<view @click="clickAvatar"> |
|
|
|
|
|
<image :src="userInfo.avatar" mode="aspectFill" class="center-img" v-if="userInfo.avatar"></image> |
|
|
|
|
|
<image src="../../../static/images/empty.png" mode="aspectFill" class="center-img" v-else></image> |
|
|
</view> |
|
|
</view> |
|
|
<view class="lf-row-center"> |
|
|
|
|
|
<view class="lf-color-white lf-font-36 lf-m-l-20">182****5380 </view> |
|
|
|
|
|
|
|
|
<view class="lf-row-center" @click="clickMobile"> |
|
|
|
|
|
<view class="lf-color-white lf-font-36 lf-m-l-20">{{ userInfo.mobile_replace || '未登录,点此登录' }}</view> |
|
|
<view class="lf-iconfont icon-xiangyou lf-font-20 lf-m-l-10 lf-color-white"></view> |
|
|
<view class="lf-iconfont icon-xiangyou lf-font-20 lf-m-l-10 lf-color-white"></view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
@ -99,6 +100,7 @@ |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import lfTabbar from '@/components/lf-tabbar/lf-tabbar.vue' |
|
|
import lfTabbar from '@/components/lf-tabbar/lf-tabbar.vue' |
|
|
|
|
|
import { getUrl } from '@/common/js/utils.js'; |
|
|
export default { |
|
|
export default { |
|
|
components: { |
|
|
components: { |
|
|
lfTabbar |
|
|
lfTabbar |
|
|
@ -147,9 +149,37 @@ |
|
|
name: '商家中心', |
|
|
name: '商家中心', |
|
|
icon: 'icon-Group-', |
|
|
icon: 'icon-Group-', |
|
|
path: '/pages/business/center/center' |
|
|
path: '/pages/business/center/center' |
|
|
}] |
|
|
|
|
|
|
|
|
}], |
|
|
|
|
|
userInfo: {mobile_replace: '正在获取'}, // 用户信息 |
|
|
|
|
|
token: '', // 用户token |
|
|
|
|
|
code: '' |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
onShow(){ |
|
|
|
|
|
var userInfo = this.$cookieStorage.get('user_info'); |
|
|
|
|
|
console.log("userInfo", userInfo); |
|
|
|
|
|
this.userInfo = userInfo || {}; |
|
|
|
|
|
}, |
|
|
|
|
|
onLoad(){ |
|
|
|
|
|
var token = this.$cookieStorage.get('user_token'); |
|
|
|
|
|
this.token = token; |
|
|
|
|
|
if (token) { |
|
|
|
|
|
// #ifdef MP-WEIXIN |
|
|
|
|
|
if (this.code) { |
|
|
|
|
|
uni.checkSession({ |
|
|
|
|
|
success: res => { |
|
|
|
|
|
if (res.errMsg != 'checkSession:ok') { |
|
|
|
|
|
this.getCode(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
this.getCode(); |
|
|
|
|
|
} |
|
|
|
|
|
// #endif |
|
|
|
|
|
} |
|
|
|
|
|
// this.getUserInfo(); |
|
|
|
|
|
}, |
|
|
// 页面滚动 |
|
|
// 页面滚动 |
|
|
onPageScroll(event){ |
|
|
onPageScroll(event){ |
|
|
if(event.scrollTop >= 50){ |
|
|
if(event.scrollTop >= 50){ |
|
|
@ -158,6 +188,98 @@ |
|
|
this.nav_bg_color = 'transparent'; |
|
|
this.nav_bg_color = 'transparent'; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
methods: { |
|
|
|
|
|
// 接口获取用户信息 |
|
|
|
|
|
getUserInfo(){ |
|
|
|
|
|
this.$http.get({ |
|
|
|
|
|
api: 'api/user', |
|
|
|
|
|
header: { |
|
|
|
|
|
Authorization: this.token |
|
|
|
|
|
} |
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
console.log("1111", res) |
|
|
|
|
|
this.userInfo = res.data; |
|
|
|
|
|
this.$cookieStorage.set('user_info', res.data); |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
// 用户点击了自己的头像,此时做判断,已有头像就跳转到设置页,没有则授权获取用户微信信息 |
|
|
|
|
|
clickAvatar(){ |
|
|
|
|
|
if(this.token && this.userInfo.avatar){ |
|
|
|
|
|
this.$url('/pages/user/my/setting'); |
|
|
|
|
|
}else{ |
|
|
|
|
|
uni.getUserProfile({ |
|
|
|
|
|
desc: '获取你的昵称、头像、地区及性别', |
|
|
|
|
|
lang: 'zh_CN', |
|
|
|
|
|
complete: result => { |
|
|
|
|
|
console.log("result", result) |
|
|
|
|
|
if(result.errMsg == 'getUserProfile:ok'){ |
|
|
|
|
|
let options = { |
|
|
|
|
|
iv: result.iv, |
|
|
|
|
|
encryptedData: result.encryptedData, |
|
|
|
|
|
code: this.code |
|
|
|
|
|
}; |
|
|
|
|
|
this.updateUserInfo(options); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
// 点击手机号,如果没有登录,则跳转到登录 |
|
|
|
|
|
clickMobile(){ |
|
|
|
|
|
if(this.token){ |
|
|
|
|
|
this.$url('/pages/user/my/setting'); |
|
|
|
|
|
}else{ |
|
|
|
|
|
let url = getUrl(); |
|
|
|
|
|
this.$url('/pages/user/register/register?url=' + url); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
// 静默登录获取code |
|
|
|
|
|
getCode(){ |
|
|
|
|
|
uni.login({ |
|
|
|
|
|
success: res => { |
|
|
|
|
|
if (res.code) { |
|
|
|
|
|
this.code = res.code; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
// 更新用户信息 |
|
|
|
|
|
updateUserInfo(data){ |
|
|
|
|
|
uni.showLoading({ |
|
|
|
|
|
title: '完善信息中', |
|
|
|
|
|
mask: true |
|
|
|
|
|
}); |
|
|
|
|
|
this.$http.get({ |
|
|
|
|
|
api: 'api/user/bindUserMiniInfo', |
|
|
|
|
|
data: data, |
|
|
|
|
|
header: { |
|
|
|
|
|
Authorization: this.token |
|
|
|
|
|
} |
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
res = res.data; |
|
|
|
|
|
if (res.status) { |
|
|
|
|
|
// #ifdef MP-WEIXIN |
|
|
|
|
|
this.getUserInfo(); |
|
|
|
|
|
// #endif |
|
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
} else { |
|
|
|
|
|
uni.showModal({ |
|
|
|
|
|
content: res.message || '请求失败', |
|
|
|
|
|
showCancel: false |
|
|
|
|
|
}); |
|
|
|
|
|
this.getCode(); |
|
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
} |
|
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
}).catch(rej=>{ |
|
|
|
|
|
uni.showModal({ |
|
|
|
|
|
content: rej.message || '请求失败', |
|
|
|
|
|
showCancel: false |
|
|
|
|
|
}); |
|
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
|