Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
a8fae94d
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6048
Star
92
Fork
165
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
a8fae94d
编写于
11月 27, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(dialogPage): 补充 getPageStyle setPageStyle 示例
上级
7fcb629b
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
285 addition
and
13 deletion
+285
-13
pages.json
pages.json
+20
-13
pages/API/dialog-page/dialog-3.uvue
pages/API/dialog-page/dialog-3.uvue
+182
-0
pages/API/dialog-page/page-style.uts
pages/API/dialog-page/page-style.uts
+83
-0
未找到文件。
pages.json
浏览文件 @
a8fae94d
...
@@ -1481,6 +1481,14 @@
...
@@ -1481,6 +1481,14 @@
}
}
},
},
//
#endif
//
#endif
//
#ifdef
APP-ANDROID
||
APP-IOS
||
WEB
{
"path"
:
"pages/API/dialog-page/dialog-3"
,
"style"
:
{
"navigationBarTitleText"
:
"dialogPage3"
}
},
//
#endif
//
#ifdef
APP-ANDROID
||
APP-IOS
||
MP-WEIXIN
//
#ifdef
APP-ANDROID
||
APP-IOS
||
MP-WEIXIN
{
{
"path"
:
"pages/API/create-interstitial-ad/create-interstitial-ad"
,
"path"
:
"pages/API/create-interstitial-ad/create-interstitial-ad"
,
...
@@ -2323,10 +2331,9 @@
...
@@ -2323,10 +2331,9 @@
}
}
},
},
{
{
"path"
:
"pages/template/WXS/WXS"
,
"path"
:
"pages/template/WXS/WXS"
,
"style"
:
"style"
:
{
{
"navigationBarTitleText"
:
"WXS"
"navigationBarTitleText"
:
"WXS"
}
}
}
}
//
#endif
//
#endif
...
...
pages/API/dialog-page/dialog-3.uvue
0 → 100644
浏览文件 @
a8fae94d
<template>
<view id="dialog3" class="dialog-container">
<scroll-view class="dialog-content">
<text>title: {{ title }}</text>
<template v-for="(item, index) in PageStyleArray">
<view class="page-style-item" v-if="currentPageStyle[item.key] != null" :key="index">
<view class="item-text">
<text class="item-text-key">{{ item.key }}:</text>
<text class="item-text-value">{{
currentPageStyle[item.key]
}}</text>
</view>
<view class="mt-10" v-if="item.type == 'boolean'">
<switch :checked="currentPageStyle.getBoolean(item.key)"
@change="switchChange(item.key, $event as UniSwitchChangeEvent)">
</switch>
</view>
<view class="mt-10" v-else-if="item.type == 'number'">
<slider :value="currentPageStyle.getNumber(item.key)" :show-value="true"
@change="sliderChange(item.key, $event as UniSliderChangeEvent)" />
</view>
<view class="mt-10" v-else-if="item.type == 'string'">
<radio-group class="radio-set-value" @change="radioChange(item.key, $event as RadioGroupChangeEvent)">
<radio class="ml-10" v-for="(item2, index2) in item.value" :key="index2" :value="item2"
:checked="currentPageStyle[item.key] == item2">{{ item2 }}
</radio>
</radio-group>
</view>
</view>
</template>
<text class="mt-10 choose-close-animation-type-title">choose close dialogPage animationType</text>
<radio-group class="choose-close-animation-type-radio-group" @change="handleChooseAnimationType">
<radio class="ml-10 mt-10" v-for="item in closeAnimationTypeList" :key="item" :value="item"
:checked="closeAnimationType == item">{{ item }}
</radio>
</radio-group>
<button class="mt-10" id="dialog1-close-dialog" @click="closeDialog">
closeDialog
</button>
</scroll-view>
</view>
</template>
<script>
import { PageStyleItem, PageStyleArray } from './page-style.uts';
import {
state,
setLifeCycleNum
} from '@/store/index.uts'
type CloseAnimationType =
'auto' |
'none' |
'slide-out-right' |
'slide-out-left' |
'slide-out-top' |
'slide-out-bottom' |
'fade-out' |
'zoom-in' |
'zoom-fade-in'
export default {
data() {
return {
title: 'dialog 3',
PageStyleArray: PageStyleArray as PageStyleItem[],
currentPageStyle: {} as UTSJSONObject,
closeAnimationType: 'none' as CloseAnimationType,
closeAnimationTypeList: [
'auto',
'none',
'slide-out-right',
'slide-out-left',
'slide-out-top',
'slide-out-bottom',
'fade-out',
'zoom-in',
'zoom-fade-in'
]
}
},
onLoad(_ : OnLoadOptions) {
this.getPageStyle()
},
methods: {
getPageStyle() {
this.currentPageStyle = this.$page.getPageStyle()
},
radioChange(key : string, e : RadioGroupChangeEvent) {
this.setStyleValue(key, e.detail.value);
},
sliderChange(key : string, e : UniSliderChangeEvent) {
this.setStyleValue(key, e.detail.value);
},
switchChange(key : string, e : UniSwitchChangeEvent) {
this.setStyleValue(key, e.detail.value);
},
setStyleValue(key : string, value : any) {
const style = {}
style[key] = value
this.setPageStyle(style)
this.getPageStyle()
},
setPageStyle(style : UTSJSONObject) {
this.$page.setPageStyle(style);
},
handleChooseAnimationType(e : RadioGroupChangeEvent){
this.closeAnimationType = e.detail.value as CloseAnimationType
},
closeDialog() {
uni.closeDialogPage({
animationType: this.closeAnimationType,
success(res) {
console.log('closeDialog success', res)
},
fail(err) {
console.log('closeDialog fail', err)
},
complete(res) {
console.log('closeDialog complete', res)
}
})
}
}
}
</script>
<style>
.dialog-container {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.3);
display: flex;
justify-content: center;
align-items: center;
}
.dialog-content {
width: 90%;
height: 500px;
padding: 10px 6px;
background-color: #fff;
border-radius: 6px;
}
.mt-10 {
margin-top: 10px;
}
.ml-10 {
margin-left: 10px;
}
.page-style-item {
padding: 6px 0;
margin-top: 10px;
background-color: #ffffff;
border-radius: 5px;
}
.item-text {
flex-direction: row;
}
.item-text-key {
font-weight: bold;
}
.item-text-value {
margin-left: 5px;
}
.radio-set-value {
flex-direction: row;
}
.choose-close-animation-type-title{
font-weight: bold;
}
.choose-close-animation-type-radio-group{
flex-direction: row;
flex-wrap: wrap;
}
</style
pages/API/dialog-page/page-style.uts
0 → 100644
浏览文件 @
a8fae94d
export type PageStyleItem = {
key : string
type : string
value : Array<any>
}
export const PageStyleArray = [
{
key: "navigationBarBackgroundColor",
type: "string",
value: ["#007AFF", "#FFFFFF", "#000000"]
},
{
key: "navigationBarTextStyle",
type: "string",
value: ["white", "black"]
},
{
key: "navigationBarTitleText",
type: "string",
value: ["dialogPage", "title2", "title3"]
},
{
key: "navigationStyle",
type: "string",
value: ["default", "custom"]
},
{
key: "backgroundColor",
type: "string",
value: ["#FFFFFF", "#000000"]
},
{
key: "backgroundColorContent",
type: "string",
value: ["#FFFFFF", "transparent", "#000000"]
},
{
key: "backgroundTextStyle",
type: "string",
value: ["dark", "light"]
},
{
key: "enablePullDownRefresh",
type: "boolean",
value: [true, false]
},
{
key: "onReachBottomDistance",
type: "number",
value: [50, 100]
},
{
key: "pageOrientation",
type: "string",
value: ["auto", "portrait", "landscape"]
},
{
key: "backgroundColorTop",
type: "string",
value: ["#FFFFFF", "#000000"]
},
{
key: "backgroundColorBottom",
type: "string",
value: ["#FFFFFF", "#000000"]
},
{
key: "navigationBarAutoBackButton",
type: "boolean",
value: [true, false]
},
{
key: "hideStatusBar",
type: "boolean",
value: [true, false]
},
{
key: "hideBottomNavigationIndicator",
type: "boolean",
value: [true, false]
}] as PageStyleItem[]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录