| | |
| | | <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"); |
| | |
| | | }); |
| | | </script> |
| | | |
| | | <style> |
| | | /*每个页面公共css */ |
| | | <style lang='scss'> |
| | | </style> |