|
@@ -141,14 +141,27 @@ export default {
|
|
|
onLoad() {
|
|
|
// 获取用户是否授权
|
|
|
//0:为取消授权 1:为已授权 2:为未操作
|
|
|
- authorize.getSetting().then(res => {
|
|
|
- if (res == 1) {
|
|
|
- console.log('用户已授权')
|
|
|
+ // if(wx.getUserProfile){
|
|
|
+ // this.GetWxAuthorize()
|
|
|
+ // }else{
|
|
|
+ // this.isRequest = true
|
|
|
+ // }
|
|
|
+ authorize
|
|
|
+ .checkLogin()
|
|
|
+ .then(res => {
|
|
|
this.GetWxAuthorize()
|
|
|
- } else {
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
this.isRequest = true
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ // authorize.getSetting().then(res => {
|
|
|
+ // if (res == 1) {
|
|
|
+ // console.log('用户已授权')
|
|
|
+ // this.GetWxAuthorize()
|
|
|
+ // } else {
|
|
|
+ // this.isRequest = true
|
|
|
+ // }
|
|
|
+ // })
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(['hasLogin', 'userInfo'])
|
|
@@ -164,24 +177,24 @@ export default {
|
|
|
async GetWxAuthorize() {
|
|
|
// 获取微信code
|
|
|
const wechatCode = await authorize.getCode('weixin')
|
|
|
- this.UserService.userInfoLogin({
|
|
|
- code: wechatCode ,
|
|
|
- })
|
|
|
- .then(res => {
|
|
|
- // 登录成功 将信息保存在userInfo中 保存在本地和store
|
|
|
- this.login(res.data)
|
|
|
- this.organizeId = res.data.organizeId
|
|
|
- this.getUserInfoPersonal(this.organizeId)
|
|
|
- this.refresh = true
|
|
|
- this.isRequest = true
|
|
|
- })
|
|
|
- .catch(err => {
|
|
|
- // 缓存游客openid
|
|
|
- uni.setStorageSync('openid', err.data.openid)
|
|
|
- this.logout()
|
|
|
- this.refresh = true
|
|
|
- this.isRequest = true
|
|
|
+ this.UserService.userInfoLogin({
|
|
|
+ code: wechatCode
|
|
|
})
|
|
|
+ .then(res => {
|
|
|
+ // 登录成功 将信息保存在userInfo中 保存在本地和store
|
|
|
+ this.login(res.data)
|
|
|
+ this.organizeId = res.data.organizeId
|
|
|
+ this.getUserInfoPersonal(this.organizeId)
|
|
|
+ this.refresh = true
|
|
|
+ this.isRequest = true
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ // 缓存游客openid
|
|
|
+ uni.setStorageSync('openid', err.data.openid)
|
|
|
+ this.logout()
|
|
|
+ this.refresh = true
|
|
|
+ this.isRequest = true
|
|
|
+ })
|
|
|
},
|
|
|
//初始化个人中心数据
|
|
|
getUserInfoPersonal(organizeId) {
|
|
@@ -205,21 +218,38 @@ export default {
|
|
|
},
|
|
|
// 栏目跳转
|
|
|
navigator(url) {
|
|
|
- authorize.getSetting().then(res => {
|
|
|
- console.log('是否已授权',res);
|
|
|
- //0:为取消授权 1:为已授权 2:为未操作
|
|
|
- if (res == 1) {
|
|
|
- if (this.hasLogin) {
|
|
|
- // 已登录
|
|
|
- this.$api.navigateTo(url)
|
|
|
- } else {
|
|
|
- // 未登录
|
|
|
- this.$api.navigateTo(`/pages/login/login`)
|
|
|
+ const _that = this
|
|
|
+ authorize
|
|
|
+ .checkLogin()
|
|
|
+ .then(res => {
|
|
|
+ if (res === 1) {
|
|
|
+ if (this.hasLogin) {
|
|
|
+ // 已登录
|
|
|
+ _that.$api.navigateTo(url)
|
|
|
+ } else {
|
|
|
+ // 未登录
|
|
|
+ _that.$api.navigateTo(`/pages/login/login`)
|
|
|
+ }
|
|
|
}
|
|
|
- } else {
|
|
|
- this.$api.navigateTo(`/pages/authorization/authorization`)
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ _that.$api.navigateTo(`/pages/authorization/authorization`)
|
|
|
+ })
|
|
|
+ // authorize.getSetting().then(res => {
|
|
|
+ // console.log('是否已授权',res);
|
|
|
+ // //0:为取消授权 1:为已授权 2:为未操作
|
|
|
+ // if (res == 1) {
|
|
|
+ // if (this.hasLogin) {
|
|
|
+ // // 已登录
|
|
|
+ // this.$api.navigateTo(url)
|
|
|
+ // } else {
|
|
|
+ // // 未登录
|
|
|
+ // this.$api.navigateTo(`/pages/login/login`)
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // this.$api.navigateTo(`/pages/authorization/authorization`)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
},
|
|
|
//下拉刷新
|
|
|
onPullDownRefresh() {
|