quanyawei
2023-11-15 6f922e8b81cacf9d6fd99ae7aeba06e8c6370e4f
App.vue
@@ -3,7 +3,6 @@
      getDic
   } from '@/utils/login.js' // 配置文件
   import store from '@/store/index.js'
   import routingIntercept from '@/utils/permission.js'
   import {
      httpPost,
      httpGet
@@ -13,22 +12,22 @@
         console.log('optionsonShow', options)
         if (options.scene === 1007 || options.scene === 1014 || options.scene === 1008) {
            // 通过单人聊天会话分享进入
            this.getWXCode()
            // this.getWXCode()
         }
      },
      onLaunch() {
         // 自动登录检测
         let token = uni.getStorageSync('token')
         console.log('apptoken', token)
         console.log('apptoken1', !token)
         if (!token) {
            uni.login({
               provider: 'weixin',
               success: loginRes => {
                  console.log('loginRes', loginRes)
                  console.log('loginRes1', loginRes)
                  httpGet('/AppUser/wx/login', {
                     'code': loginRes.code
                  }).then(result => {
                     routingIntercept()
                     console.log('AppUser1', result)
                     try {
                        if (result.data.code === 0) {
                           uni.clearStorageSync()
@@ -79,59 +78,53 @@
          *
          */
         getWXCode() {
            let token = uni.getStorageSync('token')
            console.log('apptoken', token)
            if (!token) {
               uni.login({
                  provider: 'weixin',
                  success: loginRes => {
                     console.log('loginRes', loginRes)
                     httpGet('/AppUser/wx/login', {
                        'code': loginRes.code
                     }).then(result => {
                        routingIntercept()
                        try {
                           if (result.data.code === 0) {
                              uni.clearStorageSync()
                              uni.setStorageSync('userInfor', JSON.stringify(result.data))
                              uni.setStorageSync('tonken', result.data.token)
                              uni.setStorageSync('openId', result.data.openId)
                              getDic()
                              this.$isResolve()
                           } else {
                              uni.clearStorageSync()
                              uni.setStorageSync('openId', result.data.openId)
                              uni.showModal({
                                 title: '未登录',
                                 content: '您未登录,需要登录后才能继续',
                                 showCancel: false,
                                 confirmText: '确定',
                                 success: res => {
                                    if (res.confirm) {
                                       uni.reLaunch({
                                          url: '/pages/login/login',
                                       })
                                    }
                                 },
                              })
                              this.$isResolve()
                           }
                        } catch (e) {
                           console.error(e)
            uni.login({
               provider: 'weixin',
               success: loginRes => {
                  console.log('loginRes2', loginRes)
                  httpGet('/AppUser/wx/login', {
                     'code': loginRes.code
                  }).then(result => {
                     console.log('AppUser2', result)
                     try {
                        if (result.data.code === 0) {
                           uni.clearStorageSync()
                           uni.setStorageSync('userInfor', JSON.stringify(result.data))
                           uni.setStorageSync('tonken', result.data.token)
                           uni.setStorageSync('openId', result.data.openId)
                           getDic()
                           this.$isResolve()
                        } else {
                           uni.clearStorageSync()
                           uni.setStorageSync('openId', result.data.openId)
                           uni.showModal({
                              title: '未登录',
                              content: '您未登录,需要登录后才能继续',
                              showCancel: false,
                              confirmText: '确定',
                              success: res => {
                                 if (res.confirm) {
                                    uni.reLaunch({
                                       url: '/pages/login/login',
                                    })
                                 }
                              },
                           })
                           this.$isResolve()
                        }
                     }).catch(errors => {
                        console.log('appdddd', errors)
                        uni.showToast({
                           title: errors,
                           icon: 'none',
                        })
                        this.$isResolve()
                     } catch (e) {
                        console.error(e)
                     }
                  }).catch(errors => {
                     console.log('appdddd2', errors)
                     uni.showToast({
                        title: errors,
                        icon: 'none',
                     })
                  }
               })
            } else {
               this.$isResolve()
            }
                     this.$isResolve()
                  })
               }
            })
         },
         getLogin(data) {
            // 调用接口。将登录code传给后端进行判断
@@ -165,6 +158,7 @@
   html {
      height: 100%;
      width: 750rpx;
   }
   .formItemContent {