From 4a0caa2a9251457f0b5a9c73bffdf2c4b5e1e1d8 Mon Sep 17 00:00:00 2001 From: Liuyi <candymxq888@outlook.com> Date: 星期六, 23 十一月 2024 16:50:58 +0800 Subject: [PATCH] 添加运维登录页 --- App.vue | 68 +++++++++++++++------------------ 1 files changed, 31 insertions(+), 37 deletions(-) diff --git a/App.vue b/App.vue index 1b3e91d..f3f4216 100644 --- a/App.vue +++ b/App.vue @@ -1,35 +1,35 @@ <script setup> import { onLaunch, onShow, onHide } from "@dcloudio/uni-app"; - import { wxLoginApi } from './api/index.js' + // import { wxLoginApi } from './api/index.js' - //用户打开小程序默认授权 - function wxLogin(){ - // uni.removeStorageSync('openId'); - if(!uni.getStorageSync('openId')){ - wx.login({ - success:async (res1)=>{ - //存储微信登录的code,调用后端接口传递code参数,返回openid(也就是userId)存储到本地,通过判断本地是否存在openId,存在表示已登录 - uni.setStorageSync('code',res1.code) - await wxLoginApi({code:res1.code}).then((res2) =>{ - if(res2.code == 200){ - uni.setStorageSync('openId',res2.data.userId) - uni.setStorageSync('token',res2.data.token) - }else{ - console.log('登录接口调用失败') - } - }) - }, - fail:(e) =>{ - uni.showToast({ - title: '微信登录失败,请退出重试!', - duration: 2000, - icon:'fail' - }); - console.log(e) - } - }) - } - } + // //用户打开小程序默认授权 + // function wxLogin(){ + // // uni.removeStorageSync('openId'); + // if(!uni.getStorageSync('openId')){ + // wx.login({ + // success:async (res1)=>{ + // //存储微信登录的code,调用后端接口传递code参数,返回openid(也就是userId)存储到本地,通过判断本地是否存在openId,存在表示已登录 + // uni.setStorageSync('code',res1.code) + // await wxLoginApi({code:res1.code}).then((res2) =>{ + // if(res2.code == 200){ + // uni.setStorageSync('openId',res2.data.userId) + // uni.setStorageSync('token',res2.data.token) + // }else{ + // console.log('登录接口调用失败') + // } + // }) + // }, + // fail:(e) =>{ + // uni.showToast({ + // title: '微信登录失败,请退出重试!', + // duration: 2000, + // icon:'fail' + // }); + // console.log(e) + // } + // }) + // } + // } // //申请获取用户位置权限 // let userLocation = { // lat:'', @@ -97,15 +97,9 @@ // } // } onLaunch(async() => { - await wxLogin() + // await wxLogin() // await getUserLocation() - console.log('进入项目启动页APP.vue了') - }); - onShow(() => { - console.log("App Show"); - }); - onHide(() => { - console.log("App Hide"); + console.log('进入APP.vue') }); </script> -- Gitblit v1.9.3