ll
liukangdong
2025-01-22 a5f40b4c2590a3d61592f1918d689d4932545248
h5/pages/login.vue
@@ -29,7 +29,9 @@
      loginPost,
      getUserInfo,
      sendSMsPost,
      ywWxAuthorize
      ywWxAuthorize,
      getRecordByUserPoint
   } from '@/api'
   import {
      mapState,
@@ -45,11 +47,19 @@
               code: ''
            },
            downTime: 0,
            code: '111'
            // code: ''
            code: ''
         }
      },
      onLoad(option) {
         console.log('onLoad');
         // https://zhcg.fnwtzx.com/#/pages/login?type=0&ywid=ywid
         if (option.ywid || option.ywid == 0) {
            uni.setStorageSync('ywinfo', {
               type: option.type,
               ywid: option.ywid
            })
         }
      },
      onShow() {
         // return
         var that = this
@@ -66,19 +76,31 @@
            ywWxAuthorize({
               code: code || this.code
            }).then(res => {
               if (res.code === 200) {
               if (res.code === 200) {
                  console.log('res', res);
                  that.$store.commit('setOpenId', res.data.openid)
                  if (res.data.token && res.data.token != '') {
                  if (res.data.token && res.data.token != '') {
                     that.$store.commit('setToken', res.data.token)
                     getUserInfo().then(ress => {
                        that.$store.commit('setUserInfo', ress.data)
                     })
                     setTimeout(() => {
                        uni.redirectTo({
                           url: "/pages/index"
                     const ywinfo = uni.getStorageSync('ywinfo') || {}
                     if (ywinfo.ywid && (ywinfo.type || ywinfo.type == 0)) {
                        getRecordByUserPoint({pointCode: ywinfo.ywid}).then(res => {
                           if(res.data && res.data.id){
                              uni.setStorageSync('ywinfo', {})
                              uni.redirectTo({
                                 url: "/pages/polling/point?id=" + res.data.id
                              })
                           }
                        })
                     }, 300)
                     } else {
                        setTimeout(() => {
                           uni.redirectTo({
                              url: "/pages/index"
                           })
                        }, 300)
                     }
                  }
               }
            })
@@ -92,12 +114,6 @@
         }
      },
      // onBackPress(options) {
      //    uni.redirectTo({
      //       url: '/pages/login/login'
      //    })
      //    return true
      // },
      methods: {
         ...mapMutations(["setToken", "setUserInfo"]),
         onLogin() {
@@ -122,10 +138,24 @@
                  this.setToken(res.data)
                  this.showToast('登录成功')
                  getUserInfo().then(ress => {
                     this.setUserInfo(ress.data)
                     uni.redirectTo({
                        url: "/pages/index"
                     })
                     this.setUserInfo(ress.data)
                     const ywinfo = uni.getStorageSync('ywinfo') || {}
                     if (ywinfo.ywid && (ywinfo.type || ywinfo.type == 0)) {
                     getRecordByUserPoint({pointCode: ywinfo.ywid}).then(res => {
                        getRecordByUserPoint({pointCode: ywinfo.ywid}).then(res => {
                           if(res.data && res.data.id){
                              uni.setStorageSync('ywinfo', {})
                              uni.redirectTo({
                                 url: "/pages/polling/point?id=" + res.data.id
                              })
                           }
                        })
                     })
                     } else {
                        uni.redirectTo({
                           url: "/pages/index"
                        })
                     }
                  })
               }
            })