update uniapp

This commit is contained in:
全栈小学生 2024-06-15 15:43:09 +08:00
parent 96533ab7b0
commit 8a1dea9ea9
4 changed files with 119 additions and 64 deletions

View File

@ -1,22 +1,20 @@
<script setup lang="ts">
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
import manifest from '@/manifest.json'
import { launchInterceptor } from '@/utils/interceptor'
import { getToken, isWeixinBrowser, getSiteId } from '@/utils/common'
import useMemberStore from '@/stores/member'
import useConfigStore from '@/stores/config'
import useSystemStore from '@/stores/system'
import { useLogin } from '@/hooks/useLogin'
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
import { launchInterceptor } from '@/utils/interceptor'
import { getToken, isWeixinBrowser, getSiteId } from '@/utils/common'
import useMemberStore from '@/stores/member'
import useConfigStore from '@/stores/config'
import useSystemStore from '@/stores/system'
import { useLogin } from '@/hooks/useLogin'
import { useShare } from '@/hooks/useShare'
onLaunch(async (data) => {
onLaunch(async(data) => {
//
launchInterceptor()
//
launchInterceptor()
uni.removeStorageSync('isWatchShare')
// #ifdef H5
uni.getSystemInfoSync().platform == 'ios' && (uni.setStorageSync('initUrl', location.href))
// #ifdef H5
uni.getSystemInfoSync().platform == 'ios' && (uni.setStorageSync('initUrl', location.href))
//
window.parent.postMessage(JSON.stringify({
@ -28,11 +26,11 @@
window.addEventListener('message', event => {
try {
let data = {
type :''
type: ''
};
if(typeof event.data == 'string') {
if (typeof event.data == 'string') {
data = JSON.parse(event.data)
}else if(typeof event.data == 'object') {
} else if (typeof event.data == 'object') {
data = event.data
}
if (data.type && data.type == 'appOnReady') {
@ -46,48 +44,68 @@
}
}, false);
// id
if (process.env.NODE_ENV == 'development' && (getSiteId(uni.getStorageSync('wap_site_id') || import.meta.env.VITE_SITE_ID) === '')) return;
// #endif
// id
if (process.env.NODE_ENV == 'development' && (getSiteId(uni.getStorageSync('wap_site_id') || import.meta.env.VITE_SITE_ID) === '')) return;
const configStore = useConfigStore()
await configStore.getLoginConfig()
const { wechatInit } = useShare()
wechatInit()
// #endif
useSystemStore().getMapFn()
useSystemStore().getSiteInfoFn()
const configStore = useConfigStore()
await configStore.getTabbarConfig()
await configStore.getLoginConfig()
// tabbar
uni.hideTabBar()
useSystemStore().getMapFn()
useSystemStore().getSiteInfoFn()
//
if (getToken()) {
const memberStore = useMemberStore()
await memberStore.setToken(getToken())
}
try {
// tabbar
uni.hideTabBar()
} catch (e) {
if (!getToken()) {
const login = useLogin()
//
// #ifdef MP
login.getAuthCode()
// #endif
// #ifdef H5
if (isWeixinBrowser()) {
data.query.code ? login.authLogin(data.query.code) : login.getAuthCode('snsapi_userinfo')
}
// #endif
}
})
}
onShow(() => {
})
//
if (getToken()) {
const memberStore = useMemberStore()
await memberStore.setToken(getToken())
onHide(() => {
})
setTimeout(() => {
if (!uni.getStorageSync('openid')) {
const memberInfo = useMemberStore().info
// #ifdef MP-WEIXIN
memberInfo && memberInfo.weapp_openid && uni.setStorageSync('openid', memberInfo.weapp_openid)
// #endif
// #ifdef H5
isWeixinBrowser() && memberInfo && memberInfo.wx_openid && uni.setStorageSync('openid', memberInfo.wx_openid)
// #endif
}
}, 1000)
}
if (!getToken()) {
const login = useLogin()
//
// #ifdef MP
login.getAuthCode()
// #endif
// #ifdef H5
if (isWeixinBrowser()) {
data.query.code ? login.authLogin(data.query.code) : login.getAuthCode('snsapi_userinfo')
}
// #endif
}
})
onShow(() => {
})
onHide(() => {
})
</script>
<style>
uni-page-head {
display: none!important;
}
uni-page-head {
display: none !important;
}
</style>

View File

@ -61,23 +61,44 @@
import topTabbar from '@/components/top-tabbar/top-tabbar.vue'
import useDiyStore from '@/app/stores/diy';
import { ref, onMounted, nextTick, computed } from 'vue';
import { getLocation } from '@/utils/common';
import { ref, onMounted, nextTick, computed, watch } from 'vue';
import { useRouter } from 'vue-router';
import { getLocation } from '@/utils/common';
import Sortable from 'sortablejs';
import { range } from 'lodash-es';
import { onPageScroll } from '@dcloudio/uni-app'
import useConfigStore from '@/stores/config'
const props = defineProps(['data','pullDownRefreshCount']);
const diyStore = useDiyStore();
const data = computed(() => {
if (diyStore.mode == 'decorate') {
return diyStore;
} else {
return props.data;
}
const router = useRouter();
const data = computed(()=>{
if (diyStore.mode == 'decorate') {
return diyStore;
} else {
return props.data;
}
})
// - - start
// #ifdef H5
watch(() => router.currentRoute.value, (newRoute) => {
if(newRoute.path != "/addon/shop/pages/index"){
diyStore.topFixedStatus = 'home'
}
});
// #endif
// #ifdef MP
wx.onAppRoute(function(res) {
if(res.path != "addon/shop/pages/index"){
diyStore.topFixedStatus = 'home'
}
});
// #endif
// - - end
const tabbarAddonName = computed(() => {
return useConfigStore().addon;
})

View File

@ -1,5 +1,5 @@
{
"name" : "wx59e6ba6050bbe7bc",
"name" : "",
"appid" : "__UNI__ED923AB",
"description" : "",
"versionName" : "1.0.0",

View File

@ -86,6 +86,9 @@
{
"path": "app/pages/member/commission",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.commission%"
},
"needLogin": true
@ -93,6 +96,9 @@
{
"path": "app/pages/member/balance",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.balance%"
},
"needLogin": true
@ -128,10 +134,10 @@
{
"path": "app/pages/member/index",
"style": {
"navigationBarTitleText": "%pages.member.index%",
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.index%",
"usingComponents": {
"diy-group": "../../../../addon/components/diy/group/index",
"fixed-group": "../../../../addon/components/fixed/group/index"
@ -152,10 +158,20 @@
{
"path": "app/pages/member/point",
"style": {
// #ifndef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.point%"
},
"needLogin": true
},
{
"path": "app/pages/member/point_detail",
"style": {
"navigationBarTitleText": "%pages.member.point_detail%"
},
"needLogin": true
},
{
"path": "app/pages/member/account",
"style": {