update uni-app

This commit is contained in:
全栈小学生 2023-07-01 16:22:24 +08:00
parent e0b9bb5804
commit 78abbed304
22 changed files with 286 additions and 297 deletions

View File

@ -71,4 +71,8 @@
})
</script>
<style></style>
<style>
uni-page-head {
display: none!important;
}
</style>

View File

@ -75,4 +75,11 @@ export function fetchBase64Image(data : AnyObject) {
*/
export function getSiteInfo() {
return request.get('site')
}
/**
* id
*/
export function getWeappTemplateId(keys: string) {
return request.get('weapp/subscribemsg', { keys })
}

View File

@ -21,12 +21,12 @@
<script setup lang="ts">
//
import { ref, computed } from 'vue';
import { ref, computed, watch } from 'vue';
import { redirect, img } from '@/utils/common';
import useDiyStore from '@/stores/diy';
import { getArticleAll } from '@/api/article';
const props = defineProps(['component', 'index']);
const props = defineProps(['component', 'index', 'pullDownRefresh']);
const diyStore = useDiyStore();
const articleList = ref<Array<any>>([]);
@ -58,6 +58,13 @@
return style;
})
watch(
() => props.pullDownRefresh,
(newValue, oldValue) => {
//
}
)
const getArticleListFn = () => {
interface dataStructure {
ids ?: Array<number>,

View File

@ -5,7 +5,7 @@
{{diyComponent.navTitle}}
</div>
<view v-if="diyComponent.layout == 'vertical'" class="graphic-nav">
<view class="graphic-nav-item" v-for=" (item, index) in diyComponent.list" :key="item.id">
<view class="graphic-nav-item" v-for="(item, index) in diyComponent.list" :key="item.id">
<app-link :data="item.link" class="flex items-center justify-between py-[30rpx] px-[32rpx]"
:class="[index == 0 ? 'border-t-0':'border-t']">
@ -39,25 +39,17 @@
:style="{ height: swiperHeight }" @change="swiperChange">
<swiper-item class="graphic-nav-wrap flex flex-wrap"
v-for="(numItem, numIndex) in Math.ceil(diyComponent.list.length / (diyComponent.pageCount * diyComponent.rowCount))">
<!-- #ifdef MP-WEIXIN -->
<view class="graphic-nav-item" :class="[diyComponent.mode]" v-for=" (item, index) in diyComponent.list"
:key="item.id"
v-if="index >= [(numItem) * (diyComponent.pageCount * diyComponent.rowCount)] && index < [(numItem+1) * (diyComponent.pageCount * diyComponent.rowCount)]"
:style="{ width: 100 / diyComponent.rowCount + '%' }">
<!-- #endif -->
<!-- #ifdef H5 -->
<view class="graphic-nav-item" :class="[diyComponent.mode]"
v-for=" (item, index) in diyComponent.list" :key="item.id"
v-if="index >= [(numItem - 1) * (diyComponent.pageCount * diyComponent.rowCount)] && index < [numItem * (diyComponent.pageCount * diyComponent.rowCount)]"
:style="{ width: 100 / diyComponent.rowCount + '%' }">
<!-- #endif -->
<template v-for="(item, index) in diyComponent.list">
<view class="graphic-nav-item" :class="[diyComponent.mode]" :key="item.id"
v-if="swiperCondition(index,numItem)" :style="{ width: 100 / diyComponent.rowCount + '%' }">
<app-link :data="item.link" class="flex flex-col items-center box-border py-2">
<view class="graphic-img relative flex items-center justify-center w-10 h-10"
v-if="diyComponent.mode != 'text'"
:style="{ width: diyComponent.imageSize * 2 + 'rpx', height: diyComponent.imageSize * 2 + 'rpx' }">
:style="{ width: diyComponent.imageSize * 2 + 'rpx', height: diyComponent.imageSize * 2 + 'rpx' }">
<image :src="img(item.imageUrl)" mode="aspectFill"
:style="{ maxWidth: diyComponent.imageSize * 2 + 'rpx', maxHeight: diyComponent.imageSize * 2 + 'rpx', borderRadius: diyComponent.aroundRadius * 2 + 'rpx' }">
</image>
@ -79,11 +71,12 @@
</app-link>
</view>
</template>
</swiper-item>
</swiper>
<scroll-view v-else :scroll-x="diyComponent.showStyle == 'singleSlide'"
:class="['graphic-nav','graphic-nav-'+diyComponent.showStyle]">
:class="['graphic-nav','graphic-nav-' + diyComponent.showStyle]">
<!-- #ifdef MP -->
<view class="uni-scroll-view-content">
<!-- #endif -->
@ -131,7 +124,7 @@
import useDiyStore from '@/stores/diy';
import { useLogin } from '@/hooks/useLogin';
const props = defineProps(['component', 'index']);
const props = defineProps(['component', 'index', 'pullDownRefresh']);
const diyStore = useDiyStore();
@ -153,24 +146,46 @@
return style;
})
watch(
() => props.pullDownRefresh,
(newValue, oldValue) => {
//
}
)
const swiperIndex = ref(0);
const swiperChange = e => {
swiperIndex.value = e.detail.current;
};
const swiperCondition = (index, numItem) => {
let count = diyComponent.value.pageCount * diyComponent.value.rowCount;
let result = true;
// #ifdef MP-WEIXIN
result = index >= [(numItem) * (count)] && index < [(numItem + 1) * (count)];
// #endif
// #ifdef H5
result = index >= [(numItem - 1) * (count)] && index < [numItem * (count)];
// #endif
return result;
}
const swiperHeight = ref('');
const handleData = () => {
var height = 0;
if (diyComponent.value.mode == 'graphic') {
height = (21 + 6 + 14 + 8 + diyComponent.value.imageSize) * diyComponent.value.pageCount; // 21 = 8 = 14 = 8 =
height = (21 + 6 + 14 + 8 + diyComponent.value.imageSize) * diyComponent.value.pageCount; // 21 = 6 = 14 = 8 =
} else if (diyComponent.value.mode == 'img') {
height = (14 + 8 + diyComponent.value.imageSize) * diyComponent.value.pageCount; // 14 = 8 =
} else if (diyComponent.value.mode == 'text') {
height = (21 + 14 + 8) * diyComponent.value.pageCount; // 21 = 14 = 8 =
}
swiperHeight.value = height + 'rpx';
swiperHeight.value = (height * 2) + 'rpx';
};
onMounted(() => {

View File

@ -1,27 +1,35 @@
<template>
<view class="diy-group" id="componentList">
<view v-for="(component, index) in data.value" :key="component.id"
@click="diyStore.changeCurrentIndex(index, component)" class="draggable-element relative cursor-move"
:class="{ selected: diyStore.currentIndex == index,decorate : diyStore.mode == 'decorate' }"
:style="component.pageStyle">
<fixed-group :component="component" :index="index" :pullDownRefresh="props.pullDownRefresh"></fixed-group>
<template v-if="component.componentName == 'Article'">
<diy-article :component="component" :index="index"></diy-article>
<diy-article :component="component" :index="index"
:pullDownRefresh="props.pullDownRefresh"></diy-article>
</template>
<template v-if="component.componentName == 'GraphicNav'">
<diy-graphic-nav :component="component" :index="index"></diy-graphic-nav>
<diy-graphic-nav :component="component" :index="index"
:pullDownRefresh="props.pullDownRefresh"></diy-graphic-nav>
</template>
<template v-if="component.componentName == 'HorzBlank'">
<diy-horz-blank :component="component" :index="index"></diy-horz-blank>
<diy-horz-blank :component="component" :index="index"
:pullDownRefresh="props.pullDownRefresh"></diy-horz-blank>
</template>
<template v-if="component.componentName == 'ImageAds'">
<diy-image-ads :component="component" :index="index"></diy-image-ads>
<diy-image-ads :component="component" :index="index"
:pullDownRefresh="props.pullDownRefresh"></diy-image-ads>
</template>
<template v-if="component.componentName == 'MemberInfo'">
<diy-member-info :component="component" :index="index"></diy-member-info>
<diy-member-info :component="component" :index="index"
:pullDownRefresh="props.pullDownRefresh"></diy-member-info>
</template>
<template v-if="component.componentName == 'Text'">
<diy-text :component="component" :index="index"></diy-text>
<diy-text :component="component" :index="index" :pullDownRefresh="props.pullDownRefresh"></diy-text>
</template>
</view>
<template v-if="diyStore.mode != 'decorate' && data.global.bottomTabBarSwitch">
@ -32,10 +40,10 @@
</template>
<script lang="ts" setup>
import useDiyStore from '@/stores/diy';
import { onMounted, nextTick, computed, ref } from 'vue';
import { onMounted, nextTick, computed, ref, watch } from 'vue';
import Sortable from 'sortablejs';
import { range } from 'lodash-es';
const props = defineProps(['data']);
const props = defineProps(['data', 'pullDownRefresh']);
const diyStore = useDiyStore();
const data = computed(() => {

View File

@ -5,10 +5,10 @@
<script setup lang="ts">
//
import { computed } from 'vue';
import { computed, watch } from 'vue';
import useDiyStore from '@/stores/diy';
const props = defineProps(['component', 'index']);
const props = defineProps(['component', 'index', 'pullDownRefresh']);
const diyStore = useDiyStore();
@ -26,6 +26,13 @@
if (diyComponent.value.componentBgColor) style += 'background-color:' + diyComponent.value.componentBgColor + ';';
return style;
})
watch(
() => props.pullDownRefresh,
(newValue, oldValue) => {
//
}
)
</script>
<style></style>

View File

@ -27,7 +27,7 @@
import { img } from '@/utils/common';
import useDiyStore from '@/stores/diy';
const props = defineProps(['component', 'index']);
const props = defineProps(['component', 'index', 'pullDownRefresh']);
const diyStore = useDiyStore();
@ -54,6 +54,13 @@
return style;
})
watch(
() => props.pullDownRefresh,
(newValue, oldValue) => {
//
}
)
const imgHeight = computed(() => {
return (diyComponent.value.imageHeight * 2) + 'rpx';
})

View File

@ -64,7 +64,7 @@
</template>
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { computed, ref, watch } from 'vue'
import useMemberStore from '@/stores/member'
import { useLogin } from '@/hooks/useLogin'
import { img, isWeixinBrowser, redirect, urlDeconstruction, moneyFormat } from '@/utils/common'
@ -72,7 +72,7 @@
import { wechatSync } from '@/api/system'
import useDiyStore from '@/stores/diy'
const props = defineProps(['component', 'index']);
const props = defineProps(['component', 'index', 'pullDownRefresh']);
const diyStore = useDiyStore();
@ -99,6 +99,13 @@
return style;
})
watch(
() => props.pullDownRefresh,
(newValue, oldValue) => {
//
}
)
const memberStore = useMemberStore()
// #ifdef H5

View File

@ -38,11 +38,11 @@
<script setup lang="ts">
//
import { ref, computed } from 'vue';
import { ref, computed, watch } from 'vue';
import { redirect, img } from '@/utils/common';
import useDiyStore from '@/stores/diy';
const props = defineProps(['component', 'index']);
const props = defineProps(['component', 'index', 'pullDownRefresh']);
const diyStore = useDiyStore();
const diyComponent = computed(() => {
@ -62,6 +62,13 @@
if (diyComponent.value.bottomRounded) style += 'border-bottom-right-radius:' + diyComponent.value.bottomRounded * 2 + 'rpx;';
return style;
})
watch(
() => props.pullDownRefresh,
(newValue, oldValue) => {
//
}
)
</script>
<style lang="scss" scoped>

View File

@ -0,0 +1,39 @@
<template>
<view :style="warpCss">
固定模板示例我也可以装修
我定义的数据源{{ diyComponent.componentName }}
</view>
</template>
<script setup lang="ts">
import { computed, watch } from 'vue';
import useDiyStore from '@/stores/diy';
const props = defineProps(['component', 'index', 'pullDownRefresh']);
const diyStore = useDiyStore();
const diyComponent = computed(() => {
if (diyStore.mode == 'decorate') {
return diyStore.value[props.index];
} else {
return props.component;
}
})
const warpCss = computed(() => {
var style = '';
style += 'height:' + diyComponent.value.height * 2 + 'rpx;';
if (diyComponent.value.componentBgColor) style += 'background-color:' + diyComponent.value.componentBgColor + ';';
return style;
})
watch(
() => props.pullDownRefresh,
(newValue, oldValue) => {
//
}
)
</script>
<style></style>

View File

@ -1,14 +1,14 @@
<template>
<view class="fixed-group">
<template v-if="props.component.componentName == 'DemoIndex'">
<fixed-demo-index :component="props.component" :index="props.index"
:pullDownRefresh="props.pullDownRefresh"></fixed-demo-index>
</template>
</view>
</template>
<script lang="ts" setup>
import { computed } from 'vue';
const props = defineProps(['data']);
const data = computed(() => {
return props.data.value;
})
import { computed, watch } from 'vue';
const props = defineProps(['component', 'index', 'pullDownRefresh']);
</script>
<style lang="scss" scoped>
@import './index.scss';

View File

@ -0,0 +1,30 @@
import { getWeappTemplateId } from '@/api/system'
/**
*
*/
export const useSubscribeMessage = () => {
const request = (keys: string)=> {
// #ifdef MP-WEIXIN
const method = getWeappTemplateId
// #endif
// #ifdef MP
method(keys).then(({ data }) => {
uni.requestSubscribeMessage({
tmplIds: data,
success: (res) => {
console.log("requestSubscribeMessage:success", res)
},
fail: (res) => {
console.log('requestSubscribeMessage:fail', res)
}
})
}).catch()
// #endif
}
return {
request
}
}

View File

@ -1,5 +1,4 @@
import { nextTick } from 'vue'
import { setDocumentTitle } from '@/utils/common'
class Language {
private i18n: any
@ -20,10 +19,6 @@ class Language {
this.i18n.global.locale = locale
}
uni.setLocale(locale)
// #ifdef H5
setDocumentTitle(path)
// #endif
}
/**

View File

@ -1,6 +1,6 @@
{
"name" : "NiuCloud-ADMIN",
"appid" : "__UNI__BFCE0C3",
"name" : "",
"appid" : "__UNI__ED923AB",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",

View File

@ -3,108 +3,74 @@
{
"path": "pages/index/index",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.index.index%"
"navigationBarTitleText": "%pages.index.index%",
"enablePullDownRefresh": true
}
},
{
"path": "pages/article/list",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.article.list%"
}
},
{
"path": "pages/auth/agreement",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.auth.agreement%"
}
},
{
"path": "pages/auth/bind",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.auth.bind%"
}
},
{
"path": "pages/auth/login",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.auth.login%"
}
},
{
"path": "pages/auth/register",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.auth.register%"
}
},
{
"path": "pages/auth/resetpwd",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.auth.resetpwd%"
}
},
{
"path": "pages/index/diy",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.index.diy%"
"navigationBarTitleText": "%pages.index.diy%",
"enablePullDownRefresh": true
}
},
{
"path": "pages/index/close",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.index.close%"
}
},
{
"path": "pages/index/nosite",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.index.nosite%"
}
},
{
"path": "pages/article/detail",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.article.detail%"
}
},
{
"path": "pages/member/apply_cash_out",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.apply_cash_out%"
},
"needLogin": true
@ -112,9 +78,6 @@
{
"path": "pages/member/commission",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.commission%"
},
"needLogin": true
@ -122,9 +85,6 @@
{
"path": "pages/member/balance",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.balance%"
},
"needLogin": true
@ -132,9 +92,6 @@
{
"path": "pages/member/recharge_record",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.recharge_record%"
},
"needLogin": true
@ -142,9 +99,6 @@
{
"path": "pages/member/recharge_record_detail",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.recharge_record_detail%"
},
"needLogin": true
@ -152,45 +106,31 @@
{
"path": "pages/member/detailed_account",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.detailed_account%"
}
},
{
"path": "pages/member/cash_out",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.cash_out%"
}
},
{
"path": "pages/member/cash_out_detail",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.cash_out_detail%"
}
},
{
"path": "pages/member/index",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.index%"
"navigationBarTitleText": "%pages.member.index%",
"enablePullDownRefresh": true
}
},
{
"path": "pages/member/personal",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.personal%"
},
"needLogin": true
@ -198,9 +138,6 @@
{
"path": "pages/member/point",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.point%"
},
"needLogin": true
@ -208,9 +145,6 @@
{
"path": "pages/member/account",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.account%"
},
"needLogin": true
@ -218,9 +152,6 @@
{
"path": "pages/member/account_edit",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.member.account_edit%"
},
"needLogin": true
@ -228,27 +159,18 @@
{
"path": "pages/pay/browser",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.pay.browser%"
}
},
{
"path": "pages/pay/result",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.pay.result%"
}
},
{
"path": "pages/setting/index",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.setting.index%"
},
"needLogin": true
@ -256,18 +178,12 @@
{
"path": "pages/webview/index",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.webview.index%"
}
},
{
"path": "pages/index/develop",
"style": {
// #ifdef H5
"navigationStyle": "custom",
// #endif
"navigationBarTitleText": "%pages.index.develop%"
}
} // {{PAGE}}

View File

@ -4,18 +4,10 @@
<view v-show="!loading">
<!-- 自定义模板渲染 -->
<view class="diy-template-wrap bg-index" v-if="data.mode != 'fixed'"
<view class="diy-template-wrap bg-index"
:style="{ backgroundColor: data.global.pageBgColor,minHeight: 'calc(100vh - 50px)',backgroundImage : data.global.bgUrl ? 'url(' + img(data.global.bgUrl) + ')' : '' }">
<diy-group :data="data"></diy-group>
</view>
<!-- 固定模板渲染 -->
<view class="fixed-template-wrap" v-if="data.mode == 'fixed'">
<fixed-group :data="data"></fixed-group>
<diy-group :data="data" :pullDownRefresh="pullDownRefresh"></diy-group>
</view>
@ -25,7 +17,7 @@
<script setup lang="ts">
import { ref, reactive, computed } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { onLoad, onShow, onPullDownRefresh } from '@dcloudio/uni-app';
import { getDiyInfo } from '@/api/diy';
import useDiyStore from '@/stores/diy';
import { useShare } from '@/hooks/useShare'
@ -37,6 +29,7 @@
const loading = ref(true);
const diyStore = useDiyStore();
const pullDownRefresh = ref(0)
const diyData = reactive({
global: {},
@ -66,6 +59,12 @@
name.value = option.name || '';
});
//
onPullDownRefresh(() => {
pullDownRefresh.value++;
uni.stopPullDownRefresh();
})
onShow(() => {
//
if (diyStore.mode == 'decorate') {
@ -79,32 +78,22 @@
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 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 share = res.data.share ? JSON.parse(res.data.share) : null;

View File

@ -4,18 +4,10 @@
<view v-show="!loading">
<!-- 自定义模板渲染 -->
<view class="diy-template-wrap bg-index" v-if="data.mode != 'fixed'"
<view class="diy-template-wrap bg-index"
:style="{ backgroundColor: data.global.pageBgColor,minHeight: 'calc(100vh - 50px)',backgroundImage : data.global.bgUrl ? 'url(' + img(data.global.bgUrl) + ')' : '' }">
<diy-group :data="data"></diy-group>
</view>
<!-- 固定模板渲染 -->
<view class="fixed-template-wrap" v-if="data.mode == 'fixed'">
<fixed-group :data="data"></fixed-group>
<diy-group :data="data" :pullDownRefresh="pullDownRefresh"></diy-group>
</view>
@ -25,7 +17,7 @@
<script setup lang="ts">
import { ref, reactive, computed } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { onLoad, onShow, onPullDownRefresh } from '@dcloudio/uni-app';
import { getDiyInfo } from '@/api/diy';
import useDiyStore from '@/stores/diy';
import { useShare } from '@/hooks/useShare'
@ -38,6 +30,7 @@
const loading = ref(true);
const diyStore = useDiyStore();
const pullDownRefresh = ref(0)
//
const diyData = reactive({
@ -63,6 +56,12 @@
// #endif
});
//
onPullDownRefresh(() => {
pullDownRefresh.value++;
uni.stopPullDownRefresh();
})
onShow(() => {
//
if (diyStore.mode == 'decorate') {
@ -74,35 +73,23 @@
if (res.data.value) {
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
})
}
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
})
}
loading.value = false;

View File

@ -4,18 +4,10 @@
<view v-show="!loading">
<!-- 自定义模板渲染 -->
<view class="diy-template-wrap bg-index" v-if="data.mode != 'fixed'"
<view class="diy-template-wrap bg-index"
:style="{ backgroundColor: data.global.pageBgColor,minHeight: 'calc(100vh - 50px)',backgroundImage : data.global.bgUrl ? 'url(' + img(data.global.bgUrl) + ')' : '' }">
<diy-group :data="data"></diy-group>
</view>
<!-- 固定模板渲染 -->
<view class="fixed-template-wrap" v-if="data.mode == 'fixed'">
<fixed-group :data="data"></fixed-group>
<diy-group :data="data" :pullDownRefresh="pullDownRefresh"></diy-group>
</view>
@ -25,7 +17,7 @@
<script setup lang="ts">
import { ref, reactive, computed } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { onLoad, onShow, onPullDownRefresh } from '@dcloudio/uni-app'
import { getDiyInfo } from '@/api/diy'
import useDiyStore from '@/stores/diy'
import useMemberStore from '@/stores/member'
@ -33,6 +25,7 @@
const loading = ref(true);
const diyStore = useDiyStore();
const pullDownRefresh = ref(0)
const diyData = reactive({
global: {},
@ -57,6 +50,12 @@
// #endif
});
//
onPullDownRefresh(() => {
pullDownRefresh.value++;
uni.stopPullDownRefresh();
})
onShow(() => {
//
if (diyStore.mode == 'decorate') {
@ -68,32 +67,22 @@
if (res.data.value) {
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 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
})
}
loading.value = false;
});

View File

@ -22,6 +22,7 @@ const useMemberStore = defineStore('member', {
await this.getMemberInfo()
},
async getMemberInfo() {
if (!this.token) return
await getMemberInfo()
.then((res : any) => {
this.info = res.data
@ -31,6 +32,7 @@ const useMemberStore = defineStore('member', {
})
},
async logout(isRedirect : boolean = false) {
if (!this.token) return
await logout().then(() => {
this.$reset()
removeToken()

View File

@ -176,7 +176,13 @@ export function isUrl(str : string) : boolean {
* @returns
*/
export function img(path : string) : string {
// #ifdef H5
return isUrl(path) ? path : `${import.meta.env.VITE_IMG_DOMAIN || location.origin}/${path}`
// #endif
// #ifndef H5
return isUrl(path) ? path : `${import.meta.env.VITE_IMG_DOMAIN}/${path}`
// #endif
}
/**
@ -232,31 +238,4 @@ export function getSiteId(siteid : number) {
// #ifndef H5
return siteid
// #endif
}
/**
* html标题
* @param {Object} route
*/
export function setDocumentTitle(route: string) {
if (process.env.NODE_ENV != 'production') return
try {
const locale: AnyObject = {
'zh-Hans': pagesZh,
'en': pagesEn
}
const key = route.replace('/', '').replaceAll('/', '.')
if (locale[ uni.getLocale() ][key]) {
setTimeout(() => {
uni.setNavigationBarTitle({
title: locale[ uni.getLocale() ][key],
fail(e) {
setDocumentTitle(route)
}
})
}, 500)
}
} catch (e) {
console.log(e)
}
}

View File

@ -1,6 +1,6 @@
import { language } from '@/locale'
import { checkNeedLogin } from '@/utils/auth'
import { redirect, urlDeconstruction, getToken, getSiteId, setDocumentTitle } from '@/utils/common'
import { redirect, urlDeconstruction, getToken, getSiteId } from '@/utils/common'
import { memberLog } from '@/api/auth'
import { nextTick } from 'vue'
@ -17,17 +17,14 @@ export const redirectInterceptor = () => {
// 加载语言包
language.loadLocaleMessages(route.path, uni.getLocale())
// 开发模式下如果未配置站点ID则跳转到开发环境配置页面
// #ifdef H5
if (process.env.NODE_ENV == 'development') {
if ((getSiteId(uni.getStorageSync('wap_site_id') || import.meta.env.VITE_SITE_ID) === '') && route.path != '/pages/index/develop') {
if ((getSiteId(import.meta.env.VITE_SITE_ID || uni.getStorageSync('wap_site_id')) === '') && route.path != '/pages/index/develop') {
redirect({ url: '/pages/index/develop', mode: 'reLaunch' })
}
}
// 设置网站标题
setDocumentTitle(route.path)
// #endif
// 校验是否需要登录
@ -51,20 +48,17 @@ export const launchInterceptor = () => {
// #ifdef H5
if (process.env.NODE_ENV == 'development') {
// 后台DIY装修页面时获取站点ID
if (location.search.indexOf('?mode=decorate&site_id=') != -1) {
uni.setStorageSync('wap_site_id', location.search.replace('?mode=decorate&site_id=',''));
if (location.search.indexOf('site_id=') != -1) {
let site_id = location.search.substr(location.search.indexOf('site_id=')+8);
uni.setStorageSync('wap_site_id', site_id);
}
if (location.search.indexOf('?mode=preview&site_id=') != -1) {
uni.setStorageSync('wap_site_id', location.search.replace('?mode=preview&site_id=',''));
}
if (getSiteId(uni.getStorageSync('wap_site_id') || import.meta.env.VITE_SITE_ID) === '') {
if (getSiteId(import.meta.env.VITE_SITE_ID || uni.getStorageSync('wap_site_id')) === '') {
launch.path = '/pages/index/develop';
uni.setStorageSync('develop_before_path', launch.path);
redirect({ url: '/pages/index/develop', mode: 'reLaunch' })
}
}
// 设置网站标题
setDocumentTitle(launch.path)
// #endif
// 加载语言包

View File

@ -24,11 +24,11 @@ class Request {
// #ifndef H5
this.baseUrl = import.meta.env.VITE_APP_BASE_URL
// #endif
this.baseUrl.substr(-1) != '/' && (this.baseUrl += '/')
this.baseUrl.substr(-1) != '/' && (this.baseUrl += '/')
try {
if (process.env.NODE_ENV == 'development') {
this.config.header[import.meta.env.VITE_REQUEST_HEADER_SITEID_KEY] = getSiteId(uni.getStorageSync('wap_site_id') || import.meta.env.VITE_SITE_ID)
this.config.header[import.meta.env.VITE_REQUEST_HEADER_SITEID_KEY] = getSiteId(import.meta.env.VITE_SITE_ID || uni.getStorageSync('wap_site_id'))
} else {
this.config.header[import.meta.env.VITE_REQUEST_HEADER_SITEID_KEY] = getSiteId(import.meta.env.VITE_SITE_ID)
}
@ -47,7 +47,7 @@ class Request {
getToken() && (this.config.header[import.meta.env.VITE_REQUEST_HEADER_TOKEN_KEY] = getToken())
this.config.header[import.meta.env.VITE_REQUEST_HEADER_CHANNEL_KEY] = getAppChannel()
if (process.env.NODE_ENV == 'development') {
this.config.header[import.meta.env.VITE_REQUEST_HEADER_SITEID_KEY] = getSiteId(uni.getStorageSync('wap_site_id') || import.meta.env.VITE_SITE_ID)
this.config.header[import.meta.env.VITE_REQUEST_HEADER_SITEID_KEY] = getSiteId(import.meta.env.VITE_SITE_ID || uni.getStorageSync('wap_site_id'))
} else {
this.config.header[import.meta.env.VITE_REQUEST_HEADER_SITEID_KEY] = getSiteId(import.meta.env.VITE_SITE_ID)
}