Browse Source

恢复历史版本

master
Gao xiaosong 3 years ago
parent
commit
42defa78c6
  1. 82
      pages/user/User/index.vue

82
pages/user/User/index.vue

@ -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;
} }

Loading…
Cancel
Save