From 4e3e18cdb0d75c098b68353ef8c86cdd7c0f79b2 Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期四, 21 八月 2025 15:27:34 +0800
Subject: [PATCH] 111
---
small-program/App.vue | 67 ++++++++++++++++++++++++++++++++-
1 files changed, 64 insertions(+), 3 deletions(-)
diff --git a/small-program/App.vue b/small-program/App.vue
index a981323..9bfe61a 100644
--- a/small-program/App.vue
+++ b/small-program/App.vue
@@ -1,7 +1,69 @@
<script>
+ import { mapState } from 'vuex'
export default {
+ computed: {
+ ...mapState(['userInfo','openid'])
+ },
onLaunch: function() {
- console.log('App Launch')
+ var that = this;
+ if (!this.openid || this.openid =='') {
+ uni.login({
+ provider: 'weixin',
+ success: async function (loginRes) {
+ let { code } = loginRes;
+ let res = await that.$u.api.wxLogin({ code })
+ if (res && res.code === 200) {
+ that.$store.commit('setToken', res.data.token)
+ that.$store.commit('setOpenid', res.data.openid)
+ that.$store.commit('setUserInfo', res.data.member)
+ uni.getLocation({
+ type: 'wgs84',
+ success: (addr) => {
+ that.$store.commit('setPosition', { latitude: addr.latitude, longitude: addr.longitude })
+ that.$isResolve()
+ },
+ fail: (err) => {
+ console.error('鑾峰彇浣嶇疆澶辫触', err);
+ that.$isResolve()
+ }
+ });
+
+ }
+ }
+ });
+ } else {
+ var that = this
+ let res = this.$u.api.getMemberInfo({}).then(res =>{
+ if (res && res.code === 200) {
+ that.$store.commit('setUserInfo', res.data)
+ uni.getLocation({
+ type: 'wgs84',
+ success: (addr) => {
+ that.$store.commit('setPosition', { latitude: addr.latitude, longitude: addr.longitude })
+ that.$isResolve()
+ },
+ fail: (err) => {
+ console.error('鑾峰彇浣嶇疆澶辫触', err);
+ that.$isResolve()
+ }
+ });
+ } else {
+ that.$store.commit('setToken','')
+ that.$store.commit('setUserInfo',{})
+ uni.getLocation({
+ type: 'wgs84',
+ success: (addr) => {
+ that.$store.commit('setPosition', { latitude: addr.latitude, longitude: addr.longitude })
+ that.$isResolve()
+ },
+ fail: (err) => {
+ console.error('鑾峰彇浣嶇疆澶辫触', err);
+ that.$isResolve()
+ }
+ });
+ }
+ })
+ }
},
onShow: function() {
console.log('App Show')
@@ -13,6 +75,5 @@
</script>
<style lang="scss">
- /* 娉ㄦ剰瑕佸啓鍦ㄧ涓�琛岋紝鍚屾椂缁檚tyle鏍囩鍔犲叆lang="scss"灞炴�� */
- @import "uview-ui/index.scss";
+ @import "uview-ui/index.scss";
</style>
\ No newline at end of file
--
Gitblit v1.9.3