mirror of
https://gitee.com/niucloud-team/niucloud.git
synced 2025-12-14 10:32:49 +00:00
update uniapp
This commit is contained in:
parent
96533ab7b0
commit
8a1dea9ea9
@ -1,22 +1,20 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
|
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
|
||||||
import manifest from '@/manifest.json'
|
import { launchInterceptor } from '@/utils/interceptor'
|
||||||
import { launchInterceptor } from '@/utils/interceptor'
|
import { getToken, isWeixinBrowser, getSiteId } from '@/utils/common'
|
||||||
import { getToken, isWeixinBrowser, getSiteId } from '@/utils/common'
|
import useMemberStore from '@/stores/member'
|
||||||
import useMemberStore from '@/stores/member'
|
import useConfigStore from '@/stores/config'
|
||||||
import useConfigStore from '@/stores/config'
|
import useSystemStore from '@/stores/system'
|
||||||
import useSystemStore from '@/stores/system'
|
import { useLogin } from '@/hooks/useLogin'
|
||||||
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({
|
window.parent.postMessage(JSON.stringify({
|
||||||
@ -28,11 +26,11 @@
|
|||||||
window.addEventListener('message', event => {
|
window.addEventListener('message', event => {
|
||||||
try {
|
try {
|
||||||
let data = {
|
let data = {
|
||||||
type :''
|
type: ''
|
||||||
};
|
};
|
||||||
if(typeof event.data == 'string') {
|
if (typeof event.data == 'string') {
|
||||||
data = JSON.parse(event.data)
|
data = JSON.parse(event.data)
|
||||||
}else if(typeof event.data == 'object') {
|
} else if (typeof event.data == 'object') {
|
||||||
data = event.data
|
data = event.data
|
||||||
}
|
}
|
||||||
if (data.type && data.type == 'appOnReady') {
|
if (data.type && data.type == 'appOnReady') {
|
||||||
@ -46,48 +44,68 @@
|
|||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
// 缺少站点id,拦截
|
// 缺少站点id,拦截
|
||||||
if (process.env.NODE_ENV == 'development' && (getSiteId(uni.getStorageSync('wap_site_id') || import.meta.env.VITE_SITE_ID) === '')) return;
|
if (process.env.NODE_ENV == 'development' && (getSiteId(uni.getStorageSync('wap_site_id') || import.meta.env.VITE_SITE_ID) === '')) return;
|
||||||
// #endif
|
|
||||||
|
|
||||||
const configStore = useConfigStore()
|
const { wechatInit } = useShare()
|
||||||
await configStore.getLoginConfig()
|
wechatInit()
|
||||||
|
// #endif
|
||||||
|
|
||||||
useSystemStore().getMapFn()
|
const configStore = useConfigStore()
|
||||||
useSystemStore().getSiteInfoFn()
|
await configStore.getTabbarConfig()
|
||||||
|
await configStore.getLoginConfig()
|
||||||
|
|
||||||
// 隐藏tabbar
|
useSystemStore().getMapFn()
|
||||||
uni.hideTabBar()
|
useSystemStore().getSiteInfoFn()
|
||||||
|
|
||||||
// 判断是否已登录
|
try {
|
||||||
if (getToken()) {
|
// 隐藏tabbar
|
||||||
const memberStore = useMemberStore()
|
uni.hideTabBar()
|
||||||
await memberStore.setToken(getToken())
|
} 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>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
uni-page-head {
|
uni-page-head {
|
||||||
display: none!important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -61,23 +61,44 @@
|
|||||||
import topTabbar from '@/components/top-tabbar/top-tabbar.vue'
|
import topTabbar from '@/components/top-tabbar/top-tabbar.vue'
|
||||||
|
|
||||||
import useDiyStore from '@/app/stores/diy';
|
import useDiyStore from '@/app/stores/diy';
|
||||||
import { ref, onMounted, nextTick, computed } from 'vue';
|
import { ref, onMounted, nextTick, computed, watch } from 'vue';
|
||||||
import { getLocation } from '@/utils/common';
|
import { useRouter } from 'vue-router';
|
||||||
|
import { getLocation } from '@/utils/common';
|
||||||
import Sortable from 'sortablejs';
|
import Sortable from 'sortablejs';
|
||||||
import { range } from 'lodash-es';
|
import { range } from 'lodash-es';
|
||||||
import { onPageScroll } from '@dcloudio/uni-app'
|
import { onPageScroll } from '@dcloudio/uni-app'
|
||||||
import useConfigStore from '@/stores/config'
|
import useConfigStore from '@/stores/config'
|
||||||
|
|
||||||
const props = defineProps(['data','pullDownRefreshCount']);
|
const props = defineProps(['data','pullDownRefreshCount']);
|
||||||
const diyStore = useDiyStore();
|
const diyStore = useDiyStore();
|
||||||
|
const router = useRouter();
|
||||||
const data = computed(() => {
|
const data = computed(()=>{
|
||||||
if (diyStore.mode == 'decorate') {
|
if (diyStore.mode == 'decorate') {
|
||||||
return diyStore;
|
return diyStore;
|
||||||
} else {
|
} else {
|
||||||
return props.data;
|
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(() => {
|
const tabbarAddonName = computed(() => {
|
||||||
return useConfigStore().addon;
|
return useConfigStore().addon;
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name" : "wx59e6ba6050bbe7bc",
|
"name" : "",
|
||||||
"appid" : "__UNI__ED923AB",
|
"appid" : "__UNI__ED923AB",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "1.0.0",
|
"versionName" : "1.0.0",
|
||||||
|
|||||||
@ -86,6 +86,9 @@
|
|||||||
{
|
{
|
||||||
"path": "app/pages/member/commission",
|
"path": "app/pages/member/commission",
|
||||||
"style": {
|
"style": {
|
||||||
|
// #ifndef H5
|
||||||
|
"navigationStyle": "custom",
|
||||||
|
// #endif
|
||||||
"navigationBarTitleText": "%pages.member.commission%"
|
"navigationBarTitleText": "%pages.member.commission%"
|
||||||
},
|
},
|
||||||
"needLogin": true
|
"needLogin": true
|
||||||
@ -93,6 +96,9 @@
|
|||||||
{
|
{
|
||||||
"path": "app/pages/member/balance",
|
"path": "app/pages/member/balance",
|
||||||
"style": {
|
"style": {
|
||||||
|
// #ifndef H5
|
||||||
|
"navigationStyle": "custom",
|
||||||
|
// #endif
|
||||||
"navigationBarTitleText": "%pages.member.balance%"
|
"navigationBarTitleText": "%pages.member.balance%"
|
||||||
},
|
},
|
||||||
"needLogin": true
|
"needLogin": true
|
||||||
@ -128,10 +134,10 @@
|
|||||||
{
|
{
|
||||||
"path": "app/pages/member/index",
|
"path": "app/pages/member/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "%pages.member.index%",
|
|
||||||
// #ifndef H5
|
// #ifndef H5
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
// #endif
|
// #endif
|
||||||
|
"navigationBarTitleText": "%pages.member.index%",
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"diy-group": "../../../../addon/components/diy/group/index",
|
"diy-group": "../../../../addon/components/diy/group/index",
|
||||||
"fixed-group": "../../../../addon/components/fixed/group/index"
|
"fixed-group": "../../../../addon/components/fixed/group/index"
|
||||||
@ -152,10 +158,20 @@
|
|||||||
{
|
{
|
||||||
"path": "app/pages/member/point",
|
"path": "app/pages/member/point",
|
||||||
"style": {
|
"style": {
|
||||||
|
// #ifndef H5
|
||||||
|
"navigationStyle": "custom",
|
||||||
|
// #endif
|
||||||
"navigationBarTitleText": "%pages.member.point%"
|
"navigationBarTitleText": "%pages.member.point%"
|
||||||
},
|
},
|
||||||
"needLogin": true
|
"needLogin": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "app/pages/member/point_detail",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "%pages.member.point_detail%"
|
||||||
|
},
|
||||||
|
"needLogin": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "app/pages/member/account",
|
"path": "app/pages/member/account",
|
||||||
"style": {
|
"style": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user