From a1dff2a58c62cc273d320d00a9c8faed7bf12a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=A8=E6=A0=88=E5=B0=8F=E5=AD=A6=E7=94=9F?= <1518079521@qq.com> Date: Wed, 21 Jun 2023 16:55:50 +0800 Subject: [PATCH] update uni-app --- uni-app/components/app-link/app-link.vue | 1 + uni-app/components/diy/graphic-nav/index.vue | 2 +- uni-app/components/fixed/group/index.scss | 0 uni-app/components/fixed/group/index.vue | 15 ++++ uni-app/pages.json | 3 +- uni-app/pages/index/develop.vue | 8 +-- uni-app/pages/index/diy.vue | 69 +++++++++++++------ uni-app/pages/index/index.vue | 72 ++++++++++++++------ uni-app/pages/member/index.vue | 68 ++++++++++++------ uni-app/utils/common.ts | 2 +- uni-app/utils/request.ts | 2 +- 11 files changed, 171 insertions(+), 71 deletions(-) create mode 100644 uni-app/components/fixed/group/index.scss create mode 100644 uni-app/components/fixed/group/index.vue diff --git a/uni-app/components/app-link/app-link.vue b/uni-app/components/app-link/app-link.vue index 35b2c9fc5..57ad635ac 100644 --- a/uni-app/components/app-link/app-link.vue +++ b/uni-app/components/app-link/app-link.vue @@ -6,6 +6,7 @@ + \ No newline at end of file diff --git a/uni-app/pages.json b/uni-app/pages.json index 966f9bf3f..33a6a9526 100644 --- a/uni-app/pages.json +++ b/uni-app/pages.json @@ -296,7 +296,8 @@ "easycom": { "custom": { "^u-(.*)": "uview-plus/components/u-$1/u-$1.vue", - "diy-(\W.*)": "@/components/diy/$1/index.vue" + "diy-(\W.*)": "@/components/diy/$1/index.vue", + "fixed-(\W.*)": "@/components/fixed/$1/index.vue" } } } \ No newline at end of file diff --git a/uni-app/pages/index/develop.vue b/uni-app/pages/index/develop.vue index f9654050e..ee778b50c 100644 --- a/uni-app/pages/index/develop.vue +++ b/uni-app/pages/index/develop.vue @@ -41,10 +41,10 @@ uni.showToast({ title: t('pleaseEnterNumber'), icon: 'none' }); return; } - if (formData.siteId > 9999999) { - uni.showToast({ title: t('maximumCannotExceed') + '9999999', icon: 'none' }); - return; - } + // if (formData.siteId > 9999999) { + // uni.showToast({ title: t('maximumCannotExceed') + '9999999', icon: 'none' }); + // return; + // } uni.setStorageSync('wap_site_id', formData.siteId); diff --git a/uni-app/pages/index/diy.vue b/uni-app/pages/index/diy.vue index e77d311c9..d47db6cbb 100644 --- a/uni-app/pages/index/diy.vue +++ b/uni-app/pages/index/diy.vue @@ -1,10 +1,24 @@ @@ -62,22 +76,35 @@ name: name.value }).then((res : any) => { if (res.data.value) { - let sources = JSON.parse(res.data.value); - diyData.global = sources.global; - diyData.value = sources.value; - diyData.value.forEach((item, index) => { - item.pageStyle = ''; - if (item.pageBgColor) item.pageStyle += 'background-color:' + item.pageBgColor + ';'; - if (item.margin) { - item.pageStyle += 'padding-top:' + item.margin.top * 2 + 'rpx' + ';'; - item.pageStyle += 'padding-bottom:' + item.margin.bottom * 2 + 'rpx' + ';'; - item.pageStyle += 'padding-right:' + item.margin.both * 2 + 'rpx' + ';'; - item.pageStyle += 'padding-left:' + item.margin.both * 2 + 'rpx' + ';'; - } - }); - uni.setNavigationBarTitle({ - title: diyData.global.title - }) + let data = res.data; + diyData.mode = data.mode; + + if (data.mode == 'diy') { + let sources = JSON.parse(res.data.value); + diyData.global = sources.global; + diyData.value = sources.value; + diyData.value.forEach((item, index) => { + item.pageStyle = ''; + if (item.pageBgColor) item.pageStyle += 'background-color:' + item.pageBgColor + ';'; + if (item.margin) { + item.pageStyle += 'padding-top:' + item.margin.top * 2 + 'rpx' + ';'; + item.pageStyle += 'padding-bottom:' + item.margin.bottom * 2 + 'rpx' + ';'; + item.pageStyle += 'padding-right:' + item.margin.both * 2 + 'rpx' + ';'; + item.pageStyle += 'padding-left:' + item.margin.both * 2 + 'rpx' + ';'; + } + }); + uni.setNavigationBarTitle({ + title: diyData.global.title + }) + } else if (data.mode == 'fixed') { + // 固定模板 + let sources = JSON.parse(res.data.value); + diyData.title = data.title; + diyData.value = sources; + uni.setNavigationBarTitle({ + title: diyData.title + }) + } } let share = res.data.share ? JSON.parse(res.data.share) : null; diff --git a/uni-app/pages/index/index.vue b/uni-app/pages/index/index.vue index a6cbd5ff5..3601004dc 100644 --- a/uni-app/pages/index/index.vue +++ b/uni-app/pages/index/index.vue @@ -1,10 +1,24 @@ @@ -25,6 +39,7 @@ const loading = ref(true); const diyStore = useDiyStore(); + // 自定义页面 数据 const diyData = reactive({ global: {}, value: [] @@ -57,22 +72,37 @@ name: 'DIY_INDEX' }).then((res : any) => { if (res.data.value) { - let sources = JSON.parse(res.data.value); - diyData.global = sources.global; - diyData.value = sources.value; - diyData.value.forEach((item, index) => { - item.pageStyle = ''; - if (item.pageBgColor) item.pageStyle += 'background-color:' + item.pageBgColor + ';'; - if (item.margin) { - item.pageStyle += 'padding-top:' + item.margin.top * 2 + 'rpx' + ';'; - item.pageStyle += 'padding-bottom:' + item.margin.bottom * 2 + 'rpx' + ';'; - item.pageStyle += 'padding-right:' + item.margin.both * 2 + 'rpx' + ';'; - item.pageStyle += 'padding-left:' + item.margin.both * 2 + 'rpx' + ';'; - } - }); - uni.setNavigationBarTitle({ - title: diyData.global.title - }) + let data = res.data; + diyData.mode = data.mode; + if (data.mode == 'diy') { + // 自定义模板 + let sources = JSON.parse(data.value); + diyData.title = sources.title; + diyData.global = sources.global; + diyData.value = sources.value; + diyData.value.forEach((item, index) => { + item.pageStyle = ''; + if (item.pageBgColor) item.pageStyle += 'background-color:' + item.pageBgColor + ';'; + if (item.margin) { + item.pageStyle += 'padding-top:' + item.margin.top * 2 + 'rpx' + ';'; + item.pageStyle += 'padding-bottom:' + item.margin.bottom * 2 + 'rpx' + ';'; + item.pageStyle += 'padding-right:' + item.margin.both * 2 + 'rpx' + ';'; + item.pageStyle += 'padding-left:' + item.margin.both * 2 + 'rpx' + ';'; + } + }); + uni.setNavigationBarTitle({ + title: diyData.global.title + }) + + } else if (data.mode == 'fixed') { + // 固定模板 + let sources = JSON.parse(res.data.value); + diyData.title = data.title; + diyData.value = sources; + uni.setNavigationBarTitle({ + title: diyData.title + }) + } } loading.value = false; diff --git a/uni-app/pages/member/index.vue b/uni-app/pages/member/index.vue index 18440a435..413245049 100644 --- a/uni-app/pages/member/index.vue +++ b/uni-app/pages/member/index.vue @@ -1,10 +1,24 @@ @@ -52,22 +66,34 @@ name: 'DIY_MEMBER_INDEX' }).then((res : any) => { if (res.data.value) { - let sources = JSON.parse(res.data.value); - diyData.global = sources.global; - diyData.value = sources.value; - diyData.value.forEach((item, index) => { - item.pageStyle = ''; - if (item.pageBgColor) item.pageStyle += 'background-color:' + item.pageBgColor + ';'; - if (item.margin) { - item.pageStyle += 'padding-top:' + item.margin.top * 2 + 'rpx' + ';'; - item.pageStyle += 'padding-bottom:' + item.margin.bottom * 2 + 'rpx' + ';'; - item.pageStyle += 'padding-right:' + item.margin.both * 2 + 'rpx' + ';'; - item.pageStyle += 'padding-left:' + item.margin.both * 2 + 'rpx' + ';'; - } - }); - uni.setNavigationBarTitle({ - title: diyData.global.title - }) + let data = res.data; + diyData.mode = data.mode; + if (data.mode == 'diy') { + let sources = JSON.parse(res.data.value); + diyData.global = sources.global; + diyData.value = sources.value; + diyData.value.forEach((item, index) => { + item.pageStyle = ''; + if (item.pageBgColor) item.pageStyle += 'background-color:' + item.pageBgColor + ';'; + if (item.margin) { + item.pageStyle += 'padding-top:' + item.margin.top * 2 + 'rpx' + ';'; + item.pageStyle += 'padding-bottom:' + item.margin.bottom * 2 + 'rpx' + ';'; + item.pageStyle += 'padding-right:' + item.margin.both * 2 + 'rpx' + ';'; + item.pageStyle += 'padding-left:' + item.margin.both * 2 + 'rpx' + ';'; + } + }); + uni.setNavigationBarTitle({ + title: diyData.global.title + }) + } else if (data.mode == 'fixed') { + // 固定模板 + let sources = JSON.parse(res.data.value); + diyData.title = data.title; + diyData.value = sources; + uni.setNavigationBarTitle({ + title: diyData.title + }) + } } loading.value = false; }); diff --git a/uni-app/utils/common.ts b/uni-app/utils/common.ts index 237364f8b..4599043e7 100644 --- a/uni-app/utils/common.ts +++ b/uni-app/utils/common.ts @@ -224,7 +224,7 @@ export function mobileConceal(mobile : string) : string { */ export function getSiteId(siteid : number) { // #ifdef H5 - const match = location.href.match(/\/s(\d*)\//); + const match = location.href.match(/\/wap\/(\d*)\//); if (match) return match[1] else return siteid // #endif diff --git a/uni-app/utils/request.ts b/uni-app/utils/request.ts index 5badf61ce..375009586 100644 --- a/uni-app/utils/request.ts +++ b/uni-app/utils/request.ts @@ -21,10 +21,10 @@ class Request { // #ifdef H5 this.baseUrl = import.meta.env.VITE_APP_BASE_URL || `${location.origin}/api/` // #endif - // #ifndef H5 this.baseUrl = import.meta.env.VITE_APP_BASE_URL // #endif + this.baseUrl.substr(-1) != '/' && (this.baseUrl += '/') try { if (process.env.NODE_ENV == 'development') {