Browse Source

feat(登录): 实现微信登录功能并优化用户信息处理

- 在App.vue中启用登录功能
- 为未设置昵称的用户添加默认显示文本
- 根据环境版本控制用户信息校验逻辑
- 简化微信登录按钮文本
- 修改store.js中的用户信息处理逻辑
master
前端-胡立永 1 day ago
parent
commit
43fb0666c9
5 changed files with 31 additions and 12 deletions
  1. +1
    -1
      App.vue
  2. +11
    -0
      pages/index/agreement.vue
  3. +1
    -1
      pages/index/index.vue
  4. +1
    -1
      pages_order/auth/wxLogin.vue
  5. +17
    -9
      store/store.js

+ 1
- 1
App.vue View File

@ -5,7 +5,7 @@
this.$store.commit('initConfig')
// this.$store.commit('getBanner')
// this.$store.commit('getArticleList')
// this.$store.commit('getProblemList')
this.$store.commit('login')
},
onHide: function() {}
}


+ 11
- 0
pages/index/agreement.vue View File

@ -96,6 +96,8 @@
</template>
<script>
const accountInfo = wx.getAccountInfoSync();
let envVersion = accountInfo.miniProgram.envVersion;
import { mapState } from 'vuex'
export default {
data() {
@ -157,6 +159,15 @@
return
}
if(['release'].includes(envVersion)){
if(!this.userInfo.nickName || !this.userInfo.headImage){
uni.navigateTo({
url: '/pages_order/auth/wxUserInfo'
})
return
}
}
this.$store.commit('getUserInfo', () => {
uni.navigateTo({
url: '/pages/index/index'


+ 1
- 1
pages/index/index.vue View File

@ -10,7 +10,7 @@
<view class="info">
<view class="title">
{{ userInfo.nickName }}
{{ userInfo.nickName || '尊敬的用户 你好' }}
</view>
<view class="list">
欢迎来到百富门的世界


+ 1
- 1
pages_order/auth/wxLogin.vue View File

@ -12,7 +12,7 @@
<image src="../static/auth/wx.png" mode=""></image>
</view>
<view class="">
微信登录
登录
</view>
</view>
<view class="btn b2"


+ 17
- 9
store/store.js View File

@ -5,6 +5,10 @@ Vue.use(Vuex); //vue的插件机制
import api from '@/api/api.js'
const accountInfo = wx.getAccountInfoSync();
let envVersion = accountInfo.miniProgram.envVersion;
//Vuex.Store 构造器选项
const store = new Vuex.Store({
state: {
@ -64,15 +68,19 @@ const store = new Vuex.Store({
state.userInfo = res.result.userInfo
uni.setStorageSync('token', res.result.token)
if(!state.userInfo.nickName || !state.userInfo.headImage){
uni.navigateTo({
url: '/pages_order/auth/wxUserInfo'
})
}else{
uni.navigateTo({
url: '/pages/index/index'
})
}
// if(!['release'].includes(envVersion)){
// return
// }
// if(!state.userInfo.nickName || !state.userInfo.headImage){
// uni.navigateTo({
// url: '/pages_order/auth/wxUserInfo'
// })
// }else{
// uni.navigateTo({
// url: '/pages/index/index'
// })
// }
})
}
})


Loading…
Cancel
Save