恢复历史版本
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,277 +131,286 @@
|
|||||||
</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 {
|
||||||
name: NAME,
|
name: NAME,
|
||||||
components: {
|
components: {
|
||||||
SwitchWindow,
|
SwitchWindow,
|
||||||
Authorization,
|
Authorization,
|
||||||
},
|
|
||||||
props: {},
|
|
||||||
data: function() {
|
|
||||||
return {
|
|
||||||
weixin: false,
|
|
||||||
MyMenus: [],
|
|
||||||
switchActive: false,
|
|
||||||
isWeixin: false,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapGetters(['userInfo']),
|
|
||||||
...mapState(['$deviceType'])
|
|
||||||
},
|
},
|
||||||
onLoad() {
|
props: {},
|
||||||
if (this.$deviceType==='weixin') {
|
data: function() {
|
||||||
this.weixin = true
|
return {
|
||||||
}
|
canIUseGetUserProfile: false,
|
||||||
},
|
MyMenus: [],
|
||||||
methods: {
|
switchActive: false,
|
||||||
...mapMutations(['updateAuthorizationPage']),
|
isWeixin: false,
|
||||||
toLogin() {
|
}
|
||||||
this.$yrouter.push('/pages/user/Login/index')
|
},
|
||||||
},
|
computed: mapGetters(['userInfo']),
|
||||||
goReturnList() {
|
onLoad() {
|
||||||
this.$yrouter.push('/pages/order/ReturnList/index')
|
if (wx.getUserProfile) {
|
||||||
},
|
this.canIUseGetUserProfile = true
|
||||||
goMyOrder(type) {
|
}
|
||||||
this.$yrouter.push({
|
},
|
||||||
path: '/pages/order/MyOrder/index',
|
methods: {
|
||||||
query: {
|
...mapMutations(['updateAuthorizationPage']),
|
||||||
type,
|
toLogin() {
|
||||||
},
|
this.$yrouter.push('/pages/user/Login/index')
|
||||||
})
|
},
|
||||||
},
|
goReturnList() {
|
||||||
goBindPhone() {
|
this.$yrouter.push('/pages/order/ReturnList/index')
|
||||||
this.$yrouter.push('/pages/user/BindingPhone/index')
|
},
|
||||||
},
|
goMyOrder(type) {
|
||||||
goUserCoupon() {
|
this.$yrouter.push({
|
||||||
this.$yrouter.push('/pages/user/coupon/UserCoupon/index')
|
path: '/pages/order/MyOrder/index',
|
||||||
},
|
query: {
|
||||||
goIntegral() {
|
type,
|
||||||
this.$yrouter.push('/pages/user/signIn/Integral/index')
|
},
|
||||||
},
|
})
|
||||||
goUserPromotion() {
|
},
|
||||||
this.$yrouter.push('/pages/user/promotion/UserPromotion/index')
|
goBindPhone() {
|
||||||
},
|
this.$yrouter.push('/pages/user/BindingPhone/index')
|
||||||
goUserAccount() {
|
},
|
||||||
this.$yrouter.push('/pages/user/UserAccount/index')
|
goUserCoupon() {
|
||||||
},
|
this.$yrouter.push('/pages/user/coupon/UserCoupon/index')
|
||||||
goPersonalData() {
|
},
|
||||||
this.$yrouter.push('/pages/user/PersonalData/index')
|
goIntegral() {
|
||||||
},
|
this.$yrouter.push('/pages/user/signIn/Integral/index')
|
||||||
getPhoneNumber(e) {
|
},
|
||||||
// 判断一下这里是不是小程序 如果是小程序,走获取微信手机号进行绑定
|
goUserPromotion() {
|
||||||
if (e.mp.detail.errMsg == 'getPhoneNumber:ok') {
|
this.$yrouter.push('/pages/user/promotion/UserPromotion/index')
|
||||||
uni.showLoading({
|
},
|
||||||
title: '绑定中',
|
goUserAccount() {
|
||||||
})
|
this.$yrouter.push('/pages/user/UserAccount/index')
|
||||||
wxappBindingPhone({
|
},
|
||||||
encryptedData: e.mp.detail.encryptedData,
|
goPersonalData() {
|
||||||
iv: e.mp.detail.iv,
|
this.$yrouter.push('/pages/user/PersonalData/index')
|
||||||
})
|
},
|
||||||
.then(res => {
|
getPhoneNumber(e) {
|
||||||
// this.User();
|
// 判断一下这里是不是小程序 如果是小程序,走获取微信手机号进行绑定
|
||||||
this.$store.dispatch('userInfo', true)
|
if (e.mp.detail.errMsg == 'getPhoneNumber:ok') {
|
||||||
uni.hideLoading()
|
uni.showLoading({
|
||||||
uni.showToast({
|
title: '绑定中',
|
||||||
title: res.msg,
|
})
|
||||||
icon: 'success',
|
wxappBindingPhone({
|
||||||
duration: 2000,
|
encryptedData: e.mp.detail.encryptedData,
|
||||||
})
|
iv: e.mp.detail.iv,
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.then(res => {
|
||||||
uni.hideLoading()
|
// this.User();
|
||||||
this.$store.dispatch('userInfo', true)
|
this.$store.dispatch('userInfo', true)
|
||||||
console.log(error)
|
uni.hideLoading()
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: error.msg || error.response.data.msg || error.response.data.message,
|
title: res.msg,
|
||||||
icon: 'none',
|
icon: 'success',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
// // 获取当前环境的服务商
|
.catch(error => {
|
||||||
// uni.getProvider({
|
uni.hideLoading()
|
||||||
// service: "oauth",
|
this.$store.dispatch('userInfo', true)
|
||||||
// success: function (res) {
|
console.log(error)
|
||||||
// // 此处可以排除h5
|
uni.showToast({
|
||||||
// if (res.provider) {
|
title: error.msg || error.response.data.msg || error.response.data.message,
|
||||||
// uni.login({
|
icon: 'none',
|
||||||
// success: loginRes => {
|
duration: 2000,
|
||||||
// bindingPhone({
|
})
|
||||||
// code: loginRes.code,
|
})
|
||||||
// encryptedData: e.mp.detail.encryptedData,
|
// // 获取当前环境的服务商
|
||||||
// iv: e.mp.detail.iv
|
// uni.getProvider({
|
||||||
// })
|
// service: "oauth",
|
||||||
// .then(res => {
|
// success: function (res) {
|
||||||
// // this.User();
|
// // 此处可以排除h5
|
||||||
// this.$store.dispatch("userInfo", true);
|
// if (res.provider) {
|
||||||
// uni.hideLoading();
|
// uni.login({
|
||||||
// uni.showToast({
|
// success: loginRes => {
|
||||||
// title: res.msg,
|
// bindingPhone({
|
||||||
// icon: "success",
|
// code: loginRes.code,
|
||||||
// duration: 2000
|
// encryptedData: e.mp.detail.encryptedData,
|
||||||
// });
|
// iv: e.mp.detail.iv
|
||||||
// })
|
// })
|
||||||
// .catch(error => {
|
// .then(res => {
|
||||||
// uni.hideLoading();
|
// // this.User();
|
||||||
// this.$store.dispatch("userInfo", true);
|
// this.$store.dispatch("userInfo", true);
|
||||||
// console.log(error);
|
// uni.hideLoading();
|
||||||
// uni.showToast({
|
// uni.showToast({
|
||||||
// title: error.msg ||
|
// title: res.msg,
|
||||||
// error.response.data.msg ||
|
// icon: "success",
|
||||||
// error.response.data.message,
|
// duration: 2000
|
||||||
// icon: "none",
|
// });
|
||||||
// duration: 2000
|
// })
|
||||||
// });
|
// .catch(error => {
|
||||||
// });
|
// uni.hideLoading();
|
||||||
// },
|
// this.$store.dispatch("userInfo", true);
|
||||||
// fail() {
|
// console.log(error);
|
||||||
// reject("绑定失败");
|
// uni.showToast({
|
||||||
// }
|
// title: error.msg ||
|
||||||
// });
|
// error.response.data.msg ||
|
||||||
// }
|
// error.response.data.message,
|
||||||
// },
|
// icon: "none",
|
||||||
// fail() {
|
// duration: 2000
|
||||||
// reject("获取环境服务商失败");
|
// });
|
||||||
// }
|
// });
|
||||||
// });
|
// },
|
||||||
} else {
|
// fail() {
|
||||||
uni.showToast({
|
// reject("绑定失败");
|
||||||
title: '已拒绝授权',
|
// }
|
||||||
icon: 'none',
|
// });
|
||||||
duration: 2000,
|
// }
|
||||||
})
|
// },
|
||||||
}
|
// fail() {
|
||||||
},
|
// reject("获取环境服务商失败");
|
||||||
// 获取用户授权,读取头像、昵称
|
// }
|
||||||
getUserInfo(data) {
|
// });
|
||||||
if (data.detail.errMsg == 'getUserInfo:fail auth deny') {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '取消授权',
|
title: '已拒绝授权',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
})
|
})
|
||||||
return
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 申请获取用户信息
|
|
||||||
async getUserInfoProfile(data) {
|
|
||||||
if (isWeixin()) {
|
|
||||||
let wechatInit = wechat()
|
|
||||||
if (wechatInit) {
|
|
||||||
await oAuth()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
changeswitch(data) {
|
// 获取用户授权,读取头像、昵称
|
||||||
this.switchActive = data
|
getUserInfo(data) {
|
||||||
},
|
if (data.detail.errMsg == 'getUserInfo:fail auth deny') {
|
||||||
// 获取用户信息
|
uni.showToast({
|
||||||
MenuUser() {
|
title: '取消授权',
|
||||||
getMenuUser()
|
icon: 'none',
|
||||||
.then(res => {
|
duration: 2000,
|
||||||
uni.hideLoading()
|
})
|
||||||
this.MyMenus = res.data.routine_my_menus
|
return
|
||||||
})
|
}
|
||||||
.catch(error => {
|
},
|
||||||
uni.hideLoading()
|
// 申请获取用户信息
|
||||||
console.log(error)
|
getUserInfoProfile(data) {
|
||||||
})
|
wx.getUserProfile({
|
||||||
},
|
lang: 'zh_CN',
|
||||||
goPages(index) {
|
desc: '需要获取您的信息用来展示',
|
||||||
let url = this.MyMenus[index].uniapp_url
|
success: res => {
|
||||||
if (url === '/pages/user/promotion/UserPromotion/index' && this.userInfo.statu === 1) {
|
uni.showLoading({
|
||||||
if (!this.userInfo.isPromoter) {
|
title: '正在更新信息...',
|
||||||
uni.showToast({
|
duration: 2000,
|
||||||
title: '您还没有推广权限!!',
|
})
|
||||||
icon: 'none',
|
getProvider().then(provider => {
|
||||||
duration: 2000,
|
// 环境提供商
|
||||||
})
|
if (!provider) {
|
||||||
return
|
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) {
|
||||||
|
this.switchActive = data
|
||||||
|
},
|
||||||
|
// 获取用户信息
|
||||||
|
MenuUser() {
|
||||||
|
getMenuUser()
|
||||||
|
.then(res => {
|
||||||
|
uni.hideLoading()
|
||||||
|
this.MyMenus = res.data.routine_my_menus
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
uni.hideLoading()
|
||||||
|
console.log(error)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
goPages(index) {
|
||||||
|
let url = this.MyMenus[index].uniapp_url
|
||||||
|
if (url === '/pages/user/promotion/UserPromotion/index' && this.userInfo.statu === 1) {
|
||||||
|
if (!this.userInfo.isPromoter) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '您还没有推广权限!!',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (url === '/pages/orderAdmin/OrderIndex/index' && !this.userInfo.adminid) {
|
if (url === '/pages/orderAdmin/OrderIndex/index' && !this.userInfo.adminid) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '您还不是管理员!!',
|
title: '您还不是管理员!!',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log(this.userInfo)
|
console.log(this.userInfo)
|
||||||
if (url === '/pages/orderAdmin/OrderCancellation/index' && !this.userInfo.checkStatus) {
|
if (url === '/pages/orderAdmin/OrderCancellation/index' && !this.userInfo.checkStatus) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '您没有核销权限,请后台店员设置!!',
|
title: '您没有核销权限,请后台店员设置!!',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$yrouter.push({
|
this.$yrouter.push({
|
||||||
path: this.MyMenus[index].uniapp_url,
|
path: this.MyMenus[index].uniapp_url,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
goPages2() {
|
goPages2() {
|
||||||
this.$yrouter.push({
|
this.$yrouter.push({
|
||||||
path: '/pages/shop/GoodsList/index',
|
path: '/pages/shop/GoodsList/index',
|
||||||
query: {
|
query: {
|
||||||
// id: 0,
|
// id: 0,
|
||||||
title: '积分商城',
|
title: '积分商城',
|
||||||
isIntegral: true,
|
isIntegral: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
userInfo() {
|
userInfo() {
|
||||||
this.MenuUser()
|
this.MenuUser()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
if (this.$store.getters.token) {
|
if (this.$store.getters.token) {
|
||||||
//
|
//
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '加载中',
|
title: '加载中',
|
||||||
})
|
})
|
||||||
this.$store.dispatch('getUser', true)
|
this.$store.dispatch('getUser', true)
|
||||||
this.MenuUser()
|
this.MenuUser()
|
||||||
this.isWeixin = isWeixin()
|
this.isWeixin = isWeixin()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onHide() {
|
onHide() {
|
||||||
console.log('离开用户中心')
|
console.log('离开用户中心')
|
||||||
this.updateAuthorizationPage(false)
|
this.updateAuthorizationPage(false)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -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