1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| <script setup>
| import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
| import { wxLoginApi } from './api/index.js'
| onLaunch(() => {
| uni.removeStorageSync('openId');
| if(!uni.getStorageSync('openId')){
| wx.login({
| success:async (res1)=>{
| //存储微信登录的code
| 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");
| });
| onHide(() => {
| console.log("App Hide");
| });
| </script>
|
| <style lang='scss'>
| </style>
|
|