恢复历史版本
This commit is contained in:
@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="user">
|
<view class="user">
|
||||||
<view v-if="$store.getters.token || userInfo.uid">
|
<view v-if="$store.getters.token || userInfo.uid">
|
||||||
<view class="getUserBaseData header bg-color-red acea-row row-between-wrapper" v-if="$deviceType === 'routine' && !userInfo.avatar && !userInfo.nickname">
|
<view class="getUserBaseData header bg-color-red acea-row row-between-wrapper" v-if="!userInfo.avatar && !userInfo.nickname">
|
||||||
<button class="userDataBtn" v-if="weixin" @tap="getUserInfoProfile">授权并查看用户信息</button>
|
<button class="userDataBtn" v-if="canIUseGetUserProfile" @tap="getUserInfoProfile">授权并查看用户信息</button>
|
||||||
<button class="userDataBtn" v-else @getuserinfo="getUserInfo" open-type="getUserInfo">授权并查看用户信息</button>
|
<button class="userDataBtn" v-else @getuserinfo="getUserInfo" open-type="getUserInfo">授权并查看用户信息</button>
|
||||||
</view>
|
</view>
|
||||||
<view class="header bg-color-red acea-row row-between-wrapper" v-else>
|
<view class="header bg-color-red acea-row row-between-wrapper" v-else>
|
||||||
@ -131,32 +131,13 @@
|
|||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import {
|
import { mapState, mapGetters, mapMutations, mapActions } from 'vuex'
|
||||||
mapState,
|
import { getUserInfo, getMenuUser, wxappAuth, bindingPhone, wxappBindingPhone, wxappGetUserInfo } from '@/api/user'
|
||||||
mapGetters,
|
import { isWeixin, VUE_APP_RESOURCES_URL, parseQuery, getProvider } from '@/utils'
|
||||||
mapMutations,
|
|
||||||
mapActions
|
|
||||||
} from 'vuex'
|
|
||||||
import {
|
|
||||||
getUserInfo,
|
|
||||||
getMenuUser,
|
|
||||||
wxappAuth,
|
|
||||||
bindingPhone,
|
|
||||||
wxappBindingPhone,
|
|
||||||
wxappGetUserInfo
|
|
||||||
} from '@/api/user'
|
|
||||||
import {
|
|
||||||
isWeixin,
|
|
||||||
VUE_APP_RESOURCES_URL,
|
|
||||||
parseQuery,
|
|
||||||
getProvider
|
|
||||||
} from '@/utils'
|
|
||||||
import SwitchWindow from '@/components/SwitchWindow'
|
import SwitchWindow from '@/components/SwitchWindow'
|
||||||
import Authorization from '@/pages/authorization/index'
|
import Authorization from '@/pages/authorization/index'
|
||||||
import cookie from '@/utils/store/cookie'
|
import cookie from '@/utils/store/cookie'
|
||||||
|
|
||||||
import { wechat, oAuth, } from '@/libs/wechat'
|
|
||||||
|
|
||||||
const NAME = 'User'
|
const NAME = 'User'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -168,19 +149,16 @@ export default {
|
|||||||
props: {},
|
props: {},
|
||||||
data: function() {
|
data: function() {
|
||||||
return {
|
return {
|
||||||
weixin: false,
|
canIUseGetUserProfile: false,
|
||||||
MyMenus: [],
|
MyMenus: [],
|
||||||
switchActive: false,
|
switchActive: false,
|
||||||
isWeixin: false,
|
isWeixin: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: mapGetters(['userInfo']),
|
||||||
...mapGetters(['userInfo']),
|
|
||||||
...mapState(['$deviceType'])
|
|
||||||
},
|
|
||||||
onLoad() {
|
onLoad() {
|
||||||
if (this.$deviceType==='weixin') {
|
if (wx.getUserProfile) {
|
||||||
this.weixin = true
|
this.canIUseGetUserProfile = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -313,13 +291,44 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 申请获取用户信息
|
// 申请获取用户信息
|
||||||
async getUserInfoProfile(data) {
|
getUserInfoProfile(data) {
|
||||||
if (isWeixin()) {
|
wx.getUserProfile({
|
||||||
let wechatInit = wechat()
|
lang: 'zh_CN',
|
||||||
if (wechatInit) {
|
desc: '需要获取您的信息用来展示',
|
||||||
await oAuth()
|
success: res => {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '正在更新信息...',
|
||||||
|
duration: 2000,
|
||||||
|
})
|
||||||
|
getProvider().then(provider => {
|
||||||
|
// 环境提供商
|
||||||
|
if (!provider) {
|
||||||
|
reject()
|
||||||
}
|
}
|
||||||
|
// 获取开发code
|
||||||
|
uni.login({
|
||||||
|
provider: provider,
|
||||||
|
success: async loginRes => {
|
||||||
|
wxappGetUserInfo({
|
||||||
|
encryptedData: res.encryptedData,
|
||||||
|
iv: res.iv,
|
||||||
|
code: loginRes.code, // 开发code
|
||||||
|
}).then(res => {
|
||||||
|
if (res.status === 200) {
|
||||||
|
this.userInfo.avatar = res.data.avatar
|
||||||
|
this.userInfo.nickname = res.data.nickname
|
||||||
|
} else {
|
||||||
|
uni.showLoading({
|
||||||
|
title: res.msg,
|
||||||
|
duration: 2000,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
},
|
},
|
||||||
changeswitch(data) {
|
changeswitch(data) {
|
||||||
this.switchActive = data
|
this.switchActive = data
|
||||||
@ -419,7 +428,6 @@ export default {
|
|||||||
color: rgba(255, 255, 255, 1);
|
color: rgba(255, 255, 255, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer-line-height {
|
.footer-line-height {
|
||||||
height: 1 * 100rpx;
|
height: 1 * 100rpx;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user