Liuyi
2024-09-29 0560eed4a389f806dc3254a526e929e8476c868a
App.vue
@@ -1,10 +1,21 @@
<script setup>
   import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
   // import {getToken} from './util/auth';
   import { wxLoginApi } from './api/index.js'
   onLaunch(() => {
     console.log("App Launch");
     //判断是否登录
      // let token = getToken()
      if(!uni.getStorageSync('openId')){
         wx.login({
            success:async (res1)=>{
               uni.setStorageSync('code',res1.code)
               await wxLoginApi({code:res1.code}).then((res2) =>{
               uni.setStorageSync('openId',res2.data.userId)
               uni.setStorageSync('token',res2.data.token)
              })
            },
            fail:(e) =>{
               console.log(e)
            }
         })
      }
   });
   onShow(() => {
     console.log("App Show");
@@ -14,6 +25,5 @@
   });
</script>
<style>
   /*每个页面公共css */
<style lang='scss'>
</style>